
:root {
  color-scheme: dark;
  --bg: #101426;
  --panel: #171d34;
  --panel2: #1e2744;
  --line: rgba(177, 190, 255, .15);
  --text: #f6f7ff;
  --muted: #a8b0d0;
  --cyan: #5ce6df;
  --purple: #9b83ff;
  --pink: #ff76b7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(94,75,190,.23), transparent 42%),
    radial-gradient(ellipse at 100% 38%, rgba(32,191,198,.12), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand {
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.8px;
  text-decoration: none;
}

.brand span {
  color: var(--cyan);
  margin-left: 5px;
}

.tag {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

.intro {
  text-align: center;
  margin-bottom: 23px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--cyan);
  font-size: 10px;
  letter-spacing: 2.5px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 49px);
  line-height: 1.08;
  letter-spacing: -1.8px;
}

h1 span {
  color: var(--purple);
}

.sub {
  max-width: 490px;
  margin: 11px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(30,38,68,.95), rgba(22,28,49,.95));
}

.stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1.6px;
  font-weight: 900;
}

.stat strong {
  font-size: 27px;
  font-variant-numeric: tabular-nums;
}

.game-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(23,29,52,.94);
  box-shadow: 0 20px 55px rgba(0,0,0,.16);
}

.gamebar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 4px 12px;
  color: var(--muted);
  font-size: 11px;
}

#status {
  color: var(--text);
  font-weight: 800;
}

.hint {
  font-size: 10px;
  text-align: right;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: auto;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(130,151,230,.16);
  border-radius: 15px;
  background: #11182d;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(15,21,40,.82);
  text-align: center;
}

.overlay[hidden] {
  display: none;
}

.overlay-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  font-size: 28px;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(20px, 4vw, 27px);
  letter-spacing: -.7px;
}

.overlay p {
  max-width: 310px;
  margin: 9px 0 19px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.primary,
.secondary {
  border: 0;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .15s, filter .15s;
}

.primary {
  padding: 13px 18px;
  color: #101426;
  background: linear-gradient(105deg, var(--cyan), #a4f4e8);
  box-shadow: 0 7px 22px rgba(92,230,223,.15);
}

.primary span {
  margin-left: 14px;
  font-size: 16px;
}

.primary:hover,
.secondary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 4px 9px;
}

.control-copy strong {
  display: block;
  font-size: 12px;
}

.control-copy span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 39px);
  grid-template-rows: repeat(2, 36px);
  gap: 5px;
}

.dpad button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

.dpad button:active {
  background: var(--cyan);
  color: #101426;
}

.dpad .up {
  grid-column: 2;
  grid-row: 1;
}

.dpad button[aria-label="Left"] {
  grid-column: 1;
  grid-row: 2;
}

.dpad button[aria-label="Down"] {
  grid-column: 2;
  grid-row: 2;
}

.dpad button[aria-label="Right"] {
  grid-column: 3;
  grid-row: 2;
}

.actions {
  display: flex;
  gap: 9px;
  padding: 6px 4px 2px;
}

.secondary {
  padding: 11px 14px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
}

.secondary:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 3px 4px;
  color: #7781a7;
  font-size: 10px;
}

button:focus-visible {
  outline: 3px solid white;
  outline-offset: 3px;
}

@media (max-width: 520px) {
  body {
    padding: 13px;
  }

  .topbar {
    margin-bottom: 25px;
  }

  .game-card {
    padding: 9px;
    border-radius: 18px;
  }

  .stats {
    gap: 7px;
  }

  .stat {
    padding: 11px 10px;
  }

  .stat strong {
    font-size: 23px;
  }

  .gamebar {
    font-size: 10px;
  }

  .hint {
    max-width: 45%;
  }

  .controls {
    align-items: center;
  }

  .dpad {
    grid-template-columns: repeat(3, 35px);
    grid-template-rows: repeat(2, 33px);
  }

  .control-copy {
    max-width: 48%;
  }

  .footer {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
