/* ==========================================================================
   Base: reset, design tokens, page shell, stage layout
   ========================================================================== */

:root {
  --void: #05070e;
  --void-2: #0a0f1c;
  --ink: #e6f0ff;
  --ink-dim: #8ea3c4;
  --ink-faint: #5a6d8c;

  --accent: #22d3ee;
  --accent-2: #a855f7;

  --panel: rgba(148, 197, 255, 0.045);
  --panel-line: rgba(148, 197, 255, 0.12);
  --panel-line-strong: rgba(148, 197, 255, 0.24);

  --radius: 14px;
  --radius-sm: 9px;
  --gap: clamp(0.75rem, 2vw, 1.38rem);

  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  --glow: 0 0 0 1px rgba(34, 211, 238, 0.28), 0 8px 30px -12px rgba(34, 211, 238, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--void);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Soft coloured wash behind everything, so the flat black has some depth. */
.aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 32% at 22% 18%, rgba(34, 211, 238, 0.16), transparent 70%),
    radial-gradient(34% 30% at 80% 22%, rgba(168, 85, 247, 0.15), transparent 70%),
    radial-gradient(46% 36% at 50% 96%, rgba(59, 130, 246, 0.13), transparent 72%);
  filter: blur(12px);
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: var(--gap);
  padding: var(--gap) clamp(0.75rem, 2.5vw, 2rem);
  max-width: 1180px;
  margin-inline: auto;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: var(--gap);
  min-height: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: min(100%, 190px);
  min-height: 0;
}

/* The board is sized by height so it always fits the viewport, and the canvas
   keeps a 1:2 aspect ratio to match the 10x20 field. */
.board-frame {
  position: relative;
  height: 100%;
  aspect-ratio: 1 / 2;
  max-width: 100%;
  border-radius: var(--radius);
  padding: 0;
  background: rgba(5, 7, 14, 0.6);
  box-shadow:
    0 0 0 1px var(--panel-line),
    0 30px 70px -30px rgba(0, 0, 0, 0.9),
    0 0 60px -20px rgba(34, 211, 238, 0.25);
}

.board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
}

.combo {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.88rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #0a0f1c;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  scale: 0.85;
  transition: opacity 0.18s ease, scale 0.18s ease;
  pointer-events: none;
}

.combo.is-visible {
  opacity: 1;
  scale: 1;
}

.combo b {
  font-family: var(--font-mono);
  font-size: 1.19rem;
}

/* ------------------------------------------------------------- shared bits --- */

/*
  Revealed only by the inline watchdog in index.html, when the ES module graph
  failed to load — which is what happens when the file is opened directly.
*/
.boot-failure {
  margin: 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(251, 146, 60, 0.45);
  border-radius: var(--radius);
  font-size: 1.05rem;
  line-height: 1.6;
  color: #fed7aa;
  background: rgba(251, 146, 60, 0.12);
}

.boot-failure strong {
  display: block;
  margin-bottom: 0.2rem;
  color: #fdba74;
}

.boot-failure code {
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: #fff;
  background: rgba(5, 7, 14, 0.6);
}

.panel {
  padding: 0.7rem 0.8rem 0.85rem;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(6px);
}

.panel__title {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.1em 0.35em;
  border: 1px solid var(--panel-line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-dim);
  background: rgba(148, 197, 255, 0.07);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.93rem;
  color: var(--ink-faint);
}

.footer p {
  margin: 0;
}

.notice {
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(251, 146, 60, 0.35);
  border-radius: var(--radius-sm);
  color: #fdba74;
  background: rgba(251, 146, 60, 0.1);
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 900px) {
  .stage {
    grid-template-columns: auto;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .rail {
    display: none;
  }
}

@media (max-height: 620px) {
  .panel--keys,
  .panel--scoring {
    display: none;
  }
}

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