/* =========================================================
   Bazza's Migration: game page styles.
   Shared tokens, buttons and fonts come from styles.css.
   ========================================================= */

.game-page {
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(60% 50% at 0% 0%, rgba(226, 87, 43, 0.12), transparent 70%),
    radial-gradient(60% 50% at 100% 100%, rgba(62, 143, 191, 0.14), transparent 70%),
    #07080b;
}

/* ---------- Top bar ---------- */
.game-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  max-width: 1400px;
  margin-inline: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 0.5rem) var(--gutter) 0.6rem;
}

.game-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
  color: var(--ice);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  font-size: 0.9rem;
}
.game-back svg { width: 20px; height: 20px; }
.game-back:hover { color: var(--gold); }

.game-title {
  font-weight: 900;
  font-size: clamp(1.05rem, 0.85rem + 1.1vw, 1.6rem);
  letter-spacing: 0.06em;
  color: var(--gold);
}

.game-tools { display: flex; gap: 0.5rem; }
.tool-btn {
  min-height: 40px;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid rgba(143, 211, 244, 0.5);
  border-radius: 8px;
  background: rgba(24, 29, 42, 0.9);
  color: var(--text);
  font: 800 0.85rem/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.tool-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 520px) {
  .game-title { order: -1; width: 100%; text-align: center; }
  .game-top { justify-content: space-between; }
}

/* ---------- Stage ---------- */
.game-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--gutter) 2.5rem;
}

.stage {
  position: relative;
  width: 320px;
  height: 180px;
  container-type: inline-size;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  box-shadow:
    0 0 0 2px rgba(242, 193, 78, 0.55),
    0 0 0 6px rgba(242, 193, 78, 0.08),
    0 24px 70px rgba(0, 0, 0, 0.65);
}
.stage:focus { outline: none; }

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* ---------- Overlay screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.2rem, 1.5cqw, 0.9rem);
  padding: 3cqw 4cqw;
  overflow: auto;
  text-align: center;
  background: radial-gradient(circle at 50% 45%, rgba(13, 15, 20, 0.6), rgba(13, 15, 20, 0.88));
}
.screen[hidden] { display: none; }
.screen--title { background: linear-gradient(180deg, rgba(13, 15, 20, 0.25), rgba(13, 15, 20, 0.8)); }

.screen h2 {
  font-weight: 900;
  font-size: clamp(1.05rem, 6.2cqw, 3.2rem);
  color: var(--gold);
  text-shadow: 0 3px 0 #000, 0 0 24px rgba(242, 193, 78, 0.3);
}
.screen--title h2 { font-size: clamp(1.3rem, 8cqw, 4.2rem); }

.screen-kicker {
  color: var(--ice);
  font-weight: 800;
  font-size: clamp(0.6rem, 2.1cqw, 0.95rem);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.screen-text {
  max-width: 34em;
  color: var(--text);
  font-size: clamp(0.72rem, 2.5cqw, 1.2rem);
  line-height: 1.4;
  text-shadow: 0 1px 4px #000;
}
.screen-meta { color: var(--muted); font-size: clamp(0.68rem, 2.1cqw, 1rem); }
.screen-text strong,
.screen-meta strong { color: var(--gold); }
.new-high { color: var(--ember-bright); font-weight: 800; }

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: clamp(0.1rem, 1.2cqw, 0.6rem);
}
.screen .btn {
  min-height: 36px;
  padding: 0.5rem 1rem;
  font-size: clamp(0.7rem, 2.2cqw, 1rem);
}

.test-note { color: var(--ember-bright); font-weight: 700; }

/* Story card between levels */
.screen--story { background: radial-gradient(circle at 50% 50%, rgba(13, 15, 20, 0.82), rgba(13, 15, 20, 0.95)); }
.story-line {
  max-width: 22em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 5cqw, 2.6rem);
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 3px 0 #000;
  animation: story-in 0.9s ease both;
}
@keyframes story-in { from { opacity: 0; letter-spacing: 0.08em; } to { opacity: 1; } }
.story-timer {
  width: min(55%, 240px);
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.story-timer span {
  display: block;
  height: 100%;
  background: var(--gold);
  transform-origin: left;
}
.story-timer.run span { animation: story-timer 5.2s linear forwards; }
@keyframes story-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Touch controls ---------- */
.touch-controls { display: none; }

.has-touch .touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 640px;
  padding-top: 0.9rem;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
/* Only shown while a level is running */
.has-touch body:not(.is-playing) .touch-controls { visibility: hidden; }

.tc-group { display: flex; gap: 0.8rem; }

.tc-btn {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  padding: 0;
  border: 2px solid rgba(242, 193, 78, 0.6);
  border-radius: 50%;
  background: rgba(24, 29, 42, 0.85);
  color: var(--text);
  font: 800 0.85rem/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background-color 0.08s ease;
}
.tc-btn svg { width: 30px; height: 30px; }
.tc-btn--hiss { border-color: rgba(143, 211, 244, 0.75); color: var(--ice); }
.tc-btn--jump { border-color: rgba(255, 122, 69, 0.75); color: var(--ember-bright); }
.tc-btn.is-down { background: var(--gold); color: #170c06; transform: scale(0.93); }

/* Landscape phones: float the buttons over the bottom corners */
@media (orientation: landscape) and (pointer: coarse) {
  .has-touch .touch-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.6rem);
    z-index: 20;
    max-width: none;
    padding: 0 calc(env(safe-area-inset-right, 0px) + 0.9rem) 0 calc(env(safe-area-inset-left, 0px) + 0.9rem);
    pointer-events: none;
  }
  .has-touch .tc-group { pointer-events: auto; }
  .tc-btn { width: 64px; height: 64px; opacity: 0.82; }
}

/* ---------- How to play ---------- */
.howto {
  width: 100%;
  max-width: 760px;
  margin-top: 2.2rem;
  padding: 1.5rem clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.howto h2 { font-size: 1.5rem; color: var(--gold); }

.keys { display: grid; gap: 0.55rem; margin: 1rem 0 0; }
.keys div { display: grid; grid-template-columns: minmax(9.5rem, auto) 1fr; gap: 0.25rem 1rem; align-items: baseline; }
.keys dt { white-space: nowrap; color: var(--muted); }
.keys dd { margin: 0; }
@media (max-width: 480px) {
  .keys div { grid-template-columns: 1fr; }
}

kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 0.05em 0.45em;
  border: 1px solid rgba(236, 230, 218, 0.25);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font: 800 0.85em/1.5 var(--font-body);
  text-align: center;
}

.howto-tips { margin: 1.1rem 0 0; padding-left: 1.2rem; color: var(--muted); }
.howto-tips li + li { margin-top: 0.3rem; }
.howto-note {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ice);
  font-size: 0.95rem;
}
