/* ==========================================================================
   Campo Minado — folha de estilo única, organizada em blocos:
   1. Tokens e temas   2. Base   3. Barra superior   4. Dificuldades
   5. Painel e HUD     6. Ferramentas   7. Tabuleiro   8. Fim de partida
   9. Diálogos        10. Rodapé      11. Responsivo e movimento
   ========================================================================== */

/* 1. Tokens e temas ------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #e9edf6;
  --bg-glow-1: rgba(59, 108, 246, 0.16);
  --bg-glow-2: rgba(16, 179, 163, 0.14);
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-sunken: #f2f5fc;
  --border: #d6ddee;
  --border-strong: #c2cbe4;
  --text: #16203a;
  --text-muted: #5c6885;
  --accent: #3b6cf6;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(59, 108, 246, 0.12);
  --danger: #dc2f36;
  --danger-soft: rgba(220, 47, 54, 0.12);
  --success: #12916f;

  --tile-a: #ccd6ea;
  --tile-b: #b0bdd9;
  --tile-hover-a: #d6dff0;
  --tile-hover-b: #bcc8e2;
  --tile-open: #eff3fb;
  --tile-open-alt: #e8eefa;
  --grid-line: #dbe2f1;
  --tile-shine: rgba(255, 255, 255, 0.75);
  --tile-shadow: rgba(28, 40, 74, 0.22);

  --n1: #1d4ed8;
  --n2: #15803d;
  --n3: #d92d20;
  --n4: #7e22ce;
  --n5: #b45309;
  --n6: #0e7490;
  --n7: #1f2937;
  --n8: #64748b;

  --flag: #d92d20;
  --flag-pole: #334155;
  --mine: #1f2937;
  --wrong: #d92d20;
  --hint: #0d9488;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-panel: 0 24px 60px -28px rgba(20, 32, 68, 0.5), 0 2px 6px rgba(20, 32, 68, 0.06);
  --shadow-pop: 0 18px 40px -16px rgba(20, 32, 68, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-digits: "SF Mono", "JetBrains Mono", "Cascadia Mono", ui-monospace, "Roboto Mono", Consolas, monospace;

  --zoom: 1;
}

/* Tema escuro: aplicado por escolha explícita ou pela preferência do sistema. */
:root[data-theme="escuro"] {
  color-scheme: dark;

  --bg: #0a0e1a;
  --bg-glow-1: rgba(59, 108, 246, 0.22);
  --bg-glow-2: rgba(16, 179, 163, 0.16);
  --surface: rgba(20, 26, 43, 0.82);
  --surface-solid: #141a2b;
  --surface-sunken: #101625;
  --border: #26304a;
  --border-strong: #364163;
  --text: #e8edfa;
  --text-muted: #94a2c2;
  --accent: #5b8bff;
  --accent-contrast: #08101f;
  --accent-soft: rgba(91, 139, 255, 0.18);
  --danger: #f26d72;
  --danger-soft: rgba(242, 109, 114, 0.16);
  --success: #34d399;

  --tile-a: #3a4665;
  --tile-b: #2b3450;
  --tile-hover-a: #46557a;
  --tile-hover-b: #333e5f;
  --tile-open: #171e31;
  --tile-open-alt: #1b2338;
  --grid-line: #232c46;
  --tile-shine: rgba(255, 255, 255, 0.14);
  --tile-shadow: rgba(0, 0, 0, 0.45);

  --n1: #7aa6ff;
  --n2: #4ade80;
  --n3: #fb7185;
  --n4: #c084fc;
  --n5: #fbbf24;
  --n6: #22d3ee;
  --n7: #e2e8f0;
  --n8: #9aa6bf;

  --flag: #ff6b6b;
  --flag-pole: #cbd5e1;
  --mine: #e8edfa;
  --wrong: #fb7185;
  --hint: #2dd4bf;

  --shadow-panel: 0 28px 70px -30px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 20px 50px -18px rgba(0, 0, 0, 0.85);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="sistema"] {
    color-scheme: dark;

    --bg: #0a0e1a;
    --bg-glow-1: rgba(59, 108, 246, 0.22);
    --bg-glow-2: rgba(16, 179, 163, 0.16);
    --surface: rgba(20, 26, 43, 0.82);
    --surface-solid: #141a2b;
    --surface-sunken: #101625;
    --border: #26304a;
    --border-strong: #364163;
    --text: #e8edfa;
    --text-muted: #94a2c2;
    --accent: #5b8bff;
    --accent-contrast: #08101f;
    --accent-soft: rgba(91, 139, 255, 0.18);
    --danger: #f26d72;
    --danger-soft: rgba(242, 109, 114, 0.16);
    --success: #34d399;

    --tile-a: #3a4665;
    --tile-b: #2b3450;
    --tile-hover-a: #46557a;
    --tile-hover-b: #333e5f;
    --tile-open: #171e31;
    --tile-open-alt: #1b2338;
    --grid-line: #232c46;
    --tile-shine: rgba(255, 255, 255, 0.14);
    --tile-shadow: rgba(0, 0, 0, 0.45);

    --n1: #7aa6ff;
    --n2: #4ade80;
    --n3: #fb7185;
    --n4: #c084fc;
    --n5: #fbbf24;
    --n6: #22d3ee;
    --n7: #e2e8f0;
    --n8: #9aa6bf;

    --flag: #ff6b6b;
    --flag-pole: #cbd5e1;
    --mine: #e8edfa;
    --wrong: #fb7185;
    --hint: #2dd4bf;

    --shadow-panel: 0 28px 70px -30px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 20px 50px -18px rgba(0, 0, 0, 0.85);
  }
}

