/* Song Battle – gebaut auf dem Nocturne-Design-System (Tokens aus styles.css des Claude-Design-Projekts) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-accent: #9184d9;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);
  --color-neutral-100: #f3f5fe; --color-neutral-200: #e4e7f5; --color-neutral-300: #cfd3e5; --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab; --color-neutral-600: #75798c; --color-neutral-700: #595d6c; --color-neutral-800: #3f424d; --color-neutral-900: #292b31;
  --color-accent-100: #f5f4ff; --color-accent-200: #e7e5fe; --color-accent-300: #d2cefd; --color-accent-400: #b5abfc; --color-accent-500: #968ae0;
  --color-accent-600: #796cbf; --color-accent-700: #5d5294; --color-accent-800: #423a6a; --color-accent-900: #2b2741;
  --color-section: #262a60; --color-section-glow: #353b80; --color-section-ghost: #4c5397;
  --color-ok: #7fc8a9; --color-warn: #e0b36a;
  --font-heading: "Inter", system-ui, sans-serif; --font-heading-weight: 500; --font-body: "Inter", system-ui, sans-serif;
  --space-1: 2.8px; --space-2: 5.6px; --space-3: 8.4px; --space-4: 11.2px; --space-6: 16.8px; --space-8: 22.4px;
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 14px;
  --shadow-sm: 0 0 0 1px #3f424d; --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,0.55); --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0,0,0,0.65);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text); font-family: var(--font-body);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--color-section-glow) 45%, transparent), transparent 70%);
  background-attachment: fixed;
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: var(--font-heading-weight); line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2); text-wrap: balance; }
h1 { font-size: clamp(30px, 6vw, 42px); } h2 { font-size: 26px; } h3 { font-size: 19px; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
.muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.kicker { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); font-weight: 500; }
.hr { height: 1px; border: 0; margin: var(--space-4) 0; background: linear-gradient(to right, transparent, var(--color-divider) 48px, var(--color-divider) calc(100% - 48px), transparent); }
[hidden] { display: none !important; }

.wrap { max-width: 1080px; margin: 0 auto; padding-block: var(--space-6) 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* — nav — */
.nav { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) 0 var(--space-6); flex-wrap: wrap; }
.nav-brand { font-family: var(--font-heading); font-weight: 600; font-size: 18px; margin-right: auto; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; letter-spacing: -0.01em; }
.nav-brand .mark { width: 10px; height: 10px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 12px var(--color-accent); }
.nav .code-chip { font-variant-numeric: tabular-nums; letter-spacing: 0.18em; font-weight: 600; }

/* — buttons — */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; text-decoration: none; font-family: var(--font-heading); font-weight: 500; font-size: 14px; line-height: 1.2; color: var(--color-text); background: transparent; border: 1px solid transparent; padding: 8px 14px; border-radius: var(--radius-md); white-space: nowrap; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: 6px; }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-danger { color: #e39a9a; border-color: color-mix(in srgb, #e39a9a 50%, transparent); }
.btn-lg { font-size: 16px; padding: 12px 20px; }
.btn-block { width: 100%; }
.btn i { font-size: 1.15em; }
.btn-sm { font-size: 12.5px; padding: 5px 10px; gap: 5px; border-radius: 6px; }
.btn-icon { width: 36px; height: 36px; padding: 0; flex: none; border-radius: var(--radius-md); }
.btn-icon i { font-size: 20px; }

/* — forms — */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.input { width: 100%; min-height: 40px; padding: 8px 12px; font: inherit; font-size: 15px; color: var(--color-text); caret-color: var(--color-accent); background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.input.code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 600; font-size: 20px; text-align: center; }
.row { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--color-accent); width: 16px; height: 16px; }
select.input { appearance: auto; }

/* — cards — */
.card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-6); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); min-width: 0; }
.card-title { font-family: var(--font-heading); font-weight: 500; font-size: 17px; line-height: 1.2; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; letter-spacing: 0.02em; padding: 3px 10px; border-radius: 6px; white-space: nowrap; }
.tag-accent { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-ok { background: color-mix(in srgb, var(--color-ok) 18%, transparent); color: var(--color-ok); }

/* — home — */
.hero { display: grid; gap: var(--space-8); grid-template-columns: 1.1fr 1fr; align-items: start; }
.hero-copy h1 { margin-bottom: var(--space-4); }
.hero-copy .steps { display: grid; gap: var(--space-3); margin: var(--space-6) 0 0; padding: 0; list-style: none; max-width: 48ch; }
.hero-copy .steps li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 14px; }
.hero-copy .steps b { font-weight: 500; }
.hero-copy .steps i { font-size: 20px; color: var(--color-accent); line-height: 1.2; }
.home-forms { display: grid; gap: var(--space-4); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }

