:root {
  color-scheme: dark;
  --ink: #f3f6fa;
  --muted: #9aa3af;
  --panel: #1d2026;
  --panel-2: #15171b;
  --line: rgba(255, 255, 255, 0.11);
  --acid: #7dd3fc;
  --acid-dark: #09131a;
  --orange: #ff7448;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(125, 211, 252, 0.09), transparent 28rem),
    linear-gradient(150deg, #090a0d, #15171b 52%, #0d0f13);
}

button {
  font: inherit;
}

h1, h2, p {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--acid);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.game-shell {
  width: min(1520px, calc(100% - 24px));
  margin: 0 auto;
  padding: 8px 0 28px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(210px, 230px) minmax(560px, 1fr) minmax(260px, 300px);
  grid-template-areas: "info track controls";
  align-items: start;
  gap: 10px;
}

.side-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(29, 32, 38, 0.94);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18);
}

.info-panel {
  grid-area: info;
}

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--acid);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.brand-dot {
  width: 16px;
  height: 16px;
  border: 4px solid #15171b;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 2px var(--acid), 0 0 22px rgba(125, 211, 252, 0.48);
}

.side-brand .eyebrow {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.35;
}

.size-picker,
.difficulty-picker {
  margin: 0 0 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.difficulty-picker {
  border-color: rgba(255, 116, 72, 0.28);
  background: rgba(255, 116, 72, 0.055);
}

.picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.picker-heading strong {
  font-size: 0.72rem;
}

.size-picker .picker-heading strong { color: var(--acid); }
.difficulty-picker .picker-heading strong { color: var(--orange); }

.picker-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.picker-buttons button {
  min-width: 0;
  min-height: 34px;
  padding: 7px 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #171a20;
  font-size: 0.66rem;
  font-weight: 750;
  cursor: pointer;
}

.size-picker .picker-buttons button:hover,
.size-picker .picker-buttons button.is-active {
  border-color: var(--acid);
  color: var(--acid-dark);
  background: var(--acid);
}

.difficulty-picker .picker-buttons button:hover,
.difficulty-picker .picker-buttons button.is-active {
  border-color: var(--orange);
  color: #1b0b06;
  background: var(--orange);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 10px;
}

.stat {
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.stat-player strong { color: var(--acid); }
.stat-ai strong { color: var(--orange); }

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.55);
}

.button-primary {
  border-color: var(--acid);
  color: var(--acid-dark);
  background: var(--acid);
  font-weight: 800;
}

.button-secondary,
.button-ghost {
  background: rgba(255, 255, 255, 0.04);
}

.restart-wide {
  width: 100%;
  margin: 0 0 14px;
}

.game-status {
  min-height: 72px;
  padding: 13px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 14px;
  background: rgba(125, 211, 252, 0.045);
}

.game-status p {
  margin: 6px 0 0;
  color: #d9dee6;
  font-size: 0.85rem;
  line-height: 1.45;
}

.board-column {
  grid-area: track;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}

.board-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 330px;
  background: var(--panel-2);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}

canvas:focus-visible {
  outline: 2px solid rgba(125, 211, 252, 0.72);
  outline-offset: -3px;
}

.controls {
  display: flex;
  grid-area: controls;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

.rules-wide {
  width: 100%;
  order: -1;
}

.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  width: 100%;
  margin-top: 12px;
}

.ad-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.ad-slot-banner { margin: 12px 0 0; }

.legend {
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #d9dee6;
  font-size: 0.85rem;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend-player { background: var(--acid); }
.legend-ai { background: var(--orange); }

.rules {
  position: relative;
  width: min(560px, calc(100% - 32px));
  margin: auto;
  padding: 28px;
  border: 1px solid rgba(125, 211, 252, 0.32);
  border-radius: 24px;
  color: var(--ink);
  background: #171a20;
  box-shadow: var(--shadow);
}

.rules::backdrop {
  background: rgba(7, 8, 11, 0.78);
  backdrop-filter: blur(5px);
}

.rules h2 {
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.rules p {
  max-width: 900px;
  margin-bottom: 8px;
  color: #d7dce3;
  line-height: 1.55;
}

.rules p:last-child {
  margin-bottom: 0;
}

.rules-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  font-size: 1.25rem;
  cursor: pointer;
}

.result-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 30px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 26px;
  color: var(--ink);
  background: #171a20;
  box-shadow: var(--shadow);
  text-align: center;
}

.result-dialog::backdrop {
  background: rgba(7, 8, 11, 0.8);
  backdrop-filter: blur(5px);
}

.result-dialog h2 {
  margin-bottom: 8px;
  font-size: 2rem;
}

.result-dialog p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.result-icon {
  margin-bottom: 10px;
  font-size: 2.5rem;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 22px;
}

@media (max-width: 1100px) {
  .game-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "track track"
      "info controls";
  }

  .controls {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto;
    align-items: center;
  }

  .rules-wide,
  .legend {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .game-shell {
    width: min(100% - 12px, 1520px);
    padding-top: 6px;
  }

  .game-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "track"
      "info"
      "controls";
  }

  .canvas-wrap {
    min-height: 280px;
    aspect-ratio: auto;
  }

  .board-card {
    order: 1;
  }

  .controls {
    display: flex;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Conteúdo editorial (história/estratégia), comentários e rodapé de
   navegação -- mesmo bloco copiado em todo site do catálogo (onme.click
   e cada jogo), igual ao padrão de duplicação do zoom-pan.js. */

.page-content {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.page-content h2 {
  font-size: 1.25rem;
  margin: 0 0 12px;
}

.page-content h3 {
  font-size: 1.02rem;
  margin: 22px 0 10px;
  color: var(--acid);
}

.page-content p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 14px;
}

.page-content ul {
  color: var(--muted);
  line-height: 1.7;
  padding-left: 20px;
  margin: 0 0 14px;
}

.page-content li {
  margin-bottom: 6px;
}

.comments-section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.comments-section h2 {
  font-size: 1.25rem;
  margin: 0 0 6px;
}

.comments-hint {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 0.92rem;
}

.comments-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 26px;
}

.comments-honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

.comments-form input[type="text"],
.comments-form textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
}

.comments-form input[type="text"]:focus,
.comments-form textarea:focus {
  outline: none;
  border-color: var(--acid);
}

.comments-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.comments-error {
  color: var(--orange);
  font-size: 0.85rem;
}

.comments-submit {
  align-self: flex-start;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: var(--acid);
  color: #0b1220;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}

.comments-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.comments-submit:hover:not(:disabled) {
  filter: brightness(1.08);
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comment-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}

.comment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.comment-head strong {
  font-size: 0.88rem;
}

.comment-date {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.comment-item p {
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.55;
}

.comments-empty,
.comments-loading {
  color: var(--muted);
  font-size: 0.88rem;
}

.site-foot {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.site-foot nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.site-foot nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-foot nav a:hover {
  color: var(--ink);
}

.site-foot small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

/* Alinha .page-content/.comments-section com a coluna central do
   tabuleiro (mesmas frações de .game-layout), igual à home. */
.content-align {
  display: grid;
  grid-template-columns: minmax(210px, 230px) minmax(560px, 1fr) minmax(260px, 300px);
  gap: 10px;
}

.content-align > * {
  grid-column: 2;
}

@media (max-width: 1100px) {
  .content-align {
    grid-template-columns: 1fr;
  }
  .content-align > * {
    grid-column: 1;
  }
}