/* 2. Base ----------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 12% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 520px at 108% 8%, var(--bg-glow-2), transparent 62%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, menu, figure {
  margin: 0;
}

button, input, select {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% -120%;
  z-index: 20;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  transition: translate 0.16s ease;
}

.skip-link:focus-visible {
  translate: -50% 0;
}

:where(button, [tabindex], input, a):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.noscript {
  margin: 2rem auto;
  max-width: 32rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  text-align: center;
}

.app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.25rem);
  padding: clamp(0.75rem, 2.5vw, 1.5rem) clamp(0.6rem, 3vw, 1.5rem) 1.5rem;
}

/* 3. Barra superior ------------------------------------------------------- */

.app-bar {
  width: min(100%, 62rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: clamp(1.1rem, 1rem + 1vw, 1.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border-radius: 30%;
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #10b3a3));
  color: var(--accent-contrast);
  box-shadow: var(--shadow-pop);
}

.brand-mark svg {
  width: 62%;
  height: 62%;
}

.app-bar-actions {
  display: flex;
  gap: 0.35rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, scale 0.12s ease;
}

.icon-button svg {
  width: 1.35rem;
  height: 1.35rem;
}

.icon-button:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.icon-button:active {
  scale: 0.94;
}

.icon-button .when-off,
.icon-button .when-dark {
  display: none;
}

.icon-button[aria-pressed="false"] .when-on {
  display: none;
}

.icon-button[aria-pressed="false"] .when-off {
  display: block;
}

:root[data-theme="escuro"] #btn-theme .when-light {
  display: none;
}

:root[data-theme="escuro"] #btn-theme .when-dark {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="sistema"] #btn-theme .when-light {
    display: none;
  }
  :root[data-theme="sistema"] #btn-theme .when-dark {
    display: block;
  }
}

/* 4. Dificuldades --------------------------------------------------------- */

.layout {
  width: min(100%, 62rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.1rem);
}

.difficulties {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-lg) - 4px);
  background: var(--surface);
  backdrop-filter: blur(12px);
}

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.chip-name {
  font-weight: 650;
  font-size: 0.95rem;
}