/* — lobby — */
.lobby { display: grid; grid-template-columns: 1fr 320px; gap: var(--space-6); align-items: start; }
@media (max-width: 860px) { .lobby { grid-template-columns: 1fr; } }
.share { display: grid; grid-template-columns: 120px 1fr; gap: var(--space-4); align-items: center; }
.share img { width: 120px; height: 120px; border-radius: var(--radius-md); background: var(--color-neutral-900); padding: 6px; }
.share .big-code { font-size: 38px; letter-spacing: 0.22em; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.share .link { font-size: 13px; word-break: break-all; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.players li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; background: linear-gradient(to right, transparent, color-mix(in srgb, var(--color-text) 8%, transparent) 24px, color-mix(in srgb, var(--color-text) 8%, transparent) calc(100% - 24px), transparent) no-repeat bottom / 100% 1px; }
.players .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-neutral-600); flex: none; }
.players .dot.on { background: var(--color-ok); box-shadow: 0 0 8px var(--color-ok); }
.players .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .x { opacity: 0.5; cursor: pointer; background: none; border: 0; color: inherit; font-size: 16px; }
.players .x:hover { opacity: 1; color: #e39a9a; }

.songs { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.song-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-text) 3%, transparent); min-width: 0; }
.song-row img, .song-row .noimg { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--color-neutral-900); }
.song-row .t { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row .s { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row .meta { min-width: 0; }
.empty { padding: var(--space-6); text-align: center; border: 1px dashed var(--color-divider); border-radius: var(--radius-md); font-size: 14px; }
.status-line { font-size: 13px; min-height: 1.4em; }
.status-line.err { color: #e39a9a; }
.status-line.ok { color: var(--color-ok); }

/* — battle — (Kopf, Duell, Host-Leiste; das Fit-Layout ohne Seitenscroll folgt im nächsten Block) */
.battle-head { display: grid; grid-template-columns: auto minmax(64px, 1fr) minmax(0, auto); grid-template-areas: "left prog right"; align-items: center; column-gap: var(--space-6); row-gap: 5px; margin: 0; flex: none; min-width: 0; }
.battle-head .bh-left { grid-area: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.battle-head .kicker { margin: 0; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-head h2 { margin: 0; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-head .progress { grid-area: prog; min-width: 0; height: 3px; background: var(--color-neutral-900); border-radius: 2px; overflow: hidden; align-self: center; }
.battle-head .progress b { display: block; height: 100%; background: var(--color-accent); box-shadow: 0 0 10px var(--color-accent); transition: width .4s ease; }
.battle-head .bh-right { grid-area: right; display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.battle-head .bh-right .btn { flex: none; }
.votecount { font-size: 13.5px; line-height: 1.4; margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.votecount i { vertical-align: -2px; }
.votecount .eq { margin-right: 2px; }
.duel { display: grid; grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr); gap: var(--space-4); align-items: stretch; min-width: 0; }
.vs { display: grid; place-items: center; font-weight: 600; letter-spacing: 0.1em; color: var(--color-neutral-500); font-size: 13px; }
.contender { --cover-size: clamp(140px, 34vh, 320px); position: relative; isolation: isolate; overflow: hidden; overflow: clip; display: flex; flex-direction: column; justify-content: flex-start; gap: 14px; padding: 16px 18px; border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); transition: box-shadow .25s ease, transform .25s ease; min-width: 0; min-height: 0; }
/* Ambient-Backdrop: das Cover (app.js setzt --cover inline) liegt stark verwischt unter dem Inhalt, die Surface bleibt darunter für den Kontrast */
.contender::before { content: ""; position: absolute; inset: -35%; z-index: 0; pointer-events: none; background: var(--cover) center / cover no-repeat; filter: blur(56px) saturate(1.3); opacity: .2; transition: opacity .6s ease; }
.contender > * { position: relative; z-index: 1; }
.contender.mine::before { opacity: .28; }
.contender.winner::before { opacity: .32; }
.contender.loser::before { opacity: .06; }
.contender.mine { box-shadow: 0 0 0 1px var(--color-accent), 0 0 24px color-mix(in srgb, var(--color-accent) 35%, transparent); }
.contender.winner { box-shadow: 0 0 0 1px var(--color-ok), 0 0 28px color-mix(in srgb, var(--color-ok) 35%, transparent); }
.contender.loser { opacity: 0.55; }
.contender .head { display: grid; grid-template-columns: var(--cover-size) minmax(0, 1fr); gap: 18px; align-items: center; min-width: 0; flex: none; }
.contender .head img, .contender .head .noimg { width: var(--cover-size); height: var(--cover-size); border-radius: 12px; object-fit: cover; background: var(--color-neutral-900); box-shadow: 0 12px 32px rgba(0,0,0,.45); flex: none; }
.contender .meta { min-width: 0; }
.contender .title { font-size: 26px; font-weight: 500; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.contender .artist, .contender .by { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.contender .artist { font-size: 15px; margin-top: 6px; }
.contender .by { font-size: 13px; margin-top: 2px; }
.contender iframe { display: block; width: 100%; height: 80px; flex: none; border: 0; border-radius: 12px; background: var(--color-neutral-900); }
.contender .vote { width: 100%; margin-top: auto; flex: none; }
.contender .result { display: none; align-items: center; gap: 10px; font-size: 13.5px; flex: none; margin-top: auto; }
.contender .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--color-neutral-900); overflow: hidden; }
.contender .bar b { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width .6s ease; }
.contender.winner .bar b { background: var(--color-ok); }
.contender .pct { font-variant-numeric: tabular-nums; min-width: 2.4em; text-align: right; font-weight: 500; }
.contender .cnt { white-space: nowrap; }
.contender .crown { position: absolute; top: 12px; right: 14px; font-size: 24px; color: var(--color-ok); filter: drop-shadow(0 0 8px var(--color-ok)); display: none; z-index: 2; pointer-events: none; }
.contender.winner .crown { display: block; }
.closed .contender .result { display: flex; }
.closed .contender .vote { display: none; }

.hostbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin-top: var(--space-6); padding: var(--space-4); border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-accent) 8%, transparent); border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent); }
.hostbar .fill { flex: 1 1 160px; min-width: 0; font-size: 13px; }
.decided { margin-top: var(--space-4); font-size: 14px; line-height: 1.4; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.decided i { font-size: 17px; color: var(--color-accent); vertical-align: -3px; margin-right: 2px; }
.decided b { font-weight: 500; }

/* — Battle-Fit: Match-Screen ohne Seitenscroll. app.js setzt body.fit, solange #screen-battle aktiv ist.
   Budget Phone 390×740: nav ≈ 42 + Kopf ≈ 58 + 2 Karten (48 Cover + 80 Player + 41 Button) + VS 30 + Host-Leiste ≈ 52. — */
body.fit { --fit-gap: clamp(6px, 1.2vh, 12px); --fit-pad: clamp(6px, 1vh, 10px); height: 100vh; height: 100dvh; overflow: hidden; }
body.fit .wrap { max-width: 1240px; height: 100vh; height: 100dvh; display: flex; flex-direction: column; min-height: 0; padding-top: var(--fit-gap); padding-bottom: max(var(--fit-gap), env(safe-area-inset-bottom, 0px)); }
body.fit .nav { flex: none; padding: 2px 0 var(--fit-gap); gap: 10px; }
body.fit .nav .btn { padding-block: 6px; }
.screen-fit { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; gap: var(--fit-gap, 8px); }
.screen-fit .duel { flex: 1 1 auto; min-height: 0; margin-block: auto; }
.screen-fit .decided { flex: none; margin: 0; font-size: 13.5px; }
.screen-fit .hostbar { flex: none; margin: 0; padding: var(--fit-pad, 8px) 12px; gap: 8px 10px; }
.screen-fit .hostbar .fill { flex: 1 1 120px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.screen-fit .hostbar .btn { padding: 7px 12px; font-size: 13.5px; }
@media (min-width: 761px) {
  .screen-fit .duel { max-height: clamp(380px, 68vh, 680px); }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .contender { --cover-size: clamp(120px, 20vh, 180px); }
  .contender .title { font-size: 21px; }
}
@media (min-height: 860px) {
  .contender iframe { height: 152px; }
}
/* Große Desktops (1920×1080): Karten dürfen wachsen – mehr Cover, mehr Luft, gleiche Proportionen */
@media (min-width: 1400px) and (min-height: 1000px) {
  body.fit .wrap { max-width: 1320px; }
  .contender { padding: 20px 22px; gap: 16px; }
  .contender .head { gap: 22px; }
  .battle-head h2 { font-size: 24px; }
}
@media (max-width: 760px) {
  .battle-head { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "left btn" "prog prog" "votes votes"; column-gap: 10px; row-gap: 4px; }
  .battle-head .bh-right { display: contents; }
  .battle-head .votecount { grid-area: votes; font-size: 13px; }
  .battle-head .bh-right .btn { grid-area: btn; justify-self: end; }
  .battle-head .bh-left { flex-direction: row; align-items: baseline; gap: 8px; }
  .battle-head .bh-left .kicker { order: 2; flex: 0 1 auto; min-width: 0; font-size: 10.5px; }
  .battle-head h2 { font-size: 18px; flex: none; }
  .duel { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--fit-gap, 8px); }
  .duel .vs { padding: 0; }
  .duel .vs span { width: 30px; height: 30px; font-size: 9.5px; letter-spacing: 0.08em; }
  .contender { padding: 10px; gap: 6px; }
  .contender .head { grid-template-columns: 48px minmax(0, 1fr); gap: 10px; }
  .contender .head img, .contender .head .noimg { width: 48px; height: 48px; border-radius: 6px; box-shadow: none; }
  .contender .title { font-size: 15px; -webkit-line-clamp: 1; }
  .contender .artist { font-size: 12px; margin-top: 0; }
  .contender .by { font-size: 11px; margin-top: 0; }
  .contender .vote.btn-lg { padding: 10px 16px; }
  .contender .crown { top: 8px; right: 10px; font-size: 20px; }
}
@media (max-width: 480px) {
  body.fit .nav-brand { font-size: 16px; }
  body.fit .conn > :not(.dot) { display: none; }
}
/* Fallback für sehr niedrige Viewports (Phone quer, kleine Fenster): statt zu beschneiden scrollt die Match-Sektion intern, die Seite nie. */
@media (max-height: 659px) {
  body.fit .screen-fit { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
  .screen-fit .duel { flex: 1 0 auto; max-height: none; margin-block: 0; grid-template-rows: auto; }
}

/* Münzwurf bei Gleichstand */
.coin-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--color-bg) 82%, transparent); backdrop-filter: blur(6px); z-index: 50; padding: 16px; }
.coin-box { text-align: center; display: grid; gap: var(--space-4); justify-items: center; }
.coin-box h3 { margin: 0; }
.coin { width: 180px; height: 180px; position: relative; perspective: 900px; }
.coin .face { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; backface-visibility: hidden; box-shadow: 0 0 0 3px var(--color-accent), 0 0 40px color-mix(in srgb, var(--color-accent) 45%, transparent); background: var(--color-surface); display: grid; place-items: center; }
.coin .face img { width: 100%; height: 100%; object-fit: cover; }
.coin .face.b { transform: rotateY(180deg); }
.coin-inner { position: absolute; inset: 0; transform-style: preserve-3d; animation: spin 2.6s cubic-bezier(.2,.8,.2,1) forwards; }
.coin-inner.land-b { animation-name: spinB; }
@keyframes spin  { from { transform: rotateY(0) } to { transform: rotateY(1800deg) } }
@keyframes spinB { from { transform: rotateY(0) } to { transform: rotateY(1980deg) } }
.coin-label { font-size: 14px; }
.coin-result { font-size: 20px; font-weight: 500; min-height: 1.4em; }
@media (prefers-reduced-motion: reduce) { .coin-inner { animation-duration: .6s; } }

/* — bracket — */
.bracket-wrap { overflow-x: auto; padding-bottom: var(--space-3); }
.bracket { display: flex; gap: var(--space-8); align-items: stretch; min-width: max-content; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: var(--space-4); min-width: 210px; }
.round h4 { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-neutral-500); margin: 0; }
.m { display: grid; gap: 2px; border-radius: var(--radius-md); background: var(--color-surface); padding: 6px; box-shadow: var(--shadow-sm); font-size: 13px; }
.m.cur { box-shadow: 0 0 0 1px var(--color-accent), 0 0 18px color-mix(in srgb, var(--color-accent) 30%, transparent); }
.m .slot { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 5px; min-width: 0; }
.m .slot img, .m .slot .noimg { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; background: var(--color-neutral-900); }
.m .slot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.m .slot.win { background: color-mix(in srgb, var(--color-ok) 12%, transparent); color: var(--color-ok); }
.m .slot.lose { opacity: 0.5; }
.m .slot .n { font-variant-numeric: tabular-nums; font-size: 12px; opacity: 0.8; }
.m .slot.tbd { opacity: 0.4; font-style: italic; }
.m .how { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-500); padding: 2px 6px 0; }

