/* Kopf oder Zahl — Anthrazit + Gold, WCAG-AA-Kontraste, Tabular Figures */
:root {
  --bg0: #0a0b0e;
  --bg1: #101116;
  --panel: #17181d;
  --panel2: #1e2026;
  --border: #2a2d35;
  --border-hi: #3a3e48;
  --text: #eceae4;
  --muted: #a5a29a;
  --gold: #d4af37;
  --gold-hi: #ecc95c;
  --gold-dark: #191204;
  --green: #3ddc84;
  --green-deep: #0f3d26;
  --red: #f0506e;
  --red-deep: #3d1019;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input {
  font: inherit; color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
input:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.82em; word-break: break-all; }

#app { height: 100%; display: flex; flex-direction: column; }

/* ---- Topbar ---------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand {
  font-weight: 800; letter-spacing: 0.14em; font-size: 1.02rem;
  display: flex; align-items: center; gap: 10px;
}
.brand em { font-style: normal; color: var(--gold); font-weight: 600; letter-spacing: 0.06em; }
.brand-coin {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #f0d98c 0%, #d4af37 45%, #8a6d1c 100%);
  box-shadow: inset 0 0 0 3px rgba(215, 216, 211, 0.85), 0 0 10px rgba(212, 175, 55, 0.45);
}
.balance-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 8px 7px 14px;
}
.balance-box b { color: var(--gold-hi); font-size: 1.05rem; }

/* ---- Layout ---------------------------------------------------------------- */
.layout {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 330px 1fr;
}

/* ---- Panel ----------------------------------------------------------------- */
.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg1);
  border-radius: var(--radius);
  padding: 4px; gap: 4px;
}
.tab {
  padding: 9px 0; border-radius: 7px; font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--panel2); color: var(--text); }
.tab:hover:not(.active) { color: var(--text); }

.lbl { font-size: 0.82rem; color: var(--muted); margin-top: 4px; display: block; }

.bet-row { display: flex; gap: 6px; }
.bet-input-wrap { position: relative; flex: 1 1 auto; }
.bet-input-wrap .cur {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gold); font-weight: 700; pointer-events: none;
}
.bet-input-wrap input { padding-right: 30px; font-weight: 600; }
.mini-btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px; font-weight: 600; min-width: 40px;
}
.mini-btn:hover { border-color: var(--border-hi); background: #23252c; }
.mini-btn:active { transform: translateY(1px); }

.hit-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 2px 2px 0;
  font-size: 0.84rem;
}
.hit-line b { color: var(--green); font-size: 0.95rem; }

/* Serien-Zustand: das Herzstück während einer laufenden Serie */
.series-card {
  background: linear-gradient(180deg, #221c0d 0%, #1a1509 100%);
  border: 1px solid rgba(212, 175, 55, 0.55);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
  animation: card-in 0.25s ease-out;
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.12);
}
@keyframes card-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.sc-label { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.sc-amount { font-size: 1.7rem; font-weight: 800; color: var(--gold-hi); line-height: 1.25; }
.sc-next { font-size: 0.82rem; color: var(--text); }
.sc-next b { color: var(--green); }

/* Ein-Klick-Wurf: die Seite IST der Wurf */
.throws { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.throw-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 72px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.throw-btn canvas {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
}
.tb-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.tb-name { font-weight: 800; letter-spacing: 0.06em; font-size: 0.98rem; }
.tb-sub { font-size: 0.72rem; color: var(--muted); }
.throw-btn.kopf:hover:not(:disabled) {
  border-color: #c8c9c4; background: #22242a;
  box-shadow: 0 0 16px rgba(200, 201, 196, 0.15);
}
.throw-btn.zahl:hover:not(:disabled) {
  border-color: var(--gold); background: #23200f;
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.18);
}
.throw-btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.throw-btn:disabled { opacity: 0.5; cursor: default; }

.turbo-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.86rem; font-weight: 600;
  transition: border-color 0.15s, color 0.15s;
}
.turbo-toggle svg { width: 15px; height: 15px; }
.turbo-toggle .tt-state { margin-left: auto; font-size: 0.76rem; }
.turbo-toggle.active { color: var(--gold-hi); border-color: rgba(212, 175, 55, 0.6); }
.turbo-toggle.active .tt-state { color: var(--gold-hi); }