.chip-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chip:hover {
  background: var(--accent-soft);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-pop);
}

.chip[aria-pressed="true"] .chip-meta {
  color: color-mix(in srgb, var(--accent-contrast) 78%, transparent);
}

/* 5. Painel e HUD --------------------------------------------------------- */

.panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-panel);
}

.hud {
  width: min(100%, 26rem);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
}

.readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.readout svg {
  width: 1.1rem;
  height: 1.1rem;
}

.readout:first-child svg {
  color: var(--flag);
}

.digits {
  font-family: var(--font-digits);
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text);
}

.digits.is-alarm {
  color: var(--danger);
}

.face {
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: linear-gradient(165deg, var(--tile-hover-a), var(--tile-b));
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--tile-shine), 0 6px 14px -8px var(--tile-shadow);
  transition: scale 0.12s ease, filter 0.16s ease;
}

.face:hover {
  filter: brightness(1.06);
}

.face:active {
  scale: 0.93;
}

.face-icon {
  font-size: 1.6rem;
  line-height: 1;
}

/* 6. Ferramentas ---------------------------------------------------------- */

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tool svg {
  width: 1.05rem;
  height: 1.05rem;
}

.tool:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
}

.tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.tool-square {
  width: 2rem;
  padding: 0.35rem 0;
  justify-content: center;
  font-size: 1rem;
}

.zoom {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.25rem;
}

