:root {
  --bg: #0c0e14;
  --panel: #161a24;
  --ink: #e8ecf4;
  --dim: #8b93a7;
  --red: #e0143c;
  --pink: #e8789c;
  --hair: #d8dce8;
  --line: #2a3144;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  --safe-l: env(safe-area-inset-left);
  --safe-r: env(safe-area-inset-right);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#shell {
  display: flex; flex-direction: column;
  height: 100%; height: 100dvh;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}
#hud {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; flex: 0 0 auto; min-height: 40px;
  position: relative; z-index: 20; /* above .stick-zone (6); below #overlay (24) so menus stay on top */
  pointer-events: auto;
}
#hud h1 { font-size: 13px; margin: 0; letter-spacing: .12em; font-weight: 700; flex: 1; }
#hud .back, #hud .ghost {
  color: var(--ink); text-decoration: none;
  border: 2px solid var(--dim); padding: 3px 9px; font-size: 13px; background: #0000;
}
#hudstats { font-size: 11px; color: var(--hair); letter-spacing: .06em; white-space: nowrap; }
#hudstats b { color: var(--red); font-weight: 700; }
#stage {
  flex: 1 1 auto; position: relative; min-height: 0; min-width: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #05060a;
  background-image:
    linear-gradient(rgba(224,20,60,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(224,20,60,.05) 1px, transparent 1px);
  background-size: 16px 16px;
}
#stage canvas {
  image-rendering: pixelated; image-rendering: crisp-edges;
  display: block; background: #07080c;
  box-shadow: 0 0 0 2px #1b2030, 0 0 0 3px #e0143c55;
}
#pad { flex: 0 0 auto; }
.pad {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 18px 10px; gap: 12px;
}
/* Floating analog joystick (pad.js). .stick-zone = touch area, .stick(.dpad) = base ring at its rest spot.
   Skin = colours only: games override these variables (e.g. on #pad) in their own CSS, never the rules below. */
#pad, .pad {
  --joy-base: rgba(20,22,28,.72);   /* base disc */
  --joy-ring: rgba(200,204,216,.55);/* base ring, 1.5px */
  --joy-tick: #c8ccd8;              /* direction arrows, idle (shown at .55 opacity) */
  --joy-tick-on: #c8ccd8;           /* lit direction arrow */
  --joy-knob: #2a2e38;              /* knob fill */
  --joy-knob-on: #343946;           /* knob fill while held */
  --joy-knob-ring: #c8ccd8;         /* knob outline, 2px */
}
.stick-zone {
  position: relative; z-index: 6; /* resting ring may rise above the pad row (on-screen clamp): stay over stage art, under #hud (20) and #overlay (24) */
  flex: 1 1 auto; align-self: stretch; min-width: 128px; min-height: 124px;
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  --stick-inset: 0px; --stick-overflow-y: 24px;
}
/* Jump (and any game) sets body.menu-nopad in landscape menus so the left column cannot steal touches. */
body.menu-nopad .stick-zone { visibility: hidden; pointer-events: none; }
.stick {
  position: absolute; left: 2px; top: 0; bottom: 0; margin: auto 0; width: 120px; height: 120px;
  border-radius: 50%; background: var(--joy-base); border: 1.5px solid var(--joy-ring);
  pointer-events: none; opacity: .5;
  transition: opacity .16s ease-out, transform .16s ease-out;
}
.stick.active { opacity: 1; transition: opacity .06s linear; }
.stick .knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: var(--joy-knob); border: 2px solid var(--joy-knob-ring);
  transition: transform .14s cubic-bezier(.3,1.6,.5,1);
}
.stick.active .knob { transition: none; background: var(--joy-knob-on); }
.stick .tick {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0; border: 5px solid transparent; margin: -5px 0 0 -5px;
  opacity: .55; z-index: 1; /* drawn over the knob: at full push the knob edge (R + 0.4 knob r) passes the arrow */
}
.stick .tick.u { border-bottom-color: var(--joy-tick); transform: translateY(-48px); }
.stick .tick.d { border-top-color: var(--joy-tick); transform: translateY(48px); }
.stick .tick.l { border-right-color: var(--joy-tick); transform: translateX(-48px); }
.stick .tick.r { border-left-color: var(--joy-tick); transform: translateX(48px); }
.stick.on-u .tick.u, .stick.on-d .tick.d, .stick.on-l .tick.l, .stick.on-r .tick.r { opacity: 1; }
.stick.on-u .tick.u { border-bottom-color: var(--joy-tick-on); } .stick.on-d .tick.d { border-top-color: var(--joy-tick-on); }
.stick.on-l .tick.l { border-right-color: var(--joy-tick-on); } .stick.on-r .tick.r { border-left-color: var(--joy-tick-on); }
.stick .lab {
  position: absolute; left: calc(100% + 6px); font-style: normal; font-size: 9px; letter-spacing: .1em;
  color: var(--dim); white-space: nowrap; pointer-events: none;
}
.stick .lab.u { top: 6px; } .stick .lab.d { bottom: 6px; }
.stick .lab.l { right: calc(100% + 6px); left: auto; top: 50%; margin-top: -6px; }
.stick .lab.r { top: 50%; margin-top: -6px; }
@media (prefers-reduced-motion: reduce) {
  .stick, .stick .knob, .stick.active { transition: none; }
}
.ab { display: flex; gap: 16px; align-items: center; touch-action: none; }
.ab .btn {
  width: 62px; height: 62px; border-radius: 50%;
  border: 2px solid transparent; background: #14161c; color: inherit;
  --ab-press: transparent;
  font-weight: 800; font-size: 16px; letter-spacing: .06em;
  box-shadow: none;
  display: grid; place-items: center; padding: 0;
}
.ab .btn.a { border-color: #e0143c; color: #e0143c; --ab-press: rgba(224,20,60,.2); }
.ab .btn.b { border-color: #c8ccd8; color: #c8ccd8; --ab-press: rgba(200,204,216,.2); }
.ab .btn.on {
  transform: scale(.96); box-shadow: none;
  background: linear-gradient(var(--ab-press), var(--ab-press)), #14161c;
}
.ab .btn i { font-style: normal; font-family: inherit; }

#overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(6,7,12,.72); z-index: 24; padding: 16px;
}
#overlay.show { display: flex; }
#overlay .card {
  background: #121624; border: 2px solid #e0143c; color: var(--ink);
  padding: 18px 16px; max-width: 320px; width: 100%; text-align: center;
  box-shadow: 0 0 0 1px #000, 0 8px 0 #0006;
}
#overlay .card h2 { margin: 0 0 8px; font-size: 16px; letter-spacing: .14em; }
#overlay .card p { margin: 6px 0; font-size: 12px; color: var(--dim); line-height: 1.55; }
#overlay .card .score { color: var(--red); font-size: 20px; letter-spacing: .1em; }
#overlay .card button, #overlay .card .go {
  margin-top: 12px; background: #e0143c; color: #fff; border: 0;
  padding: 8px 18px; font: inherit; letter-spacing: .12em; cursor: pointer;
  display: inline-block; text-decoration: none;
}

