/* PRISM FALL — dark instrument-panel aesthetic.
   Midnight navy field, restrained cyan/violet/coral accents,
   generous spacing, crisp hierarchy. No decorative clutter. */

:root {
  --bg-0: #05070f;
  --bg-1: #0a0e1e;
  --bg-2: #10162c;
  --surface: rgba(18, 25, 48, 0.72);
  --line: rgba(140, 170, 220, 0.10);
  --line-strong: rgba(140, 170, 220, 0.18);
  --text: #dfe6f5;
  --text-dim: #7d89a8;
  --cyan: #3fd8f5;
  --violet: #a78bfa;
  --coral: #ff6b81;
  --glow-cyan: rgba(63, 216, 245, 0.35);
  --font-ui: "Segoe UI Variable Text", "Segoe UI", -apple-system,
    BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Segoe UI Variable Display", "Segoe UI", -apple-system,
    BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg-0);
  color: var(--text);
  overflow: hidden;
  display: grid;
  place-items: center;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Aurora background ─────────────────────────────────────────── */

.aurora {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 80% at 50% 110%, var(--bg-2), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  z-index: 0;
}

.aurora-blob {
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}

.b1 {
  background: radial-gradient(circle, rgba(63, 216, 245, 0.10), transparent 65%);
  top: -18vmax; left: -12vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
.b2 {
  background: radial-gradient(circle, rgba(167, 139, 250, 0.10), transparent 65%);
  bottom: -22vmax; right: -14vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}
.b3 {
  background: radial-gradient(circle, rgba(255, 107, 129, 0.05), transparent 65%);
  top: 30%; left: 55%;
  animation: drift1 38s ease-in-out infinite alternate-reverse;
}

@keyframes drift1 { to { transform: translate(9vmax, 6vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-8vmax, -7vmax) scale(1.1); } }

/* ── Frame ─────────────────────────────────────────────────────── */

.frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.8vh, 20px);
  padding: clamp(14px, 2.2vh, 26px);
  max-height: 100dvh;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  font-family: var(--font-num);
  font-size: clamp(17px, 2.2vw, 23px);
  font-weight: 250;
  letter-spacing: 0.42em;
  color: var(--text);
  text-transform: uppercase;
}
.wordmark span {
  color: var(--cyan);
  font-weight: 600;
  text-shadow: 0 0 18px var(--glow-cyan);
}

.masthead-actions { display: flex; gap: 8px; }

.chip {
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.08s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.chip:active { transform: translateY(1px); }
.chip[aria-pressed="true"] { color: var(--cyan); border-color: rgba(63, 216, 245, 0.35); }
.chip[aria-pressed="false"] { opacity: 0.6; }
.chip.danger:hover { color: var(--coral); border-color: rgba(255, 107, 129, 0.4); }

/* ── Stage ─────────────────────────────────────────────────────── */

.stage {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: clamp(10px, 1.4vw, 18px);
  align-items: stretch;
  justify-content: center;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: clamp(92px, 9vw, 120px);
}

.gauge {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gauge h2 {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.gauge h2.sub { margin-top: 6px; }

.stat {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
}
.stat.big { font-size: clamp(22px, 2vw, 28px); color: var(--cyan); }
.stat.small { font-size: 15px; color: var(--text-dim); }

.well {
  border-radius: 8px;
  background: rgba(4, 6, 14, 0.55);
  border: 1px solid rgba(140, 170, 220, 0.06);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
}

.mini canvas { display: block; }

/* ── Board ─────────────────────────────────────────────────────── */

.board-well {
  position: relative;
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(16, 22, 44, 0.85), rgba(8, 11, 24, 0.9));
  border: 1px solid var(--line-strong);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#board-canvas { display: block; border-radius: 4px; }

.flash-banner {
  position: absolute;
  left: 0; right: 0;
  top: 38%;
  text-align: center;
  font-family: var(--font-num);
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0;
  pointer-events: none;
}
.flash-banner.show { animation: banner 1.1s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: scale(0.92); }
  18% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}

/* ── Overlay ───────────────────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: rgba(5, 7, 15, 0.88);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 5;
}
.overlay[hidden] { display: none; }

.overlay-card { text-align: center; padding: 28px 24px; max-width: 300px; }

.overlay-kicker {
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 10px;
}

.overlay-title {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 250;
  letter-spacing: 0.3em;
  margin-bottom: 12px;
}
.overlay-title span { color: var(--cyan); }

.overlay-body {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.65;
  margin-bottom: 22px;
  white-space: pre-line;
}

.cta {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), #7cc6f8);
  border: none;
  border-radius: 8px;
  padding: 13px 34px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(63, 216, 245, 0.25);
  transition: transform 0.1s, box-shadow 0.15s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(63, 216, 245, 0.4); }
.cta:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }
.cta:active { transform: translateY(0); }

/* ── Touch controls ────────────────────────────────────────────── */

.pad { display: none; }

@media (pointer: coarse), (max-width: 640px) {
  body { overflow: auto; }
  .frame { gap: 8px; }
  .keys { display: none; }
  .stage {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "board right"
      "left  left";
  }
  .board-well { grid-area: board; }
  .rail-right { grid-area: right; }
  .rail-left {
    grid-area: left;
    flex-direction: row;
    width: auto;
  }
  .rail-left .gauge { flex: 1; }
  .pad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(44px, 7.6dvh);
    gap: 7px;
    width: min(420px, 94vw);
    margin: 0 auto;
  }
  .pad-btn[data-action="left"] { grid-column: 1; }
  .pad-btn[data-action="softdrop"] { grid-column: 2; }
  .pad-btn[data-action="rotateCCW"] { grid-column: 3; }
  .pad-btn[data-action="right"] { grid-column: 4; }
  .pad-btn[data-action="rotateCW"] { grid-column: 1; }
  .pad-btn[data-action="harddrop"] { grid-column: 2 / 4; }
  .pad-btn[data-action="hold"] { grid-column: 4; }
}

.pad-btn {
  font: inherit;
  font-size: 15px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  touch-action: none;
}
.pad-btn.pressed {
  background: rgba(63, 216, 245, 0.16);
  border-color: rgba(63, 216, 245, 0.5);
  color: var(--cyan);
}

/* ── Footer key hints ──────────────────────────────────────────── */

.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 11px;
  color: var(--text-dim);
}

kbd {
  font-family: inherit;
  font-size: 10px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1.5px 6px;
  margin: 0 1px;
}

/* ── Reduced motion ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .aurora-blob { animation: none; }
  .flash-banner.show { animation: none; opacity: 0; }
}

body.no-fx .aurora-blob { animation: none; }