/* — Turnierbaum-Drawer (body-level, außerhalb von .wrap; app.js: hidden=false, dann .open im nächsten Frame; Transitions im Motion-Layer) — */
.drawer { position: fixed; inset: 0; z-index: 45; }
.drawer-backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--color-bg) 72%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 92vw); display: flex; flex-direction: column; min-height: 0; background: var(--color-surface); box-shadow: 0 0 0 1px var(--color-neutral-800), -12px 0 40px rgba(0,0,0,.45); padding-top: env(safe-area-inset-top, 0px); }
.drawer-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 14px 16px 10px; background: linear-gradient(to right, transparent, var(--color-divider) 32px, var(--color-divider) calc(100% - 32px), transparent) no-repeat bottom / 100% 1px; }
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer .bracket-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }
.drawer .round { min-width: 200px; }
@media (max-width: 760px) {
  .drawer-panel { top: auto; left: 0; width: auto; height: 85vh; height: 85dvh; max-height: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 0 0 1px var(--color-neutral-800), 0 -12px 40px rgba(0,0,0,.45); padding-top: 0; }
  .drawer-panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--color-neutral-700); }
  .drawer-head { padding-top: 20px; }
}

/* — done — */
.champion { display: grid; grid-template-columns: 220px 1fr; gap: var(--space-8); align-items: center; padding: var(--space-8); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--color-section), var(--color-section-glow)); box-shadow: var(--shadow-md); }
.champion { position: relative; isolation: isolate; overflow: hidden; overflow: clip; }
.champion::before { content: ""; position: absolute; inset: -35%; z-index: 0; pointer-events: none; background: linear-gradient(135deg, color-mix(in srgb, var(--color-section) 65%, transparent), color-mix(in srgb, var(--color-section-glow) 65%, transparent)), var(--cover) center / cover no-repeat; filter: blur(70px) saturate(1.3); }
.champion > * { position: relative; z-index: 1; }
.champion img, .champion .noimg { width: 220px; height: 220px; border-radius: var(--radius-lg); object-fit: cover; box-shadow: 0 20px 50px rgba(0,0,0,.5); background: var(--color-neutral-900); }
.champion h2 { font-size: clamp(26px, 5vw, 40px); margin: var(--space-2) 0; }
@media (max-width: 680px) { .champion { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--color-surface); box-shadow: var(--shadow-md); padding: 10px 16px; border-radius: var(--radius-md); font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
.toast.err { border-left: 3px solid #e39a9a; }
.conn { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-warn); }
.conn.on .dot { background: var(--color-ok); box-shadow: 0 0 8px var(--color-ok); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-8) 0 var(--space-3); }
.section-title h3 { margin: 0; }

