:root {
  color-scheme: dark;
  --bg: #090d17;
  --panel: rgba(17, 24, 39, 0.78);
  --panel-strong: rgba(17, 24, 39, 0.94);
  --text: #eef7ff;
  --muted: #a9b6c9;
  --cyan: #53f0ff;
  --lime: #9eff6e;
  --gold: #ffd166;
  --danger: #ff4d6d;
  --line: rgba(118, 242, 255, 0.2);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(83, 240, 255, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 28%, rgba(158, 255, 110, 0.14), transparent 16rem),
    linear-gradient(180deg, #111827 0%, #090d17 64%, #05070d 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  touch-action: manipulation;
}

button {
  color: inherit;
  font: inherit;
}

.shell {
  width: min(100vw, 940px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 5vw, 2.65rem);
  line-height: 1;
  letter-spacing: 0.02em;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.stats span,
.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.stats span {
  min-width: 92px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.stats strong {
  color: var(--text);
  font-size: 1rem;
}

.game-wrap {
  position: relative;
  width: min(100%, calc(100svh - 150px));
  min-width: min(100%, 280px);
  aspect-ratio: 1;
  justify-self: center;
  align-self: center;
  border: 1px solid rgba(83, 240, 255, 0.42);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 42px rgba(83, 240, 255, 0.12);
  background: #0a1020;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 7, 13, 0.42);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.modal {
  width: min(100%, 390px);
  padding: 22px;
  border: 1px solid rgba(83, 240, 255, 0.24);
  border-radius: 8px;
  background: var(--panel-strong);
  text-align: center;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

.modal h2 {
  margin-bottom: 8px;
  font-size: 1.65rem;
}

.modal p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.7;
}

.primary {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary {
  width: 100%;
  padding: 13px 16px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--lime));
  color: #061018;
  box-shadow: 0 0 18px rgba(83, 240, 255, 0.24), inset 0 -3px 0 rgba(0, 0, 0, 0.16);
}

.message {
  width: min(680px, 100%);
  margin: 0 auto;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}

.primary:active {
  transform: translateY(1px);
}

.hint {
  margin: 0 auto;
  max-width: 680px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: center;
}

@media (max-width: 620px) {
  .shell {
    padding-inline: 10px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .stats {
    width: 100%;
    justify-content: stretch;
  }

  .stats span {
    flex: 1;
    min-width: 0;
    padding-inline: 6px;
  }

  .game-wrap {
    width: min(100%, calc(100svh - 190px));
  }
}
