:root {
  color-scheme: dark;
  --bg: #08121d;
  --surface: #101d2a;
  --surface-raised: #142434;
  --surface-soft: #0d1823;
  --line: #233646;
  --line-strong: #334a5d;
  --text: #edf4f8;
  --muted: #91a6b6;
  --faint: #6d8496;
  --mint: #83e7c1;
  --mint-dark: #1b5849;
  --blue: #8cb8f8;
  --coral: #ff8b9a;
  --red: #b8475b;
  --green: #27785b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: radial-gradient(ellipse at 52% -22%, #1c3448 0, transparent 52%), var(--bg); }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: clamp(26px, 6vw, 42px); border: 1px solid rgba(145, 166, 182, .19); border-radius: 18px; background: linear-gradient(155deg, rgba(20, 36, 52, .97), rgba(13, 24, 35, .98)); box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
.auth-brand { margin-bottom: 36px; }
.auth-card h1 { margin-bottom: 10px; font-size: clamp(28px, 5vw, 36px); }
.auth-copy { margin-bottom: 26px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card input[type="password"] { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: #0b1722; }
.auth-card .start-button { width: 100%; }
.auth-note { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.login-error { margin: 0; color: #ffacb5; font-size: 12px; line-height: 1.5; }
.auth-content { min-height: 100vh; }
.logout-button { min-width: 84px; }
button, input, select { font: inherit; }
button, select, input[type="range"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 56px); border-bottom: 1px solid rgba(145, 166, 182, .13); background: rgba(8, 18, 29, .82); }
.brand { min-height: 44px; display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand-mark { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid rgba(131, 231, 193, .55); border-radius: 12px; color: var(--mint); font-size: 19px; font-weight: 750; box-shadow: inset 0 0 16px rgba(131, 231, 193, .07); }
.brand strong, .brand small { display: block; letter-spacing: .16em; }
.brand strong { font-size: 12px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.mode-badge, .connection-state { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .11em; }
.mode-badge { padding: 8px 10px; border: 1px solid var(--line); border-radius: 99px; background: rgba(20, 36, 52, .55); }
.live-dot, .status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px rgba(131, 231, 193, .6); }
.connection-state { letter-spacing: .02em; text-transform: none; font-size: 12px; }

.app-shell { width: min(1600px, 100%); margin: 0 auto; padding: 36px clamp(16px, 3vw, 44px) 52px; }
.intro-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--mint); font-size: 9px; font-weight: 750; letter-spacing: .17em; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 720px; margin-bottom: 8px; font-size: clamp(27px, 3vw, 40px); line-height: 1.08; letter-spacing: -.04em; text-wrap: balance; }
.lede { max-width: 760px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.seed-chip { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; margin-bottom: 3px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 99px; color: #bdd0dd; font-size: 11px; background: rgba(16, 29, 42, .7); }
.seed-symbol { color: var(--mint); font-size: 17px; }

.workspace { display: grid; grid-template-columns: minmax(240px, 286px) minmax(440px, 1fr) minmax(240px, 286px); align-items: start; gap: 16px; }
.panel { min-width: 0; overflow: hidden; border: 1px solid rgba(145, 166, 182, .16); border-radius: 16px; background: linear-gradient(155deg, rgba(20, 36, 52, .94), rgba(13, 24, 35, .97)); box-shadow: 0 20px 55px rgba(0, 0, 0, .18); }
.setup-panel, .history-panel { padding: 20px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
h2 { margin-bottom: 0; font-size: 16px; letter-spacing: -.02em; }
.step-number { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.form-stack { display: grid; gap: 12px; }
.field-label { display: block; margin: 5px 0 -4px; color: #bac9d4; font-size: 11px; font-weight: 650; }
input[type="number"], select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: #0b1722; font-size: 12px; }
input[type="number"] { font-variant-numeric: tabular-nums; }
select { cursor: pointer; }
select option { background: var(--surface); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid > div { min-width: 0; }
.field-grid input { min-width: 0; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: 11px; font-weight: 750; transition-property: background-color, border-color, color, scale, opacity; transition-duration: 150ms; transition-timing-function: ease-out; }
.button:active:not(:disabled) { scale: .96; }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { color: #071a17; background: var(--mint); box-shadow: 0 6px 20px rgba(131, 231, 193, .12); }
.button-primary:hover:not(:disabled) { background: #a2f4d5; }
.start-button { margin-top: 8px; min-height: 47px; font-size: 12px; }
.button-icon { font-size: 12px; }
.button-secondary { border-color: var(--line-strong); color: #cfdae2; background: #142433; }
.button-secondary:hover:not(:disabled) { border-color: #587187; background: #1b3042; }
.button-danger { border-color: rgba(255, 139, 154, .28); color: var(--coral); background: rgba(184, 71, 91, .12); }
.button-danger:hover:not(:disabled) { background: rgba(184, 71, 91, .23); }
.setup-note { display: flex; gap: 9px; margin-top: 17px; padding: 12px 11px; border: 1px solid rgba(140, 184, 248, .16); border-radius: 10px; color: #a8bfd1; background: rgba(64, 108, 161, .08); }
.setup-note > span { width: 16px; height: 16px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(140, 184, 248, .48); border-radius: 50%; color: var(--blue); font-size: 10px; font-weight: 700; }
.setup-note p { margin: 0; color: #c0d1dc; font-size: 11px; line-height: 1.55; }
.settings-box { margin-top: 17px; border-top: 1px solid rgba(145, 166, 182, .13); }
.settings-box summary { min-height: 44px; display: flex; align-items: center; padding: 5px 0; color: #b9c8d3; cursor: pointer; font-size: 11px; font-weight: 650; }
.compact-form { margin-top: 8px; gap: 9px; }
.compact-form .button { margin-top: 5px; }

.main-column { display: grid; gap: 16px; }
.live-panel { padding: 20px 22px 17px; }
.live-heading { align-items: center; margin-bottom: 16px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: #aebfcb; font-size: 10px; background: rgba(8, 18, 29, .4); }
.status-dot { width: 6px; height: 6px; background: #72899a; box-shadow: none; }
.status-pill[data-status="running"] .status-dot { background: var(--mint); box-shadow: 0 0 11px rgba(131, 231, 193, .55); }
.status-pill[data-status="paused"] .status-dot { background: #f3c56d; box-shadow: 0 0 10px rgba(243, 197, 109, .4); }
.status-pill[data-status="completed"] .status-dot { background: var(--blue); box-shadow: 0 0 10px rgba(140, 184, 248, .4); }
.status-pill[data-status="failed"], .status-pill[data-status="aborted"] { color: var(--coral); }
.status-pill[data-status="failed"] .status-dot, .status-pill[data-status="aborted"] .status-dot { background: var(--coral); }
.game-stage { min-height: 260px; position: relative; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(145, 166, 182, .13); border-radius: 13px; background: radial-gradient(ellipse at 50% 43%, rgba(32, 77, 72, .3), transparent 52%), repeating-linear-gradient(0deg, transparent 0 39px, rgba(145, 166, 182, .025) 40px), #0a1721; }
.roulette-stage { width: 220px; height: 220px; position: relative; display: grid; place-items: center; }
.roulette-ring { width: 192px; height: 192px; position: absolute; border: 1px solid rgba(131, 231, 193, .34); border-radius: 50%; box-shadow: 0 0 42px rgba(56, 148, 119, .12), inset 0 0 26px rgba(56, 148, 119, .1); }
.roulette-ring::before, .roulette-ring::after { content: ""; position: absolute; inset: 10px; border: 1px dashed rgba(131, 231, 193, .2); border-radius: 50%; }
.roulette-ring::after { inset: 26px; border-style: solid; opacity: .55; }
.ring-dot { width: 5px; height: 5px; position: absolute; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px rgba(131, 231, 193, .8); }
.dot-a { left: 93px; top: 4px; }.dot-b { right: 22px; top: 28px; }.dot-c { right: 4px; top: 93px; }.dot-d { right: 24px; bottom: 25px; }.dot-e { left: 93px; bottom: 4px; }.dot-f { left: 24px; bottom: 25px; }.dot-g { left: 4px; top: 93px; }.dot-h { left: 24px; top: 28px; }
.result-ball { width: 92px; height: 92px; z-index: 1; display: grid; place-content: center; justify-items: center; border: 1px solid rgba(131, 231, 193, .4); border-radius: 50%; background: linear-gradient(150deg, #172c3c, #0b1823); box-shadow: 0 10px 32px rgba(0, 0, 0, .42); transition-property: scale, border-color, background-color; transition-duration: 180ms; }
.result-ball[data-color="red"] { border-color: rgba(255, 139, 154, .65); background: linear-gradient(150deg, #5a2937, #271b29); }
.result-ball[data-color="black"] { border-color: #657684; background: linear-gradient(150deg, #283744, #101a23); }
.result-ball[data-color="zero"] { border-color: rgba(131, 231, 193, .65); background: linear-gradient(150deg, #1c5947, #122d2a); }
.result-ball.is-new { scale: 1.06; }
#roulette-number { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.result-ball small { margin-top: 1px; color: #b1c2cd; font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.result-caption { position: absolute; bottom: 12px; color: #91a6b6; font-size: 10px; text-align: center; }
.blackjack-stage { width: min(100%, 470px); padding: 23px 22px 32px; }
.hand-block + .hand-block { margin-top: 16px; }
.hand-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: #91a6b6; font-size: 9px; font-weight: 750; letter-spacing: .14em; }
.hand-title b { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.cards-row { min-height: 56px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card { width: 40px; height: 54px; display: grid; place-items: center; border: 1px solid #d0dfdc; border-radius: 7px; color: #172b31; background: linear-gradient(155deg, #f3f4ec, #c9d7d2); box-shadow: 0 4px 9px rgba(0, 0, 0, .25); font-size: 15px; font-weight: 750; animation: deal-in 180ms ease-out; }
.card.card-red { color: #bd4c60; }
.card.card-back { color: #dce9ec; border-color: rgba(131, 231, 193, .5); background: repeating-linear-gradient(45deg, #123b3a, #123b3a 4px, #1b5651 4px, #1b5651 8px); }
.empty-card { color: #758a9a; font-size: 10px; }
.hand-divider { height: 1px; position: relative; margin: 16px 0; background: rgba(145, 166, 182, .13); text-align: center; }
.hand-divider span { position: relative; top: -7px; padding: 0 10px; color: #647c8e; background: #0d1a25; font-size: 8px; letter-spacing: .18em; }
.hand-outcome { margin: 8px 0 0; color: var(--mint); font-size: 10px; }
.hand-outcome[data-result="loss"] { color: var(--coral); }

.live-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; border: 1px solid rgba(145, 166, 182, .12); border-radius: 10px; background: rgba(8, 18, 29, .35); }
.stat-cell { min-width: 0; padding: 10px 11px; }
.stat-cell + .stat-cell { border-left: 1px solid rgba(145, 166, 182, .12); }
.stat-cell span, .chart-footer span { display: block; margin-bottom: 5px; color: #7890a0; font-size: 8px; font-weight: 700; letter-spacing: .1em; }
.stat-cell strong { display: block; overflow: hidden; color: #e1edf2; font-size: 14px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.stat-cell:nth-child(3) strong { color: var(--mint); }
.stat-cell:nth-child(4) strong { font-size: 10px; }
.tempo-control { margin: 16px 2px 0; }
.tempo-label-row { display: flex; align-items: center; justify-content: space-between; color: #b9c8d3; font-size: 10px; font-weight: 650; }
.tempo-label-row output { color: var(--mint); font-size: 13px; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 44px; margin: 8px 0 0; accent-color: var(--mint); cursor: pointer; }
.tempo-scale { display: flex; justify-content: space-between; color: #6e8494; font-size: 8px; font-weight: 700; letter-spacing: .1em; }
.speed-relation { margin: 8px 0 0; color: var(--mint); font-size: 10px; font-variant-numeric: tabular-nums; }
.transport-controls { display: flex; gap: 8px; margin-top: 14px; }
.transport-controls .button { min-width: 0; flex: 1; min-height: 44px; padding: 0 8px; }

.chart-panel { padding: 18px 20px 14px; }
.chart-heading { align-items: center; margin-bottom: 7px; }
.chart-legend { display: flex; align-items: center; gap: 7px; color: #91a6b6; font-size: 9px; }
.legend-swatch { width: 14px; height: 2px; display: inline-block; background: var(--mint); box-shadow: 0 0 7px rgba(131, 231, 193, .6); }
.chart-wrap { min-height: 176px; position: relative; }
#balance-chart { width: 100%; height: 176px; display: block; }
.chart-empty { position: absolute; top: 47%; left: 0; width: 100%; color: #6e8494; font-size: 10px; text-align: center; pointer-events: none; }
.chart-footer { display: flex; justify-content: space-between; gap: 8px; padding-top: 4px; border-top: 1px solid rgba(145, 166, 182, .12); }
.chart-footer span { margin: 0; font-size: 9px; font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }

.history-intro { margin: -10px 0 16px; color: #8da2b1; font-size: 10px; line-height: 1.5; }
.count-badge { min-width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 99px; color: #b8c8d3; background: #0b1722; font-size: 10px; font-variant-numeric: tabular-nums; }
.run-history { max-height: 630px; display: grid; align-content: start; gap: 8px; overflow: auto; }
.empty-history { margin: 0; padding: 20px 5px; color: #718798; font-size: 10px; text-align: center; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; padding: 11px 10px; border: 1px solid rgba(145, 166, 182, .13); border-radius: 10px; background: rgba(8, 18, 29, .35); }
.history-select { min-width: 0; min-height: 44px; display: block; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.history-select strong { display: block; overflow: hidden; color: #dce8ee; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.history-select small { display: block; margin-top: 5px; color: #8298a8; font-size: 9px; font-variant-numeric: tabular-nums; }
.history-status { align-self: start; padding: 4px 6px; border-radius: 99px; color: var(--mint); background: rgba(131, 231, 193, .09); font-size: 8px; text-transform: uppercase; }
.history-status[data-status="aborted"], .history-status[data-status="failed"] { color: var(--coral); background: rgba(255, 139, 154, .08); }
.delete-run { width: 44px; height: 44px; grid-column: 2; grid-row: 2; border: 1px solid rgba(145, 166, 182, .18); border-radius: 8px; color: #91a6b6; background: transparent; cursor: pointer; }
.delete-run:hover { color: var(--coral); border-color: rgba(255, 139, 154, .5); }
.history-foot { display: flex; align-items: center; gap: 8px; margin-top: 17px; padding-top: 13px; border-top: 1px solid rgba(145, 166, 182, .12); color: #718798; font-size: 9px; }
.db-icon { color: var(--mint); font-size: 14px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); background: #152739; box-shadow: 0 10px 40px rgba(0,0,0,.35); font-size: 11px; opacity: 0; translate: 0 8px; pointer-events: none; transition-property: opacity, translate; transition-duration: 160ms; }
.toast.show { opacity: 1; translate: 0 0; }

@keyframes deal-in { from { opacity: 0; translate: 0 5px; scale: .96; } to { opacity: 1; translate: 0 0; scale: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(230px, 270px) minmax(390px, 1fr); }
  .history-panel { grid-column: 1 / -1; }
  .run-history { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 340px; }
}
@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; }
  .topbar-right { gap: 10px; }
  .logout-button { min-width: 76px; padding: 0 10px; }
  .mode-badge { display: none; }
  .app-shell { padding: 25px 13px 36px; }
  .intro-row { display: block; margin-bottom: 19px; }
  .seed-chip { margin-top: 14px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .main-column { grid-row: 1; }
  .setup-panel { grid-row: 2; }
  .history-panel { grid-row: 3; grid-column: auto; }
  .live-panel { padding: 17px 14px 14px; }
  .game-stage { min-height: 235px; }
  .live-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-cell:nth-child(3) { border-left: 0; border-top: 1px solid rgba(145, 166, 182, .12); }
  .stat-cell:nth-child(4) { border-top: 1px solid rgba(145, 166, 182, .12); }
  .stat-cell:nth-child(2) { border-left: 1px solid rgba(145, 166, 182, .12); }
  .transport-controls { flex-wrap: wrap; }
  .transport-controls .button { min-width: 30%; }
  .run-history { grid-template-columns: 1fr; }
}
@media (max-width: 390px) {
  .field-grid { grid-template-columns: 1fr; }
  .brand strong { font-size: 11px; }
  .connection-state { display: none; }
  .transport-controls .button { font-size: 10px; }
}

/* Strategievergleich (M5) */
.analysis-panel { margin-top: 18px; }
.analysis-intro { margin: 0 0 16px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.series-progress { margin: 12px 0 0; min-height: 16px; color: var(--blue); font-size: 11px; font-variant-numeric: tabular-nums; }
.verdict { margin: 14px 0 0; padding: 13px 15px; border: 1px solid rgba(255, 139, 154, .32); border-left: 3px solid var(--coral); border-radius: 10px; background: rgba(255, 139, 154, .06); }
.verdict-headline { display: block; color: #ffdde1; font-size: 12px; line-height: 1.5; }
.verdict p { margin: 7px 0 0; color: #c9d6de; font-size: 11px; line-height: 1.65; }
.table-wrap { margin-top: 16px; overflow-x: auto; }
.series-table { width: 100%; border-collapse: collapse; font-size: 10px; font-variant-numeric: tabular-nums; }
.series-table th, .series-table td { padding: 8px 9px; border-bottom: 1px solid rgba(145, 166, 182, .13); text-align: right; white-space: nowrap; }
.series-table thead th { color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.series-table tbody th { text-align: left; color: #dbe7ee; font-size: 10px; font-weight: 650; }
.series-table tbody tr[data-running="true"] { background: rgba(140, 184, 248, .05); }
.series-table .stops { color: #8fa5b5; font-size: 9px; text-align: left; white-space: normal; }
.delta[data-sign="plus"] { color: var(--mint); }
.delta[data-sign="minus"] { color: var(--coral); }
.delta.mean { font-weight: 700; }
.delta.median { color: #cfdde6; }