/* ═══════════════════════════ Motion ═══════════════════════════
   Ein Easing für alles (cubic-bezier(.2,.8,.2,1)), kurze Dauern, Akzent als Glow – nie als Fläche. */
:root { --ease: cubic-bezier(.2,.8,.2,1); }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes fadeIn   { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideL   { from { opacity: 0; transform: translateX(-32px) } to { opacity: 1; transform: none } }
@keyframes slideR   { from { opacity: 0; transform: translateX(32px) } to { opacity: 1; transform: none } }
@keyframes popIn    { 0% { opacity: 0; transform: scale(.6) } 70% { transform: scale(1.06) } 100% { opacity: 1; transform: scale(1) } }
@keyframes pop      { 0% { transform: scale(1) } 40% { transform: scale(1.035) } 100% { transform: scale(1) } }
@keyframes bump     { 0% { transform: scale(1) } 50% { transform: scale(1.3); color: var(--color-accent) } 100% { transform: scale(1) } }
@keyframes glowPulse{ 0%,100% { box-shadow: 0 0 0 1px var(--color-accent), 0 0 16px color-mix(in srgb, var(--color-accent) 22%, transparent) } 50% { box-shadow: 0 0 0 1px var(--color-accent), 0 0 36px color-mix(in srgb, var(--color-accent) 55%, transparent) } }
@keyframes winGlow  { 0% { box-shadow: 0 0 0 1px var(--color-ok), 0 0 0 color-mix(in srgb, var(--color-ok) 0%, transparent) } 50% { box-shadow: 0 0 0 1px var(--color-ok), 0 0 48px color-mix(in srgb, var(--color-ok) 55%, transparent) } 100% { box-shadow: 0 0 0 1px var(--color-ok), 0 0 28px color-mix(in srgb, var(--color-ok) 35%, transparent) } }
@keyframes crownDrop{ 0% { opacity: 0; transform: translateY(-22px) rotate(-14deg) scale(.5) } 60% { opacity: 1; transform: translateY(3px) rotate(5deg) scale(1.12) } 100% { opacity: 1; transform: none } }
@keyframes shimmer  { from { background-position: 200% 0 } to { background-position: -200% 0 } }
@keyframes drift    { 0% { transform: translate(0,0) scale(1) } 50% { transform: translate(3%, 5%) scale(1.06) } 100% { transform: translate(0,0) scale(1) } }
@keyframes breathe  { 0%,100% { box-shadow: 0 0 10px var(--color-accent) } 50% { box-shadow: 0 0 22px var(--color-accent), 0 0 4px var(--color-accent) } }
@keyframes spinRing { to { transform: rotate(360deg) } }
@keyframes sweep    { from { left: -60% } to { left: 120% } }
@keyframes land     { 0% { transform: scale(1) } 30% { transform: scale(1.14) } 60% { transform: scale(.96) } 100% { transform: scale(1) } }
@keyframes eq       { 0%,100% { height: 25% } 50% { height: 100% } }
@keyframes pulseDot { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-ok) 60%, transparent) } 70% { box-shadow: 0 0 0 7px transparent } }

