/* fighter2.4minuten.ch — clean rewrite. Modern, dark, minimal. */
:root {
  color-scheme: dark;
  --bg: #06080d;
  --bg-2: #0b0e16;
  --panel: #141821;
  --panel-2: #1a1f2c;
  --ink: #e8ecf4;
  --mut: #7a8499;
  --accent: #ff5a36;
  --accent-2: #ff224a;
  --p1: #3ddc97;
  --p2: #ff4f6d;
  --ok: #3ddc97;
  --err: #ff4f6d;
  --line: #232a39;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  min-height: 100vh;
  overflow: hidden;
}
/* Stage bg replaces the body bg during a fight so the level image is
   visible behind the (alpha) canvas. */
body.fight #stage-bg { background-color: #000; }

/* ── stage background ────────────────────────────────────────────────── */
/* Sits below the canvas. Always 100vh tall, auto width centred — the
   image scales by height so its aspect ratio is preserved. z-index 0
   keeps it ABOVE the body's solid bg but below the canvas (z-index 1). */
#stage-bg {
  position: fixed; inset: 0;
  background: var(--bg) center bottom / auto 100vh no-repeat;
  z-index: 0;
  display: none;
}
#stage-bg.show { display: block; }

/* ── three.js canvas above the stage bg ──────────────────────────────── */
#three-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  display: block; z-index: 1;
}

/* ── scenes ──────────────────────────────────────────────────────────── */
.scene {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 28px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(6,8,13,.55), rgba(6,8,13,.85));
}
.scene.active { display: flex; }

/* ── title ───────────────────────────────────────────────────────────── */
#scene-title::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(800px 500px at 20% 30%, rgba(255,90,54,.16), transparent 60%),
    radial-gradient(900px 600px at 80% 70%, rgba(61,220,151,.10), transparent 60%);
  pointer-events: none;
}
.title-wrap {
  position: relative;
  text-align: center;
  animation: titleIn .5s cubic-bezier(.2,.7,.2,1);
}
@keyframes titleIn { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } }
.title-wrap h1 {
  margin: 0;
  font-size: clamp(54px, 11vw, 132px);
  font-weight: 900;
  letter-spacing: -.04em;
  background: linear-gradient(140deg, #fff 0%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 30px rgba(255,90,54,.45));
}
.title-wrap h1 .em { color: var(--accent); -webkit-text-fill-color: var(--accent); margin: 0 .15em; }
.title-wrap .subtitle {
  margin: 0 0 36px;
  color: var(--mut);
  font-size: 14px;
  letter-spacing: .4em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.title-actions {
  display: flex; gap: 12px; justify-content: center;
}
.title-wrap .build {
  margin-top: 36px;
  color: var(--mut);
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn-primary, .btn-ghost {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 12px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s, box-shadow .12s;
}
.btn-primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border: 1px solid transparent;
  color: #fff;
  box-shadow: 0 8px 26px rgba(255,90,54,.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(255,90,54,.55); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--mut);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── select ──────────────────────────────────────────────────────────── */
.select-header {
  position: absolute; top: 28px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
}
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-2); border: 1.5px solid var(--line);
  color: var(--mut);
  display: flex; align-items: center; justify-content: center;
  font: 700 13px ui-monospace, Menlo, monospace;
  transition: .25s;
}
.step-dot.on {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 18px rgba(255,90,54,.55);
}
.step-line { width: 50px; height: 2px; background: var(--line); border-radius: 1px; }

.select-step {
  width: 100%; max-width: 1100px;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  animation: stepIn .35s cubic-bezier(.2,.7,.2,1);
}
/* The HTML [hidden] attribute normally sets display: none, but the rule
   above wins specificity. Restore the intent explicitly. */
.select-step[hidden] { display: none !important; }
@keyframes stepIn { 0% { opacity: 0; transform: translateY(14px); } 100% { opacity: 1; transform: translateY(0); } }
.select-step h2 {
  margin: 60px 0 0;
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 900; letter-spacing: -.025em;
}
.select-step h2 .accent {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.vs-line {
  display: flex; align-items: center; gap: 24px;
  font-size: 20px; font-weight: 800;
}
.vs-line .vs {
  font-size: 32px;
  background: linear-gradient(180deg, #fff 0%, var(--accent) 60%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  width: 100%;
}
.char-card {
  position: relative;
  aspect-ratio: 3/4;
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: .2s;
  overflow: hidden;
}
.char-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.char-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.2); }
.char-card .avatar {
  width: 100%; aspect-ratio: 1/1;
  background: center/contain no-repeat;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.6));
}
.char-card .avatar.placeholder {
  background: linear-gradient(140deg, #2a3144, #1a1f2c);
  display: flex; align-items: center; justify-content: center;
  font: 900 48px ui-sans-serif; color: var(--mut);
}
.char-card .name { font-weight: 800; font-size: 14px; text-align: center; }
.char-card .meta { font-size: 11px; color: var(--mut); text-align: center; font-family: ui-monospace, Menlo, monospace; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; width: 100%;
}
.level-card {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  overflow: hidden; cursor: pointer;
  transition: .2s;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.level-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.2); }
