:root {
  --gold: #ffd76a;
  --red: #ff5a4a;
  --blue: #6ab4ff;
  --panel: rgba(10, 12, 20, 0.92);
  --panel-edge: rgba(255, 215, 106, 0.5);
  --ink: #f2ecdd;
  --dim: #9aa0b4;
  --display-font: 'Arial Black', 'Avenir Next Condensed', 'Helvetica Neue', sans-serif;
  --body-font: 'Avenir Next', 'Trebuchet MS', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #05060a; }
body {
  font-family: var(--body-font);
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
canvas.gl { display: block; width: 100%; height: 100%; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top {
  position: absolute; top: 12px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 18px; align-items: center;
}
.round-chip {
  background: var(--panel); border: 2px solid var(--panel-edge);
  padding: 6px 18px; border-radius: 4px;
  font-family: var(--display-font); font-size: 20px; letter-spacing: 2px;
  color: var(--gold); text-align: center; min-width: 130px;
}
.round-chip .clock { font-size: 26px; color: #fff; }
.round-chip .clock.warn { color: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.45; } }

.statbar {
  position: absolute; top: 16px; width: min(26vw, 300px);
  display: flex; flex-direction: column; gap: 4px;
}
.statbar.left { left: 16px; align-items: flex-start; }
.statbar.right { right: 16px; align-items: flex-end; }
.statbar .name {
  font-family: var(--display-font); font-size: 13px; letter-spacing: 1.5px;
  color: var(--ink); text-shadow: 0 2px 0 #000;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.12);
  padding: 2px 8px; border-radius: 3px;
}
.bar { width: 100%; height: 14px; background: rgba(0,0,0,0.65); border: 1px solid rgba(255,255,255,0.25); border-radius: 2px; position: relative; overflow: hidden; }
.bar .fill { position: absolute; inset: 0; transform-origin: left center; }
.statbar.left .fill { transform-origin: left center; }
.statbar.right .fill { transform-origin: right center; }
.fill.stamina { background: linear-gradient(90deg, #7ad76a, #c9e34a); }
.fill.body { background: linear-gradient(90deg, #e8a33a, #e8d33a); height: 6px !important; }
.fill.health { background: linear-gradient(90deg, #e85555, #ff8a5a); }
.bar.thin { height: 6px; }
.cut-flag { font-size: 11px; font-weight: 700; color: #ff5a4a; letter-spacing: 1px; text-shadow: 0 1px 0 #000; }
.gas-flag { font-size: 11px; font-weight: 700; color: #ffd76a; letter-spacing: 1px; text-shadow: 0 1px 0 #000; }

/* announcer banner */
#banner {
  position: absolute; top: 26%; left: 0; right: 0; text-align: center;
  font-family: var(--display-font); font-size: clamp(34px, 7vw, 84px);
  letter-spacing: 6px; color: var(--gold);
  text-shadow: 0 4px 0 #000, 0 0 30px rgba(255, 215, 106, 0.35);
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 1.6, 0.4, 1);
  pointer-events: none;
}
#banner.show { opacity: 1; transform: scale(1); }
#banner .sub {
  display: block; font-size: clamp(14px, 2.4vw, 24px); color: var(--ink);
  letter-spacing: 3px; margin-top: 8px; text-shadow: 0 2px 0 #000;
}

/* punch feedback */
#feedback {
  position: absolute; bottom: 22%; left: 0; right: 0; text-align: center;
  font-family: var(--display-font); font-size: 22px; letter-spacing: 2px;
  color: #fff; opacity: 0; pointer-events: none;
  text-shadow: 0 2px 0 #000;
}
#feedback.pop { animation: fbpop 0.5s ease-out; }
@keyframes fbpop { 0% { opacity: 0; transform: translateY(10px) scale(0.85); } 15% { opacity: 1; transform: scale(1.08); } 100% { opacity: 0; transform: translateY(-6px); } }

/* touch pad is up: lift feedback above the buttons, hide keyboard-only hints */
#hud.pad-on #feedback { bottom: 44%; }
#hud.pad-on #hints { display: none; }

/* control hints */
#hints {
  position: absolute; bottom: 12px; left: 0; right: 0; display: flex;
  justify-content: center; gap: 8px; flex-wrap: wrap; pointer-events: none;
}
#hints .hint {
  background: rgba(10, 12, 20, 0.75); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px; padding: 4px 10px; font-size: 12px; color: var(--dim);
}
#hints .hint b { color: var(--ink); font-family: var(--display-font); font-size: 11px; letter-spacing: 1px; }

/* vignette + tunnel vision */
#vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 140px rgba(0,0,0,0.75); }
#tunnel { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s; box-shadow: inset 0 0 240px 60px rgba(120, 0, 0, 0.85); }
#tunnel.on { opacity: 0.85; }
#replay-tag {
  position: absolute; top: 70px; left: 24px; font-family: var(--display-font);
  letter-spacing: 4px; color: var(--red); font-size: 22px; text-shadow: 0 2px 0 #000;
  border: 2px solid var(--red); padding: 4px 12px; border-radius: 4px;
  animation: pulse 0.6s infinite alternate;
}

/* get-up minigame */
#getup {
  position: absolute; bottom: 18%; left: 50%; transform: translateX(-50%);
  text-align: center; pointer-events: none;
}
#getup .title { font-family: var(--display-font); font-size: 40px; color: var(--red); letter-spacing: 4px; text-shadow: 0 3px 0 #000; }
#getup .sub { color: var(--ink); margin: 6px 0; font-size: 15px; }
#getup .meter { width: 260px; height: 22px; border: 2px solid #fff; background: rgba(0,0,0,0.6); margin: 8px auto; }
#getup .meter .fill { height: 100%; background: linear-gradient(90deg, #ff5a4a, #ffd76a); transform-origin: left; }
#getup .count { font-family: var(--display-font); font-size: 64px; color: #fff; text-shadow: 0 4px 0 #000; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 30%, rgba(20, 24, 40, 0.88), rgba(5, 6, 10, 0.96));
  overflow-y: auto; padding: 4vh 16px;
}
.screen.clear { background: transparent; }
.title-logo {
  font-family: var(--display-font); font-size: clamp(44px, 9vw, 110px);
  letter-spacing: 8px; color: var(--gold); text-align: center; line-height: 0.95;
  text-shadow: 0 6px 0 #000, 0 0 40px rgba(255,215,106,0.3);
}
.title-logo small { display: block; font-size: 0.28em; color: var(--ink); letter-spacing: 10px; }
.tagline { color: var(--dim); letter-spacing: 3px; font-size: 14px; text-transform: uppercase; }
.menu { display: flex; flex-direction: column; gap: 10px; min-width: min(320px, 80vw); }
.btn {
  font-family: var(--display-font); letter-spacing: 2px; font-size: 18px;
  padding: 13px 26px; text-align: center; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,215,106,0.16), rgba(255,215,106,0.05));
  color: var(--gold); border: 2px solid var(--panel-edge); border-radius: 4px;
  transition: transform 0.06s ease, background 0.15s;
  touch-action: manipulation;
}
.btn:hover, .btn:focus-visible { background: rgba(255, 215, 106, 0.3); outline: none; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #e8b93a, #c8961f); color: #1a1000; border-color: #ffd76a; }
.btn.primary:hover { background: #ffd76a; }
.btn.danger { border-color: rgba(255, 90, 74, 0.6); color: var(--red); }
.btn.small { font-size: 14px; padding: 9px 16px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.panel {
  background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 6px;
  padding: 20px 24px; max-width: min(680px, 92vw);
}
.panel h2 { font-family: var(--display-font); letter-spacing: 3px; color: var(--gold); margin-bottom: 12px; font-size: 22px; }
.panel h3 { font-family: var(--display-font); letter-spacing: 2px; margin: 14px 0 6px; font-size: 15px; color: var(--ink); }
.panel p, .panel li { color: var(--ink); line-height: 1.55; font-size: 14px; }
.panel .dim { color: var(--dim); font-size: 13px; }

.kbd {
  display: inline-block; font-family: var(--display-font); font-size: 11px;
  background: #262a36; border: 1px solid #4a5064; border-bottom-width: 3px;
  border-radius: 4px; padding: 2px 8px; margin: 1px 2px; color: #fff; letter-spacing: 1px;
}
.controls-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; align-items: center; }
.controls-grid .what { color: var(--dim); }

/* fighter select */
.roster { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; max-width: 900px; }
.fighter-card {
  width: 200px; background: var(--panel); border: 2px solid rgba(255,255,255,0.14);
  border-radius: 6px; padding: 14px; cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.fighter-card:hover, .fighter-card:focus-visible { border-color: var(--gold); transform: translateY(-3px); outline: none; }
.fighter-card.locked { opacity: 0.45; cursor: default; }
.fighter-card .avatar { width: 64px; height: 64px; margin: 0 auto 8px; position: relative; }
.fighter-card .nm { font-family: var(--display-font); font-size: 14px; color: var(--ink); text-align: center; }
.fighter-card .nk { font-size: 11px; color: var(--gold); text-align: center; letter-spacing: 1px; margin-top: 2px; }
.fighter-card .rec { font-size: 11px; color: var(--dim); text-align: center; margin-top: 4px; }
.fighter-card .rivalry { font-size: 11px; color: var(--dim); text-align: center; margin-top: 6px; line-height: 1.4; }
.fighter-card.champ::after {
  content: 'CHAMPION'; position: absolute; font-size: 9px; letter-spacing: 2px;
  background: var(--gold); color: #1a1000; padding: 2px 6px; transform: translate(64px, -6px); font-weight: bold;
}
.stats-row { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.stat-pip { width: 12px; height: 12px; background: #333a4a; border-radius: 2px; }
.stat-pip.on { background: var(--gold); }

/* creator */
.creator-layout { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; align-items: flex-start; max-width: 900px; }
.creator-form { display: flex; flex-direction: column; gap: 10px; min-width: 280px; }
.creator-form label { font-size: 12px; color: var(--dim); letter-spacing: 1px; display: flex; flex-direction: column; gap: 4px; }
.creator-form input[type="text"] {
  background: #161a24; border: 1px solid #3a4054; color: var(--ink);
  padding: 8px 10px; border-radius: 4px; font-size: 15px; font-family: var(--body-font);
}
input[type="range"] { accent-color: var(--gold); width: 100%; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 4px; border: 2px solid transparent; cursor: pointer; }
.swatch.sel { border-color: #fff; }
.stat-trade { display: flex; flex-direction: column; gap: 6px; }
.stat-trade .row { display: grid; grid-template-columns: 90px 1fr 26px; gap: 8px; align-items: center; font-size: 12px; color: var(--dim); }
.points-left { font-family: var(--display-font); color: var(--gold); font-size: 14px; letter-spacing: 1px; }
#creatorPreview { width: 300px; height: 380px; position: relative; border: 2px solid var(--panel-edge); border-radius: 6px; background: rgba(8,10,16,0.8); overflow: hidden; }

/* corner break */
.corner-choices { display: flex; flex-direction: column; gap: 10px; width: min(420px, 88vw); }
.corner-choices .btn { text-align: left; }
.corner-choices .btn .why { display: block; font-size: 11px; color: inherit; opacity: 0.7; letter-spacing: 0.5px; margin-top: 3px; }

/* scorecard */
.scorecard { width: min(640px, 94vw); }
.scorecard table { width: 100%; border-collapse: collapse; font-size: 13px; }
.scorecard th, .scorecard td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.1); text-align: center; }
.scorecard th { color: var(--gold); font-family: var(--display-font); letter-spacing: 1px; font-weight: normal; font-size: 12px; }
.scorecard td:first-child, .scorecard th:first-child { text-align: left; }
.judge-cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.judge { background: rgba(255,255,255,0.06); border-radius: 4px; padding: 10px 14px; text-align: center; min-width: 110px; }
.judge .who { font-size: 10px; color: var(--dim); letter-spacing: 2px; margin-bottom: 4px; }
.judge .win { font-family: var(--display-font); color: var(--gold); font-size: 15px; }
.verdict { font-family: var(--display-font); font-size: 26px; letter-spacing: 3px; text-align: center; color: var(--gold); margin: 8px 0; }
.verdict small { display: block; color: var(--ink); font-size: 13px; margin-top: 4px; letter-spacing: 1px; }

/* round card girl interstitial */
#roundcard {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; background: rgba(5,6,10,0.82);
}
#roundcard .card {
  font-family: var(--display-font); font-size: 60px; letter-spacing: 6px; color: #fff;
  border: 4px solid var(--gold); padding: 20px 48px; border-radius: 8px;
  text-shadow: 0 4px 0 #000; background: linear-gradient(180deg, #26201a, #191510);
  transform: rotate(-2deg);
}

/* settings */
.set-row { display: grid; grid-template-columns: 140px 1fr 60px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; color: var(--dim); }
.set-row .val { text-align: right; color: var(--ink); font-family: var(--display-font); font-size: 13px; }
.toggle { display: flex; gap: 6px; }
.toggle .opt { padding: 6px 14px; border: 1px solid #3a4054; border-radius: 4px; cursor: pointer; font-size: 12px; color: var(--dim); }
.toggle .opt.sel { border-color: var(--gold); color: var(--gold); background: rgba(255,215,106,0.1); }

/* touch controls */
#touch { position: absolute; inset: 0; pointer-events: none; display: none; }
#touch.on { pointer-events: auto; display: block; }
#joyZone {
  position: absolute; left: 0; bottom: 0; width: 45%; height: 55%;
  pointer-events: auto;
}
#joyBase {
  position: absolute; width: 110px; height: 110px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.05);
  opacity: 0; transition: opacity 0.2s;
}
#joyKnob {
  position: absolute; width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,0.3); opacity: 0; transition: opacity 0.2s;
}
#joyZone.active #joyBase, #joyZone.active #joyKnob { opacity: 1; }
.tbtns { position: absolute; right: 10px; bottom: 12px; display: grid; grid-template-columns: repeat(3, 64px); grid-auto-rows: 56px; gap: 8px; }
.tbtn {
  border: 2px solid rgba(255,255,255,0.3); border-radius: 10px;
  background: rgba(20, 24, 36, 0.7); color: var(--ink);
  font-family: var(--display-font); font-size: 12px; letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  touch-action: manipulation; line-height: 1.1; padding: 2px;
}
.tbtn:active, .tbtn.held { background: rgba(255, 215, 106, 0.35); border-color: var(--gold); }
.tbtn.def { border-color: rgba(106, 180, 255, 0.5); color: var(--blue); }
.tbtn.body-mod.sel { border-color: var(--red); color: var(--red); background: rgba(255,90,74,0.2); }