/* Ambient-Hintergrund: zwei langsam driftende Glows (Nocturne: Tiefe durch Gradient, nicht durch Fläche) */
body { background-image: none; }
body::before {
  content: ""; position: fixed; left: -10%; right: -10%; top: -20%; height: 75vh; pointer-events: none; z-index: -1; filter: blur(14px);
  background:
    radial-gradient(55% 60% at 22% 30%, color-mix(in srgb, var(--color-section-glow) 60%, transparent), transparent 70%),
    radial-gradient(40% 50% at 82% 12%, color-mix(in srgb, var(--color-accent-800) 70%, transparent), transparent 70%);
  animation: drift 22s ease-in-out infinite; will-change: transform;
}

/* Screen-Wechsel */
section.enter { animation: fadeUp .5s var(--ease) both; }

/* Nav */
.nav-brand .mark { animation: breathe 3.2s ease-in-out infinite; }
.conn.on .dot { animation: pulseDot 2.4s ease-out infinite; }
.code-chip { animation: popIn .45s var(--ease) both; }

/* Buttons – Micro-Interaktionen */
.btn { transition: background .18s ease, border-color .18s ease, transform .14s var(--ease), box-shadow .22s ease, opacity .2s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.97); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 20px color-mix(in srgb, var(--color-accent) 30%, transparent); }
.input { transition: border-color .18s ease, box-shadow .22s ease; }
.input:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 20%, transparent); }