.level-card .thumb { position: absolute; inset: 0; background: center/cover no-repeat; }
.level-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(6,8,13,.9));
  pointer-events: none;
}
.level-card .name {
  position: absolute; left: 12px; right: 12px; bottom: 10px;
  font-weight: 800; font-size: 15px;
  text-shadow: 0 2px 12px rgba(0,0,0,.8); z-index: 1;
}
.level-card.random .thumb {
  background: repeating-linear-gradient(45deg, #1a1f2c 0 12px, #10141d 12px 24px);
}
.level-card.random .icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; opacity: .5;
}

.select-actions {
  display: flex; gap: 14px; margin-top: 12px;
}

/* ── loading ─────────────────────────────────────────────────────────── */
.loading-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.loading-ring {
  width: 48px; height: 48px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap p { color: var(--mut); font-size: 13px; font-family: ui-monospace, Menlo, monospace; margin: 0; }

/* ── fight HUD ───────────────────────────────────────────────────────── */
#scene-fight { background: transparent; pointer-events: none; }
.hud { position: absolute; top: 16px; left: 0; right: 0; padding: 0 24px; }
.hp { display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: center; max-width: 1200px; margin: 0 auto; }
.hp-side { display: flex; flex-direction: column; gap: 4px; }
.hp-side.p1 { align-items: flex-start; }
.hp-side.p2 { align-items: flex-end; }
.hp-name { font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hp-side.p1 .hp-name { color: var(--p1); }
.hp-side.p2 .hp-name { color: var(--p2); }
.hp-bar {
  width: 100%; max-width: 460px; height: 14px;
  background: rgba(11,14,22,.7); border: 1px solid var(--line); border-radius: 4px;
  overflow: hidden;
}
.hp-fill {
  width: 100%; height: 100%;
  transition: width .25s cubic-bezier(.2,.7,.2,1);
}
.hp-side.p1 .hp-fill { background: linear-gradient(90deg, var(--p1) 0%, #6fffc1 100%); }
.hp-side.p2 .hp-fill { background: linear-gradient(270deg, var(--p2) 0%, #ff8a9b 100%); }
.timer {
  font: 900 36px ui-monospace, Menlo, monospace;
  color: #fff;
  text-shadow: 0 4px 18px rgba(0,0,0,.7);
  min-width: 70px; text-align: center;
}
.announce {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.8);
  font: 900 clamp(48px, 8vw, 96px) ui-sans-serif;
  letter-spacing: -.03em;
  background: linear-gradient(180deg, #fff 0%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px rgba(255,90,54,.5));
  opacity: 0;
  transition: opacity .25s, transform .25s;
}
.announce.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