/* pause */
#pauseScreen .menu { min-width: 260px; }

/* gym */
#gymScreen { justify-content: space-between; padding-bottom: 3vh; }
#gymScreen .menu { flex-direction: row; justify-content: center; }
#drillHud {
  position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 6px;
  padding: 12px 20px; text-align: center; min-width: 300px;
}
#drillHud .dname { font-family: var(--display-font); letter-spacing: 2px; color: var(--gold); font-size: 17px; }
#drillHud .ddesc { font-size: 13px; color: var(--ink); margin-top: 4px; }
#drillHud .dprog { font-family: var(--display-font); font-size: 13px; color: var(--ink); margin-top: 6px; }

/* mobile adjustments */
@media (max-width: 760px) {
  .round-chip { font-size: 14px; min-width: 100px; padding: 4px 10px; }
  .round-chip .clock { font-size: 18px; }
  .statbar { width: 34vw; top: 8px; }
  .statbar .name { font-size: 10px; }
  .bar { height: 11px; }
  #hints { display: none; }
  #banner { top: 32%; }
  #getup .title { font-size: 30px; }
  #getup .count { font-size: 46px; }
  .panel { padding: 14px; max-height: 84vh; overflow-y: auto; }
  .controls-grid { font-size: 12px; }
  .fighter-card { width: 46vw; max-width: 200px; }
  .creator-layout { flex-direction: column; align-items: center; }
  .scorecard { font-size: 12px; }
  .btn { font-size: 15px; padding: 12px 18px; }
  .title-logo { letter-spacing: 4px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .round-chip { padding: 2px 8px; }
  .statbar { top: 4px; }
  .bar { height: 9px; }
}
