:root {
    --felt: #0e5934;
    --felt-dark: #083d23;
    --gold: #d4af37;
    --rail: #3a1f10;
    --good: #4ade80;
    --bad:  #f87171;
    --warn: #fbbf24;
    --card-bg: #fafafa;
    --red: #c0252a;
    --black: #111;
    --bg: #1a1a1a;
    --panel: #1f1f1f;
    --panel-2: #292929;
    --border: #333;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: #eee; min-height: 100vh;
    font-size: 15px;
  }
  header {
    background: #111; padding: 10px 20px;
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    border-bottom: 2px solid var(--gold);
  }
  header h1 { margin: 0; font-size: 22px; color: var(--gold); white-space: nowrap; }
  nav.tabs { display:flex; gap:4px; flex-wrap: wrap; }
  nav.tabs button {
    background: #222; color: #ccc; border: 1px solid #333;
    padding: 9px 16px; font-size: 14px; border-radius: 6px; cursor: pointer;
    font-weight: 600;
  }
  nav.tabs button:hover { background: #2a2a2a; }
  nav.tabs button.active { background: var(--gold); color: #000; border-color: var(--gold); }
  header .grow { flex: 1; }
  header .stats { font-size: 13px; opacity: 0.85; }
  header .stats span { margin-left: 12px; }
  header button.icon {
    background: transparent; border: 1px solid #555; color: #ccc;
    padding: 7px 11px; border-radius: 4px; cursor: pointer; font-size: 13px;
  }
  header button.icon:hover { background: #333; }

  main { padding: 12px; max-width: 1400px; margin: 0 auto; }
  section.tab-pane { display: none; }
  section.tab-pane.active { display: block; }

  /* === LIVE TRAINER === */
  .live-layout {
    display: grid; grid-template-columns: 1fr 380px;
    gap: 12px;
  }
  .table-wrap { position: relative; }
  .table {
    background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 80%);
    border: 14px solid var(--rail);
    border-radius: 50% / 35%;
    width: 100%; aspect-ratio: 16/10;
    position: relative; box-shadow: 0 0 30px rgba(0,0,0,0.6) inset;
  }
  .seat { position: absolute; transform: translate(-50%, -50%); width: 130px; text-align: center; }
  .seat .name {
    background: #222; border: 1px solid #555; border-radius: 6px;
    padding: 4px 6px; font-size: 13px; font-weight: 600;
  }
  .seat.hero .name { background: #1e3a8a; border-color: #60a5fa; color: #fff; }
  .seat.folded .name { opacity: 0.45; }
  .seat .stack { font-size: 12px; opacity: 0.85; margin-top: 2px;}
  .seat.acting .name { box-shadow: 0 0 0 2px var(--warn); }
  .seat .cards { display:flex; justify-content:center; gap:3px; margin-top:4px; }
  .mini-card {
    width: 34px; height: 44px; border-radius: 4px;
    background: var(--card-bg); color: var(--black);
    font-size: 15px; font-weight: 700;
    display:flex; align-items:center; justify-content:center;
    border: 1px solid #999;
    letter-spacing: -0.5px;
  }
  .mini-card.back {
    background: repeating-linear-gradient(45deg, #1e3a8a, #1e3a8a 4px, #2563eb 4px, #2563eb 8px);
    color: transparent;
  }
  .mini-card.red { color: var(--red); }
  .seat .badge {
    display: inline-block; margin-top: 2px;
    background: #000; color: var(--gold); font-size: 11px;
    padding: 1px 5px; border-radius: 8px; border: 1px solid var(--gold);
  }
  .seat .last-action { margin-top: 3px; font-size: 12px; min-height: 14px; color: #ffe9a8; }
  .seat .last-action.thinking { color: #93c5fd; font-style: italic; }
  .dealer-btn {
    position: absolute; width: 22px; height: 22px;
    background: #fff; color: #000; border-radius: 50%;
    text-align: center; font-weight: 700; font-size: 12px;
    line-height: 22px; box-shadow: 0 1px 3px #0006;
  }
  .center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; width: 60%; }
  .board { display: flex; gap: 6px; justify-content: center; min-height: 70px;}
  .card {
    width: 60px; height: 84px; background: var(--card-bg); color: var(--black);
    border-radius: 6px; font-weight: 700;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 1px solid #777; box-shadow: 0 2px 4px #0006;
  }
  .card.red { color: var(--red); }
  .card .r { font-size: 26px; line-height: 1; letter-spacing: -1px; }
  .card .s { font-size: 22px; line-height: 1; }
  .pot { margin-top: 10px; font-size: 16px; background: #00000088; padding: 5px 14px; border-radius: 12px; display: inline-block; color: var(--gold); border: 1px solid var(--gold); }
  .street-label { margin-top: 6px; font-size: 13px; opacity: 0.85; }

  .panel {
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px; display: flex; flex-direction: column; gap: 12px;
  }
  .hero-info { display: flex; gap: 10px; align-items: center; background: var(--panel-2); padding: 8px; border-radius: 6px; }
  .hero-cards { display:flex; gap:4px; }
  .hero-info .label { font-size: 13px; opacity: 0.7; }
  .hero-info .pos { font-size: 16px; font-weight: 700; color: var(--gold); }
  .actions { display:flex; flex-direction: column; gap:6px; }
  .actions .row { display:flex; gap:6px; }
  button.btn {
    flex: 1; padding: 11px; border: none; border-radius: 6px;
    font-size: 15px; font-weight: 700; cursor: pointer;
    background: #444; color: #eee;
  }
  button.btn:hover:not(:disabled) { background: #555; }
  button.btn:disabled { opacity: 0.4; cursor: not-allowed; }
  button.btn.fold { background: #6b1d1d; }
  button.btn.fold:hover:not(:disabled) { background: #8a2424; }
  button.btn.call { background: #2563eb; }
  button.btn.call:hover:not(:disabled) { background: #3b82f6; }
  button.btn.raise { background: #166534; }
  button.btn.raise:hover:not(:disabled) { background: #1d8347; }
  button.btn.deal { background: var(--gold); color: #000; }
  button.btn.deal:hover:not(:disabled) { background: #ecc14a; }
  .raise-input {
    display: flex; gap: 6px; align-items: center; padding: 6px;
    background: var(--panel-2); border-radius: 6px;
  }
  .raise-input input {
    flex: 1; padding: 6px; background: #111; border: 1px solid #555;
    color: #eee; border-radius: 4px;
  }
  .raise-presets { display:flex; gap:4px; }
  .raise-presets button {
    flex:1; padding: 4px; font-size: 11px;
    background:#333; color:#ccc; border:1px solid #555;
    border-radius: 4px; cursor:pointer;
  }
  .raise-presets button:hover { background:#444; }
  .feedback {
    background: var(--panel-2); padding: 11px; border-radius: 6px;
    border-left: 4px solid #555; min-height: 80px; font-size: 14px;
    line-height: 1.55;
  }
  .feedback.good { border-color: var(--good); }
  .feedback.bad  { border-color: var(--bad); }
  .feedback.warn { border-color: var(--warn); }
  .feedback .verdict { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
  .feedback .verdict.good { color: var(--good); }
  .feedback .verdict.bad  { color: var(--bad); }
  .feedback .verdict.warn { color: var(--warn); }
  .feedback .meta { margin-top: 6px; font-size: 11px; opacity: 0.6; }
  .ai-tip {
    margin-top: 8px; padding: 10px;
    background: linear-gradient(180deg, #1e293b, #0f172a);
    border-left: 3px solid #60a5fa; border-radius: 4px;
    font-size: 12.5px; line-height: 1.5; color: #e0eaff;
  }
  .ai-tip .ai-label { font-size: 11px; color: #93c5fd; font-weight: 700; margin-bottom: 4px; }
  .ai-tip-loading { font-style: italic; opacity: 0.7; }
  .ai-tip-error { color: #fca5a5; font-style: italic; font-size: 11px; }
  .coach-report { font-size: 14px; }
  .coach-report-meta {
    margin-bottom: 10px;
    color: #a8b3c7;
    font-size: 12px;
  }
  .markdown-body {
    color: #e5edf8;
    line-height: 1.6;
  }
  .markdown-body h3,
  .markdown-body h4,
  .markdown-body h5 {
    margin: 14px 0 6px;
    color: var(--gold);
    font-size: 16px;
  }
  .markdown-body h3:first-child,
  .markdown-body h4:first-child,
  .markdown-body h5:first-child { margin-top: 0; }
  .markdown-body p { margin: 0 0 10px; }
  .markdown-body ul {
    margin: 0 0 12px 18px;
    padding: 0;
  }
  .markdown-body li { margin: 5px 0; }
  .markdown-body strong { color: #fff; }
  .markdown-body code {
    background: #111827;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 1px 4px;
    color: #fde68a;
  }
  .log {
    background: #161616; border: 1px solid var(--border); border-radius: 6px;
    padding: 8px; font-size: 12px; max-height: 180px; overflow-y: auto;
    font-family: ui-monospace, Menlo, monospace;
  }
  .log div { padding: 1px 0; }
  .log .you { color: var(--gold); }
  .log .opp { color: #9ca3af; }
  .log .system { color: #6ee7b7; }
  .log .show { color: #fde68a; }
  .log .narrate { color: #93c5fd; font-style: italic; }

  /* === SCENARIO / EVALUATOR / QUIZ COMMON === */
  .module {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 8px; padding: 16px; margin-bottom: 12px;
  }
  .module h2 { margin: 0 0 8px 0; color: var(--gold); font-size: 18px; }
  .module h3 { margin: 12px 0 6px 0; font-size: 14px; color: #fde68a;}
  .scenario-board {
    background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 90%);
    border: 8px solid var(--rail); border-radius: 16px;
    padding: 20px; text-align: center;
  }
  .scenario-board .info { font-size: 14px; color: #fde68a; margin-bottom: 8px; }
  .scenario-board .hole-cards { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
  .scenario-board .community { display: flex; justify-content: center; gap: 6px; min-height: 76px; align-items: center; }
  .scenario-board .pot-stack { font-size: 13px; opacity: 0.85; margin-top: 6px; }
  .options { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
  .options button {
    padding: 12px; background: #333; border: 1px solid #555; color: #eee;
    border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
  }
  .options button:hover { background: #444; }
  .options button.correct { background: #166534; border-color: var(--good); }
  .options button.wrong { background: #6b1d1d; border-color: var(--bad); }
  .answer {
    margin-top: 12px; padding: 12px; background: var(--panel-2);
    border-left: 4px solid var(--gold); border-radius: 4px;
    font-size: 13px; line-height: 1.6;
  }
  .answer .head { font-weight: 700; margin-bottom: 4px; }

  /* === HAND EVALUATOR === */
  .picker {
    display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; max-width: 540px;
    margin-bottom: 6px;
  }
  .picker button {
    aspect-ratio: 1/1; background: #2a2a2a; color: #eee;
    border: 1px solid #444; cursor: pointer; font-size: 12px; font-weight: 700;
    border-radius: 3px;
  }
  .picker button:hover { background: #3a3a3a; }
  .picker button.disabled { opacity: 0.3; cursor: not-allowed; }
  .suits { display: flex; gap: 4px; margin-bottom: 12px; }
  .suits button {
    padding: 6px 10px; background: #2a2a2a; color: #eee; border: 1px solid #444;
    border-radius: 4px; cursor: pointer; font-size: 16px;
  }
  .suits button.active { background: var(--gold); color: #000; border-color: var(--gold); }
  .suits button.red.active { color: var(--red); }
  .slots { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
  .slot-group { background: var(--panel-2); padding: 10px; border-radius: 6px; }
  .slot-group .label { font-size: 12px; opacity: 0.7; margin-bottom: 6px; }
  .slot-row { display: flex; gap: 6px; }
  .slot {
    width: 50px; height: 70px; border: 2px dashed #555; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; background: #161616;
  }
  .slot.filled { border-style: solid; }
  .slot.active { border-color: var(--gold); }
  .eval-result {
    background: var(--panel-2); padding: 14px; border-radius: 6px;
    margin-top: 10px;
  }
  .eval-result .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #333; }
  .eval-result .row:last-child { border-bottom: none; }
  .eval-result .label { opacity: 0.8; }
  .eval-result .value { font-weight: 700; color: var(--gold); }
  .eval-result .outs-list { font-size: 12px; opacity: 0.85; margin-top: 6px; }

  /* === QUIZ === */
  .quiz-progress { display: flex; gap: 4px; margin-bottom: 12px; }
  .quiz-progress div { flex: 1; height: 8px; background: #333; border-radius: 4px; }
  .quiz-progress div.done.correct { background: var(--good); }
  .quiz-progress div.done.wrong { background: var(--bad); }
  .quiz-summary { background: var(--panel-2); padding: 14px; border-radius: 6px; margin-top: 12px; line-height: 1.6; }
  .quiz-summary h3 { color: var(--gold); margin: 0 0 8px 0; }

  /* === LOG ANALYZER === */
  .drop-zone {
    border: 2px dashed #555; padding: 30px; text-align: center;
    border-radius: 8px; cursor: pointer; background: var(--panel-2);
    margin-bottom: 12px;
  }
  .drop-zone.dragover { border-color: var(--gold); background: #2a2a1a; }
  .drop-zone p { margin: 6px 0; opacity: 0.85; }
  .drop-zone .hint { font-size: 12px; opacity: 0.6; }
  .drop-zone input[type=file] { display: none; }
  .stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
  }
  .stat-card {
    background: var(--panel-2); padding: 12px; border-radius: 6px;
  }
  .stat-card h3 { margin: 0 0 8px 0; font-size: 14px; color: var(--gold); }
  .stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .stat-table th, .stat-table td {
    padding: 6px 8px; border-bottom: 1px solid #333; text-align: left;
  }
  .stat-table th { color: #fde68a; font-weight: 600; }
  .stat-table td.profit-pos { color: var(--good); }
  .stat-table td.profit-neg { color: var(--bad); }
  .chart-wrap { background: var(--panel-2); padding: 12px; border-radius: 6px; margin-top: 12px; }
  .chart-wrap canvas { max-height: 280px; }
  .pot-replay { background: var(--panel-2); padding: 10px; border-radius: 6px; margin-top: 10px; font-size: 12px; }
  .pot-replay .heading { color: var(--gold); font-weight: 700; margin-bottom: 6px; }
  .pot-replay .street { margin: 4px 0; }
  .pot-replay .street b { color: #fde68a; }
  .pot-replay .actions-line { font-family: ui-monospace, Menlo, monospace; font-size: 11px; opacity: 0.9; }

  /* === Settings dialog === */
  dialog {
    background: var(--panel); color: #eee; border: 1px solid var(--gold);
    border-radius: 8px; max-width: 600px; padding: 20px;
  }
  dialog::backdrop { background: rgba(0,0,0,0.7); }
  dialog h2 { margin-top: 0; color: var(--gold); }
  dialog ul { line-height: 1.7; }
  dialog button { margin-top: 12px; }
  .settings-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.55;
  }
  .settings-card .account-email { font-weight: 700; color: #fff; }
  .settings-card .account-meta { color: #bbb; font-size: 12px; }
  .settings-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }
  .settings-actions .btn { flex: 1; min-width: 150px; }
  .credit-history {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }
  .credit-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
  }
  .credit-history-head .btn {
    padding: 5px 9px;
    font-size: 12px;
  }
  .credit-history-list {
    max-height: 240px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #10151d;
  }
  .credit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
  }
  .credit-row:last-child { border-bottom: 0; }
  .credit-desc { color: #eee; font-size: 13px; }
  .credit-date { color: #999; font-size: 11px; margin-top: 1px; }
  .credit-amount { font-weight: 800; font-variant-numeric: tabular-nums; }
  .credit-amount.pos { color: var(--good); }
  .credit-amount.neg { color: var(--bad); }
  .credit-empty { padding: 10px; color: #aaa; font-size: 12px; }
  .hint { color: #aaa; font-size: 12px; line-height: 1.45; }
  .field { margin-bottom: 12px; }
  .field label { display: block; font-size: 12px; opacity: 0.8; margin-bottom: 4px; }
  .field label.checkbox-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    opacity: 0.9;
  }
  .field input, .field select {
    width: 100%; padding: 8px; background: #111; color: #eee;
    border: 1px solid #555; border-radius: 4px;
  }
  .field label.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    justify-self: center;
    accent-color: var(--gold);
  }
  .pill {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 11px; background: #333; color: #ccc;
  }
  .pill.on { background: #166534; color: #d1fae5; }
  .pill.off { background: #6b1d1d; color: #fee2e2; }
  .site-footer {
    padding: 18px 20px 28px;
    text-align: center;
    color: #aaa;
    font-size: 12px;
  }
  .site-footer a { color: #d4af37; text-decoration: none; }
  .site-footer a:hover { text-decoration: underline; }

  @media (max-width: 880px) {
    .live-layout { grid-template-columns: 1fr; }
    .seat { width: 100px; }
    .mini-card { width: 26px; height: 36px; font-size: 13px; }
    .card { width: 44px; height: 62px; }
    .card .r { font-size: 18px; }
    .card .s { font-size: 16px; }
    .picker { grid-template-columns: repeat(13, 1fr); }
  }