/* Equalizer – das eine Detail, das nur eine Musik-App hat */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: -2px; }
.eq i { display: block; width: 3px; height: 40%; border-radius: 1px; background: var(--color-accent); animation: eq 1.1s ease-in-out infinite; box-shadow: 0 0 6px color-mix(in srgb, var(--color-accent) 60%, transparent); }
.eq i:nth-child(2) { animation-delay: .18s; animation-duration: .9s; }
.eq i:nth-child(3) { animation-delay: .36s; animation-duration: 1.3s; }
.eq i:nth-child(4) { animation-delay: .12s; animation-duration: 1s; }
.eq i:nth-child(5) { animation-delay: .5s; animation-duration: 1.2s; }

/* Home – gestaffelter Auftritt */
.hero-copy > * { animation: fadeUp .6s var(--ease) both; }
.hero-copy > :nth-child(1) { animation-delay: .05s } .hero-copy > :nth-child(2) { animation-delay: .12s } .hero-copy > :nth-child(3) { animation-delay: .2s }
.hero-copy .steps li { animation: fadeUp .55s var(--ease) both; }
.hero-copy .steps li:nth-child(1) { animation-delay: .3s } .hero-copy .steps li:nth-child(2) { animation-delay: .38s } .hero-copy .steps li:nth-child(3) { animation-delay: .46s } .hero-copy .steps li:nth-child(4) { animation-delay: .54s }
.home-forms .card { animation: slideR .65s var(--ease) both; }
.home-forms .card:nth-child(1) { animation-delay: .22s } .home-forms .card:nth-child(2) { animation-delay: .34s }
.card { transition: box-shadow .25s ease; }
.home-forms .card:focus-within { box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-accent) 60%, transparent), 0 0 30px color-mix(in srgb, var(--color-accent) 18%, transparent); }

