/* ---------- tokens ---------- */
:root {
  --bg: #f5efe4;
  --bg-2: #ece3d3;
  --surface: #fffaf1;
  --ink: #2a2420;
  --muted: #76695b;
  --line: #e2d6c2;
  --sq-light: #efe3c8;
  --sq-dark: #b89c72;
  --frame: #5a4330;
  --frame-2: #745840;
  --piece: #2a221c;
  --piece-line: #f6ecd8;
  --accent: #2f6b50;
  --accent-2: #3d8564;
  --accent-ink: #ffffff;
  --gold: #c99228;
  --gold-soft: #f3dfae;
  --sel: #e9b23a;
  --dest: rgba(47, 107, 80, 0.5);
  --error: #b2402f;
  --ok: #2f7a55;
  --card: #fffdf7;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.08), 0 6px 18px rgba(60, 40, 20, 0.08);
  --shadow-lg: 0 10px 40px rgba(40, 25, 10, 0.18);
  --radius: 16px;
  --tap: 48px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --bg-2: #1d1a15; --surface: #221e18; --ink: #f1e9da; --muted: #b3a690; --line: #3a3228;
    --sq-light: #cdb994; --sq-dark: #94795a; --frame: #3a2b1f; --frame-2: #4c3a2a;
    --piece: #241d17; --piece-line: #f6ecd8; --accent: #5fb38a; --accent-2: #7cc8a1; --accent-ink: #0d1411;
    --gold: #e7b44a; --gold-soft: #4a3c1d; --sel: #f2c255; --dest: rgba(30, 80, 55, 0.6);
    --error: #ff8f7c; --ok: #7fd3a7; --card: #2a251e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f; --bg-2: #1d1a15; --surface: #221e18; --ink: #f1e9da; --muted: #b3a690; --line: #3a3228;
  --sq-light: #cdb994; --sq-dark: #94795a; --frame: #3a2b1f; --frame-2: #4c3a2a;
  --piece: #241d17; --piece-line: #f6ecd8; --accent: #5fb38a; --accent-2: #7cc8a1; --accent-ink: #0d1411;
  --gold: #e7b44a; --gold-soft: #4a3c1d; --sel: #f2c255; --dest: rgba(30, 80, 55, 0.6);
  --error: #ff8f7c; --ok: #7fd3a7; --card: #2a251e;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 50% -200px, var(--bg-2), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px 4px; max-width: 1040px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, var(--frame-2), var(--frame)); color: var(--gold-soft);
  font-size: 22px; box-shadow: var(--shadow);
}
.brand-text { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.brand-text small { font-family: var(--sans); font-weight: 500; font-size: 0.8rem; color: var(--muted); margin-left: 4px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.rank-btn {
  display: grid; gap: 4px; min-height: 44px; min-width: 112px; padding: 6px 12px; cursor: pointer;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  text-align: left;
}
.rank-name { font-weight: 700; font-size: 0.85rem; display: flex; gap: 6px; align-items: baseline; white-space: nowrap; }
.rank-name small { color: var(--muted); font-weight: 500; }
.xp-track { display: block; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.xp-fill {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #e8c15d); transition: width 0.8s cubic-bezier(.2, .8, .2, 1);
}

.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 14px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: 0;
}
.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); }
.icon-btn.small { width: 44px; height: 44px; box-shadow: none; font-size: 1rem; }
.icon-btn:focus-visible, .rank-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.hud {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 16px 10px; max-width: 1040px; margin: 0 auto;
  font-size: 0.85rem; color: var(--muted);
}
.hud-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line);
}
.hud-item b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ring { width: 22px; height: 22px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset 0.6s ease; }
.hud-item.done { border-color: var(--accent); }
.flame { width: 18px; height: 18px; fill: var(--muted); opacity: 0.6; }
.hud-item.hot .flame { fill: #d9661f; opacity: 1; }
.sun { width: 18px; height: 18px; fill: var(--gold); stroke: var(--gold); stroke-width: 2; stroke-linecap: round; }
@media (max-width: 420px) {
  .brand-text small { display: none; } .brand-text { font-size: 1.1rem; }
  .hud { flex-wrap: nowrap; gap: 6px; } .hud-word { display: none; } .hud-item { padding: 4px 8px 4px 6px; }
}

/* ---------- layout ---------- */
.layout {
  display: grid; gap: 10px; padding: 0 16px 28px; max-width: 1040px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "cardrow" "board" "side";
}
.card-row { grid-area: cardrow; }
.board-area { grid-area: board; }
.side { grid-area: side; display: grid; gap: 12px; align-content: start; min-width: 0; }
@media (min-width: 780px) and (min-aspect-ratio: 1/1) {
  .layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr);
    grid-template-areas: "board cardrow" "board side";
    grid-template-rows: auto 1fr; align-items: start; gap: 16px 24px;
  }
}

