@font-face {
  font-family: 'VT323';
  src: url('/fonts/vt323-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #aaa;
  --hi: #fff;
  --accent: #55f;
  --panel: transparent;
  --line: #555;
  --error: #f55;
  --font: 'VT323', ui-monospace, monospace;
  --radius: 0;
}

body[data-theme='modern'] {
  --bg: #12122e;
  --fg: #d9d6f0;
  --hi: #fff;
  --accent: #ffb84d;
  --panel: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.16);
  --error: #ff8a80;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
}
body[data-theme='classic'] { font-size: 22px; }
body[data-theme='modern'] {
  background: radial-gradient(1200px 600px at 50% -10%, #3b2a6b, transparent), linear-gradient(#12122e, #1d1340);
  background-attachment: fixed;
}
[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}
button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--hi); color: var(--hi); }
button[aria-pressed='true'] { background: var(--fg); color: var(--bg); }
button.primary { border-color: var(--accent); color: var(--hi); background: var(--accent); }
body[data-theme='classic'] button.primary { background: #00a; border-color: #55f; }
body[data-theme='modern'] button.primary { color: #1d1330; font-weight: 700; }
button.link { border: 0; text-decoration: underline; padding: 0; }
input {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 8px;
  min-width: 0;
}
body[data-theme='modern'] input { background: rgba(0, 0, 0, 0.25); }
select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 8px;
  margin-left: 6px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Lobby ---------- */
#lobby {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 32px;
}
.title { text-align: center; }
.title h1 { color: var(--hi); font-size: 2.2em; font-weight: normal; margin: 0 0 4px; letter-spacing: 0.02em; }
body[data-theme='modern'] .title h1 { font-weight: 800; letter-spacing: 0.08em; font-size: clamp(1.3em, 4.5vw, 2.4em); color: #ffd84a; }
.title h1 { white-space: nowrap; font-size: clamp(1.2em, 4.5vw, 2.2em); }
.title .sub { margin: 0 0 16px; }
.intro-text { max-width: 640px; margin: 0 auto 8px; }

/* Funkelrahmen wie SparklePause */
body[data-theme='classic'] .sparkle {
  position: absolute; inset: 8px; pointer-events: none;
  border: 10px solid transparent;
  border-image: repeating-linear-gradient(90deg, #a00 0 10px, transparent 10px 50px) 10;
  animation: sparkle 0.4s steps(5) infinite;
}
@keyframes sparkle { to { border-image-source: repeating-linear-gradient(90deg, transparent 0 40px, #a00 40px 50px); } }

.panel {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 16px;
}
.row { display: grid; gap: 4px; }
.settings { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.settings label { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 12px; }
.settings label.check, label.check { display: flex; gap: 8px; align-items: center; }
/* Lobby-Raster: links Spielen, rechts Räume und Chat */
.lobby-grid {
  margin-top: 24px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  grid-template-areas: 'play rooms' 'play chat';
  align-items: start;
}
.lobby-grid .play { grid-area: play; }
.lobby-grid .rooms { grid-area: rooms; }
.lobby-grid .chat { grid-area: chat; }
.panel h2 { margin: 0; font-size: 1.15em; color: var(--hi); font-weight: normal; }
body[data-theme='modern'] .panel h2 { font-weight: 700; }
.panel h3 { margin: 4px 0 0; font-size: 0.95em; font-weight: normal; opacity: 0.8; }
button.big { padding: 12px; font-size: 1.15em; }
.hint { margin: -10px 0 0; font-size: 0.85em; opacity: 0.75; }
.stack { display: grid; gap: 10px; margin-top: 10px; }
.settings-box .settings { margin-top: 10px; border: 0; padding: 0; }
.rooms-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.online { font-size: 0.9em; opacity: 0.85; }
.online::before { content: '●'; color: #4cd964; margin-right: 6px; }
.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.room-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px;
}
.room-list li > div:first-child { min-width: 0; display: grid; }
.room-list strong { color: var(--hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-list small { opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-btns { display: flex; gap: 6px; flex-shrink: 0; }
.empty { margin: 0; font-size: 0.9em; opacity: 0.7; }

/* Chat */
.chat .msgs {
  list-style: none; margin: 0; padding: 0 4px 0 0;
  height: 200px; overflow-y: auto; display: grid; align-content: start; gap: 2px;
  font-size: 0.95em;
}
.chat .msgs li { overflow-wrap: anywhere; }
.chat time { opacity: 0.55; font-size: 0.85em; }
.chat b { color: var(--hi); font-weight: 600; }
.chat li[data-seat='1'] b { color: #ffb36b; }
.chat li[data-seat='2'] b { color: #7fd1ff; }
.chat form { display: flex; gap: 8px; }
.chat form input { flex: 1; }
.chat .quick { display: flex; flex-wrap: wrap; gap: 6px; }
.chat .quick button { font-size: 0.85em; padding: 2px 10px; }
.chat .chat-error:empty { display: none; }
#room-chat { margin: 12px auto 0; max-width: 820px; gap: 10px; }
#room-chat .msgs { height: 140px; }
details { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
summary { cursor: pointer; color: var(--hi); }
.join { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.join input { width: 140px; text-transform: uppercase; }
#name2 { text-transform: none; }
.error { color: var(--error); min-height: 1.2em; margin: 0; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Spiel ---------- */
#game { max-width: 1280px; margin: 0 auto; padding: 8px 16px 24px; }
.topbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.topbar .spacer { flex: 1; }
#room-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#room-code { color: var(--hi); letter-spacing: 0.15em; font-size: 1.2em; }
.stage { position: relative; }
#screen {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 170px);
  object-fit: contain;
  margin: 0 auto;
  image-rendering: pixelated;
  background: #000;
}
#screen[data-mode='classic'] { aspect-ratio: 4 / 3; }
#screen[data-mode='modern'] { aspect-ratio: 640 / 350; image-rendering: auto; border-radius: var(--radius); }
.conn, .gameover {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: var(--bg); border: 2px solid var(--fg); border-radius: var(--radius);
  padding: 12px 20px; text-align: center;
}
.conn { top: 12px; }
.gameover { top: 22%; min-width: 260px; }
body[data-theme='modern'] .gameover { background: rgba(18, 18, 46, 0.92); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.gameover h2 { color: var(--hi); margin: 0 0 8px; font-weight: normal; }
.gameover table { margin: 0 auto 14px; border-spacing: 24px 2px; }
.gameover td:last-child { text-align: right; color: var(--hi); }
.status { min-height: 1.4em; margin: 8px 0; text-align: center; }
.shot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 18px; }
.shot .ctl { display: flex; align-items: center; gap: 8px; }
.shot input:not([type='range']) { width: 76px; text-align: right; }
.shot input[type='range'] { width: 200px; accent-color: var(--accent); padding: 0; border: 0; background: transparent; }
body[data-theme='classic'] .shot input[type='range'] { accent-color: #55f; }
.shot .unit { margin-left: -4px; display: inline-block; width: 0.6em; }
.shot small { width: 100%; text-align: center; opacity: 0.7; }
#shot-player { color: var(--hi); }

@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'play' 'rooms' 'chat'; }
}

@media (max-width: 600px) {
  #lobby { padding-left: 16px; padding-right: 16px; }
  .shot .ctl { width: 100%; }
  .shot input[type='range'] { flex: 1; width: auto; }
  .room-list li { flex-wrap: wrap; }
  #lobby { padding-top: 32px; }
  .title h1 { font-size: 1.5em; }
  .settings label { grid-template-columns: 1fr 90px; }
  .shot small { display: none; }
  #screen { max-height: none; }
  .topbar { gap: 6px; font-size: 0.85em; }
  .topbar button { padding: 2px 8px; }
}