.zoom-value {
  min-width: 3.1rem;
  text-align: center;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* 7. Tabuleiro ------------------------------------------------------------ */

.board-viewport {
  position: relative;
  max-width: 100%;
  max-height: min(72svh, 46rem);
  overflow: auto;
  padding: 0.35rem;
  border-radius: var(--radius-md);
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.board-viewport::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.board-viewport::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 10px;
  background: var(--border-strong);
  background-clip: content-box;
}

.board {
  /* Espaço já ocupado por cabeçalho, dificuldades, HUD, ferramentas e rodapé:
     descontamos tudo isso para que o tabuleiro caiba na tela sem rolagem. */
  --chrome: 25rem;
  --fit-width: calc((min(100vw, 62rem) - 4.5rem) / var(--cols, 9));
  --fit-height: calc((100svh - var(--chrome)) / var(--rows, 9));
  --cell: calc(clamp(15px, min(var(--fit-width), var(--fit-height)), 42px) * var(--zoom));
  --gap: max(1px, calc(var(--cell) * 0.045));

  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: max-content;
  margin: 0 auto;
  padding: var(--gap);
  border-radius: var(--radius-md);
  background: var(--grid-line);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.board.is-shaking {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.row {
  display: flex;
  gap: var(--gap);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: max(2px, calc(var(--cell) * 0.16));
  background: linear-gradient(158deg, var(--tile-a), var(--tile-b));
  box-shadow: inset 0 1px 0 var(--tile-shine), 0 1px 2px var(--tile-shadow);
  font-family: var(--font);
  font-size: calc(var(--cell) * 0.58);
  font-weight: 800;
  line-height: 1;
  color: transparent;
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease, translate 0.1s ease;
}

@media (hover: hover) {
  .cell:not(.is-open):hover {
    background: linear-gradient(158deg, var(--tile-hover-a), var(--tile-hover-b));
    translate: 0 -1px;
  }
}

.cell.is-pressed:not(.is-open) {
  background: linear-gradient(158deg, var(--tile-b), var(--tile-b));
  box-shadow: inset 0 2px 4px var(--tile-shadow);
  translate: 0;
}

.cell.is-open {
  background: var(--tile-open);
  box-shadow: none;
  cursor: default;
}

.cell.is-open:nth-child(even) {
  background: var(--tile-open-alt);
}

.cell.is-open.can-chord {
  cursor: pointer;
}

.cell-icon {
  width: 72%;
  height: 72%;
  pointer-events: none;
}

.cell.is-flag {
  color: var(--flag);
}

.cell.is-flag .cell-icon {
  animation: flag-pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell.is-question {
  color: var(--text-muted);
}

.cell.is-mine {
  color: var(--mine);
  background: var(--tile-open);
}

.cell.is-exploded {
  background: radial-gradient(circle at 50% 50%, #ffb020, var(--danger) 62%);
  color: #ffffff;
  animation: boom 0.5s ease-out;
}

.cell.is-wrong {
  color: var(--text-muted);
}

.cell.is-wrong .cell-icon {
  opacity: 0.5;
}

.cell.is-wrong::after {
  content: "";
  position: absolute;
  inset: 14%;
  background:
    linear-gradient(45deg, transparent 43%, var(--wrong) 43%, var(--wrong) 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--wrong) 43%, var(--wrong) 57%, transparent 57%);
}

.cell.is-hint {
  animation: hint-pulse 0.9s ease-in-out 2;
}

.cell.is-flash {
  animation: flash 0.28s ease-out;
}

.cell.is-revealing {
  animation: reveal-pop 0.18s ease-out backwards;
  animation-delay: calc(var(--d, 0) * 9ms);
}

.cell.is-cheer {
  animation: cheer 0.6s ease-in-out backwards;
  animation-delay: calc(var(--d, 0) * 12ms);
}

.cell[data-n="1"] { color: var(--n1); }
.cell[data-n="2"] { color: var(--n2); }
.cell[data-n="3"] { color: var(--n3); }
.cell[data-n="4"] { color: var(--n4); }
.cell[data-n="5"] { color: var(--n5); }
.cell[data-n="6"] { color: var(--n6); }
.cell[data-n="7"] { color: var(--n7); }
.cell[data-n="8"] { color: var(--n8); }

.status {
  min-height: 1.4em;
  max-width: 40rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* 8. Fim de partida ------------------------------------------------------- */

.result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--surface-solid) 62%, transparent);
  backdrop-filter: blur(3px);
  animation: fade-in 0.22s ease-out;
}

.result[hidden] {
  display: none;
}

.result-card {
  min-width: min(20rem, 100%);
  padding: 1.25rem 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-panel);
  animation: rise 0.26s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.result-emoji {
  font-size: 2.4rem;
  line-height: 1;
}

.result-card h2 {
  margin: 0.4rem 0 0.25rem;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.result-detail {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.result-record {
  margin-top: 0.5rem;
  font-weight: 700;
  color: var(--success);
}

.result-record[hidden] {
  display: none;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* 9. Diálogos ------------------------------------------------------------- */

.button {
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, scale 0.1s ease;
}

.button:hover {
  filter: brightness(1.04);
}

.button:active {
  scale: 0.97;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.button.danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.dialog {
  width: min(34rem, calc(100vw - 2rem));
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-panel);
}

.dialog::backdrop {
  background: rgba(6, 10, 22, 0.55);
  backdrop-filter: blur(3px);
}

.dialog[open] {
  animation: rise 0.2s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.dialog h2 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.dialog h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dialog p {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.help-list {
  padding-left: 1.1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
}

.help-list b {
  color: var(--text);
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-sunken);
  font-family: var(--font-digits);
  font-size: 0.78em;
  text-align: center;
  color: var(--text);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  padding: 0;
}

.fieldset {
  margin: 0 0 1rem;
  padding: 0.75rem 0 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.fieldset legend {
  padding: 0 0.5rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.segmented {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.segmented label {
  flex: 1;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--accent-contrast);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.switch {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.5rem 0;
  cursor: pointer;
}

.switch input {
  appearance: none;
  flex: none;
  width: 2.4rem;
  height: 1.4rem;
  margin: 0.1rem 0 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.16s ease;
}

.switch input::after {
  content: "";
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0.175rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: translate 0.16s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.switch input:checked {
  background: var(--accent);
}

.switch input:checked::after {
  translate: 1rem 0;
}

.switch-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
}

.switch-note {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.field input,
.seed-row input {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-variant-numeric: tabular-nums;
}

.field-note {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.field-error {
  margin-top: 0.4rem;
  min-height: 1.2em;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
}

.seed-row {
  display: flex;
  gap: 0.5rem;
}

.seed-row input {
  flex: 1;
  min-width: 0;
}

.stats-wrap {
  overflow-x: auto;
}

#dlg-stats {
  width: min(38rem, calc(100vw - 2rem));
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.stats-table th,
.stats-table td {
  padding: 0.5rem 0.45rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table th:first-child,
.stats-table td:first-child {
  text-align: left;
}

.stats-table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.stats-empty {
  color: var(--text-muted);
}

/* 10. Rodapé -------------------------------------------------------------- */

.app-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.seed {
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-sunken);
  font-family: var(--font-digits);
  font-size: 0.95em;
  color: var(--text);
  cursor: pointer;
}

.seed:hover {
  border-color: var(--border-strong);
}

.hints kbd {
  margin: 0 0.1em;
}

/* 11. Responsivo e movimento --------------------------------------------- */

@media (max-width: 40rem) {
  .brand {
    font-size: 1.05rem;
    white-space: nowrap;
  }

  .brand-mark {
    width: 2em;
    height: 2em;
  }

  /* Título + cinco ícones pediam ~430 px e empurravam a página para o lado em
     qualquer celular mais estreito que isso (todo iPhone). */
  .app-bar {
    gap: 0.5rem;
    flex-wrap: wrap; /* rede de segurança: melhor quebrar a linha que estourar a tela */
  }

  .app-bar-actions {
    gap: 0;
  }

  .icon-button {
    width: 2.25rem;
    height: 2.25rem;
  }

  .chip-meta {
    display: none;
  }

  .chip {
    padding: 0.45rem 0.7rem;
  }

  .board {
    --chrome: 20rem;
    --fit-width: calc((100vw - 3rem) / var(--cols, 9));
  }

  .board-viewport {
    max-height: 66svh;
  }

  .hints {
    display: none;
  }
}

/* Abaixo de ~425 px (todo iPhone) nem assim cabe: o símbolo sai, o nome fica. */
@media (max-width: 26.5rem) {
  .brand-mark {
    display: none;
  }
}

@media (max-width: 22.5rem) {
  .brand {
    font-size: 0.95rem;
  }

  .icon-button {
    width: 2.1rem;
    height: 2.1rem;
  }
}

@keyframes reveal-pop {
  from { opacity: 0.25; scale: 0.86; }
  to { opacity: 1; scale: 1; }
}

@keyframes flag-pop {
  from { scale: 0.3; rotate: -18deg; }
  to { scale: 1; rotate: 0deg; }
}

@keyframes boom {
  0% { scale: 0.7; filter: brightness(2.2); }
  45% { scale: 1.18; }
  100% { scale: 1; filter: brightness(1); }
}

@keyframes shake {
  10%, 90% { translate: -2px 0; }
  20%, 80% { translate: 4px 0; }
  30%, 50%, 70% { translate: -6px 0; }
  40%, 60% { translate: 6px 0; }
}

@keyframes hint-pulse {
  0%, 100% { box-shadow: inset 0 1px 0 var(--tile-shine), 0 1px 2px var(--tile-shadow); }
  50% { box-shadow: 0 0 0 3px var(--hint), 0 0 18px -2px var(--hint); }
}

@keyframes flash {
  0%, 100% { background: linear-gradient(158deg, var(--tile-a), var(--tile-b)); }
  50% { background: var(--danger-soft); }
}

@keyframes cheer {
  0%, 100% { translate: 0 0; }
  40% { translate: 0 -22%; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise {
  from { opacity: 0; translate: 0 12px; scale: 0.97; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
