:root {
  --bg: #0a0c10;
  --panel: #12161d;
  --line: #262c37;
  --text: #e9edf3;
  --muted: #8b94a3;
  --accent: #ffd83d;
  --accent2: #ff4545;
  --good: #3dff7a;
  --bad: #ff4545;
  --blue: #3dd5ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; }
.hidden { display: none !important; }

.screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
#home { background:
  radial-gradient(ellipse at 15% 20%, rgba(255,69,69,.13), transparent 50%),
  radial-gradient(ellipse at 85% 80%, rgba(61,213,255,.12), transparent 50%), var(--bg); }
.card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }

.logo { margin: 0; font-size: clamp(38px, 10vw, 52px); font-weight: 900; letter-spacing: -.03em; line-height: 1;
  font-style: italic; color: var(--accent2); text-shadow: 0 0 24px rgba(255,69,69,.35); }
.logo span { color: var(--accent); text-shadow: 0 0 24px rgba(255,216,61,.35); }
.tag { color: var(--muted); margin: 10px 0 24px; font-size: 15px; }

.field { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
input { width: 100%; margin-top: 6px; background: #0b0e13; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 17px; font-family: inherit; outline: none; }
input:focus { border-color: var(--accent); }

.btn { appearance: none; border: 1px solid var(--line); background: #1b2029; color: var(--text); font: inherit;
  font-weight: 700; font-size: 16px; padding: 12px 18px; border-radius: 10px; cursor: pointer; width: 100%; }
.btn:hover { background: #222834; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #17140a; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { width: auto; font-size: 14px; padding: 8px 14px; }
.btn.tiny { font-size: 12px; padding: 6px 10px; margin-top: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 20px 0 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join { display: flex; gap: 10px; }
.join input { margin: 0; text-transform: uppercase; letter-spacing: .3em; font-weight: 800; text-align: center; flex: 1; min-width: 0; }
.join .btn { width: auto; }
.err { color: var(--bad); min-height: 1.2em; font-size: 14px; margin: 10px 0 0; }
.hint { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0; min-height: 1em; }

.help { margin-top: 16px; color: var(--muted); font-size: 14px; }
.help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.help ul { padding-left: 18px; line-height: 1.55; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.g { background: var(--good); } .dot.r { background: var(--bad); } .dot.b { background: var(--blue); }
#install { margin-top: 12px; }

#lobby .card { text-align: center; }
.kicker { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .15em; text-transform: uppercase; font-weight: 700; }
.codebig { font-size: 56px; font-weight: 900; letter-spacing: .18em; color: var(--accent); margin: 4px 0 12px; padding-left: .18em; }
.players { list-style: none; padding: 0; margin: 20px 0; text-align: left; }
.players li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: #0d1015; margin-bottom: 6px; font-weight: 600; }
.players .sw { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 10px currentColor; background: currentColor; flex: none; }
.players .badge { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.colors { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 10px 0 20px; }
.colors button { appearance: none; width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; padding: 0;
  background: currentColor; cursor: pointer; box-shadow: 0 0 10px currentColor; transition: transform .1s; }
.colors button:hover:not(:disabled) { transform: scale(1.12); }
.colors button.mine { border-color: #fff; transform: scale(1.12); }
.colors button:disabled { opacity: .2; box-shadow: none; cursor: not-allowed; }
.hint.small { font-size: 12px; margin: 4px 0 10px; }
#locals { text-align: left; }
.local { background: #0d1015; border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.lrow { display: flex; align-items: center; gap: 6px; }
.lrow .sw { width: 14px; height: 14px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: none; }
.lrow .lname { flex: 1; min-width: 0; margin: 0; padding: 8px 10px; font-size: 14px; }
.key { appearance: none; min-width: 44px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-bottom-width: 3px;
  background: #1b2029; color: var(--text); font: inherit; font-size: 13px; font-weight: 800; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.key.wait { border-color: var(--accent); color: var(--accent); }
.rm { appearance: none; border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; }
.rm:hover { color: var(--bad); }
.colors.small { justify-content: flex-start; gap: 7px; margin: 10px 0 0; }
.colors.small button { width: 22px; height: 22px; border-width: 2px; box-shadow: 0 0 6px currentColor; }
#addLocal { margin: 2px auto 20px; display: block; }
#lobbyErr:empty { display: none; }
.tgt { display: flex; gap: 6px; align-items: center; }
.tgt .unit { color: var(--muted); font-size: 13px; margin-left: -2px; }
.tgt input { width: 72px; margin: 0; padding: 7px 8px; font-size: 14px; text-align: center; }
.chip { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.chip.on { background: var(--accent); color: #17140a; border-color: var(--accent); }
.switch { width: 20px; height: 20px; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; flex: none; }
.rule { color: var(--muted); font-size: 11px; font-weight: 700; margin: 8px 0 0; }
.rule:empty { display: none; }
.settings { text-align: left; margin: 0 0 20px; }
.settings .kicker, .settings .hint { text-align: center; }
.settings .hint { margin: 4px 0 10px; font-size: 13px; }
.settings.locked .hint { display: block; }
.settings:not(.locked) .hint { display: none; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px;
  background: #0d1015; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.opt.col { flex-direction: column; align-items: stretch; }
.seg { display: flex; gap: 4px; background: #0b0e13; border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #17140a; }
select { background: #0b0e13; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font: inherit; font-size: 14px; }
/* Extras: eine Zeile pro Extra mit Häufigkeit */
.pus { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.purow { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-top: 1px solid #1a1f28; }
.purow .ic { width: 24px; height: 24px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center;
  font-size: 13px; font-weight: 900; flex: none; }
.purow .nm { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--text); }
.purow .nm small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.purow.off .ic, .purow.off .nm { opacity: .4; }
.purow.na { opacity: .3; }
.purow.na .nm::after { content: " – nicht in diesem Modus"; font-weight: 500; color: var(--muted); font-size: 11px; }
.seg.small button { font-size: 12px; padding: 5px 7px; }

/* Optionen-Zusammenfassung in der Lobby */
.optsum { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left;
  background: #0d1015; border-radius: 10px; padding: 10px 12px; margin: 4px 0 20px; }
.optsum span { color: var(--muted); font-size: 13px; font-weight: 600; }
.optsum .btn { flex: none; }

/* Fenster (Optionen, Konto, Bestenliste) */
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-start; justify-content: center;
  background: rgba(5,6,8,.78); padding: 24px 16px; overflow-y: auto; }
.mcard { position: relative; margin: auto 0; text-align: left; }
.mcard.wide { max-width: 520px; }
.mcard h2 { margin: 0 0 16px; font-size: 22px; font-weight: 900; }
.mclose { position: absolute; top: 12px; right: 12px; appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.mclose:hover { color: var(--text); background: #1b2029; }
.mdone { margin-top: 6px; }
.field small { font-weight: 500; }
.links { text-align: center; font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.linkbtn { appearance: none; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0 2px; }
.linkbtn:hover { text-decoration: underline; }
.ok { color: var(--good); font-size: 14px; margin: 0 0 10px; }
.ok:empty { display: none; }
.vfy { color: var(--good); font-size: 13px; font-weight: 900; }
/* Offline (Platz wird freigehalten) */
.players li.off, #scores li.off { opacity: .45; }
.offl { font-size: 11px; color: var(--muted); font-weight: 600; }
#scores li.off .nm::after { content: " (offline)"; color: var(--muted); font-weight: 500; font-size: 12px; }
#acctIn #friendsBtn { flex: 1 1 100%; margin-top: 4px; }
#friendsCount { color: var(--good); }
#lobbyFriends { margin-left: 6px; }
/* Freunde */
.addfriend { display: flex; gap: 6px; }
.addfriend input { margin: 0; padding: 9px 12px; font-size: 15px; }
.addfriend .btn { flex: none; }
#friendMsg { margin: 8px 0 4px; min-height: 0; }
#friendMsg:empty { display: none; }
.fsec { margin-top: 14px; }
.fsec h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.frow { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #1a1f28; }
.frow .dot { width: 10px; height: 10px; border-radius: 50%; background: #3a4250; flex: none; }
.frow.on .dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
.frow .who { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; }
.frow .who small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.frow .btn { width: auto; padding: 6px 10px; font-size: 13px; }
.frow .rm { padding: 4px 6px; }
.fempty { color: var(--muted); font-size: 13px; padding: 8px 4px; }
/* Leiste oben bei Verbindungsabbruch, Einladung unten */
.netbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: #5a3b00; color: #ffe2a8; text-align: center;
  font-size: 13px; font-weight: 700; padding: 8px 12px; }
.invitebox { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; box-shadow: 0 10px 40px rgba(0,0,0,.6);
  font-size: 14px; max-width: calc(100% - 24px); }
.invitebox .btn { width: auto; padding: 7px 12px; font-size: 14px; }
.invitebox .rm { font-size: 16px; }
.acct { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.acct .btn { flex: 1; }
.acct b { color: var(--text); }
#boardBtn { margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.stats div { background: #0d1015; border-radius: 10px; padding: 10px 12px; }
.stats b { display: block; font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); font-weight: 600; }
.danger summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 700; }
.danger form { margin-top: 10px; }
.tablewrap { overflow-x: auto; }
table.board { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.board th { text-align: right; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.board td { text-align: right; padding: 7px 8px; border-bottom: 1px solid #1a1f28; }
table.board th:nth-child(2), table.board td:nth-child(2) { text-align: left; }
table.board td:nth-child(2) { font-weight: 700; }
table.board tr.me td { color: var(--accent); }
table.board td.empty { text-align: center; color: var(--muted); padding: 20px; }
.settings.locked button, .settings.locked select { cursor: default; }
.result { font-weight: 700; color: var(--accent); min-height: 0; margin: 0 0 12px; }
.result:empty { display: none; }
#startBtn { margin-bottom: 6px; }

/* --- Spiel --- */
#game { padding: 0; height: 100%; gap: 0; align-items: stretch; background: #050608; }
#stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; min-width: 0; }
#arena { position: relative; }
#arena canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#trails { background: #000; border-radius: 4px; }
#banner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: clamp(22px, 5vw, 54px); font-weight: 900; font-style: italic; pointer-events: none; padding: 20px;
  text-shadow: 0 2px 18px rgba(0,0,0,.9); }
#banner small { display: block; font-size: .45em; font-style: normal; color: var(--muted); margin-top: 8px; font-weight: 700; }

#toast { position: absolute; left: 0; right: 0; top: 14px; text-align: center; pointer-events: none; font-weight: 800;
  font-size: clamp(14px, 2.2vw, 20px); text-shadow: 0 2px 10px rgba(0,0,0,.95); opacity: 0; transition: opacity .25s; }
#toast.on { opacity: 1; }
#toast small { display: block; font-size: .7em; color: var(--muted); font-weight: 700; }


/* Pause-Knopf nur auf Touch-Geräten (am PC: P oder Esc); liegt über den Steuerflächen */
.pausebtn { display: none; position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6; appearance: none;
  border: 1px solid var(--line); background: rgba(18,22,29,.85); color: var(--text); font: inherit; font-size: 15px; font-weight: 900;
  width: 52px; height: 40px; border-radius: 10px; letter-spacing: 2px; padding: 0 0 0 2px; touch-action: manipulation; }
@media (pointer: coarse) { body.ingame .pausebtn { display: block; } }
.pausemenu { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,8,.72); padding: 20px; }
.pausemenu .card { max-width: 300px; text-align: center; }
.pausemenu h2 { margin: 0 0 4px; font-size: 32px; font-style: italic; font-weight: 900; color: var(--accent); }
.pausemenu .btn { margin-top: 8px; }

#board { width: 190px; flex: none; background: var(--panel); border-left: 1px solid var(--line); padding: 14px 12px; overflow-y: auto; }
.boardhead { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 10px; }
#roomTag { letter-spacing: .12em; color: var(--accent); }
#scores { list-style: none; margin: 0; padding: 0; }
#scores li { display: flex; align-items: center; gap: 8px; padding: 7px 4px; font-weight: 700; font-size: 15px; border-bottom: 1px solid #1a1f28; }
#scores li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#scores li .pt { font-variant-numeric: tabular-nums; font-size: 18px; }
#scores li.dead { opacity: .38; }
#scores li.me .nm::after { content: " (du)"; color: var(--muted); font-weight: 500; font-size: 12px; }

.touch { display: none; position: fixed; top: 0; bottom: 0; width: 50%; z-index: 5; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* Im Spiel: keine Antipp-Markierung, kein Lang-Drücken-Menü, keine Textauswahl */
body.ingame { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.touch.left { left: 0; } .touch.right { right: 0; }
/* Die ganze Bildschirmhälfte ist der Knopf – das soll man auch sehen */
.touch.left { border-right: 1px dashed rgba(255,255,255,.08); }
.touch span { position: absolute; bottom: 16px; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; color: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.04); transition: all .08s; }
.touch em { position: absolute; bottom: 88px; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(255,255,255,.22); }
.touch.left span { left: 16px; } .touch.right span { right: 16px; }
.touch.left em { left: 16px; width: 64px; text-align: center; } .touch.right em { right: 16px; width: 64px; text-align: center; }
.touch.on span { color: #17140a; background: rgba(255,216,61,.85); border-color: rgba(255,216,61,.85); }
@media (pointer: coarse) { body.ingame .touch { display: block; } }

#rotate { display: none; position: fixed; inset: 0; z-index: 20; background: var(--bg); color: var(--text);
  align-items: center; justify-content: center; flex-direction: column; font-size: 20px; font-weight: 700; gap: 12px; }
#rotate div { font-size: 54px; color: var(--accent); }
@media (orientation: portrait) and (pointer: coarse) { body.ingame #rotate { display: flex; } }

/* Handy quer: Punkteliste schmal */
@media (max-height: 520px) {
  #board { width: 128px; padding: 8px 8px; }
  #scores li { padding: 4px 2px; font-size: 13px; }
  #scores li .pt { font-size: 15px; }
  #stage { padding: 4px; }
  .boardhead { margin-bottom: 4px; }
}
#scores .sw { width: 10px; height: 10px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: none; }
