:root {
  --red: #ff4d5e;
  --blue: #3d8bff;
  --gold: #ffd166;
  --ink: #fff7ee;
  --muted: #d9c4d8;
  --panel: rgba(28, 12, 40, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --font: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body.theme-eis { background: radial-gradient(ellipse at 50% 110%, #3fa7d6 0%, #1b4f8a 38%, #10284f 70%, #08142a 100%) fixed; }
body.theme-dreh { background: radial-gradient(ellipse at 50% 110%, #d94fc9 0%, #6a1f8a 38%, #2b0f4a 70%, #12072a 100%) fixed; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(ellipse at 50% 110%, #c2461f 0%, #6a1a33 38%, #2a0f3a 70%, #140824 100%) fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- Namensschilder ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.plabel, .pulabel { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.plabel {
  font-weight: 800; font-size: 12px; padding: 2px 7px; border-radius: 99px;
  background: rgba(0, 0, 0, 0.45); border: 1.5px solid currentColor; text-shadow: 0 1px 2px #000;
}
.plabel.team0 { color: #ffb3ba; }
.plabel.team1 { color: #a9cbff; }
.plabel.me { color: #fff; background: rgba(0, 0, 0, 0.6); font-size: 13px; }
.plabel .picon:not(:empty) { margin-left: 4px; }
.pulabel { font-size: 22px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }

/* ---------- Bildschirme ---------- */
.screen {
  z-index: 10;
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow-y: auto; touch-action: pan-y;
}
.panel {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; gap: 12px; margin: auto;
}
.panel.wide { width: min(560px, 100%); }
h1, h2, h3 { margin: 0; }
h2 { font-size: 24px; text-align: center; }
.logo { text-align: center; line-height: 0.9; font-size: clamp(44px, 14vw, 64px); font-weight: 900; letter-spacing: 2px; transform: rotate(-3deg); margin: 4px 0 2px; }
.logo span { display: block; }
.logo .l1 { color: var(--red); text-shadow: 0 4px 0 #7d1020, 0 8px 20px rgba(255, 77, 94, 0.5); }
.logo .l2 { color: var(--blue); text-shadow: 0 4px 0 #0f2f75, 0 8px 20px rgba(61, 139, 255, 0.5); margin-left: 40px; }
.tagline { text-align: center; color: var(--muted); margin: 0; font-size: 15px; }
.hint { color: var(--muted); margin: 0; font-size: 14px; line-height: 1.45; }
.hint.small { font-size: 13px; }
.status { min-height: 1.3em; text-align: center; margin: 0; color: var(--gold); font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
input {
  font: inherit; font-size: 17px; font-weight: 700; color: var(--ink); background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px; outline: none; width: 100%;
  -webkit-user-select: text; user-select: text;
}
input:focus { border-color: var(--gold); }

.btn {
  font: inherit; font-weight: 800; font-size: 16px; color: var(--ink); cursor: pointer;
  background: linear-gradient(#4a2a63, #36194d); border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px; padding: 12px 16px; box-shadow: 0 4px 0 #1d0b2c; transition: transform 0.06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1d0b2c; }
.btn.big { font-size: 18px; padding: 15px 18px; }
.btn.small { font-size: 13px; padding: 7px 10px; box-shadow: 0 3px 0 #1d0b2c; }
.btn.accent { background: linear-gradient(#ff6b5e, #e0304a); box-shadow: 0 4px 0 #7d1020; border-color: rgba(255, 255, 255, 0.3); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; font: inherit; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; min-width: 80px;
  background: rgba(255, 255, 255, 0.06); border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 8px;
}
.seg button.on { color: #fff; background: rgba(255, 209, 102, 0.18); border-color: var(--gold); }
.seg.locked button { pointer-events: none; }
.seg.locked button:not(.on) { opacity: 0.4; }

.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; text-align: center; letter-spacing: 6px; font-size: 22px; flex: 1; min-width: 0; }

.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.code { font-size: 40px; font-weight: 900; letter-spacing: 8px; color: var(--gold); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-col { border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; border: 1.5px solid; }
.team-col.t0 { background: rgba(255, 77, 94, 0.12); border-color: rgba(255, 77, 94, 0.5); }
.team-col.t1 { background: rgba(61, 139, 255, 0.12); border-color: rgba(61, 139, 255, 0.5); }
.team-col h3 { font-size: 15px; }
.team-col.t0 h3 { color: #ffb3ba; }
.team-col.t1 h3 { color: #a9cbff; }
.team-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; min-height: 60px; }
.team-col li { background: rgba(0, 0, 0, 0.25); border-radius: 9px; padding: 7px 9px; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-col li.bot { color: var(--muted); font-weight: 600; font-style: italic; }
.team-col li.empty { color: rgba(255, 255, 255, 0.35); font-weight: 600; background: transparent; border: 1.5px dashed var(--line); }
.team-col li .tag { font-size: 11px; color: var(--gold); margin-left: 4px; }

.help ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; font-size: 15px; color: #f1e3f0; }

.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
.stats th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); text-align: right; padding: 4px 6px; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats td { padding: 7px 6px; text-align: right; border-top: 1px solid var(--line); font-weight: 700; }
.stats tr.team0 td:first-child { color: #ffb3ba; }
.stats tr.team1 td:first-child { color: #a9cbff; }
#result-title { font-size: clamp(24px, 8vw, 36px); font-weight: 900; text-align: center; }
#result-title.win { color: var(--gold); text-shadow: 0 4px 20px rgba(255, 209, 102, 0.5); }
#result-title.lose { color: #c9b6d6; }

/* Ergebnis soll das Spielfeld nicht komplett verdecken */
#scr-result { background: rgba(10, 4, 18, 0.35); }
#scr-menu .panel, #scr-ai .panel, #scr-local .panel, #scr-online .panel, #scr-help .panel { background: rgba(28, 12, 40, 0.78); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.scorebar {
  position: absolute; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; background: rgba(0, 0, 0, 0.45); border-radius: 99px; padding: 6px 14px;
  border: 1px solid var(--line); font-weight: 900;
}
.scorebar .team { display: flex; align-items: center; gap: 7px; font-size: 13px; letter-spacing: 1px; }
.scorebar .t0 .tname { color: var(--red); }
.scorebar .t1 .tname { color: var(--blue); }
.dots { display: flex; gap: 4px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); display: block; }
.t0 .dots i.on { background: var(--red); border-color: var(--red); box-shadow: 0 0 8px var(--red); }
.t1 .dots i.on { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 8px var(--blue); }
.scorebar .mid { text-align: center; min-width: 96px; white-space: nowrap; }
#round-lbl { font-size: 12px; color: var(--muted); }
#shrink-lbl { font-size: 11px; color: var(--gold); min-height: 13px; }
#shrink-lbl.warn { color: #ff7a3d; animation: blink 0.5s infinite alternate; }
@keyframes blink { to { opacity: 0.4; } }

#banner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#banner .b {
  position: absolute; left: 0; right: 0; text-align: center; font-weight: 900; font-size: clamp(30px, 9vw, 68px); padding: 0 10px;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.35), 0 0 30px rgba(0, 0, 0, 0.5); top: 38%; transform: translateY(-50%);
}
#banner .b.pop { animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
#banner .b2 { display: none; }
#banner .red { color: var(--red); }
#banner .blue { color: var(--blue); }
#banner .gold { color: var(--gold); }
#banner small { display: block; font-size: 0.35em; color: #fff; margin-top: 4px; }
@keyframes pop { from { transform: translateY(-50%) scale(0.3); opacity: 0; } to { transform: translateY(-50%) scale(1); opacity: 1; } }

#toasts {
  position: fixed; z-index: 20; pointer-events: none; top: calc(56px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 92%;
}
.toast {
  background: rgba(0, 0, 0, 0.6); border-radius: 99px; padding: 6px 14px; font-weight: 800; font-size: 14px; text-align: center;
  animation: toast 2.4s forwards; border: 1px solid var(--line);
}
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.icon-btn {
  position: absolute; top: calc(8px + var(--safe-t)); width: 40px; height: 40px; border-radius: 50%; pointer-events: auto;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); color: #fff; font-size: 17px; cursor: pointer; z-index: 5;
}
#btn-quit { left: 10px; }
#btn-mute { right: 10px; }

/* Zu zweit: Anzeige seitlich, Banner doppelt (einmal gedreht) */
body.duo #hud .scorebar {
  top: 50%; left: 4px; transform-origin: 0 0; transform: rotate(90deg) translate(-50%, -100%) scale(0.85);
  background: rgba(0, 0, 0, 0.35); padding: 4px 10px; gap: 8px;
}
body.duo #hud #banner .b1 { top: 70%; }
body.duo #hud #banner .b2 { display: block; top: 30%; transform: translateY(-50%) rotate(180deg); }
body.duo #hud #banner .b2.pop { animation: pop2 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop2 { from { transform: translateY(-50%) rotate(180deg) scale(0.3); opacity: 0; } to { transform: translateY(-50%) rotate(180deg) scale(1); opacity: 1; } }
body.duo #toasts { top: 58%; }
body.duo #hud .icon-btn { width: 34px; height: 34px; font-size: 14px; left: auto; right: 4px; background: rgba(0, 0, 0, 0.3); }
body.duo #hud #btn-mute { top: calc(50% + 4px); }
body.duo #hud #btn-quit { top: calc(50% - 38px); }

/* ---------- Touch-Steuerung ---------- */
#touch { position: fixed; inset: 0; touch-action: none; }
.pad { position: absolute; left: 0; right: 0; }
.pad-full { top: 0; bottom: 0; }
.pad-bottom { bottom: 0; height: 50%; }
.pad-top { top: 0; height: 50%; transform: rotate(180deg); }
.stick-hint {
  position: absolute; left: calc(26px + env(safe-area-inset-left, 0px)); bottom: calc(26px + var(--safe-b));
  width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, 0.55); transition: opacity 0.4s; pointer-events: none;
}
.stick-hint .stick-base { position: absolute; inset: 0; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.3); }
.stick-hint.gone { opacity: 0; }
.stick { position: absolute; left: 0; top: 0; width: 0; height: 0; display: none; pointer-events: none; }
.stick.on { display: block; }
.stick::before {
  content: ''; position: absolute; width: 112px; height: 112px; left: -56px; top: -56px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.35);
}
.stick-knob {
  position: absolute; left: 0; top: 0; width: 52px; height: 52px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #cfc3dc); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); transform: translate(-50%, -50%);
}
.dash-btn {
  --cd: 0;
  position: absolute; right: calc(26px + env(safe-area-inset-right, 0px)); bottom: calc(30px + var(--safe-b));
  width: 104px; height: 104px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; letter-spacing: 1px; pointer-events: none;
  background: radial-gradient(circle at 40% 35%, #ff8a7a, #e0304a 70%); box-shadow: 0 6px 0 #7d1020, 0 10px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s, filter 0.15s;
}
.dash-btn span { position: relative; z-index: 1; text-shadow: 0 2px 2px rgba(0, 0, 0, 0.4); }
.dash-ring {
  position: absolute; inset: -7px; border-radius: 50%;
  background: conic-gradient(rgba(20, 8, 30, 0.75) calc(var(--cd) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 55px, #000 56px); mask: radial-gradient(circle, transparent 55px, #000 56px);
}
.dash-btn:not(.ready) { filter: saturate(0.4) brightness(0.8); }
.dash-btn.ready { animation: ready 0.25s; }
.dash-btn.heavy { background: radial-gradient(circle at 40% 35%, #ffc36b, #d9771c 70%); }
.dash-btn.press { transform: scale(0.9); }
@keyframes ready { 50% { transform: scale(1.12); } }

.t0 .dots i { border-color: rgba(255, 77, 94, 0.6); }
.t1 .dots i { border-color: rgba(61, 139, 255, 0.6); }
@media (max-width: 440px) {
  .scorebar { gap: 8px; padding: 5px 10px; }
  .scorebar .tname { display: none; }
  .scorebar .mid { min-width: 88px; }
}
@media (min-aspect-ratio: 4/3) {
  .scorebar { gap: 16px; padding: 7px 20px; }
}
@media (hover: hover) and (pointer: fine) {
  .stick-hint span { display: none; }
}

/* ---------- Arena-Auswahl ---------- */
.arena-seg button { min-width: 46%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.center { text-align: center; }

/* ---------- Deine Figur ---------- */
#look-canvas { width: 100%; height: 200px; display: block; border-radius: 16px; background: radial-gradient(circle at 50% 70%, rgba(255, 120, 80, 0.35), transparent 70%); }
.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.look-item {
  font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(255, 255, 255, 0.06); border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 4px;
}
.look-item .li-icon { font-size: 24px; }
.look-item .li-name { font-size: 12px; font-weight: 700; }
.look-item.on { border-color: var(--gold); background: rgba(255, 209, 102, 0.18); }
.look-item.locked { opacity: 0.5; }

/* ---------- Freischaltungen im Ergebnis ---------- */
#result-unlocks:empty { display: none; }
#result-unlocks { text-align: center; background: rgba(255, 209, 102, 0.12); border: 1.5px solid var(--gold); border-radius: 14px; padding: 10px; animation: ready 0.5s; }
.unlock-title { font-weight: 900; color: var(--gold); margin-bottom: 6px; }
.unlock { display: inline-block; background: rgba(0, 0, 0, 0.3); border-radius: 99px; padding: 5px 12px; margin: 3px; font-weight: 800; }

/* ---------- Zeitlupen-Wiederholung ---------- */
#replay-badge {
  display: none; position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 12;
  font-weight: 900; letter-spacing: 2px; font-size: 15px; background: rgba(0, 0, 0, 0.7); padding: 7px 16px; border-radius: 99px; text-align: center;
}
#replay-badge small { display: block; font-size: 10px; letter-spacing: 0; color: var(--muted); font-weight: 700; }
#replay-badge .rec { color: #ff3b3b; animation: blink 0.6s infinite alternate; }
body.replaying #replay-badge { display: block; }
body.replaying::before, body.replaying::after {
  content: ''; position: fixed; left: 0; right: 0; height: 9vh; background: #000; z-index: 11; pointer-events: none;
}
body.replaying::before { top: 0; }
body.replaying::after { bottom: 0; }
body.replaying #hud .scorebar, body.replaying #touch, body.replaying #toasts { visibility: hidden; }

/* ---------- Aufladen ---------- */
.dash-btn { --ch: 0; flex-direction: column; }
.dash-btn small { position: relative; z-index: 1; font-size: 9px; font-weight: 700; letter-spacing: 0; opacity: 0.8; }
.dash-charge {
  position: absolute; inset: -12px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: conic-gradient(#ffe14d calc(var(--ch) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 57px, #000 58px); mask: radial-gradient(circle, transparent 57px, #000 58px);
}
.dash-btn.charging .dash-charge { opacity: 1; }
.dash-btn.charging { transform: scale(calc(0.92 + var(--ch) * 0.1)); }
.dash-btn.full { box-shadow: 0 6px 0 #7d1020, 0 0 30px #ffe14d; animation: blink 0.15s infinite alternate; }
.dash-btn.press:not(.charging) { transform: scale(0.9); }

/* ---------- Hügel-Balken ---------- */
#hill-bar { display: flex; gap: 4px; margin: 3px 0 1px; }
#hill-bar i { --p: 0; flex: 1; height: 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); overflow: hidden; position: relative; }
#hill-bar i::after { content: ''; position: absolute; top: 0; bottom: 0; width: calc(var(--p) * 100%); border-radius: 99px; }
#hill-bar .h0::after { right: 0; background: var(--red); box-shadow: 0 0 8px var(--red); }
#hill-bar .h1::after { left: 0; background: var(--blue); box-shadow: 0 0 8px var(--blue); }

/* ---------- Turnier ---------- */
.btn.gold { background: linear-gradient(#ffd166, #e89b1c); color: #3a2200; box-shadow: 0 4px 0 #8a5300; border-color: rgba(255, 255, 255, 0.4); }
.tour-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.tour-list li { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 13px; background: rgba(255, 255, 255, 0.06); border: 1.5px solid var(--line); }
.tour-list .t-icon { font-size: 26px; }
.tour-list .t-main { flex: 1; min-width: 0; }
.tour-list .t-main small { color: var(--muted); }
.tour-list .t-text { display: block; font-size: 13px; color: #f1e3f0; margin-top: 3px; }
.tour-list .t-badge { font-size: 20px; }
.tour-list .tour-current { border-color: var(--gold); background: rgba(255, 209, 102, 0.14); }
.tour-list .tour-locked { opacity: 0.5; }
.tour-list .tour-done { opacity: 0.75; }
.tour-list .boss .t-icon { font-size: 32px; filter: drop-shadow(0 0 6px #ffd166); }

/* ---------- Emojis ---------- */
#emotes {
  position: absolute; right: calc(8px + env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-60%);
  display: flex; flex-direction: column; gap: 8px; pointer-events: auto;
}
#emotes button {
  width: 44px; height: 44px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; padding: 0;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); transition: transform 0.08s;
}
#emotes button:active { transform: scale(0.85); }
.plabel { position: absolute; }
.plabel .pemo {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 0) scale(0); font-size: 30px; line-height: 1;
  margin-bottom: 4px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5)); pointer-events: none; opacity: 0;
}
.plabel .pemo.show { animation: emo 2.2s ease-out forwards; }
@keyframes emo {
  0% { transform: translate(-50%, 10px) scale(0.2); opacity: 0; }
  12% { transform: translate(-50%, -6px) scale(1.25); opacity: 1; }
  22%, 80% { transform: translate(-50%, -8px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -26px) scale(0.9); opacity: 0; }
}
.pill { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 800; color: #3a2200; background: var(--gold); border-radius: 99px; padding: 3px 10px; }
