:root {
  --ink: #eef3ff;
  --muted: #9ba8c5;
  --panel: rgba(22, 32, 56, 0.82);
  --line: rgba(168, 189, 232, 0.18);
  --accent: #7df2a7;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000;
}

button {
  font: inherit;
  cursor: pointer;
}

/* Main page spacing and centered game area. */
.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto 36px;
}

.brand {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand span {
  color: var(--accent);
  font-size: 1.4em;
  text-shadow: 0 0 18px var(--accent);
}

.text-button,
.secondary-button {
  padding: 10px 14px;
  color: var(--ink);
  font-weight: 650;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: 0.2s ease;
}

.text-button:hover,
.secondary-button:hover {
  background: rgba(125, 242, 167, 0.1);
  border-color: rgba(125, 242, 167, 0.6);
}

.game-layout {
  max-width: 620px;
  margin: auto;
  text-align: center;
}

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

.game-heading h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 6vw, 3.15rem);
  line-height: 1.05;
  letter-spacing: -0.06em;
}

/* Score cards stay in one neat row. */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 12px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: 1.35rem;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  background: #14233b;
  border: 1px solid rgba(125, 242, 167, 0.45);
  border-radius: 20px;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.35), 0 0 45px rgba(72, 202, 129, 0.12);
}

.board-wrap::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: inherit;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

/* This panel covers the board before play. */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(8, 14, 28, 0.77);
  backdrop-filter: blur(8px);
}

.overlay.is-hidden {
  display: none;
}

.game-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  font-size: 2.2rem;
  background: rgba(125, 242, 167, 0.13);
  border: 1px solid rgba(125, 242, 167, 0.35);
  border-radius: 18px;
  place-items: center;
}

.overlay h2 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.overlay p:not(.eyebrow) {
  max-width: 330px;
  margin: 10px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.primary-button {
  min-width: 175px;
  padding: 13px 18px;
  color: #0c1b14;
  font-weight: 850;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(76, 211, 125, 0.3);
}

.primary-button:hover {
  background: #a1ffc1;
  transform: translateY(-1px);
}

.secondary-button {
  margin-top: 10px;
}

.game-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-height: 56px;
}

.control-hint {
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.87rem;
}

kbd {
  display: inline-grid;
  min-width: 21px;
  height: 21px;
  margin: 0 1px;
  color: var(--ink);
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  place-items: center;
}

.restart-button {
  display: none;
  margin-top: 0;
}

/* Phone controls appear only on small screens. */
.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 52px);
  justify-content: center;
  gap: 7px;
}

.touch-controls button {
  height: 46px;
  color: var(--ink);
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.touch-controls button:first-child {
  grid-column: 2;
}

.touch-controls button:active {
  background: rgba(125, 242, 167, 0.25);
}

.dialog-content {
  position: relative;
  padding: 34px;
}

dialog {
  width: min(92vw, 510px);
  padding: 0;
  color: var(--ink);
  background: #162039;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 25px 80px #000;
}

dialog::backdrop {
  background: rgba(3, 7, 15, 0.72);
  backdrop-filter: blur(4px);
}

.dialog-content h2 {
  margin: 0 0 16px;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.dialog-content ol {
  padding-left: 23px;
  margin: 0 0 24px;
  color: #c9d3ea;
  line-height: 1.55;
  text-align: left;
}

.dialog-content li + li {
  margin-top: 10px;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  color: var(--ink);
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  border-radius: 9px;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 16px;
  }

  .site-header {
    margin-bottom: 28px;
  }

  .game-heading h1 {
    font-size: 2.25rem;
  }

  .overlay {
    padding: 22px;
  }

  .touch-controls {
    display: grid;
  }

  .control-hint {
    display: none;
  }
}
