* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #0b0710; color: #fff;
  font-family: "Avenir Next", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.hidden { display: none !important; }

#loading { font-size: 28px; font-weight: 800; letter-spacing: .08em; background: #0b0710; }

/* Menü, Lobby, Bestenliste */
#screen {
  gap: 18px; padding: 24px; overflow-y: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at center, rgba(10,5,20,.25), rgba(10,5,20,.82));
}
#screen h1 {
  font-size: clamp(44px, 7.5vw, 92px); font-weight: 900; letter-spacing: .01em; line-height: 1;
  background: linear-gradient(180deg, #fff6d8, #ffb36b 55%, #ff5f7e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #2a1440) drop-shadow(0 0 30px rgba(255,140,90,.45));
}
.tag { opacity: .9; font-size: 18px; text-align: center; }
.slots { display: grid; grid-template-columns: repeat(4, minmax(140px, 190px)); gap: 14px; }
@media (max-width: 760px) { .slots { grid-template-columns: repeat(2, minmax(130px, 170px)); } }
.slot {
  border-radius: 20px; padding: 14px; min-height: 150px; text-align: center;
  background: rgba(255,255,255,.06); border: 2px dashed rgba(255,255,255,.25);
  display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.slot small { opacity: .8; font-size: 12px; }
.slot.joined {
  border-style: solid; border-color: var(--c);
  background: linear-gradient(165deg, color-mix(in srgb, var(--c) 45%, transparent), rgba(0,0,0,.35));
  box-shadow: 0 0 26px color-mix(in srgb, var(--c) 55%, transparent);
  animation: pop .35s ease-out;
}
.slot canvas { width: 76px; height: 76px; image-rendering: auto; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; font-weight: 800; font-size: 16px; color: #fff; cursor: pointer;
  padding: 12px 22px; border-radius: 14px; border: 2px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.1); transition: transform .1s, background .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255,255,255,.18); }
.btn.primary { background: linear-gradient(180deg, #ff9a5a, #ff4d6d); border-color: #ffd0a0; box-shadow: 0 6px 0 #8a1f3a; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; }
kbd {
  display: inline-block; font: inherit; font-size: .75em; font-weight: 700;
  padding: 1px 6px; border-radius: 6px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.3); margin-left: 4px;
}
.controls { font-size: 13px; opacity: .85; display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; max-width: 920px; }
.hint { font-size: 13px; opacity: .65; text-align: center; }
.achs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 920px; }
.ach { padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.07); font-size: 13px; opacity: .45; border: 1px solid transparent; }
.ach.on { opacity: 1; background: rgba(255,215,90,.2); border-color: rgba(255,215,90,.6); }
.achs-title { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }

/* HUD */
#hud { position: fixed; top: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; pointer-events: none; flex-wrap: wrap; }
.card {
  min-width: 120px; padding: 8px 12px; border-radius: 14px; display: flex; flex-direction: column; gap: 5px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 40%, rgba(0,0,0,.4)), rgba(0,0,0,.45));
  border: 2px solid var(--c); backdrop-filter: blur(6px); transition: opacity .3s, filter .3s;
}
.card.out { opacity: .4; filter: grayscale(.8); }
.card .name { font-weight: 900; font-size: 15px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.pips i.on { background: #ffd65a; border-color: #fff3b0; box-shadow: 0 0 10px #ffd65a; }
.cds { display: flex; gap: 6px; }
.cd { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.cd em { display: block; height: 100%; width: 100%; background: var(--c); }
.cd.s em { background: #fff; }

/* Spieler-Labels */
#labels { position: fixed; inset: 0; pointer-events: none; }
.plabel {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-weight: 900; font-size: 13px;
  padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.45); border: 2px solid var(--c);
  display: flex; gap: 6px; align-items: center; will-change: transform;
}
.plabel .n { color: var(--c); }
.plabel .w { font-variant-numeric: tabular-nums; }

/* Zentrale Ansagen */
#center { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
#center .big {
  font-size: clamp(56px, 11vw, 140px); font-weight: 900; line-height: 1;
  text-shadow: 0 6px 0 rgba(30,10,40,.8), 0 0 40px rgba(255,180,120,.6);
  animation: pop .45s cubic-bezier(.2,1.6,.4,1);
}
#center .big.small { font-size: clamp(36px, 6vw, 72px); }
#center .sub { margin-top: 10px; font-size: 20px; font-weight: 700; opacity: .9; text-shadow: 0 2px 8px #000; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Erfolge */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 16px; min-width: 260px;
  background: linear-gradient(160deg, rgba(80,50,10,.9), rgba(30,15,40,.92)); border: 2px solid #ffd65a;
  box-shadow: 0 0 30px rgba(255,214,90,.4); animation: slidein .4s cubic-bezier(.2,1.4,.4,1); transition: opacity .5s, transform .5s;
}
.toast.bye { opacity: 0; transform: translateX(40px); }
.toast .ti { font-size: 32px; }
.toast b { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #ffd65a; }
.toast small { opacity: .8; }
@keyframes slidein { from { transform: translateX(120%); } to { transform: translateX(0); } }

.menu { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 940px; width: 100%; margin: auto 0; }
#screen h2 { font-size: clamp(28px, 4vw, 44px); font-weight: 900; text-shadow: 0 4px 0 #2a1440; }
.code { font-family: ui-monospace, Menlo, monospace; letter-spacing: .15em; color: #ffd65a; background: rgba(0,0,0,.35); padding: 2px 12px; border-radius: 10px; }
.msg { background: rgba(255,90,95,.2); border: 1px solid rgba(255,90,95,.6); padding: 8px 14px; border-radius: 12px; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.profile label { font-weight: 800; display: flex; gap: 10px; align-items: center; }
.profile .stats { font-size: 14px; opacity: .85; }
input { font: inherit; font-weight: 800; color: #fff; background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.35); border-radius: 12px; padding: 8px 12px; outline: none; }
input:focus { border-color: #ffd65a; }
#codeIn { width: 110px; text-align: center; letter-spacing: .2em; text-transform: uppercase; }
.menu-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; width: min(360px, 90vw); }
.menu-actions .join { display: flex; gap: 8px; } .menu-actions .join input { flex: 1; } .menu-actions .join .btn { flex: 1; }
.btn.big { font-size: 19px; padding: 14px 22px; }
.btn.small { font-size: 13px; padding: 6px 12px; }
.how { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 13px; opacity: .85; }
.share { font-size: 14px; opacity: .9; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.wait { font-weight: 800; opacity: .85; padding: 12px; }
.slot { position: relative; }
.slot .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; opacity: .7; }
table.board { border-collapse: collapse; min-width: min(560px, 92vw); background: rgba(0,0,0,.3); border-radius: 14px; overflow: hidden; }
.board th, .board td { padding: 8px 14px; text-align: left; } .board th { background: rgba(255,255,255,.08); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.board tr:nth-child(even) td { background: rgba(255,255,255,.03); } .board tr.me td { background: rgba(255,214,90,.18); }
.card.mine { box-shadow: 0 0 18px var(--c); }
.card .pw { margin-right: 2px; }
.plabel.ghost { opacity: .7; border-style: dashed; }
#mute { position: fixed; right: 12px; top: 12px; z-index: 20; font-size: 20px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.3); border-radius: 12px; padding: 6px 9px; cursor: pointer; color: #fff; }
#hud { padding: 0 60px; }

/* Touch */
#touch { position: fixed; inset: 0; z-index: 10; pointer-events: none; touch-action: none; }
#touch .tzone { position: absolute; left: 0; top: 70px; bottom: 0; width: 58%; pointer-events: auto; touch-action: none; }
.tstick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); background: rgba(255,255,255,.06); opacity: 0; transition: opacity .15s; pointer-events: none; }
.tstick.on { opacity: 1; }
.tknob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255,255,255,.55); box-shadow: 0 0 20px rgba(255,255,255,.4); }
.tbtn {
  position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; color: #fff; font: inherit; font-weight: 900;
  border: 3px solid rgba(255,255,255,.6); background: conic-gradient(rgba(255,255,255,.35) calc(var(--cd, 1) * 360deg), rgba(0,0,0,.35) 0);
  text-shadow: 0 2px 4px #000; -webkit-user-select: none; user-select: none;
}
.tbtn.down { transform: scale(.92); border-color: #ffd65a; }
.tdash { right: calc(28px + env(safe-area-inset-right)); bottom: calc(40px + env(safe-area-inset-bottom)); width: 104px; height: 104px; font-size: 18px; }
.tshock { right: calc(146px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 76px; height: 76px; font-size: 14px; }

/* Lobby: Match-Modus */
.modes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mode { font: inherit; color: #fff; cursor: pointer; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.18);
  border-radius: 14px; padding: 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 150px; }
.mode small { font-size: 11px; opacity: .75; }
.mode.on { border-color: #ffd65a; background: rgba(255,214,90,.16); box-shadow: 0 0 14px rgba(255,214,90,.35); }
.mode:disabled { cursor: default; }
.mode:disabled:not(.on) { opacity: .45; }

/* Rennen: Fortschrittsleiste */
#racebar { position: fixed; left: 50%; transform: translateX(-50%); top: 92px; width: min(560px, 80vw); pointer-events: none; }
#racebar .track { position: relative; height: 8px; border-radius: 6px; background: rgba(255,255,255,.18); box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
#racebar .flood { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: linear-gradient(90deg, rgba(255,90,40,.2), #ff6a3a); box-shadow: 0 0 10px #ff6a3a; }
#racebar i { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: 2px solid #fff; transform: translate(-50%, -50%); box-shadow: 0 0 8px var(--c); transition: left .1s linear; }
#racebar i.out { opacity: .35; filter: grayscale(1); }
#racebar .goal { position: absolute; right: -14px; top: 50%; transform: translateY(-52%); color: #ffe7a0; font-size: 22px; text-shadow: 0 0 10px #ffd27a; }
@media (max-width: 700px) { #racebar { top: 120px; } }
#modebar { position: fixed; left: 50%; transform: translateX(-50%); top: 88px; pointer-events: none; padding: 6px 16px; border-radius: 999px;
  background: rgba(10, 8, 24, .55); box-shadow: 0 0 0 1px rgba(255,255,255,.14); color: #fff6dc; font-weight: 700; font-size: 15px;
  letter-spacing: .02em; white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
#modebar.hidden { display: none; }
#hud.many { gap: 6px; }
#hud.many .card { min-width: 92px; padding: 5px 8px; gap: 3px; border-radius: 11px; }
#hud.many .card .name { font-size: 12px; }
#hud.many .pips i { width: 10px; height: 10px; }

.mode-desc { display: none; }

/* ---------- Handy (schmal oder Touch im Hochformat) ---------- */
@media (max-width: 600px) {
  #screen { padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom)); gap: 10px; }
  .menu { gap: 12px; }
  #screen h1 { font-size: 46px; }
  #screen h2 { font-size: 24px; text-align: center; padding-right: 44px; }
  .tag { font-size: 14px; max-width: 330px; }
  .profile label { width: min(360px, 92vw); justify-content: space-between; }
  .profile label input { flex: 1; min-width: 0; }
  .btn { font-size: 15px; padding: 10px 16px; }
  .btn.big { padding: 12px 16px; }
  .share { font-size: 12px; gap: 6px; }

  /* Lobby: kompakte Plätze, 4 pro Reihe */
  .slots { grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
  .slot { min-height: 0; padding: 6px 3px; border-radius: 12px; gap: 2px; }
  .slot canvas { width: 46px; height: 46px; }
  .slot b { font-size: 11px; line-height: 1.15; overflow-wrap: anywhere; }
  .slot small { font-size: 9px; line-height: 1.15; }
  .slot:not(.joined) b { font-size: 11px; opacity: .6; }
  .slot:not(.joined) small { display: none; }
  .slot .x { top: 0; right: 2px; font-size: 16px; }

  /* Playlists als Chips, Beschreibung der gewählten darunter */
  .modes { gap: 6px; }
  .mode { min-width: 0; padding: 6px 10px; border-radius: 999px; }
  .mode b { font-size: 13px; }
  .mode small { display: none; }
  .mode-desc { display: block; font-size: 12px; opacity: .8; text-align: center; margin-top: -4px; }

  /* Start-Leiste bleibt unten sichtbar */
  .lobby-actions { position: sticky; bottom: calc(-14px - env(safe-area-inset-bottom)); width: calc(100% + 24px); margin: 0 -12px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); gap: 8px; flex-wrap: nowrap;
    background: linear-gradient(180deg, rgba(10,5,20,0), rgba(10,5,20,.92) 30%); z-index: 2; }
  .lobby-actions .btn { flex: 1; padding: 11px 6px; }
  .lobby-actions .btn.primary { flex: 1.6; }
  .lobby-actions .wait { flex: 2; padding: 8px; font-size: 13px; text-align: center; }
  .lobby-achs, .controls { display: none; }
  .hint { font-size: 12px; }

  /* Erfolge im Menü: nur Symbole */
  .achs { gap: 6px; max-width: 340px; }
  .ach { padding: 5px 8px; font-size: 16px; }
  .ach .an { display: none; }
  .how { font-size: 12px; }
  table.board { font-size: 13px; } .board th, .board td { padding: 6px 8px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #screen { padding: 10px 16px; gap: 8px; }
  #screen h1 { font-size: 40px; }
  .menu { gap: 8px; }
  .slot { min-height: 0; padding: 6px; } .slot canvas { width: 44px; height: 44px; }
  .slots { grid-template-columns: repeat(8, minmax(70px, 110px)); gap: 6px; }
  .mode small { display: none; } .mode { min-width: 0; padding: 6px 12px; }
  .lobby-achs, .controls { display: none; }
}

/* ---------- Handy im Spiel: kompaktes HUD, kurze Labels ---------- */
@media (max-width: 600px) {
  #hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: calc(4px + env(safe-area-inset-top)) 52px 0 6px; top: 4px; }
  #hud:has(.card:nth-child(3):last-child), #hud:has(.card:nth-child(2):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card, #hud.many .card { min-width: 0; padding: 3px 6px; gap: 2px; border-radius: 9px; border-width: 1.5px; }
  .card .name, #hud.many .card .name { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pips, #hud.many .pips { gap: 3px; }
  .pips i, #hud.many .pips i { width: 7px; height: 7px; border-width: 1.5px; }
  .cds { gap: 3px; } .cd { height: 3px; }
  .plabel { font-size: 10px; padding: 1px 6px; }
  .plabel .n { display: none; }
  #modebar { top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); font-size: 12px; padding: 4px 12px; max-width: 94vw; overflow: hidden; text-overflow: ellipsis; }
  #racebar { top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); width: 86vw; }
  #center .big { font-size: 34px !important; }
  #center .sub { font-size: 13px !important; padding: 0 16px; }
}