/* ---------- tabuleiro ---------- */
.board-area { display: flex; justify-content: center; }
.board-frame {
  /* cabe na largura e na altura (cabeçalho + carta + painel ficam visíveis) */
  --size: max(200px, min(calc(100vw - 52px), 46dvh, calc(100dvh - 330px), 520px));
  padding: 10px; border-radius: 22px;
  background: linear-gradient(150deg, var(--frame-2), var(--frame));
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
@media (min-width: 780px) and (min-aspect-ratio: 1/1) {
  .board-frame { --size: min(56vw - 60px, 74dvh - 120px, 560px); }
}
.board {
  width: var(--size); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  border-radius: 12px; overflow: hidden; touch-action: manipulation; user-select: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.sq {
  position: relative; border: 0; margin: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--sq-light); container-type: size;
  transition: background-color 0.2s;
}
.sq.dark { background: var(--sq-dark); }
.sq:focus-visible { outline: 3px solid var(--accent); outline-offset: -6px; z-index: 2; }
.sq.selected::before {
  content: ""; position: absolute; inset: 6%; border-radius: 14%;
  background: color-mix(in srgb, var(--sel) 30%, transparent); box-shadow: inset 0 0 0 3px var(--sel);
}
.sq.dest::after {
  content: ""; position: absolute; width: 24%; aspect-ratio: 1; border-radius: 50%; background: var(--dest);
  animation: pop 0.18s ease-out;
}
.sq.hint-from::before {
  content: ""; position: absolute; inset: 6%; border-radius: 14%; box-shadow: inset 0 0 0 3px var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.sq.hint-to::after {
  content: ""; position: absolute; inset: 14%; border: 3px dashed var(--accent); border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
.sq.last-from { background-image: linear-gradient(color-mix(in srgb, var(--sel) 22%, transparent), color-mix(in srgb, var(--sel) 22%, transparent)); }
.sq.last-to { background-image: linear-gradient(color-mix(in srgb, var(--sel) 32%, transparent), color-mix(in srgb, var(--sel) 32%, transparent)); }
.sq.shake { animation: shake 0.32s; }
.sq .coord {
  position: absolute; left: 7%; bottom: 5%; font-size: max(10px, 9cqmin); font-weight: 600;
  color: color-mix(in srgb, var(--piece) 45%, transparent); pointer-events: none;
}

.piece { display: grid; place-items: center; pointer-events: none; position: relative; z-index: 1; }
.board .piece { width: 82cqmin; height: 82cqmin; }
.piece svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(30, 15, 0, 0.28)); }
.piece .b { fill: var(--piece); stroke: var(--piece); stroke-width: 1.5; stroke-linejoin: round; }
.piece .l { fill: none; stroke: var(--piece-line); stroke-width: 2.6; stroke-linecap: round; opacity: 0.5; }
.piece .e { fill: var(--piece-line); }
.sq.selected .piece { transform: translateY(-4%) scale(1.04); transition: transform 0.15s; }

/* ---------- carta ---------- */
.card-row { display: flex; gap: 10px; align-items: flex-end; justify-content: space-between; }
.card-info { display: grid; gap: 8px; min-width: 0; flex: 1 1 auto; align-content: end; }
.card {
  background: var(--card); border-radius: 16px; padding: 6px 8px 8px; box-shadow: var(--shadow);
  border: 1px solid var(--line); flex: none;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.card-title { font-family: var(--serif); font-weight: 700; font-size: 0.8rem; }
.card-orient { font-size: 0.68rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.card-orient.changed { color: var(--accent); }
.card-wrap { position: relative; padding: 6px; }
.card-board {
  --csize: clamp(88px, 27vw, 150px);
  width: var(--csize); aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, 1fr);
  border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.card-board .csq { display: grid; place-items: center; background: var(--sq-light); container-type: size; position: relative; }
.card-board .csq.dark { background: var(--sq-dark); }
.card-board .csq.match::after {
  content: "✓"; position: absolute; right: 6%; top: 2%; font-size: max(9px, 22cqmin); font-weight: 800; color: var(--ok);
}
.card-board .piece { width: 76cqmin; height: 76cqmin; }
.card-top {
  position: absolute; width: 0; height: 0; border: 6px solid transparent; transition: all 0.3s;
}
.card-top[data-edge="top"] { top: -5px; left: calc(50% - 6px); border-bottom-color: var(--gold); }
.card-top[data-edge="bottom"] { bottom: -5px; left: calc(50% - 6px); border-top-color: var(--gold); }
.card-top[data-edge="left"] { left: -5px; top: calc(50% - 6px); border-right-color: var(--gold); }
.card-top[data-edge="right"] { right: -5px; top: calc(50% - 6px); border-left-color: var(--gold); }

.card-ops { display: grid; grid-template-columns: repeat(4, minmax(44px, 1fr)); gap: 6px; }
.card-ops:empty { display: none; }
.op-btn {
  min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  display: grid; place-items: center; gap: 0; padding: 6px 4px; box-shadow: var(--shadow); font-size: 0.72rem; font-weight: 600; color: var(--muted);
}
.op-btn .sym { font-size: 1.3rem; line-height: 1.1; color: var(--ink); }
.op-btn .op-label { display: none; }
@media (min-width: 780px) { .op-btn .op-label { display: block; } .card-ops { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.op-btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.op-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.op-btn.suggested { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.op-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- status ---------- */
.status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 0.8rem; }
.pill.soft { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.counters { display: flex; gap: 14px; flex-wrap: wrap; }
.counter { display: inline-flex; align-items: baseline; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.counter strong { font-size: 1.35rem; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 1.2ch; text-align: right; }
.counter strong.bump { animation: bump 0.25s ease-out; }

/* ---------- painel ---------- */
.panel { display: grid; gap: 10px; }
.panel h2 { font-family: var(--serif); font-size: 1.15rem; margin: 2px 0 0; }
.panel .sub { margin: -4px 0 2px; color: var(--muted); font-size: 0.9rem; }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1 1 0; }

.btn {
  min-height: var(--tap); padding: 8px 14px; border-radius: 14px; cursor: pointer; font-weight: 650;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.15;
  transition: transform 0.08s, background-color 0.15s, border-color 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { min-height: 44px; padding: 6px 14px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--error); }

.estimate-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.estimate-grid .btn { padding: 0; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-height: 50px; }

.timer { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.timer > span { display: block; height: 100%; background: var(--sel); transition: width 0.25s linear; }

/* resultado */
.result {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); text-align: center; animation: rise 0.35s cubic-bezier(.2, .8, .2, 1);
}
.stars { display: flex; justify-content: center; gap: 6px; margin: 0 0 6px; font-size: 2.4rem; line-height: 1; }
.stars span { color: var(--line); animation: star-in 0.45s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.stars span.on { color: var(--gold); text-shadow: 0 2px 8px color-mix(in srgb, var(--gold) 50%, transparent); }
.stars span:nth-child(2) { animation-delay: 0.15s; }
.stars span:nth-child(3) { animation-delay: 0.3s; }
.result .big { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; margin: 0 0 4px; color: var(--ink); }
.result p { margin: 4px 0; color: var(--muted); }
.result .good { color: var(--ok); font-weight: 600; }
.result .bad { color: var(--error); font-weight: 600; }
.xp-gain {
  display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 2px; padding: 4px 12px; border-radius: 999px;
  background: var(--gold-soft); color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums;
}
.xp-parts { list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); }
.xp-parts li { display: flex; justify-content: center; gap: 8px; }
.rank-up { margin-top: 8px; padding: 8px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); font-weight: 700; }

.solution { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.solution strong { font-family: var(--serif); }
.solution ol { margin: 8px 0 0; padding-left: 1.4em; }
.solution li { margin: 3px 0; }

.message { min-height: 1.4em; margin: 0; color: var(--muted); font-size: 0.95rem; }
.message.error { color: var(--error); font-weight: 600; }
.message.hint { color: var(--accent); font-weight: 650; }
.message.warn { color: var(--ink); }

/* ---------- avisos e confete ---------- */
.toasts {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--gold); box-shadow: var(--shadow-lg);
  animation: toast-in 0.35s cubic-bezier(.2, .9, .3, 1.2), toast-out 0.4s ease-in 3.6s forwards;
}
.toast .t-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 1.3rem;
  background: linear-gradient(145deg, #f1d68c, var(--gold)); color: #3b2a08;
}
.toast b { display: block; }
.toast small { color: var(--muted); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100dvh; pointer-events: none; z-index: 40; }

/* ---------- diálogos ---------- */
dialog {
  border: 0; border-radius: 22px; padding: 0; background: var(--surface); color: var(--ink);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: rise 0.25s cubic-bezier(.2, .8, .2, 1); }
dialog::backdrop { background: rgba(20, 12, 4, 0.45); backdrop-filter: blur(2px); }
.sheet { padding: 16px 18px 18px; display: grid; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 1.35rem; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
legend { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; padding: 0; }

.choice-cards { gap: 8px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: grid; gap: 2px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg);
  min-height: 52px; align-content: center;
}
.choice small { color: var(--muted); }
.choice input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.segmented { grid-template-columns: repeat(3, 1fr); }
.segmented legend { grid-column: 1 / -1; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center; min-height: 52px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--bg); font-weight: 650; line-height: 1.1;
}
.segmented small { color: var(--muted); font-weight: 500; font-size: 0.75rem; }
.segmented input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; cursor: pointer; }
.switch span { display: grid; }
.switch small { color: var(--muted); font-size: 0.82rem; }
.switch input {
  appearance: none; flex: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative;
  cursor: pointer; transition: background-color 0.2s; margin: 0;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch.disabled { opacity: 0.5; }

.extra { border-top: 1px solid var(--line); padding-top: 10px; }
.extra summary { cursor: pointer; font-weight: 650; min-height: 40px; display: flex; align-items: center; }
.select-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; }
select, .code-row input {
  min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 4px 10px;
}
.code-row { display: flex; gap: 8px; margin: 6px 0; }
.code-row input { flex: 1; min-width: 0; }
.code { flex: 1; font-family: ui-monospace, monospace; font-size: 1.05rem; align-self: center; }
.hint-text { color: var(--muted); font-size: 0.88rem; margin: 4px 0; }
.rules { padding-left: 1.2em; margin: 6px 0; }
.sheet-actions { position: sticky; bottom: -18px; padding: 10px 0 0; background: var(--surface); }

/* progresso */
.rank-hero { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 18px; background: linear-gradient(150deg, var(--frame-2), var(--frame)); color: #f8efdc; }
.rank-hero .medal {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(circle at 35% 30%, #f6dc93, var(--gold)); color: #3b2a08; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.rank-hero .medal .piece { width: 44px; height: 44px; }
.rank-hero .medal .piece .b { fill: #3b2a08; stroke: #3b2a08; }
.rank-hero h3 { margin: 0; font-family: var(--serif); font-size: 1.3rem; }
.rank-hero p { margin: 2px 0 6px; opacity: 0.85; font-size: 0.9rem; }
.rank-hero .xp-track { background: rgba(255, 255, 255, 0.2); height: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.kpi b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 0.8rem; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); }
.ach .a-icon {
  width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem;
  background: var(--line); color: var(--muted); filter: grayscale(1);
}
.ach .a-icon { font-weight: 800; font-size: 0.95rem; }
.ach.on .a-icon { background: linear-gradient(145deg, #f1d68c, var(--gold)); color: #3b2a08; filter: none; }
.ach b { display: block; font-size: 0.85rem; }
.ach small { display: block; color: var(--muted); font-size: 0.75rem; line-height: 1.25; }
.ach:not(.on) b { color: var(--muted); }
.goal-choice { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.goal-choice .btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.stats-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { text-align: right; padding: 6px; border-bottom: 1px solid var(--line); }
.stats-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.section-title { margin: 4px 0 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* boas-vindas */
.welcome { text-align: center; padding: 24px 22px; }
.welcome-mark {
  width: 72px; height: 72px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; font-size: 42px;
  background: linear-gradient(145deg, var(--frame-2), var(--frame)); color: var(--gold-soft); box-shadow: var(--shadow-lg);
}
.steps { text-align: left; margin: 0 auto; padding-left: 1.4em; display: grid; gap: 6px; max-width: 320px; }

.noscript { padding: 16px; }

/* ---------- animações ---------- */
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 50% { opacity: 0.45; } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes star-in { from { transform: scale(0.4); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(-20px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-12px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- estimativa opcional ---------- */
.estimate-strip { display: grid; gap: 6px; }
.estimate-strip .label { font-size: 0.85rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none; min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; scroll-snap-align: start;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- backup ---------- */
.hud-item.sync { cursor: pointer; font: inherit; color: inherit; }
.hud-item.sync .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.hud-item.sync[data-kind="ok"] .dot { background: var(--ok); }
.hud-item.sync[data-kind="syncing"] .dot { background: var(--sel); animation: pulse 1s infinite; }
.hud-item.sync[data-kind="error"] .dot { background: var(--error); }
.small-code { font-size: 0.82rem; word-break: break-all; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .btn { flex: 1 1 auto; }
.file-btn { cursor: pointer; }