.seg3 { grid-template-columns: 1fr 1fr 1fr; }

.primary {
  width: 100%;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 60%, #b8943f 100%);
  color: var(--gold-dark);
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.03em;
  border-radius: var(--radius);
  padding: 15px 0;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.25);
  margin-top: 4px;
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: translateY(1px); }
.primary:disabled {
  background: var(--panel2); color: var(--muted);
  box-shadow: none; cursor: default;
}
.cashout {
  width: 100%;
  background: linear-gradient(180deg, #46e392 0%, #27b96a 100%);
  color: #06230f;
  font-weight: 800; font-size: 1.02rem;
  border-radius: var(--radius);
  padding: 13px 0;
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(61, 220, 132, 0.22);
}
.cashout:hover { filter: brightness(1.06); }
.cashout:disabled { filter: grayscale(0.6) brightness(0.7); cursor: default; }

.auto-grid { display: flex; flex-direction: column; gap: 6px; }
.strategy-row { display: flex; gap: 6px; align-items: stretch; }
.strategy-row .strat { flex: 0 0 auto; font-size: 0.82rem; }
.strat.active { border-color: var(--gold); color: var(--gold-hi); }
.strat-inc { display: flex; gap: 4px; align-items: center; flex: 1 1 auto; }
.strat-inc input { width: 56px; padding: 6px 8px; text-align: right; }
.strat-inc span { color: var(--muted); }

.hotkeys { font-size: 0.72rem; margin-top: auto; padding-top: 10px; text-align: center; }

/* ---- Stage ------------------------------------------------------------------ */
.stage {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background:
    radial-gradient(120% 90% at 50% 30%, #1c1e26 0%, var(--bg1) 55%, var(--bg0) 100%);
}
.history {
  display: flex; gap: 6px; align-items: center;
  padding: 10px 16px 0;
  min-height: 44px;
  overflow-x: auto;
  scrollbar-width: none;
}
.history::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-width: 54px; height: 30px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: 15px;
  font-size: 0.78rem; font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--border);
  animation: chip-in 0.25s ease-out;
  padding: 0 10px;
}
@keyframes chip-in { from { transform: translateX(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.chip .dot {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 800; color: #10110a;
}
.chip .dot.kopf { background: #d7d8d3; }
.chip .dot.zahl { background: #dcb96f; }
.chip.win { border-color: rgba(61, 220, 132, 0.55); color: var(--green); }
.chip.lose { border-color: rgba(240, 80, 110, 0.5); color: var(--red); }

.stage-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.stage-wrap canvas#stage3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cinema-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.cinema-fx {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 3;
}

.series-badge {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(23, 24, 29, 0.82);
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 20px;
  padding: 7px 18px;
  backdrop-filter: blur(6px);
}
.sb-step { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.sb-mult { font-size: 1.05rem; color: var(--gold-hi); font-weight: 800; }

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  animation: ov-in 0.3s ease-out;
}
@keyframes ov-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.overlay .ov-mult {
  font-size: 3rem; font-weight: 900; letter-spacing: 0.02em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
}
.overlay .ov-amount {
  font-size: 1.4rem; font-weight: 700; margin-top: 4px;
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.8);
}
.overlay.win .ov-mult { color: var(--gold-hi); }
.overlay.win .ov-amount { color: var(--green); }
.overlay.lose .ov-mult { color: var(--red); font-size: 2rem; }
.overlay.lose .ov-amount { color: var(--muted); }

/* ---- Leiter ----------------------------------------------------------------- */
.ladder {
  display: flex; gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  flex: 0 0 auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.rung {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
  min-width: 66px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.rung .r-step { font-size: 0.66rem; color: var(--muted); font-weight: 600; }
.rung .r-mult { font-size: 0.82rem; font-weight: 700; }
.rung.done { border-color: var(--gold); background: #221d0e; }
.rung.done .r-mult { color: var(--gold-hi); }
.rung.next { border-color: var(--gold-hi); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
  50% { box-shadow: 0 0 12px 1px rgba(212, 175, 55, 0.4); }
}

/* ---- Gamebar ---------------------------------------------------------------- */
.gamebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg1);
  flex: 0 0 auto;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.gb-left { display: flex; align-items: baseline; gap: 12px; }
.gb-name { font-weight: 700; font-size: 0.88rem; }
.gb-rtp { font-size: 0.78rem; }
.gb-right { display: flex; gap: 4px; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--muted);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.icon-btn.active { color: var(--gold-hi); background: #221d0e; }

/* ---- Modals ------------------------------------------------------------------ */
.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 0;
  margin: auto; /* zentrieren — der globale Reset überschreibt sonst das Dialog-Default */
  width: min(560px, calc(100vw - 32px));
  max-height: min(82vh, 720px);
}
.modal::backdrop { background: rgba(5, 6, 8, 0.72); backdrop-filter: blur(3px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.05rem; letter-spacing: 0.02em; }
.modal-body { padding: 16px 18px 20px; overflow-y: auto; max-height: calc(82vh - 60px); }
.modal-body p { margin-bottom: 12px; line-height: 1.55; font-size: 0.92rem; }
.kv {
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.kv > span:first-child { color: var(--muted); flex: 0 0 auto; }
.kv code { text-align: right; }
.kv-edit { display: flex; gap: 6px; flex: 1 1 auto; justify-content: flex-end; }
.kv-edit input { max-width: 200px; padding: 6px 10px; }
.revealed { margin-top: 12px; }
.revealed .rv {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
  font-size: 0.8rem;
}
.revealed .rv code { display: block; margin: 2px 0 6px; color: var(--gold-hi); }
.tbl-wrap { overflow-x: auto; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--gold); font-weight: 600; }

.dist { margin-bottom: 12px; }
.dist-bar {
  display: flex; height: 18px; border-radius: 9px; overflow: hidden;
  background: var(--bg1); border: 1px solid var(--border);
}
.dist-kopf { background: #d7d8d3; }
.dist-zahl { background: #dcb96f; }
.dist-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.84rem; color: var(--muted); }
.dist-legend b { color: var(--text); }

a { color: var(--gold-hi); }

.primary.stop {
  background: linear-gradient(180deg, #f0708a 0%, var(--red) 70%, #b32744 100%);
  color: #2a060e;
  box-shadow: 0 4px 16px rgba(240, 80, 110, 0.25);
}

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  background: var(--panel2);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Responsive -------------------------------------------------------------- */
@media (max-width: 880px) {
  body { overflow-y: auto; overflow-x: hidden; }
  #app { height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; }
  .stage { order: 0; }
  .panel {
    order: 1;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .stage-wrap { height: 44vh; flex: 0 0 auto; }
  .hotkeys { display: none; }
  .overlay .ov-mult { font-size: 2.2rem; }
  .primary { padding: 16px 0; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 0.78rem; gap: 6px; letter-spacing: 0.1em; flex: 0 1 auto; min-width: 0; }
  .brand-coin { width: 17px; height: 17px; flex: 0 0 auto; }
  .balance-box { padding: 5px 6px 5px 10px; gap: 6px; flex: 0 0 auto; }
  .balance-box b { font-size: 0.95rem; }
  .balance-box .muted { display: none; }
  .gb-rtp { white-space: nowrap; }
  .gamebar { flex-wrap: wrap; gap: 4px; }
}
