:root {
  color-scheme: dark;
  --bg: #0d100f;
  --surface: #151a17;
  --surface-2: #1c231f;
  --line: #303a34;
  --text: #f0f3f1;
  --muted: #9aa69f;
  --accent: #68b787;
  --accent-strong: #8bd4a5;
  --danger: #d97b72;
  --felt: #193f2d;
  --felt-edge: #0f281d;
  --radius: 14px;
  --font: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #edf0ed;
  --surface: #f8faf8;
  --surface-2: #e4e9e5;
  --line: #c8d0ca;
  --text: #18201b;
  --muted: #5d6b63;
  --accent: #287449;
  --accent-strong: #185b37;
  --felt: #2f6a4c;
  --felt-edge: #19472f;
}

* { box-sizing: border-box; }
html { min-width: 320px; overflow-x: hidden; background: var(--bg); }
body { margin: 0; min-height: 100dvh; overflow-x: hidden; color: var(--text); background: var(--bg); font-family: var(--font); }
button, select { font: inherit; }
button, select, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 3px; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 20; padding: .7rem 1rem; color: var(--bg); background: var(--text); border-radius: 8px; }
.skip-link:focus { top: 1rem; }

.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 3vw, 2.5rem); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .72rem; color: var(--text); text-decoration: none; font-size: .95rem; letter-spacing: -.01em; }
.brand strong { color: var(--accent-strong); font-weight: 650; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--accent); border-radius: 9px; color: var(--accent-strong); font-weight: 750; }
.session-meta { display: flex; align-items: center; gap: 1rem; color: var(--muted); font: .76rem var(--mono); }
.icon-button { width: 36px; height: 36px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }

.trainer-shell { width: min(1540px, 100%); margin: 0 auto; padding: clamp(1rem, 2.8vw, 2.5rem); }
.lesson-bar { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.eyebrow { display: block; margin-bottom: .45rem; color: var(--accent-strong); font: .7rem var(--mono); letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.35rem); line-height: .98; letter-spacing: -.055em; }
.lesson-controls { display: flex; gap: .7rem; }
.lesson-controls label { display: grid; gap: .35rem; color: var(--muted); font-size: .7rem; }
select { min-width: 130px; padding: .72rem 2.3rem .72rem .8rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 1rem; min-width: 0; align-items: stretch; }
.table-stage, .coach { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table-stage { padding: clamp(.7rem, 2vw, 1.35rem); }
.table { position: relative; min-height: min(610px, 65vh); overflow: hidden; border: 10px solid var(--felt-edge); border-radius: min(22vw, 180px); background: var(--felt); box-shadow: inset 0 0 0 2px rgba(255,255,255,.08), inset 0 20px 70px rgba(0,0,0,.22); }
.felt-texture { position: absolute; inset: 0; pointer-events: none; opacity: .13; background-image: radial-gradient(circle at 25% 20%, rgba(255,255,255,.28) 0 1px, transparent 1.2px); background-size: 13px 13px; }
.action-history { position: absolute; left: 8%; top: 41%; z-index: 2; width: min(210px, 28%); padding: .65rem .72rem; color: #dce6df; background: rgba(5,12,8,.68); border: 1px solid rgba(255,255,255,.12); border-radius: 8px; backdrop-filter: blur(7px); }
.action-history-label { display: block; margin-bottom: .4rem; color: #9fb1a7; font: 600 .55rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.action-history ol { display: grid; gap: .22rem; max-height: 112px; margin: 0; padding: 0; overflow: auto; list-style: none; scrollbar-width: thin; }
.action-history li { display: grid; grid-template-columns: 28px 1fr auto; gap: .35rem; align-items: baseline; font: .58rem var(--mono); }
.action-history li strong { color: #9fb1a7; }
.action-history li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-history li b { color: #dce6df; font-weight: 650; }
.action-history li.is-key-action span, .action-history li.is-key-action b { color: var(--accent-strong); }
.seats { position: absolute; inset: 0; }
.seat { position: absolute; display: grid; justify-items: center; gap: .35rem; min-width: 116px; transform: translate(-50%, -50%); }
.seat[data-seat="0"] { left: 50%; top: 87%; }
.seat[data-seat="1"] { left: 16%; top: 72%; }
.seat[data-seat="2"] { left: 16%; top: 25%; }
.seat[data-seat="3"] { left: 50%; top: 12%; }
.seat[data-seat="4"] { left: 84%; top: 25%; }
.seat[data-seat="5"] { left: 84%; top: 72%; }
.player { position: relative; min-width: 104px; padding: .5rem .65rem; text-align: center; color: #e9efeb; background: rgba(10,16,13,.86); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; }
.player.is-hero { border-color: var(--accent-strong); }
.player.is-folded { opacity: .42; }
.player-name { display: block; font-size: .72rem; font-weight: 650; }
.player-stack { color: #aebbb4; font: .68rem var(--mono); }
.player-action { position: absolute; left: 50%; bottom: -1.25rem; width: max-content; padding: .2rem .38rem; color: #102116; background: var(--accent-strong); border-radius: 5px; transform: translateX(-50%); font: 650 .55rem var(--mono); }
.position { position: absolute; right: -.55rem; top: -.55rem; min-width: 27px; padding: .25rem .35rem; color: #102116; background: var(--accent-strong); border-radius: 7px; font: 650 .62rem var(--mono); }
.hole-cards, .board { display: flex; gap: .35rem; }
.card { display: grid; place-items: center; width: clamp(35px, 5vw, 55px); aspect-ratio: .7; color: #141917; background: #f4f3ee; border: 1px solid rgba(0,0,0,.22); border-radius: 7px; box-shadow: 0 4px 8px rgba(0,0,0,.22); font: 700 clamp(.78rem, 1.7vw, 1.15rem) var(--mono); }
.card.red { color: #b13e37; }
.card.back { color: transparent; background: repeating-linear-gradient(45deg, #28332d, #28332d 5px, #6c8576 5px, #6c8576 7px); border: 2px solid #d7ded9; }
.board-zone { position: absolute; left: 50%; top: 49%; display: grid; justify-items: center; gap: .7rem; transform: translate(-50%, -50%); }
.pot { padding: .35rem .55rem; color: #dbe4df; background: rgba(5,12,8,.5); border-radius: 7px; font: .72rem var(--mono); }
.street { color: rgba(235,245,239,.62); font: .64rem var(--mono); letter-spacing: .15em; text-transform: uppercase; }

.decision-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 92px; margin-top: 1rem; padding: 1rem; background: var(--surface-2); border-radius: 11px; }
.decision-kicker { color: var(--accent-strong); font: .67rem var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.decision-copy p { margin: .25rem 0 0; font-size: .95rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.action { min-width: 82px; padding: .72rem .9rem; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.action:hover { border-color: var(--accent); background: rgba(104,183,135,.08); }
.action:active { transform: translateY(1px) scale(.98); }
.action.primary { color: #0c1b12; background: var(--accent-strong); border-color: var(--accent-strong); font-weight: 700; }

.coach { display: flex; flex-direction: column; min-height: 100%; padding: 1.35rem; }
.coach-head { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.coach-label { color: var(--accent-strong); font: .68rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.coach h2 { margin: .55rem 0 0; font-size: clamp(1.4rem, 2.2vw, 2rem); letter-spacing: -.035em; }
.coach-content { flex: 1; padding: 1.1rem 0; color: var(--muted); line-height: 1.55; }
.coach-content p { margin: 0 0 1.15rem; }
.concept-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.concept-grid div { padding: .8rem; background: var(--surface-2); border-radius: 9px; }
.concept-grid span { display: block; margin-bottom: .3rem; font: .62rem var(--mono); color: var(--muted); }
.concept-grid strong { color: var(--text); font-size: .8rem; }
.feedback { padding: 1rem; background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 0 9px 9px 0; }
.feedback.is-miss { border-left-color: var(--danger); }
.feedback strong { display: block; margin-bottom: .4rem; color: var(--text); }
.feedback p { margin: 0; font-size: .88rem; }
.feedback-facts { margin-top: .8rem; }
.method-note { padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.method-note summary { color: var(--text); cursor: pointer; }
.method-note p { line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: 1rem; z-index: 10; max-width: min(92vw, 540px); padding: .8rem 1rem; color: #0c1b12; background: var(--accent-strong); border-radius: 10px; transform: translateX(-50%); font-weight: 650; }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .coach { min-height: auto; }
  .table { min-height: 520px; }
}

@media (max-width: 620px) {
  .topbar { height: 58px; }
  .session-meta > span { display: none; }
  .trainer-shell { padding: .8rem; }
  .lesson-bar { align-items: start; flex-direction: column; gap: 1rem; }
  .lesson-controls { width: 100%; }
  .lesson-controls label { flex: 1; min-width: 0; }
  select { min-width: 0; width: 100%; }
  .table-stage { padding: .45rem; }
  .table { min-height: 440px; border-width: 7px; border-radius: 95px; }
  .seat { min-width: 80px; gap: .2rem; }
  .seat[data-seat="1"], .seat[data-seat="2"] { left: 13%; }
  .seat[data-seat="4"], .seat[data-seat="5"] { left: 87%; }
  .player { min-width: 72px; padding: .35rem .35rem; }
  .player-name { max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .62rem; }
  .player-stack { font-size: .58rem; }
  .position { min-width: 22px; font-size: .52rem; }
  .card { width: 31px; border-radius: 5px; }
  .action-history { left: 50%; top: 40%; width: 76%; padding: .45rem .55rem; transform: translateX(-50%); }
  .action-history ol { display: flex; max-height: none; overflow-x: auto; }
  .action-history li { flex: 0 0 auto; display: flex; }
  .action-history li:not(.is-key-action):nth-child(-n+2) { display: none; }
  .player-action { bottom: -1rem; font-size: .48rem; }
  .hole-cards .card { width: 26px; }
  .decision-panel { align-items: stretch; flex-direction: column; }
  .actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .action { min-width: 0; padding: .68rem .35rem; font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
