/* Galaxy — UI-Schicht ueber dem WebGL-Canvas.
   Alles ist auf Daumenbedienung ausgelegt: grosse Trefferflaechen, keine
   Hover-Abhaengigkeiten, Safe-Area-Abstaende fuer Geraete mit Notch. */

:root {
  --bg: #05060d;
  --fg: #e8ecff;
  --dim: #8a93b8;
  --accent: #4fd2ff;
  --accent2: #ff6b58;
  --panel: rgba(14, 18, 34, 0.82);
  --edge: rgba(120, 160, 255, 0.22);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", Roboto, -apple-system, system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }

/* ---------------- Bildschirme ---------------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 14px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 14px);
  background: radial-gradient(120% 90% at 50% 10%, rgba(30, 44, 96, 0.55), rgba(5, 6, 13, 0.94) 70%);
  backdrop-filter: blur(3px);
  z-index: 10;
  animation: fade .28s ease;
}
/* Hinter dem Hauptmenue laeuft ein echtes Gefecht auf dem Canvas. Der Schleier
   darf es deshalb nur daempfen, nicht verdecken — und nicht weichzeichnen,
   sonst waere die Bewegung nicht mehr als Spiel zu erkennen. */
#menu, #splash {
  background: radial-gradient(85% 65% at 50% 45%, rgba(5, 6, 13, .34), rgba(5, 6, 13, .74) 78%);
  backdrop-filter: none;
}
#splash { background: radial-gradient(70% 55% at 50% 50%, rgba(5, 6, 13, .20), rgba(5, 6, 13, .66) 82%); }
#menu .menu-inner, #splash .menu-inner { text-shadow: 0 2px 14px rgba(0, 0, 0, .95); }
/* Im Menue steht das Logo ueber den Knoepfen, darf ihnen aber keinen Platz nehmen. */
#menu .logo { font-size: clamp(34px, 9vw, 62px); }
#namebox { text-align: left; }
#namebox label { margin-bottom: 6px; }
.pname { color: var(--accent); font-weight: 600; }
#menu button, #splash button { background: linear-gradient(180deg, rgba(40, 66, 130, .78), rgba(18, 28, 62, .82)); }
#menu input { background: rgba(8, 12, 26, .72); }
.screen.overlay { background: rgba(4, 6, 14, 0.72); backdrop-filter: blur(6px); z-index: 20; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.menu-inner {
  margin: auto; text-align: center; max-width: 480px; width: 100%;
  display: flex; flex-direction: column; gap: 14px;
}

.logo {
  font-size: clamp(46px, 13vw, 92px);
  letter-spacing: .22em; margin: 0 0 -6px; font-weight: 200;
  background: linear-gradient(180deg, #ffffff, var(--accent) 60%, #2b7ecb);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(79, 210, 255, .35));
}
.tag { color: var(--dim); margin: 0 0 10px; font-size: 15px; }
.foot { color: var(--dim); font-size: 12px; margin-top: 18px; }

.screen-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--edge); margin-bottom: 12px;
}
.screen-head h2 { margin: 0; font-weight: 400; letter-spacing: .08em; font-size: 19px; }
.counter { color: var(--dim); font-size: 13px; }
.code { color: var(--accent); letter-spacing: .3em; font-weight: 600; }

/* ---------------- Bedienelemente ---------------- */
button {
  font: inherit; color: var(--fg); cursor: pointer;
  background: linear-gradient(180deg, rgba(60, 96, 180, .38), rgba(30, 44, 92, .38));
  border: 1px solid var(--edge); border-radius: 12px;
  padding: 13px 18px; min-height: 46px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
button:active { transform: scale(.97); }
button.big { font-size: 17px; padding: 16px; letter-spacing: .04em; }
button.ghost { background: rgba(255, 255, 255, .04); }
button.small { padding: 8px 12px; min-height: 36px; font-size: 13px; }
button.back { background: none; border: none; color: var(--dim); padding: 8px 4px; }
button:disabled { opacity: .4; cursor: default; }
button.danger { color: var(--accent2); border-color: rgba(255, 107, 88, .45); }
button.danger.armed { background: rgba(255, 107, 88, .22); border-color: var(--accent2); }
.btns { display: flex; flex-direction: column; gap: 10px; }

input, select {
  font: inherit; color: var(--fg);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--edge); border-radius: 10px;
  padding: 11px 12px; min-height: 44px; width: 100%;
}
/* Die aufgeklappte Liste eines <select> zeichnet das Betriebssystem, nicht die
   Seite. Ohne diese beiden Angaben steht dort helle Schrift auf weissem Grund
   und ist unlesbar — color-scheme schaltet die native Liste auf dunkel, die
   explizite option-Regel deckt die Browser ab, die das ignorieren. */