/* Landscape: joystick left, stage center, A/B right. HUD on top. */
@media (orientation: landscape) {
  #shell {
    display: grid;
    grid-template-columns: 164px minmax(0, 1fr) 164px;
    grid-template-rows: auto 1fr;
    padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  }
  #hud { grid-column: 1 / -1; grid-row: 1; background: linear-gradient(#0c0e14, #0c0e14ee 70%, transparent); }
  #stage { grid-column: 2; grid-row: 2; }
  #pad { display: contents; }
  .pad { display: contents; }
  /* 16px from #shell's already-padded edge; --safe-l/--safe-r stay on #shell (P1-11). */
  .stick-zone { grid-column: 1; grid-row: 2; align-self: stretch; justify-self: stretch; min-width: 0; --stick-inset: 16px; --stick-overflow-y: 0px; }
  .stick { left: 16px; }
  .ab { grid-column: 3; grid-row: 2; align-self: center; justify-self: end; margin-right: 16px; flex-direction: row; }
  #overlay { grid-column: 2; grid-row: 2; }
  #shell { position: relative; }
}
@media (orientation: landscape) and (max-height: 420px) {
  #hud { min-height: 32px; padding: 2px 8px; }
  .stick { width: 104px; height: 104px; }
  .stick .knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  .stick .tick.u { transform: translateY(-41px); } .stick .tick.d { transform: translateY(41px); }
  .stick .tick.l { transform: translateX(-41px); } .stick .tick.r { transform: translateX(41px); }
  .ab .btn { width: 52px; height: 52px; }
}

/* Hub */
.hub {
  height: 100%; height: 100dvh; overflow: auto; touch-action: pan-y;
  padding: calc(10px + var(--safe-t)) 14px calc(18px + var(--safe-b));
  background:
    radial-gradient(1200px 400px at 50% -10%, #e0143c22, transparent),
    var(--bg);
}
.hub header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hub header .bust { width: 56px; height: 64px; image-rendering: pixelated; }
.hub header h1 { margin: 0; font-size: 18px; letter-spacing: .2em; }
.hub header p { margin: 2px 0 0; color: var(--dim); font-size: 11px; letter-spacing: .08em; }
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
@media (orientation: landscape) {
  .grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
.grid a, .grid .soon {
  display: block; text-decoration: none; color: var(--ink);
  background: #121624; border: 2px solid var(--line); padding: 12px 10px 10px;
  min-height: 96px; position: relative; overflow: hidden;
}
.grid a:hover, .grid a:focus { border-color: var(--red); }
.grid a kbd, .grid .soon kbd {
  display: block; font-size: 10px; color: var(--red); letter-spacing: .16em; margin-bottom: 6px;
}
.grid a h2, .grid .soon h2 { margin: 0 0 4px; font-size: 15px; letter-spacing: .06em; }
.grid a p, .grid .soon p { margin: 0; font-size: 11px; color: var(--dim); line-height: 1.4; }
.grid .soon { opacity: .55; }
.grid .soon::after {
  content: "即将推出"; position: absolute; right: 8px; top: 8px;
  font-size: 10px; color: var(--pink); letter-spacing: .1em;
}
.hub footer { margin-top: 16px; color: var(--dim); font-size: 10px; letter-spacing: .06em; }