/* Lobby */
.big-code { animation: popIn .55s var(--ease) both .1s; }
#qr { opacity: 0; transition: opacity .5s ease; } #qr.ready { opacity: 1; }
.song-row { transition: background .2s ease, transform .2s var(--ease); }
.song-row:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); transform: translateX(2px); }
.song-row.new { animation: slideL .5s var(--ease) both; }
.song-row img { animation: fadeIn .4s ease both; }
.song-row.skeleton .meta > div, .song-row.skeleton .noimg { background: linear-gradient(90deg, var(--color-neutral-900) 25%, var(--color-neutral-800) 50%, var(--color-neutral-900) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 4px; color: transparent; }
.song-row.skeleton .t { height: 14px; width: 60%; margin-bottom: 6px; } .song-row.skeleton .s { height: 11px; width: 40%; }
.players li.new { animation: fadeUp .45s var(--ease) both; }
.players .dot { transition: background .3s ease, box-shadow .3s ease; }
.players .dot.on { animation: pulseDot 2.4s ease-out infinite; }
.status-line { transition: opacity .25s ease; }

/* Battle – Auftritt der Kontrahenten, Vote-Feedback, Siegerehrung */
.battle-head .kicker, .battle-head h2 { animation: fadeUp .45s var(--ease) both; }
.duel .contender[data-side="a"] { animation: slideL .6s var(--ease) both; }
.duel .contender[data-side="b"] { animation: slideR .6s var(--ease) both .08s; }
.duel .vs { animation: popIn .5s var(--ease) both .32s; }
.vs span { position: relative; isolation: isolate; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--color-surface); box-shadow: var(--shadow-sm); font-size: 13px; color: var(--color-text); }
.vs span::before { content: ""; position: absolute; inset: -2px; border-radius: 50%; z-index: -1; background: conic-gradient(from 0deg, transparent 0 55%, var(--color-accent) 80%, transparent 100%); animation: spinRing 2.6s linear infinite; }
.vs span::after { content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -1; background: var(--color-surface); }
.contender { transition: box-shadow .35s ease, opacity .6s ease, filter .6s ease, transform .3s var(--ease); }
.contender.mine { animation: glowPulse 2.2s ease-in-out infinite; }
.contender.pop { animation: pop .38s var(--ease); }
.contender.winner { animation: land .6s var(--ease) both, winGlow 1.2s ease both; }
.contender.loser { filter: saturate(.35); }
.contender .crown { display: none; }
.contender.winner .crown { display: block; animation: crownDrop .7s var(--ease) both .3s; }
.contender .vote .vote-text { transition: opacity .15s; }
.contender .head img { transition: transform .4s var(--ease); }
.contender:hover .head img { transform: scale(1.04); }
.votecount .num { display: inline-block; font-weight: 600; font-variant-numeric: tabular-nums; }
.votecount .num.bump { animation: bump .45s var(--ease); }
.decided { animation: fadeUp .5s var(--ease) both .2s; }
.hostbar { animation: fadeUp .45s var(--ease) both .1s; }
.battle-head .progress b { box-shadow: 0 0 12px var(--color-accent); }

/* Münzwurf */
.coin-overlay { animation: fadeIn .35s ease both; }
.coin-box { animation: popIn .5s var(--ease) both .05s; }
.coin.landed { animation: land .6s var(--ease) both; }
.coin.landed .face { box-shadow: 0 0 0 3px var(--color-ok), 0 0 60px color-mix(in srgb, var(--color-ok) 55%, transparent); transition: box-shadow .4s ease; }
.coin-result.show { animation: popIn .45s var(--ease) both; color: var(--color-ok); }

/* Turnierbaum */
.m { transition: box-shadow .35s ease; }
.m.cur { animation: glowPulse 2.6s ease-in-out infinite; }
.m .slot { transition: background .4s ease, color .4s ease, opacity .5s ease; }
.m .slot.win.fresh { position: relative; overflow: hidden; }
.m .slot.win.fresh::after { content: ""; position: absolute; top: 0; bottom: 0; width: 45%; left: -60%; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--color-ok) 35%, transparent), transparent); animation: sweep 1.1s ease-out 1 both; }
.round { animation: fadeIn .5s ease both; }

