:root {
    --bg: #f7f6f2;
    --ink: #121212;
    --muted: #6b6a64;
    --line: #deddd8;
    --card: #ffffff;
    --accent: #121212;
    --danger: #c0392b;
    --radius: 18px;
    --font: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #3c6df0; outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 0 32px 64px; }
.topbar { max-width: 1240px; margin: 0 auto; padding: 24px 32px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-weight: 700; font-size: 15px; line-height: 1.05; letter-spacing: -.3px; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; background: #ffd23f; display: grid; place-items: center; font-size: 20px; font-weight: 700; border: 2px solid var(--ink); }
.link-btn { background: none; border: 0; padding: 10px 0; font-size: 15px; font-weight: 500; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 4px; border-radius: 11px; background: var(--ink); color: #fff; font-size: 12px; }

.eyebrow { font-size: 11px; letter-spacing: 1.6px; font-weight: 600; margin: 0 0 14px; color: var(--muted); display: block; }
h1 { font-size: clamp(54px, 8vw, 116px); line-height: .9; letter-spacing: -.06em; margin: 0 0 24px; font-weight: 700; }
h2 { font-size: clamp(30px, 4vw, 46px); letter-spacing: -.04em; line-height: 1; margin: 0 0 10px; }
.dot { color: #ff5a36; }
.lead { font-size: 18px; line-height: 1.5; max-width: 520px; margin: 0 0 28px; color: #3a3a36; }
.sub { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }
.hint { font-size: 16px; color: var(--muted); margin: 0 0 22px; line-height: 1.45; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.actions.stack { flex-direction: column; align-items: flex-start; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--card); font-weight: 600; font-size: 15px; transition: transform .12s, background .15s; white-space: nowrap; }
.btn:hover { background: #efeee9; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #2c2c2c; }
.btn.big { min-height: 56px; padding: 0 26px; font-size: 17px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #ebe9e3; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger.confirm { background: var(--danger); color: #fff; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--card); font-size: 18px; display: grid; place-items: center; flex-shrink: 0; }
.icon-btn.big { width: 56px; height: 56px; font-size: 28px; }

/* ---------- peça do elemento (HTML) ---------- */
.tile { --c: #ddd; --ink: #121212; container-type: inline-size; position: relative; aspect-ratio: 1; width: 100%; border-radius: 10%; background: var(--c); color: var(--ink); box-shadow: inset 0 0 0 2px rgba(0,0,0,.1); overflow: hidden; font-family: var(--font); user-select: none; transition: background .2s; }
.tile.light-ink { box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
.tile > span { position: absolute; left: 8%; right: 8%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
.tile .t-num { top: 8%; left: 9%; text-align: left; font-weight: 700; font-size: 14cqw; }
.tile .t-sym { top: 28%; font-weight: 700; font-size: 42cqw; letter-spacing: -.02em; }
.tile[data-len="3"] .t-sym { font-size: 32cqw; top: 31%; }
.tile .t-name { top: 70%; font-weight: 500; font-size: 10cqw; }
.tile .t-weight { top: 83%; font-size: 8.5cqw; opacity: .8; }
.tile .placeholder { opacity: .35; }

/* ---------- início ---------- */
.home-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; padding: 48px 0 24px; min-height: 60vh; }
.home-art { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 460px; justify-self: end; width: 100%; }
.home-art .tile:nth-child(odd) { transform: rotate(-4deg); }
.home-art .tile:nth-child(even) { transform: rotate(3deg) translateY(12px); }
.home-art .tile.empty { background: transparent; box-shadow: none; border: 2px dashed #cfcdc6; }

/* ---------- wizard ---------- */
.wizard-top { display: flex; align-items: center; gap: 16px; padding: 8px 0 24px; }
.steps { list-style: none; display: flex; gap: 8px; margin: 0; padding: 0; flex: 1; }
.steps li { height: 6px; flex: 1; max-width: 80px; border-radius: 3px; background: var(--line); transition: background .2s; }
.steps li.done { background: var(--ink); }
.step-count { font-size: 13px; color: var(--muted); font-weight: 500; }
.wizard-body { display: grid; grid-template-columns: minmax(220px, 380px) 1fr; gap: 56px; align-items: start; }
.preview-wrap { position: sticky; top: 24px; }
.preview { width: 100%; }
.preview .tile { box-shadow: 0 18px 40px -18px rgba(0,0,0,.35), inset 0 0 0 2px rgba(0,0,0,.1); }
.step-panel { min-width: 0; }
.step { min-height: 200px; }

.swatches { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; }
.swatch { aspect-ratio: 1; border-radius: 8px; border: 0; padding: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); transition: transform .1s; }
.swatch:hover { transform: scale(1.12); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); transform: scale(1.08); z-index: 1; }
.spectrum { width: 100%; height: 96px; border-radius: 12px; touch-action: none; cursor: crosshair; display: block; margin-bottom: 14px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.color-input { position: relative; overflow: hidden; }
.color-input input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }

.field { width: 100%; max-width: 520px; font-size: 34px; font-weight: 600; letter-spacing: -.02em; padding: 14px 18px; border: 2px solid var(--ink); border-radius: 14px; background: var(--card); margin-bottom: 16px; }
.field::placeholder { color: #c3c1ba; }
.field-symbol { max-width: 180px; text-align: center; font-size: 48px; }
.field-number { max-width: 240px; text-align: center; }
.stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.stepper .field { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 16px; font-weight: 600; font-size: 16px; }
.chip:hover { border-color: var(--ink); }
.warn { color: #9a6200; font-size: 14px; min-height: 1em; margin: 12px 0 0; }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; margin: 16px 0 0; }
.wizard-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 22px; border-top: 1px solid var(--line); }
.wizard-nav .btn { min-width: 130px; min-height: 54px; font-size: 16px; }

/* ---------- resultado ---------- */
.result { display: grid; grid-template-columns: minmax(240px, 440px) 1fr; gap: 56px; align-items: center; padding: 24px 0; }
.result-tile .tile { animation: pop .55s cubic-bezier(.2,1.4,.4,1); box-shadow: 0 24px 50px -20px rgba(0,0,0,.4), inset 0 0 0 2px rgba(0,0,0,.1); }
@keyframes pop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- tabela ---------- */
.table-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; padding: 8px 0 22px; }
.table-title { flex: 1; min-width: 240px; }
.title-input { width: 100%; font-size: clamp(30px, 4.4vw, 52px); font-weight: 700; letter-spacing: -.04em; border: 0; border-bottom: 2px dashed transparent; background: transparent; padding: 2px 0; }
.title-input:hover, .title-input:focus { border-bottom-color: #bdbbb4; outline: none; }
.place-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff3c4; border: 1.5px solid #e2c24a; border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-weight: 600; }
.table-scroll { overflow-x: auto; padding: 4px 2px 12px; -webkit-overflow-scrolling: touch; }
.ptable { display: grid; grid-template-columns: repeat(18, minmax(46px, 1fr)); gap: 5px; min-width: 900px; }
.cell { aspect-ratio: 1; border-radius: 10%; border: 1.5px dashed #cfcdc6; background: transparent; padding: 0; position: relative; }
.cell:hover { border-color: #8f8d86; background: #efeee9; }
.cell.filled { border: 0; }
.cell.filled .tile { transition: transform .12s; }
.cell.filled:hover .tile { transform: scale(1.06); }
.cell.target { border-color: var(--ink); border-style: solid; background: #fff3c4; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { background: #ffe58a; } }
.placing .cell:not(.filled):not(.target) { background: #fffbea; }
.cell.moving .tile { outline: 3px solid var(--ink); outline-offset: 2px; opacity: .55; }
.cell.just-placed .tile { animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
.table-tip { margin-top: 6px; }
.bench { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.bench h3 { margin: 0 0 14px; font-size: 18px; }
.bench h3 .sub { font-weight: 400; margin: 0; }
.bench-list { display: flex; flex-wrap: wrap; gap: 12px; }
.bench-item { width: 92px; border: 0; padding: 0; background: none; border-radius: 10%; }
.bench-item.moving .tile { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(18,18,18,.45); display: grid; place-items: center; padding: 16px; z-index: 20; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; background: var(--bg); border-radius: 24px; padding: 28px; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.sheet-close { position: absolute; top: 14px; right: 14px; }
.sheet-tile { width: 180px; margin: 0 auto 16px; }
.sheet h2 { text-align: center; font-size: 26px; margin-bottom: 18px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions .btn.primary { grid-column: 1 / -1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 32px; text-align: center; }

@media (max-width: 860px) {
    main { padding: 0 16px 48px; }
    .topbar { padding: 16px; }
    .home-hero { grid-template-columns: 1fr; gap: 28px; padding: 16px 0; min-height: 0; }
    .home-art { justify-self: start; max-width: 300px; order: -1; }
    .lead { font-size: 16px; }
    .wizard-top { padding: 0 0 16px; }
    .wizard-body { grid-template-columns: 1fr; gap: 18px; }
    .preview-wrap { position: static; display: flex; justify-content: center; }
    .preview { width: 150px; }
    .step { min-height: 0; }
    .swatches { gap: 3px; }
    .swatch { border-radius: 5px; }
    .field { font-size: 28px; }
    .field-symbol { font-size: 40px; }
    .wizard-nav { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0 16px; margin-top: 8px; }
    .wizard-nav .btn { flex: 1; min-width: 0; }
    .result { grid-template-columns: 1fr; gap: 24px; padding: 0; }
    .result-tile { width: min(280px, 72vw); margin: 0 auto; }
    .actions.stack { align-items: stretch; }
    .actions.stack .row .btn { flex: 1; }
    .ptable { min-width: 0; grid-template-columns: repeat(18, 46px); }
    .table-head .row .btn { flex: 1; }
    .sheet { padding: 22px 18px; }
    .sheet-tile { width: 140px; }
}
@media (max-width: 380px) {
    .sheet-actions { grid-template-columns: 1fr; }
    .btn { padding: 0 14px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
