:root {
  --ink: #2a1712;
  --panel: rgba(38, 18, 16, .78);
  --panel-solid: #3a1d18;
  --line: rgba(255, 255, 255, .12);
  --text: #fff7ec;
  --muted: #d9b9a8;
  --pink: #f0417f;
  --pink-dark: #a81f52;
  --yellow: #ffc928;
  --green: #5ccf3a;
  --cyan: #2cc6e8;
  --red: #e8303a;
  --title: 'Luckiest Guy', 'Fredoka', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--text);
  background: #3d201b;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }

/* ---------- Raum & Figuren ---------- */
#room { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#crowd {
  position: fixed; left: 0; right: 0; bottom: 5vh; z-index: 1;
  display: flex; justify-content: center; align-items: flex-end; gap: clamp(4px, 2.5vw, 48px);
  pointer-events: none; padding: 0 12px; transition: opacity .3s;
}
.guy { position: relative; display: flex; flex-direction: column; align-items: center; transition: transform .35s cubic-bezier(.2,1.4,.4,1), filter .3s, opacity .3s; pointer-events: auto; }
.guy .av { height: clamp(130px, 30vh, 290px); aspect-ratio: 120 / 222; }
.guy-name { font-family: var(--title); font-size: clamp(14px, 1.8vw, 24px); letter-spacing: 1px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.45); margin-bottom: 4px; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.guy.me .guy-name::after { content: ' ▾'; color: var(--yellow); }
.guy .speaker { position: absolute; top: -34px; font-size: 26px; opacity: 0; transition: opacity .2s; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
.guy.talking .speaker { opacity: 1; animation: pulse .5s infinite; }
.guy.spot { transform: scale(1.12); }
.guy.spot::before { content: ''; position: absolute; bottom: -10px; width: 180%; height: 40px; left: -40%; background: radial-gradient(closest-side, rgba(255,220,130,.55), transparent); z-index: -1; }
#crowd { transition: bottom .5s ease, transform .5s ease; transform-origin: 50% 100%; }
#crowd.back { bottom: 27vh; transform: scale(.66); }
#crowd.back .guy { filter: brightness(.6) saturate(.85); }
.guy.away { opacity: 0; }
#micSpot { position: absolute; left: 50%; bottom: 3vh; transform: translateX(-50%); z-index: 2; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
#micSpot:empty { display: none; }
#micSpot .who { font-family: var(--title); font-size: clamp(22px, 3vw, 38px); letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
#micSpot .stagepos { position: relative; animation: walkin .55s cubic-bezier(.2,1.3,.4,1); }
#micSpot .av { height: clamp(220px, 48vh, 440px); aspect-ratio: 120 / 222; }
#micSpot .stand { position: absolute; left: 50%; top: 40%; width: 60%; height: 62%; transform: translateX(-4%); }
#micSpot .glow { position: absolute; bottom: -14px; left: -30%; width: 160%; height: 50px; background: radial-gradient(closest-side, rgba(255,215,120,.6), transparent); }
@keyframes walkin { from { transform: translateY(40px) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
#bottom.top { top: 150px; bottom: auto; }
.guy .kick { position: absolute; top: 0; right: -6px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink); background: var(--red); color: #fff; font-weight: 700; cursor: pointer; z-index: 2; }
.guy .crown { position: absolute; top: -30px; font-size: 24px; }
.guy.jump .avbody { animation: jump .6s ease infinite alternate; }
@keyframes jump { from { transform: translateY(0); } to { transform: translateY(-14px); } }

.av { --talk: 0; }
.av svg { width: 100%; height: 100%; overflow: visible; display: block; }
.av .mouth { transform-box: fill-box; transform-origin: 50% 20%; transform: scale(calc(1 + var(--talk) * .35), calc(1 + var(--talk) * 1.8)); transition: transform .05s; }
.av .avbody { transform-origin: 50% 100%; animation: idle 3s ease-in-out infinite; }
@keyframes idle { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.012,.988); } }

/* ---------- Grundlayout ---------- */
#app { position: relative; z-index: 2; height: 100%; }
.screen { display: none; position: absolute; inset: 0; }
.screen.active { display: block; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.scroll { overflow-y: auto; padding: 20px 16px 40px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
h2, h3 { font-family: var(--title); font-weight: 400; letter-spacing: 1px; margin: 0 0 12px; }
h2 { font-size: 34px; }
h3 { font-size: 20px; color: var(--yellow); }

.panel {
  background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--line); border-radius: 22px; padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}

/* Buttons im Spiel-Look */
.btn {
  font-family: var(--title); font-size: 20px; letter-spacing: 1px; color: #fff;
  background: linear-gradient(#ff5c95, var(--pink)); border: 3px solid var(--ink); border-radius: 16px;
  padding: 12px 20px 9px; cursor: pointer; box-shadow: 0 5px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.35);
  text-shadow: 0 2px 0 rgba(0,0,0,.3); transition: transform .08s, box-shadow .08s, filter .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; user-select: none;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.yellow { background: linear-gradient(#ffd84d, var(--yellow)); color: var(--ink); text-shadow: none; }
.btn.green { background: linear-gradient(#78e05a, var(--green)); color: var(--ink); text-shadow: none; }
.btn.cyan { background: linear-gradient(#5fd9f2, var(--cyan)); color: var(--ink); text-shadow: none; }
.btn.dark { background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.18); box-shadow: none; font-size: 16px; }
.btn.small { font-size: 15px; padding: 8px 12px 6px; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
.btn.dark.small { box-shadow: none; }
.btn.big { font-size: 26px; padding: 16px 24px 12px; }
.btn.block { width: 100%; }

input[type=text], input:not([type]) {
  font: inherit; font-size: 18px; font-weight: 500; color: var(--ink); background: #fff7ec;
  border: 3px solid var(--ink); border-radius: 14px; padding: 11px 14px; outline: none; width: 100%;
}
input:focus { box-shadow: 0 0 0 4px rgba(255,201,40,.45); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.28); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--yellow); color: var(--ink); border-color: var(--ink); }
.chip:disabled { cursor: default; }
.chip small { opacity: .7; font-weight: 500; }

/* HUD oben */
.hud-tl {
  position: absolute; top: 16px; left: 16px; z-index: 5; background: rgba(40,18,16,.7); border-radius: 18px; padding: 10px 22px 8px;
  text-align: center; min-width: 180px;
}
.hud-tl .t { font-family: var(--title); font-size: clamp(24px, 3.4vw, 44px); color: #ff8fb0; line-height: 1; -webkit-text-stroke: 1.5px #6b1b2e; }
.hud-tl .s { font-family: var(--title); font-size: clamp(14px, 1.9vw, 24px); color: rgba(255,255,255,.35); letter-spacing: 2px; margin-top: 4px; }
.hud-tr {
  position: absolute; top: 16px; right: 16px; z-index: 5; font-family: var(--title); font-size: clamp(18px, 2.4vw, 32px); letter-spacing: 1px;
  background: rgba(120,20,30,.55); color: rgba(255,255,255,.55); border: 0; border-radius: 16px; padding: 10px 18px 6px; cursor: pointer;
}
.hud-tr:hover { color: #fff; background: rgba(170,30,45,.8); }

/* Punktekarten */
.cards { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; z-index: 4; }
.pcard {
  width: clamp(76px, 8.5vw, 124px); background: #fff; border-radius: 14px; border: 3px solid #fff; overflow: hidden; margin: 0 -8px;
  box-shadow: 0 8px 18px rgba(0,0,0,.4); text-align: center; transition: transform .4s cubic-bezier(.2,1.4,.4,1);
}
.pcard:nth-child(odd) { transform: rotate(-4deg) translateY(6px); }
.pcard:nth-child(even) { transform: rotate(2deg); }
.pcard .pic { height: clamp(52px, 6vw, 84px); overflow: hidden; display: flex; justify-content: center; align-items: flex-start; }
.pcard .pic .av { width: 100%; height: 100%; }
.pcard .nm { font-family: var(--title); color: var(--ink); font-size: clamp(12px, 1.35vw, 19px); padding: 4px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .sc { font-family: var(--title); color: var(--yellow); font-size: clamp(18px, 2.2vw, 32px); -webkit-text-stroke: 1.5px #8a5a00; line-height: 1.1; padding-bottom: 4px; }
.pcard.bump { animation: bump .5s; }
@keyframes bump { 50% { transform: scale(1.18); } }

/* Mitte / Unten */
#dim { position: absolute; inset: 0; background: rgba(20,8,6,.55); opacity: 0; transition: opacity .4s; pointer-events: none; z-index: 2; }
#dim.on { opacity: 1; }
#center { position: absolute; left: 0; right: 0; top: 13vh; display: flex; flex-direction: column; align-items: center; z-index: 3; text-align: center; padding: 0 16px; pointer-events: none; }
#center button, #center a { pointer-events: auto; }
#bottom { position: absolute; left: 0; right: 0; bottom: 4vh; display: flex; flex-direction: column; align-items: center; z-index: 3; padding: 0 12px; }

.sound-pic {
  width: clamp(130px, 17vw, 230px); aspect-ratio: 1 / 1.15; border-radius: 50%; overflow: hidden; background: #fff; display: grid; place-items: center;
  font-size: clamp(70px, 9vw, 130px); box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: popin .5s cubic-bezier(.2,1.5,.4,1);
}
.sound-pic img { width: 100%; height: 100%; object-fit: cover; }
.sound-title {
  font-family: var(--title); font-size: clamp(34px, 6vw, 84px); line-height: 1; margin-top: 14px;
  background: linear-gradient(#ffffff 30%, #9fe7f7); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px #0d2a38; filter: drop-shadow(0 5px 0 #0d2a38);
}
.sound-sub { font-family: var(--title); font-size: clamp(18px, 2.4vw, 32px); color: #fff; margin-top: 8px; text-shadow: 0 3px 0 rgba(0,0,0,.4); letter-spacing: 1px; }
.big-title { font-family: var(--title); font-size: clamp(42px, 8vw, 110px); color: var(--yellow); -webkit-text-stroke: 3px #6b3a14; filter: drop-shadow(0 6px 0 #6b3a14); animation: popin .6s cubic-bezier(.2,1.5,.4,1); }
@keyframes popin { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

.wave {
  position: relative; width: min(680px, 92vw); height: clamp(110px, 17vh, 180px); background: #07070f; border: 5px solid var(--cyan); border-radius: 34px;
  overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 0 0 2px rgba(0,0,0,.6);
}
.wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave .head { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: #e8132a; left: 8%; box-shadow: 0 0 8px rgba(232,19,42,.8); }
.wave .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--title); font-size: clamp(70px, 11vh, 120px); color: #fff; -webkit-text-stroke: 4px #000; animation: popin .4s; }
.caption { font-family: var(--title); font-size: clamp(18px, 2.6vw, 30px); letter-spacing: 1px; margin-top: 14px; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
.caption.go { color: var(--yellow); animation: pulse .6s infinite; }

.score {
  font-family: var(--title); font-size: clamp(64px, 11vw, 150px); line-height: 1; -webkit-text-stroke: 5px #1c2a10;
  filter: drop-shadow(0 7px 0 #1c2a10); animation: popin .55s cubic-bezier(.2,1.6,.4,1);
}
.score.good { color: #6fd23a; }
.score.mid { color: #f2b321; -webkit-text-stroke-color: #4a3000; filter: drop-shadow(0 7px 0 #4a3000); }
.score.bad { color: #f06a9a; -webkit-text-stroke-color: #4a0a22; filter: drop-shadow(0 7px 0 #4a0a22); }

/* Podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-top: 8px; }
.pod { text-align: center; width: clamp(100px, 14vw, 170px); }
.pod .av { height: clamp(120px, 22vh, 220px); aspect-ratio: 120/222; margin: 0 auto -6px; }
.pod .stand { border: 3px solid var(--ink); border-radius: 14px 14px 0 0; display: grid; place-items: center; font-family: var(--title); font-size: 44px; color: var(--ink); box-shadow: inset 0 3px 0 rgba(255,255,255,.4); }
.pod.p1 .stand { height: 120px; background: var(--yellow); }
.pod.p2 .stand { height: 85px; background: #d6dbe6; }
.pod.p3 .stand { height: 60px; background: #e09b5a; }
.pod .pn { font-family: var(--title); font-size: 22px; letter-spacing: 1px; }
.pod .ps { color: var(--yellow); font-family: var(--title); font-size: 20px; }

/* ---------- Startseite ---------- */
.home-wrap { pointer-events: none; position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding: 16px clamp(16px, 6vw, 90px); }
.home-card { pointer-events: auto; width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; }
.home-card .join { display: flex; gap: 8px; }
.home-card .join input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 700; }
.home-me { z-index: 1; position: absolute; left: clamp(20px, 14vw, 260px); bottom: 5vh; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.home-me .av { height: clamp(200px, 44vh, 400px); aspect-ratio: 120/222; }
.home-me .edit { font-family: var(--title); background: rgba(0,0,0,.45); padding: 6px 14px 3px; border-radius: 99px; margin-bottom: 6px; letter-spacing: 1px; }
.warn { background: rgba(255,160,0,.18); border: 2px solid #ffa000; border-radius: 14px; padding: 10px 14px; font-size: 15px; }
.linkrow { display: flex; gap: 8px; }

/* ---------- Lobby ---------- */
.lobby-side { position: absolute; top: 16px; right: 16px; bottom: 16px; width: min(400px, calc(100% - 32px)); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.set-row > label { display: block; font-family: var(--title); letter-spacing: 1px; color: var(--yellow); margin-bottom: 8px; font-size: 17px; }
.code-badge { cursor: pointer; }
.code-badge .t { letter-spacing: 6px; }
.chat-log { height: 110px; overflow-y: auto; background: rgba(0,0,0,.3); border-radius: 12px; padding: 8px 12px; font-size: 15px; margin-bottom: 8px; }
.add-bot { font-family: var(--title); font-size: 18px; letter-spacing: 1px; background: rgba(0,0,0,.35); color: #fff; border: 3px dashed rgba(255,255,255,.4); border-radius: 18px; width: clamp(90px, 10vw, 140px); height: clamp(130px, 22vh, 220px); cursor: pointer; margin-bottom: 20px; pointer-events: auto; }
.add-bot:hover { background: rgba(0,0,0,.5); }

/* ---------- Editor ---------- */
.editor-wrap { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr min(560px, 55vw); gap: 16px; padding: 16px; }
.editor-me { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 5vh; }
.editor-me .av { height: clamp(240px, 58vh, 520px); aspect-ratio: 120/222; }
.editor-panel { overflow-y: auto; }
.opt-group { margin-bottom: 14px; }
.opt-group h3 { font-size: 17px; margin-bottom: 8px; }
.opt-list { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { width: 58px; height: 58px; border-radius: 14px; border: 2px solid rgba(255,255,255,.18); background: rgba(0,0,0,.28); cursor: pointer; padding: 2px; overflow: hidden; }
.opt.on { border-color: var(--yellow); background: rgba(255,201,40,.28); }
.opt .av { width: 100%; height: 100%; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(0,0,0,.4); cursor: pointer; }
.swatch.on { outline: 3px solid var(--yellow); outline-offset: 2px; }
.presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.preset { background: rgba(0,0,0,.28); border: 2px solid rgba(255,255,255,.14); border-radius: 14px; padding: 4px 2px; cursor: pointer; color: var(--text); font-size: 12px; font-weight: 600; }
.preset .av { width: 100%; aspect-ratio: 1; }
.preset:hover { border-color: var(--yellow); }

/* ---------- Studio / Bestenliste ---------- */
.page { position: absolute; inset: 0; overflow-y: auto; padding: 16px; }
.page-inner { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.two { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.slist { display: grid; gap: 8px; margin: 14px 0; }
.srow { display: grid; grid-template-columns: 54px 1fr auto auto auto; gap: 8px; align-items: center; background: rgba(0,0,0,.25); border-radius: 14px; padding: 6px; }
.srow input { padding: 7px 10px; font-size: 16px; }
.rec-btn { width: 110px; height: 110px; border-radius: 50%; font-size: 46px; background: var(--red); border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink); cursor: pointer; }
.rec-btn.on { animation: pulse .8s infinite; }
.meter { height: 12px; background: rgba(0,0,0,.4); border-radius: 99px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); transition: width .05s; }
.pack-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: rgba(0,0,0,.25); margin-bottom: 8px; }
.code { font-family: ui-monospace, monospace; font-weight: 700; background: var(--yellow); color: var(--ink); border-radius: 8px; padding: 3px 8px; letter-spacing: 2px; cursor: pointer; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl td, .tbl th { padding: 10px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 500; }

/* Modal, Toast, Konfetti */
.modal { position: fixed; inset: 0; background: rgba(20,6,4,.7); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { max-width: 600px; width: 100%; max-height: 88vh; overflow-y: auto; background: var(--panel-solid); border: 2px solid var(--line); border-radius: 22px; padding: 24px; animation: popin .3s; }
.modal-card ol { padding-left: 22px; line-height: 1.6; }
#toasts { position: fixed; top: 90px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(460px, 92vw); }
.toast { background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 16px; box-shadow: 0 4px 0 var(--ink); animation: popin .3s; font-weight: 600; }
.toast.info { background: #5a2ea0; }
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti { position: absolute; top: -30px; width: 12px; height: 34px; border-radius: 8px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(540deg); } }

@media (max-width: 800px) {
  .home-wrap { align-items: flex-start; justify-content: center; padding-top: 24px; }
  .home-me { left: 50%; transform: translateX(-50%); }
  .home-me .av { height: 30vh; }
  .lobby-side { top: auto; bottom: auto; top: 110px; max-height: 50vh; right: 16px; left: 16px; width: auto; }
  .editor-wrap { grid-template-columns: 1fr; grid-template-rows: 30vh 1fr; }
  .editor-me .av { height: 28vh; }
  .presets { grid-template-columns: repeat(4, 1fr); }
  .two { grid-template-columns: 1fr; }
  .guy .av { height: 20vh; }
  .guy-name { font-size: 13px; max-width: 80px; }
  .cards { top: 88px; }
  #bottom.top { top: 200px; }
  #crowd.back { bottom: 32vh; }
  #center { top: 20vh; }
  .srow { grid-template-columns: 44px 1fr auto auto; }
  .srow .sdur { display: none; }
}

.update-btn { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 70; animation: glowpulse 1.6s infinite; }
@keyframes glowpulse { 0%,100% { box-shadow: 0 5px 0 var(--ink), 0 0 0 0 rgba(255,201,40,.7); } 50% { box-shadow: 0 5px 0 var(--ink), 0 0 0 14px rgba(255,201,40,0); } }
.voice-hud { position: fixed; left: 16px; bottom: 16px; z-index: 65; }