/* Champion */
.champion { animation: fadeUp .7s var(--ease) both; position: relative; overflow: hidden; overflow: clip; }
.champion::after { content: ""; position: absolute; z-index: 2; top: 0; bottom: 0; width: 35%; left: -60%; background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--color-text) 7%, transparent), transparent); animation: sweep 1.6s ease-out 1 both .6s; pointer-events: none; }
.champion img, .champion .noimg { animation: popIn .8s var(--ease) both .15s; }
.champion > div > * { animation: fadeUp .55s var(--ease) both; }
.champion > div > :nth-child(1) { animation-delay: .3s } .champion > div > :nth-child(2) { animation-delay: .4s } .champion > div > :nth-child(3) { animation-delay: .48s } .champion > div > :nth-child(4) { animation-delay: .56s } .champion > div > :nth-child(5) { animation-delay: .64s }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }

/* Kompakter Spotify-Player blendet ein, sobald die Karte steht */
.contender iframe { animation: fadeIn .5s ease both .2s; }

/* Drawer: Backdrop blendet, Panel gleitet (Desktop von rechts, Phone als Bottom-Sheet von unten), Inhalt folgt leicht versetzt. Schließen läuft rückwärts. */
.drawer-backdrop { opacity: 0; transition: opacity .3s ease; }
.drawer-panel { transform: translateX(100%); transition: transform .38s var(--ease); will-change: transform; }
.drawer-panel > * { opacity: 0; transform: translateY(8px); transition: opacity .28s ease, transform .32s var(--ease); }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer.open .drawer-panel > * { opacity: 1; transform: none; transition-delay: .14s; }
@media (max-width: 760px) { .drawer-panel { transform: translateY(100%); } .drawer.open .drawer-panel { transform: none; } }

/* Toast */
.toast { animation: fadeUp .3s var(--ease) both; }

/* — Genre-Gamble (Walze) + Countdown — */
.genre-card { gap: 10px; }
.genre-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.genre-head .card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.genre-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.reel { position: relative; height: 192px; overflow: hidden; border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-text) 3%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent); mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent); }
.reel::before, .reel::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; pointer-events: none; z-index: 2;
  background: linear-gradient(to right, transparent, var(--color-accent) 18%, var(--color-accent) 82%, transparent); opacity: .75; }
.reel::before { top: 64px; } .reel::after { top: 128px; }
.reel-strip { will-change: transform; transition: transform 3.6s cubic-bezier(.08,.82,.12,1); }
.reel-strip div { height: 64px; display: grid; place-items: center; font-size: 24px; font-weight: 500; letter-spacing: -0.01em; color: var(--color-neutral-300); }
.reel.landed .reel-strip div:last-child { color: var(--color-accent-300); text-shadow: 0 0 22px color-mix(in srgb, var(--color-accent) 60%, transparent); animation: land .6s var(--ease) both; }
.genre-result { font-size: clamp(28px, 3.6vw, 40px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; color: var(--color-accent-300);
  text-shadow: 0 0 28px color-mix(in srgb, var(--color-accent) 55%, transparent); animation: popIn .55s var(--ease) both; display: flex; align-items: center; gap: 12px; min-width: 0; }
.genre-result span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.genre-result i { color: var(--color-accent); font-size: .85em; flex: none; }
.genre-hint { font-size: 13px; margin: 0; }
.genre-pool { display: flex; flex-direction: column; gap: 10px; }
.genre-pool textarea { font-size: 14px; line-height: 1.5; min-height: 160px; }
.countdown-num { color: var(--color-accent-300); }

/* — Playlist-/Album-Import — */
.pl-panel { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--color-divider); animation: fadeUp .4s var(--ease) both; min-width: 0; }
.pl-head { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.pl-head img, .pl-head .noimg { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--color-neutral-900); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.pl-head .t { font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-head .s { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pl-tools .input { flex: 1 1 200px; min-height: 36px; }
.pl-list { max-height: 340px; overflow: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; scrollbar-width: thin; }
.pl-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 5px 8px; border-radius: 6px; font-size: 14px; min-width: 0; transition: background .15s ease, opacity .3s ease; }
.pl-row:hover { background: color-mix(in srgb, var(--color-text) 5%, transparent); }
.pl-row .n { font-variant-numeric: tabular-nums; color: var(--color-neutral-600); font-size: 12px; text-align: right; }
.pl-row .meta { min-width: 0; }
.pl-row .t, .pl-row .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-row .s { font-size: 12px; }
.pl-row .d { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--color-neutral-500); }
.pl-row.in { opacity: .55; }
.pl-row .btn-icon { width: 32px; height: 32px; }
.pl-row .tag { min-width: 56px; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .coin-inner { animation-duration: .01ms !important; }
}
