@import url("https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600;700&family=Space+Mono:wght@400;700&display=swap");

:root {
  color-scheme: dark;
  --ink: #f3fbff;
  --muted: #8794a7;
  --cyan: #72efff;
  --violet: #9574ff;
  --hot: #ff557d;
  --panel: rgba(10, 14, 27, 0.88);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #070912;
}

body {
  color: var(--ink);
  font-family: "Space Mono", monospace;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button, a { -webkit-tap-highlight-color: transparent; }

.game-shell {
  width: 100%;
  height: 100%;
  min-height: 340px;
  display: grid;
  grid-template-rows: 64px 1fr;
  background:
    radial-gradient(circle at 50% 45%, rgba(71, 53, 139, 0.13), transparent 48%),
    linear-gradient(145deg, #090d19, #05060c 70%);
}

.topbar {
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(14px, 3vw, 34px);
  border-bottom: 1px solid rgba(114, 239, 255, 0.12);
  background: rgba(5, 7, 14, 0.72);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(16px, 2.4vw, 22px);
  font-weight: 700;
  letter-spacing: .14em;
  text-decoration: none;
}

.brand img { width: 29px; height: 29px; }

.hud { display: flex; gap: clamp(15px, 4vw, 48px); }
.hud div { display: grid; gap: 2px; text-align: right; }
.hud span, .result-grid span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .17em;
}
.hud strong { font-size: clamp(12px, 2vw, 17px); font-variant-numeric: tabular-nums; }

.game-stage { position: relative; min-height: 0; overflow: hidden; cursor: crosshair; }
canvas { display: block; width: 100%; height: 100%; }

.seed-chip {
  position: absolute;
  top: 16px;
  left: 18px;
  color: #697589;
  font-size: 9px;
  letter-spacing: .13em;
  pointer-events: none;
}
.seed-chip strong { color: #a5b4c8; }

.throttle-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(184, 203, 218, .72);
  font: 700 10px "Chakra Petch", sans-serif;
  letter-spacing: .15em;
  pointer-events: none;
  transition: color .15s ease, opacity .4s ease;
}
.throttle-hint span {
  width: 18px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px #080b13;
}
.game-stage.throttling .throttle-hint { color: var(--cyan); }
.game-stage.throttling .throttle-hint span { background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 11, .35);
  backdrop-filter: blur(5px);
  transition: opacity .25s ease;
}
.overlay[hidden] { display: none; }

.card {
  width: min(480px, 100%);
  padding: clamp(25px, 5vw, 44px);
  text-align: center;
  border: 1px solid rgba(114, 239, 255, .25);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(114, 239, 255, .06), transparent 35%),
    var(--panel);
  box-shadow: 0 28px 80px rgba(0,0,0,.48), inset 0 0 40px rgba(91, 78, 201, .05);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
}
h1 {
  margin: 0;
  font: 700 clamp(35px, 8vw, 62px)/.95 "Chakra Petch", sans-serif;
  letter-spacing: -.035em;
  text-transform: uppercase;
}
#card-copy {
  max-width: 390px;
  margin: 20px auto 25px;
  color: #a9b3c1;
  font-size: 12px;
  line-height: 1.75;
}

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
button {
  min-height: 44px;
  padding: 0 20px;
  color: #cdd7e5;
  font: 700 11px "Space Mono", monospace;
  letter-spacing: .07em;
  text-transform: uppercase;
  border: 1px solid rgba(151, 168, 191, .25);
  border-radius: 2px;
  background: rgba(255,255,255,.04);
  cursor: pointer;
}
button:hover { border-color: rgba(114, 239, 255, .65); color: white; }
button.primary {
  color: #081015;
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 28px rgba(114, 239, 255, .24);
}
.controls { margin: 16px 0 0; color: #5f6a7a; font-size: 9px; letter-spacing: .08em; }
.touch-copy { display: none; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 23px 0;
}
.result-grid[hidden] { display: none; }
.result-grid div { padding: 12px 8px; border: 1px solid rgba(114, 239, 255, .12); background: rgba(0,0,0,.16); }
.result-grid strong { display: block; margin-top: 5px; font-size: 17px; font-variant-numeric: tabular-nums; }

.countdown {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font: 700 clamp(80px, 18vw, 160px)/1 "Chakra Petch", sans-serif;
  text-shadow: 0 0 32px var(--cyan);
  pointer-events: none;
}

.danger {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: end center;
  padding-bottom: 48px;
  border: 0 solid rgba(255, 85, 125, 0);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
}
.danger.active { opacity: 1; box-shadow: inset 0 0 60px rgba(255, 50, 94, .16); }
.danger span { color: var(--hot); font: 700 9px "Space Mono", monospace; letter-spacing: .18em; }

.toast {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 54px;
  transform: translate(-50%, 10px);
  padding: 9px 14px;
  color: #081015;
  font-size: 10px;
  font-weight: 700;
  background: var(--cyan);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.resume {
  position: absolute;
  z-index: 6;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(3,5,10,.72);
  backdrop-filter: blur(6px);
  color: white;
  font-size: 14px;
}
.resume[hidden] { display: none; }

@media (pointer: coarse), (max-width: 700px) {
  .desktop-copy { display: none; }
  .touch-copy { display: inline; }
  .game-shell { grid-template-rows: 55px 1fr; }
  .topbar { padding: 0 12px; }
  .brand { letter-spacing: .08em; font-size: 14px; }
  .brand img { width: 24px; height: 24px; }
  .hud { gap: 13px; }
  .hud span { font-size: 8px; }
  .hud strong { font-size: 11px; }
  .best-stat { display: none !important; }
  .seed-chip { top: 11px; left: 12px; }
  .card { padding: 25px 20px; }
}

@media (max-height: 500px) {
  .game-shell { grid-template-rows: 48px 1fr; }
  .card { padding: 18px 25px; width: min(570px, 90%); }
  h1 { font-size: 34px; }
  #card-copy { margin: 10px auto 14px; line-height: 1.45; }
  .controls { display: none; }
  .result-grid { margin: 12px 0; }
  .throttle-hint { bottom: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
