:root{
  /* Dark palette matching the spiele.ramsteiner.eu landing page and the
     Tetris game on the same site - so hopping between games on that hub
     feels like one connected place, not four unrelated pages. --accent is
     the same teal the landing page already uses for LoopSort's card. */
  --bg:#090c16;
  --bg-board:#0c1120;
  --surface:#131a2c;
  --surface-2:#1a2340;
  --line:#242e50;
  --text:#eef1fb;
  --text-dim:#8891b8;
  --text-faint:#525c82;
  --accent:#34d9c4;
  --accent-dim:#34d9c455;
  --warn:#ff5470;
  --good:#3ddc97;
  --gold:#ffd93d;
}
*{box-sizing:border-box;}
html,body{
  margin:0;
  min-height:100%;
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, #1a2030 0%, transparent 45%),
    radial-gradient(circle at 85% 100%, #1c1430 0%, transparent 45%),
    var(--bg);
  color:var(--text);
  overflow-x:hidden;
}
.wrap{
  min-height:100vh;
  /* iOS Safari misst 100vh an der maximalen Hoehe (Symbolleiste eingeklappt);
     wenn die Symbolleiste beim Tippen unten ein-/ausblendet, verschiebt das
     sichtbar den Inhalt. dvh kennt die tatsaechlich sichtbare Hoehe. */
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:16px 12px 40px;
}
header{
  width:100%;
  max-width:640px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:12px;
  margin-bottom:18px;
}
#heroTop{
  display:flex;
  flex-direction:column;
  align-items:center;
  width:100%;
  gap:6px;
}
.back-link{
  align-self:flex-start;
  font-size:13px;
  font-weight:600;
  color:var(--text-dim);
  text-decoration:none;
  padding:4px 2px;
}
.back-link:hover{ color:var(--accent); }
.hero-mark{ text-align:center; }
.hero-mark .title{
  font-size:clamp(28px, 7vw, 40px);
  font-weight:800;
  letter-spacing:0.01em;
  margin:2px 0 0;
  color:var(--text);
}
.hero-mark .title .title-accent{ color:var(--accent); }
h2{ color:var(--text); margin-top:0; }
.stats{
  display:flex;
  gap:10px;
  font-weight:600;
  flex-wrap:wrap;
  justify-content:center;
}
.pill{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:999px;
  padding:6px 14px;
  font-size:13px;
  color:var(--text-dim);
  transition:transform .1s ease;
}
.panel{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:18px;
  padding:22px 20px;
  width:100%;
  max-width:420px;
  text-align:center;
}
.screen-home{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
}
#board{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:24px;
  padding:24px 16px;
  width:100%;
  max-width:640px;
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:18px;
  min-height:260px;
  box-shadow:0 20px 60px -24px #000000a0;
}
.tube{
  width:56px;
  height:220px;
  display:flex;
  flex-direction:column-reverse;
  align-items:center;
  padding:6px 6px 10px;
  gap:6px;
  border-radius:14px 14px 26px 26px;
  background:linear-gradient(180deg, var(--surface-2), var(--bg-board));
  border:3px solid var(--line);
  box-shadow:inset 0 -6px 10px #00000060, 0 4px 6px #00000040;
  cursor:pointer;
  transition:transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease, border-color .18s ease;
  position:relative;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
/* Unsichtbare, vergroesserte Trefferflaeche: die Boardluecke gehoert zur
   Haelfte der jeweils naeheren Roehre, damit ein leicht daneben gesetzter
   Finger-Tap trotzdem die Roehre trifft statt ins Leere zu gehen. */
.tube::before{
  content:"";
  position:absolute;
  inset:-9px;
}
.tube:hover:not(.selected){
  transform:translateY(-4px);
  border-color:var(--accent-dim);
}
.tube.selected{
  transform:translateY(-14px);
  border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accent-dim), inset 0 -6px 10px #00000060, 0 10px 14px #00000060;
  animation:selectedPulse 1.1s ease-in-out infinite;
}
@keyframes selectedPulse{
  0%,100%{ box-shadow:0 0 0 3px var(--accent-dim), inset 0 -6px 10px #00000060, 0 10px 14px #00000060; }
  50%{ box-shadow:0 0 0 6px var(--accent-dim), inset 0 -6px 10px #00000060, 0 10px 14px #00000060; }
}
.tube.shake{ animation:shake .3s; }
.tube.invalid{ animation:shake .3s, invalidFlash .3s; }
@keyframes shake{
  0%,100%{transform:translateX(0);}
  25%{transform:translateX(-6px);}
  75%{transform:translateX(6px);}
}
@keyframes invalidFlash{
  0%,100%{ box-shadow:inset 0 -6px 10px #00000060, 0 4px 6px #00000040; }
  50%{ box-shadow:0 0 0 4px #ff547099, inset 0 -6px 10px #00000060, 0 4px 6px #00000040; }
}
.tube.complete{ animation:completeGlow 1.6s ease-in-out infinite; }
@keyframes completeGlow{
  0%,100%{ box-shadow:0 0 0 3px var(--gold), inset 0 -6px 10px #00000060, 0 4px 6px #00000040; filter:brightness(1); }
  50%{ box-shadow:0 0 14px 4px #ffd93dcc, inset 0 -6px 10px #00000060, 0 4px 6px #00000040; filter:brightness(1.15); }
}
.ball{
  width:42px;
  height:42px;
  border-radius:50%;
  flex-shrink:0;
  box-shadow:inset -4px -4px 8px #00000050, inset 3px 3px 6px #ffffff40, 0 2px 3px #00000050;
  will-change:transform;
}
.ball.spawn{ animation:drop .3s cubic-bezier(.34,1.56,.64,1) backwards; }
@keyframes drop{
  from{transform:translateY(-40px) scale(.6);opacity:0;}
  to{transform:translateY(0) scale(1);opacity:1;}
}
.confetti{
  position:fixed;
  top:-20px;
  width:8px;
  height:14px;
  border-radius:2px;
  pointer-events:none;
  z-index:50;
  animation:confettiFall linear forwards;
}
@keyframes confettiFall{
  to{ transform:translateY(110vh) rotate(540deg); opacity:0.4; }
}
.controls{
  display:flex;
  gap:10px;
  margin-top:20px;
  flex-wrap:wrap;
  justify-content:center;
}
button{
  font:inherit;
  font-weight:700;
  border-radius:11px;
  padding:10px 20px;
  background:var(--surface-2);
  color:var(--text);
  border:1px solid var(--line);
  cursor:pointer;
  transition:transform .08s ease, border-color .15s ease;
  /* iOS Safari deutet zwei schnelle Taps auf denselben Knopf (z.B.
     mehrfaches Rueckgaengig) sonst als Doppel-Tap-Zoom-Geste - das
     ignoriert sogar "user-scalable=no" aus Barrierefreiheits-Gruenden
     und sieht dann wie ein kurzes Springen des Bildschirms aus.
     touch-action:manipulation schaltet diese Gestenerkennung gezielt
     fuer Buttons ab, ohne normales Scrollen anderswo zu beeintraechtigen. */
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
button:hover{ border-color:var(--accent-dim); }
button:active{ transform:translateY(1px); }
button:disabled{
  opacity:.5;
  cursor:not-allowed;
  transform:none;
}
button.secondary{
  background:transparent;
  color:var(--text-dim);
  border:1px solid var(--line);
}
button.big, .cta{
  padding:14px 16px;
  font-size:15px;
  width:100%;
  background:linear-gradient(180deg, var(--accent), #21b39f);
  color:#052420;
  border:0;
  box-shadow:0 6px 20px -8px var(--accent-dim), inset 0 1px 0 #ffffff40;
}
button.big:hover, .cta:hover{ border-color:transparent; }
.cta.secondary{
  background:transparent;
  color:var(--text-dim);
  border:1px solid var(--line);
  box-shadow:none;
}
#overlay{
  position:fixed;
  inset:0;
  background:#00000090;
  display:none;
  align-items:center;
  justify-content:center;
  z-index:10;
  padding:16px;
}
#overlay.show{display:flex;}
.modal{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:20px;
  padding:28px 32px;
  text-align:center;
  max-width:340px;
  width:100%;
}
#overlay.show .modal{ animation:modalPop .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes modalPop{
  from{ transform:scale(.7); opacity:0; }
  to{ transform:scale(1); opacity:1; }
}
footer{
  margin-top:24px;
  font-size:12px;
  color:var(--text-faint);
  text-align:center;
  max-width:500px;
}
.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  text-align:left;
  margin-bottom:14px;
}
.field label, .field span{
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:var(--text-faint);
}
.field input, .field select{
  font:inherit;
  padding:10px 12px;
  border-radius:9px;
  border:1px solid var(--line);
  background:var(--bg-board);
  color:var(--text);
}
.field input:focus, .field select:focus{
  outline:none;
  border-color:var(--accent);
}
.eyebrow{
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:var(--text-faint);
  margin:0 0 8px;
  text-align:left;
}
.error-text{
  color:var(--warn);
  font-size:13px;
  margin:10px 0 0;
}
.tabs{
  display:flex;
  background:var(--bg-board);
  border:1px solid var(--line);
  border-radius:10px;
  padding:3px;
  gap:3px;
  margin-bottom:16px;
}
.tab-btn{
  flex:1;
  padding:9px 0;
  border:0;
  border-radius:8px;
  background:transparent;
  color:var(--text-dim);
  font-size:13px;
  font-weight:700;
  cursor:pointer;
  box-shadow:none;
}
.tab-btn:hover{ border-color:transparent; }
.tab-btn.active{
  background:var(--surface-2);
  color:var(--text);
  box-shadow:inset 0 0 0 1px var(--line);
}
.mode-choice{
  display:flex;
  gap:8px;
  margin-bottom:14px;
}
.mode-choice label{
  flex:1;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  cursor:pointer;
  font-size:13px;
  text-align:center;
  color:var(--text-dim);
  background:var(--bg-board);
  transition:all .12s ease;
}
.mode-choice input{ display:none; }
.mode-choice input:checked + span{ font-weight:700; color:var(--text); }
.mode-choice label:has(input:checked){
  border-color:var(--accent);
  background:var(--surface-2);
}
.checkbox-field{
  display:flex;
  align-items:flex-start;
  gap:8px;
  margin:2px 0 14px;
  font-size:12.5px;
  color:var(--text-dim);
  cursor:pointer;
  text-align:left;
}
.checkbox-field input{ margin-top:3px; flex-shrink:0; }
.solo-link{
  background:transparent;
  border:0;
  color:var(--text-faint);
  font-size:12.5px;
  text-decoration:underline;
  text-underline-offset:2px;
  cursor:pointer;
  padding:4px;
  margin-top:18px;
}
.solo-link:hover{ color:var(--text-dim); border-color:transparent; }
.solo-panel{ margin-top:14px; }
.player-list{
  list-style:none;
  padding:0;
  margin:0 0 16px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.player-list li{
  background:var(--bg-board);
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px 14px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:13.5px;
  color:var(--text-dim);
}
.player-list li.done{ border-color:var(--good); }
.player-list .badge{
  font-size:11px;
  padding:3px 8px;
  border-radius:999px;
  background:var(--surface-2);
  color:var(--accent);
  border:1px solid var(--line);
}
.player-list .you{ color:var(--text); font-weight:700; }
.player-list .lives{ margin-left:8px; font-size:11px; letter-spacing:1px; }
.join-room-btn{
  padding:6px 14px;
  font-size:12px;
  flex-shrink:0;
  margin-left:8px;
  background:var(--accent);
  color:#052420;
  border:0;
}
.join-room-btn:hover{ filter:brightness(1.1); border-color:transparent; }
.crown{ font-size:14px; }
.leaderboard{
  width:100%;
  border-collapse:collapse;
  margin:14px 0;
  font-size:13.5px;
}
.leaderboard th, .leaderboard td{
  padding:8px 10px;
  text-align:left;
  border-bottom:1px solid var(--line);
  color:var(--text-dim);
}
.leaderboard th{
  color:var(--text-faint);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:0.04em;
}
.leaderboard tr:first-child td{ font-weight:700; color:var(--text); }
.leaderboard tr.winner-row td{ background:#ffd93d1f; color:var(--text); }
.leaderboard .winner-badge{
  font-size:11px;
  padding:2px 8px;
  border-radius:999px;
  background:var(--gold);
  color:#3a2c00;
  margin-left:6px;
}
.leaderboard .lb-primary{ font-weight:700; color:var(--accent); background:#34d9c41a; }
.hidden{ display:none !important; }
.small-note{
  font-size:12px;
  color:var(--text-faint);
  margin-top:8px;
}
.elim-banner{
  font-size:13.5px;
  font-weight:700;
  color:var(--warn);
  background:#ff547014;
  border:1px solid #ff547040;
  border-radius:10px;
  padding:8px 12px;
  margin:0 0 10px;
  text-align:center;
}
.timer{
  font-variant-numeric:tabular-nums;
}
.link-btn{
  background:none;
  border:none;
  color:var(--text-dim);
  text-decoration:underline;
  text-underline-offset:2px;
  box-shadow:none;
  padding:4px;
  font-weight:600;
}
.link-btn:hover{ color:var(--accent); border-color:transparent; }
#inviteLinkInput{
  min-width:0;
  flex:1;
  font-size:12px;
}

@media (max-width: 480px){
  header{
    gap:8px;
    margin-bottom:12px;
  }
  .hero-mark .title{ font-size:24px; }
  .stats{ gap:6px; }
  .pill{
    padding:4px 9px;
    font-size:11px;
  }
  .wrap{ padding:10px 8px 24px; }
  .panel{ padding:18px 16px; }
  #board{ padding:16px 10px; gap:12px; }
  .tube{ width:44px; height:180px; gap:4px; padding:5px 5px 8px; }
  .tube::before{ inset:-6px; }
  .ball{ width:32px; height:32px; }
  footer{ margin-top:14px; }
  .controls{ margin-top:12px; }
}
