@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 800; font-style: normal; font-display: swap; src: url('fonts/inter-800.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 900; font-style: normal; font-display: swap; src: url('fonts/inter-900.woff2') format('woff2'); }

:root {
  --blau: #004F9F; --gruen: #63B32E; --gelb: #FAE100; --rot: #B31A30; --beige: #EDE1CA; --grau: #3A3A3A;
  --bg: #06152c; --bg2: #0b2a56; --panel: rgba(255,255,255,0.06); --text: #ffffff; --muted: rgba(255,255,255,0.72); --line: rgba(255,255,255,0.14);
  --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px);
  --vvh: 100vh; --ctrlw: 230px; --fsw: 170px;
}
@supports (height: 100dvh) { :root { --vvh: 100dvh; } }
html.light { --bg: #EDE1CA; --bg2: #f6efe0; --panel: rgba(0,79,159,0.06); --text: #1d2a3a; --muted: #4a5666; --line: rgba(0,79,159,0.18); }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); color: var(--text); font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-weight: 600; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body { min-height: 100vh; min-height: var(--vvh); background: radial-gradient(120% 70% at 50% 0%, var(--bg2) 0%, var(--bg) 70%); overflow-x: hidden; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 0 max(10px, var(--sar)) 0 max(10px, var(--sal)); }
#sa-probe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; padding: var(--sat) var(--sar) var(--sab) var(--sal); }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -0.01em; }
a { color: var(--gruen); }
button, select, input { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 10px; padding: 8px 12px; font-weight: 700; touch-action: manipulation; }
button:hover { border-color: var(--gruen); }
button.primary { background: var(--gelb); color: #1d2a3a; border-color: var(--gelb); font-weight: 900; }
button.primary:hover { background: #ffef5c; }
kbd { background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-family: inherit; }
html.light kbd { background: rgba(255,255,255,0.6); }

#head { display: flex; align-items: center; gap: 14px; padding: max(10px, var(--sat)) max(14px, var(--sar)) 6px max(14px, var(--sal)); max-width: 980px; margin: 0 auto; width: 100%; }
.logo-plate { background: #fff; border-radius: 10px; padding: 6px 10px; display: block; flex: 0 0 auto; width: 150px; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.logo-plate img { width: 100%; height: auto; display: block; }
.head-text h1 { font-size: clamp(18px, 4.5vw, 28px); line-height: 1.05; }
.head-text h1 span { color: var(--gruen); }
.claim { margin: 2px 0 0; color: var(--muted); font-size: clamp(11px, 2.8vw, 14px); font-weight: 700; }

#tabs { display: flex; gap: 6px; max-width: 980px; margin: 0 auto; padding: 4px 10px 8px; width: 100%; }
.tab { flex: 1; padding: 9px 6px; border-radius: 10px; font-weight: 800; }
.tab.active { background: var(--blau); color: #fff; border-color: var(--blau); }

.panel { width: 100%; }
.panel[hidden] { display: none !important; }
#panel-play { display: flex; flex-direction: column; align-items: center; }
#stage-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; min-height: 0; }
#stage { position: relative; width: 100%; aspect-ratio: 500 / 720; max-width: 100%; flex: 0 0 auto; border-radius: 10px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.5); background: #000; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game { width: 100%; height: 100%; display: block; }
#bigled[hidden] { display: none; }
#bigled { display: block; margin: 2px auto 4px; border-radius: 8px; background: #000; box-shadow: 0 0 20px rgba(99,179,46,0.25); }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(4,10,30,0.72); padding: 14px; z-index: 5; }
.overlay[hidden] { display: none; }
.card { background: #0e2447; color: #fff; border: 1px solid rgba(255,255,255,0.15); border-radius: 14px; padding: 18px; width: min(100%, 400px); max-height: 100%; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.6); text-align: center; }
.card h2 { font-size: 24px; color: var(--gelb); margin-bottom: 8px; }
.card p { margin: 8px 0; font-size: 14px; line-height: 1.4; }
.card .small { font-size: 11.5px; color: rgba(255,255,255,0.75); }
.card .primary { font-size: 17px; padding: 11px 22px; margin: 6px 0; }
.card .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.card input { flex: 1; min-width: 140px; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); color: #fff; }
.card label { display: block; font-size: 12px; margin-bottom: 6px; color: rgba(255,255,255,0.8); }
.big-score { font-size: 30px; font-weight: 900; color: var(--gruen); margin: 2px 0; }
.big-score span { font-variant-numeric: tabular-nums; }
.tip { font-style: italic; color: var(--gelb); }
.tables { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.tbl { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 13px; }
.tbl.active { border-color: var(--gelb); background: rgba(250,225,0,0.15); }
.sw { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.5); display: inline-block; }
.sw-blau { background: #004F9F; } .sw-hell { background: #EDE1CA; } .sw-nacht { background: #111; } .sw-court { background: #63B32E; }
.cta { display: inline-block; margin: 10px 0 0; padding: 10px 16px; background: var(--gelb); color: #1d2a3a; border-radius: 10px; font-weight: 900; text-decoration: none; }
.cta:hover { background: #ffef5c; }

#toast { position: absolute; left: 50%; bottom: 10%; transform: translate(-50%, 10px); background: rgba(0,0,0,0.78); color: #fff; padding: 8px 14px; border-radius: 20px; font-size: clamp(11px, 2.6vw, 14px); font-weight: 800; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; max-width: 95%; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgba(250,225,0,0.5); z-index: 4; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#ctrl { width: 100%; padding: 8px 0 10px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#panel-play.side { flex-direction: row; align-items: flex-start; justify-content: center; gap: 14px; }
#panel-play.side #stage-wrap { width: auto; flex: 0 1 auto; }
#panel-play.side #ctrl { width: var(--ctrlw); flex: 0 0 var(--ctrlw); padding: 0; align-items: stretch; gap: 10px; }
#panel-play.side .hud { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; text-align: left; }
#panel-play.side .hud span { display: flex; justify-content: space-between; gap: 6px; }
#panel-play.side .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#panel-play.side .buttons .sel { grid-column: 1 / -1; justify-content: space-between; }
#panel-play.side .buttons button, #panel-play.side .sel { width: 100%; }
#panel-play.side #touch-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: none; }
#panel-play.side #touch-ctrl[hidden] { display: none; }
#panel-play.side #tb-left { grid-row: 1; grid-column: 1; }
#panel-play.side #tb-right { grid-row: 1; grid-column: 2; }
#panel-play.side #tb-launch { grid-row: 2; grid-column: 1 / -1; }
.hud { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--muted); }
.hud b { color: var(--text); font-variant-numeric: tabular-nums; }
.buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.buttons button, .sel { font-size: 12.5px; padding: 7px 10px; }
.sel { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.sel select { background: transparent; color: var(--text); border: 0; font-weight: 700; }
.sel select option { color: #000; }
#touch-ctrl { display: flex; gap: 8px; width: 100%; max-width: 520px; }
#touch-ctrl[hidden] { display: none; }
#touch-ctrl button { flex: 1; padding: 14px 6px; font-size: 14px; font-weight: 900; touch-action: none; user-select: none; -webkit-user-select: none; }

#panel-scores, #panel-rules { padding: 6px 4px 20px; }
#panel-scores h2, #panel-rules h2 { font-size: 22px; margin-bottom: 6px; }
#panel-rules h3 { margin: 16px 0 6px; }
.small { font-size: 12.5px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 10px 0; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gruen); font-weight: 800; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); }
table.rules td:nth-child(2) { white-space: nowrap; }

#foot { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; padding: 14px 10px calc(24px + var(--sab)); font-size: 12px; color: var(--muted); }
#foot a { color: var(--muted); }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
#modal[hidden] { display: none; }
.modal-card { position: relative; background: #fff; color: #1d2a3a; border-radius: 14px; padding: 22px; width: min(100%, 560px); max-height: 90vh; overflow: auto; }
.modal-card h2 { color: var(--blau); font-size: 20px; margin: 10px 0 6px; }
.modal-card p { line-height: 1.5; font-size: 14px; }
.modal-card a { color: var(--blau); }
.modal-close { position: absolute; top: 8px; right: 8px; font-size: 22px; line-height: 1; padding: 2px 10px; background: #f1f1f1; color: #333; border-color: #ddd; }

/* ---- eigener Vollbild-Modus (ohne requestFullscreen) ---- */
#fsbar { display: none; }
html.fs, html.fs body { overflow: hidden; height: 100vh; height: var(--vvh); min-height: 0; background: #000; overscroll-behavior: none; position: relative; }
html.fs #head, html.fs #tabs, html.fs #foot, html.fs #ctrl { display: none; }
html.fs main { max-width: none; padding: 0 var(--sar) var(--sab) var(--sal); height: 100%; display: flex; flex-direction: column; }
html.fs #panel-play { height: 100%; justify-content: flex-start; overflow: hidden; }
html.fs #fsbar { display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px 8px; padding-top: max(4px, var(--sat)); flex: 0 0 auto; background: #000; color: #fff; font-size: 12px; font-weight: 800; min-height: 34px; white-space: nowrap; overflow: hidden; }
#fsbar .fs-score { color: var(--gruen); font-size: 15px; font-variant-numeric: tabular-nums; }
#fsbar .fs-modes { color: var(--gelb); }
#fsbar .fs-spacer { flex: 1; }
#fsbar .mini { padding: 3px 8px; font-size: 11px; background: #1b1b1b; border-color: #333; color: #fff; }
html.fs #stage-wrap { flex: 1; min-height: 0; justify-content: flex-end; }
html.fs #stage { border-radius: 0; box-shadow: none; }
/* Vollbild im Querformat: Infoleiste als Spalte links, LED-Tafel neben dem Tisch */
html.fs #panel-play.side { flex-direction: row; align-items: stretch; justify-content: flex-start; gap: 0; }
html.fs #panel-play.side #fsbar { flex-direction: column; align-items: stretch; width: var(--fsw); flex: 0 0 var(--fsw); height: 100%; padding: max(8px, var(--sat)) 8px 8px; gap: 6px; white-space: normal; text-align: center; }
html.fs #panel-play.side #fsbar .fs-score { font-size: 22px; }
html.fs #panel-play.side #fsbar .mini { padding: 6px 8px; font-size: 12px; }
html.fs #panel-play.side #stage-wrap { flex: 1 1 auto; min-width: 0; height: 100%; flex-direction: row; justify-content: center; align-items: center; gap: 12px; }
html.fs #panel-play.side #bigled { margin: 0; }

/* ---- kleine Handys ---- */
@media (max-width: 420px) {
  .card { padding: 12px; }
  .card h2 { font-size: 20px; margin-bottom: 4px; }
  .card p { font-size: 12.5px; margin: 5px 0; }
  .card .small { font-size: 10.5px; }
  .card .primary { font-size: 15px; padding: 9px 18px; margin: 4px 0; }
  .tables { gap: 4px; margin: 6px 0; }
  .tbl { padding: 5px 8px; font-size: 12px; }
  .big-score { font-size: 26px; }
  html.fs #fsbar { gap: 6px; font-size: 11px; padding: 3px 6px; }
  #fsbar .fs-score { font-size: 13px; }
  #fsbar .mini { padding: 2px 6px; font-size: 10px; }
  #fsbar #fs-streak { display: none; }
}
@media (max-height: 700px) and (max-width: 420px) {
  #head { gap: 10px; padding-top: max(6px, var(--sat)); padding-bottom: 4px; }
  .logo-plate { width: 100px; padding: 4px 6px; }
  .head-text h1 { font-size: 18px; }
  .claim { font-size: 10px; }
  #tabs { padding-top: 2px; padding-bottom: 4px; }
  .tab { padding: 6px 4px; font-size: 12px; }
  #ctrl { padding: 6px 0; gap: 6px; }
  .hud { gap: 10px; font-size: 12px; }
  .buttons button, .sel { padding: 6px 8px; font-size: 12px; }
  #touch-ctrl button { padding: 10px 4px; font-size: 12px; }
  .card p:not(.small):not(.big-score):not(.tip) { display: none; }
}
/* Handy quer: Kopf und Tabs lassen mindestens 55 % der Höhe für den Tisch.
   Die Bedienelemente stehen rechts und kosten keine Tischhöhe. */
@media (max-height: 500px) and (min-width: 600px) and (max-width: 950px) {
  #head { gap: 10px; padding-top: max(4px, var(--sat)); padding-bottom: 2px; }
  .logo-plate { width: 80px; padding: 3px 6px; }
  .head-text h1 { font-size: 18px; }
  .claim { display: none; }
  #tabs { padding-top: 2px; padding-bottom: 4px; }
  .tab { padding: 4px 6px; font-size: 12px; }
  #panel-play.side #ctrl { gap: 6px; }
  #panel-play.side .hud { font-size: 12px; gap: 4px 8px; }
  #panel-play.side .buttons button, #panel-play.side .sel { padding: 5px 8px; font-size: 12px; }
  #panel-play.side #touch-ctrl button { padding: 9px 4px; font-size: 12px; }
}

/* Titel bleibt ein Overlay innerhalb des berechneten Tisches; KI-Label oben links frei. */
#stage { container-type: size; }
#overlay-start { background: #06101b url('img/titel.webp') center / 100% 100% no-repeat; padding: 0; }
#overlay-start .card { width: 100%; height: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; overflow: hidden; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 10% 5% 3%; }
.start-logo { width: 43%; max-width: 170px; height: auto; background: white; border-radius: 8px; padding: 5px 8px; }
#overlay-start h2 { font-size: clamp(16px, 5.8cqw, 28px); line-height: 1.05; margin: 8px 0 2px; text-shadow: 0 2px 10px #000; }
#overlay-start h2 span { color: #63B32E; }
#overlay-start .start-claim { font-size: clamp(9px, 2.7cqw, 13px); margin: 4px 0; color: white; text-shadow: 0 2px 8px #000; }
#overlay-start .tables { margin: auto 0 4px; gap: 4px; }
#overlay-start .tbl { padding: 5px 6px; font-size: clamp(9px, 2.8cqw, 13px); background: rgba(4,16,34,.92); color: white; }
#overlay-start .tbl.active { background: #004F9F; }
#overlay-start .sw { width: 10px; height: 10px; }
#overlay-start .primary { font-size: clamp(12px, 4cqw, 18px); margin: 4px 0; padding: 8px 22px; }
#overlay-start .small { font-size: clamp(8px, 2.5cqw, 11px); line-height: 1.35; margin: 3px 0; text-shadow: 0 1px 4px #000; }
@container (max-height: 420px) {
  #overlay-start .small { display: none; }
  #overlay-start .start-claim { display: block; }
  #overlay-start h2 { margin-top: 4px; }
  #overlay-start .tbl { padding: 4px; }
}
