/* ------------------------------------------------------------------
   Snake 3D: layout for the game page only. Tokens, chamfer, buttons, the
   logo mark and the shared effects come from ../core.css.
   Colour roles follow STYLE-GUIDE.md: volt is the player, hot is the
   packets and death, cyan is the world and the boost meter.
   In the Gauntlet that extends as: walls are cyan, anything that is the
   player's (lives, gun, pickups) is volt, and enemies get a colour of their
   own, --foe, so they cannot be mistaken for packets. They are told apart
   from each other by shape.
   ------------------------------------------------------------------ */

/* The enemy colour. Same value as FOE in game.js; it is only for things that
   are, or name, an enemy. See STYLE-GUIDE.md, "A fourth colour in games". */
body.snake { --foe: #a45cff; }

body.snake {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--screen);
  /* No page scroll or pull-to-refresh under a swipe. */
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stage { position: fixed; inset: 0; }
.stage canvas { display: block; width: 100%; height: 100%; }

kbd {
  display: inline-block;
  min-width: 22px; padding: 4px 6px; margin: 0 2px;
  border: 1px solid var(--line-2);
  font: 500 11px/1 var(--font-mono);
  text-align: center; text-transform: uppercase;
  color: var(--text);
  background: var(--bg-2);
}

/* ---------- Top bar ---------- */
.g-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(14px, 3vw, 32px);
  font: 500 12px/1 var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase;
  pointer-events: none;
}
.g-top > * { pointer-events: auto; }
.g-toggles { display: flex; gap: 8px; }
.g-toggle {
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  background: rgba(6, 7, 11, .7);
  color: var(--muted);
  font: inherit; letter-spacing: .12em; text-transform: uppercase;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.g-toggle:hover { color: var(--volt); border-color: var(--volt); }
.g-toggle[aria-pressed="false"] { color: var(--dim); }

/* ---------- In-run HUD ---------- */
.g-hud {
  position: fixed; top: 72px; left: clamp(14px, 3vw, 32px); z-index: 60;
  width: 210px;
  pointer-events: none;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.g-score b {
  display: block; margin-top: 8px;
  font: 700 46px/1 var(--font-display);
  letter-spacing: .02em;
  color: var(--volt);
  font-variant-numeric: tabular-nums;
}
.g-score b.pop { animation: score-pop .22s steps(2); }
@keyframes score-pop { 50% { color: #fff; transform: translateY(-2px); } }
.g-stats { display: flex; gap: 22px; margin: 16px 0 18px; }
.g-stats b { display: block; margin-top: 6px; font-weight: 500; font-size: 15px; letter-spacing: .08em; color: var(--text); font-variant-numeric: tabular-nums; }
.g-meter { margin-top: 12px; }
.g-meter span { display: flex; justify-content: space-between; }
.g-meter b { font-weight: 700; color: var(--text); }
.g-bar { height: 8px; margin-top: 7px; background: var(--line); overflow: hidden; }
.g-bar i {
  display: block; height: 100%; width: 100%;
  background: repeating-linear-gradient(90deg, var(--volt) 0 6px, transparent 6px 8px);
  transform-origin: left; transform: scaleX(0);
}
.g-meter--boost .g-bar i { background: repeating-linear-gradient(90deg, var(--cyan) 0 6px, transparent 6px 8px); }
.g-meter.live b { color: var(--volt); }
.g-meter--boost.live span { color: var(--cyan); }
.g-meter--boost.empty span { color: var(--hot); }
/* Jammed: the boost is stuck on and the meter is not yours for now. */
.g-meter--boost.jam span { color: var(--hot); }
.g-meter--boost.jam .g-bar i { background: repeating-linear-gradient(90deg, var(--hot) 0 6px, transparent 6px 8px); transform: scaleX(1) !important; animation: jam-blink .16s steps(2) infinite; }
@keyframes jam-blink { 50% { opacity: .35; } }

/* Gauntlet only: level, lives, and from level 5 the weapons. */
.g-run { margin: 0 0 4px; }
.g-pips { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.g-pips-row { display: flex; gap: 5px; }
.g-pips-row i { width: 14px; height: 8px; background: var(--line); }
.g-pips-row i.on { background: var(--volt); box-shadow: 0 0 8px rgba(230, 255, 43, .5); }
.g-pips b { font-weight: 700; color: var(--dim); }
.g-pips--shield.on b { color: var(--volt); }
.g-pips--shield:not(.on) b { visibility: hidden; }
.g-arms { margin-top: 18px; padding-top: 6px; border-top: 1px dashed var(--line-2); }
.g-meter--gun b { color: var(--dim); }
.g-meter--gun.live span { color: var(--volt); }
.g-lost { animation: life-lost .5s steps(4); }
@keyframes life-lost { 0%, 50% { color: var(--hot); } 25%, 75% { color: #fff; } }

/* Level-up card. On a wide screen it sits in the top right corner, which the
   globe's disc never reaches, so it covers none of the playfield. */
.g-banner {
  position: fixed; top: 72px; right: clamp(14px, 3vw, 32px); z-index: 62;
  width: min(340px, calc(100vw - 32px));
  padding: 16px 20px 16px;
  border: 1px solid var(--foe);
  background: rgba(5, 6, 10, .86);
  pointer-events: none;
  animation: banner-in .28s steps(4) both;
}
.g-banner.out { animation: banner-out .3s steps(3) both; }
@keyframes banner-in { from { opacity: 0; clip-path: inset(0 50% 0 50%); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
@keyframes banner-out { to { opacity: 0; clip-path: inset(50% 0 50% 0); } }
.g-banner-level {
  margin: 0 0 12px;
  font: 700 12px/1 var(--font-mono);
  letter-spacing: .3em; text-transform: uppercase;
  color: var(--volt);
}
.g-banner-main { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.g-banner svg { flex: none; width: 48px; height: 48px; fill: none; color: var(--foe); stroke: var(--foe); stroke-width: 2; stroke-linejoin: miter; filter: drop-shadow(0 0 6px var(--foe)); }
.g-banner-kicker { margin: 0 0 6px; font: 500 11px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.g-banner h2 { margin: 0; font: 700 clamp(1.8rem, 5vw, 2.3rem)/1 var(--font-display); text-transform: uppercase; letter-spacing: -.01em; color: var(--foe); }
.g-banner-text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text); }
.g-banner-note { margin: 8px 0 0; font: 500 11px/1.5 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--volt); }
.g-banner-note:empty { display: none; }

.g-keys {
  position: fixed; left: 50%; bottom: 22px; z-index: 60;
  transform: translateX(-50%);
  display: flex; gap: 22px;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  color: var(--muted);
  pointer-events: none;
  transition: opacity .6s;
}
.g-keys.faded { opacity: 0; }

.g-boost {
  /* .chamfer sets position: relative; this has to win. */
  position: fixed; right: 18px; bottom: 26px; z-index: 60;
  --bd: var(--cyan); --fill: var(--bg-2);
  width: 92px; height: 92px;
  border: 0;
  color: var(--cyan);
  font: 700 12px/1 var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  touch-action: none;
}
.g-boost.held { --fill: var(--cyan); color: #000; }
.g-boost--bomb { bottom: 130px; --bd: var(--volt); color: var(--volt); height: 64px; }

/* Score popups, placed by game.js at the packet's screen position. */
#popups { position: fixed; inset: 0; z-index: 55; pointer-events: none; overflow: hidden; }
.g-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 700 18px/1 var(--font-mono);
  letter-spacing: .06em; white-space: nowrap;
  color: var(--volt);
  animation: pop-rise .75s cubic-bezier(.2, .8, .2, 1) forwards;
}
.g-pop.big { font-size: 26px; color: #fff; }
.g-pop.bad { color: var(--hot); }
/* Name tags that ride on pickups. */
.g-tag {
  position: absolute;
  transform: translate(-50%, -260%);
  padding: 3px 5px;
  font: 700 10px/1 var(--font-mono);
  letter-spacing: .14em; white-space: nowrap;
  color: #000; background: var(--volt);
}
@keyframes pop-rise {
  0% { opacity: 0; margin-top: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; margin-top: -54px; }
}

/* ---------- Panels ---------- */
.g-wrap {
  position: fixed; inset: 60px 0 0 0; z-index: 65;
  display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 16px clamp(14px, 5vw, 72px) 24px;
  overflow-y: auto;
  /* Lets the globe show through and stay clickable-through around the panel. */
  pointer-events: none;
}
.g-wrap--center { justify-content: center; background: rgba(3, 4, 7, .74); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); pointer-events: auto; }
.g-panel {
  --c: 22px;
  /* Centred by auto margins rather than align-items: when the panel is
     taller than the screen, align-items: center pushes its top out of reach
     of the scroll; auto margins collapse to zero instead. */
  margin-block: auto;
  width: 100%; max-width: 430px;
  padding: 28px 28px 26px;
  pointer-events: auto;
  user-select: text; -webkit-user-select: text;
}
.g-panel--small { max-width: 380px; }
.g-panel--over { --bd: var(--hot); }

/* One line here, not the two of the site's hero: with the mode picker above
   the speeds, a stacked title pushed the panel past a 768px-high screen. */
.g-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .22em; font-size: clamp(2.6rem, 7vw, 3.6rem); margin-bottom: 18px; }
.g-head { font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 700; text-transform: uppercase; letter-spacing: -.01em; margin-bottom: 22px; }
.g-head--hot { color: var(--hot); }
.g-blurb { color: var(--muted); font-size: 15px; line-height: 1.55; margin-bottom: 22px; }
#mode-blurb { min-height: 3.1em; margin-bottom: 18px; }
.g-label {
  display: block; margin: 0 0 10px;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}

.g-tiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.g-tier {
  padding: 12px 6px 10px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--muted);
  font: 700 11px/1 var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.g-tier small { display: block; margin-top: 7px; font-size: 10px; font-weight: 500; color: var(--dim); }
.g-tiers--two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
.g-tier:hover { color: var(--text); border-color: var(--text); }
.g-tier[aria-checked="true"] { background: var(--volt); border-color: var(--volt); color: #000; }
.g-tier[aria-checked="true"] small { color: rgba(0, 0, 0, .6); }

.g-panel > .btn { margin-bottom: 26px; }
.g-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.g-scores { width: 100%; border-collapse: collapse; margin-bottom: 18px; font: 500 12px/1 var(--font-mono); letter-spacing: .08em; }
.g-scores td { padding: 6px 0; border-bottom: 1px dashed var(--line-2); color: var(--muted); text-transform: uppercase; }
.g-scores td:first-child { width: 34px; color: var(--hot); }
.g-scores td:nth-child(2) { color: var(--text); }
.g-scores td:nth-child(3) { text-align: right; color: var(--volt); font-variant-numeric: tabular-nums; }
.g-scores td:nth-child(4) { text-align: right; width: 96px; }
.g-scores .empty td { color: var(--dim); }
.g-scores tr.fresh td { color: #000; background: var(--volt); }
.g-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin-bottom: 14px; }
.g-links .g-more { margin-bottom: 0; }
.g-mail { padding: 10px 12px; }
.g-more {
  display: inline-flex; gap: 10px; margin-bottom: 14px;
  font: 700 12px/1 var(--font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--volt);
}
.g-more i { font-style: normal; transition: transform .2s; }
.g-more:hover i { transform: translateX(5px); }
.g-help { margin: 0; font: 500 11px/2.1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }

.g-result { margin: 0 0 22px; }
.g-result div {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line-2);
  font: 500 12px/1 var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
}
.g-result dt { color: var(--muted); }
.g-result dd { margin: 0; font-variant-numeric: tabular-nums; }
.g-result div:first-child dd { color: var(--volt); font-weight: 700; }

.g-record { margin-bottom: 22px; }
.g-record .g-label { color: var(--volt); }
.g-record-row { display: flex; gap: 10px; }
.g-record input {
  width: 120px; padding: 0 14px;
  border: 1px solid var(--volt);
  background: var(--screen);
  color: var(--volt);
  font: 700 22px/1 var(--font-mono);
  letter-spacing: .3em; text-transform: uppercase;
  caret-color: var(--volt);
}
.g-record input::placeholder { color: var(--dim); }

/* Death: the whole view tears for half a second. */
.stage.shake { animation: shake .36s steps(1); }

/* Laptop-height screens: tighten the panels so the title one fits without scrolling. */
@media (max-height: 800px) {
  .g-wrap { padding-top: 8px; padding-bottom: 12px; }
  .g-panel { padding: 22px 26px 20px; }
  .g-title { margin-bottom: 12px; }
  .g-tiers { margin-bottom: 14px; }
  .g-tiers--two { margin-bottom: 10px; }
  .g-panel > .btn { margin-bottom: 18px; }
  #mode-blurb { margin-bottom: 12px; }
  .g-scores { margin-bottom: 12px; }
  .g-scores td { padding: 5px 0; }
  .g-help { line-height: 1.9; }
}

@media (max-width: 900px) {
  /* No room to dock the panel beside the globe: centre it over a dimmed view. */
  .g-wrap { justify-content: center; background: rgba(3, 4, 7, .74); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); pointer-events: auto; }
  .g-hud { width: 150px; top: 66px; }
  .g-score b { font-size: 34px; }
  .g-keys { display: none; }
  /* No free corner: top centre, above where the head is. It lands on the HUD
     for the few seconds it is up, so here it is opaque rather than see-through. */
  .g-banner { right: auto; left: 50%; margin-left: max(-170px, calc(16px - 50vw)); background: rgba(5, 6, 10, .97); }
}
@media (max-width: 520px) {
  .brand-name { display: none; }
  .g-panel { padding: 22px 20px; }
  .g-stats { margin: 12px 0 12px; }
  /* A Gauntlet HUD has twice the rows; on a phone the two that matter least go. */
  .g-hud--run .g-stats { display: none; }
  .g-hud--run .g-score b { margin-bottom: 12px; }
  .g-banner { top: 64px; padding: 12px 14px; }
  .g-banner svg { width: 40px; height: 40px; }
}