:root { color-scheme: dark; }
select { color-scheme: dark; }
select option, select optgroup {
  background: #0d1224;
  color: var(--fg);
}
label { display: block; text-align: left; color: var(--dim); font-size: 13px; margin-bottom: 10px; }
label input, label select { margin-top: 5px; }
.namerow { display: flex; align-items: center; gap: 10px; text-align: left; }
.namerow label { margin: 0; }

/* ---------------- Levelraster ---------------- */
.grid {
  display: grid; gap: 10px; overflow-y: auto; padding-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
}
.lvl {
  position: relative; border: 1px solid var(--edge); border-radius: 14px;
  padding: 12px; text-align: left; background: rgba(16, 22, 44, .7);
  min-height: 104px; display: flex; flex-direction: column; justify-content: space-between;
  background-size: cover; background-position: center; overflow: hidden;
}
.lvl::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5, 8, 20, .25), rgba(5, 8, 20, .85));
}
.lvl > * { position: relative; z-index: 1; }
.lvl .num { font-size: 12px; color: var(--dim); letter-spacing: .18em; }
.lvl .nm { font-size: 15px; margin-top: 2px; }
.lvl .meta { font-size: 11px; color: var(--dim); }
.lvl.done { border-color: rgba(120, 255, 190, .5); }
.lvl.done .nm::after { content: ' ✓'; color: #7dffbe; }
.lvl.locked { opacity: .42; }

/* ---------------- Mehrspieler ---------------- */
.watch-body { max-width: 620px; margin: 0 auto; width: 100%; }
.multi-body, .room-body, .help-body, .watch-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  touch-action: pan-y; padding-bottom: 24px;
}
.multi-body { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .multi-body { grid-template-columns: 1fr 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 16px; }
.panel h3 { margin: 0 0 12px; font-weight: 400; font-size: 15px; letter-spacing: .06em; }
.joinrow { display: flex; gap: 8px; }
.joinrow input { text-transform: uppercase; letter-spacing: .3em; text-align: center; }
.joinrow button { flex: 0 0 auto; }
.roomlist { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.roomrow {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px;
  background: rgba(255, 255, 255, .03); font-size: 14px;
}
.roomrow b { color: var(--accent); letter-spacing: .2em; }
.roomrow b.kind { letter-spacing: .04em; font-weight: 500; }

.room-body { max-width: 520px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.seatlist { display: flex; flex-direction: column; gap: 8px; }
.seat {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--edge); border-radius: 12px; background: rgba(255, 255, 255, .03);
}
.dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 12px currentColor; background: currentColor; }
.dim { color: var(--dim); }
.tiny { font-size: 12px; }
.help-body { max-width: 620px; margin: 0 auto; line-height: 1.6; font-size: 15px; }
.help-body b { color: var(--accent); font-weight: 600; }

/* ---------------- Spiel-HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) 8px calc(var(--safe-l) + 10px);
  background: linear-gradient(180deg, rgba(4, 6, 14, .78), transparent);
}
.hud-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; gap: 10px; justify-content: center;
  padding: 10px calc(var(--safe-r) + 12px) calc(var(--safe-b) + 14px) calc(var(--safe-l) + 12px);
}
.iconbtn {
  pointer-events: auto; width: 46px; height: 46px; min-height: 46px; padding: 0;
  font-size: 20px; line-height: 1; border-radius: 12px; flex: 0 0 auto;
}
.actionbtn { pointer-events: auto; min-width: 132px; backdrop-filter: blur(6px); }
.actionbtn.armed {
  border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 18px rgba(79, 210, 255, .35);
}
.hud-bottom { flex-wrap: wrap; }
.badge {
  flex: 0 0 auto; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--edge); border-radius: 8px;
  padding: 5px 9px; background: rgba(10, 16, 34, .7);
}
.bars { flex: 1; display: flex; gap: 6px; align-items: center; height: 26px; }
.bar { height: 8px; border-radius: 5px; transition: flex-grow .4s ease, opacity .3s ease; min-width: 3px; box-shadow: 0 0 10px currentColor; background: currentColor; }
.hint {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 64px); transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 10px 16px; font-size: 13px; max-width: min(90vw, 460px); text-align: center;
  animation: fade .4s ease;
}
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(var(--safe-b) + 86px); transform: translateX(-50%);
  background: rgba(10, 14, 28, .9); border: 1px solid var(--edge); border-radius: 10px;
  padding: 9px 15px; font-size: 13px; animation: fade .2s ease; white-space: nowrap;
}

#resulttitle { font-size: clamp(38px, 11vw, 70px); margin: 0; font-weight: 200; letter-spacing: .12em; }
#resulttitle.win { color: #7dffbe; text-shadow: 0 0 30px rgba(125, 255, 190, .5); }
#resulttitle.lose { color: var(--accent2); text-shadow: 0 0 30px rgba(255, 107, 88, .45); }
