:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.88);
  --ink: #172033;
  --muted: #667085;
  --line: rgba(23, 32, 51, 0.1);
  --green: #16a34a;
  --blue: #2563eb;
  --red: #dc2626;
  --gold: #d97706;
  --felt: #166534;
  --felt2: #0f5132;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 99, 235, 0.16), transparent 34rem),
    radial-gradient(circle at 100% 10%, rgba(22, 163, 74, 0.15), transparent 30rem),
    var(--bg);
}

#app {
  height: 100vh;
  padding: 10px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  min-height: 0;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(20px, 2.2vw, 30px); letter-spacing: -0.04em; }
h2 { font-size: clamp(18px, 1.9vw, 26px); letter-spacing: -0.03em; }
h3 { margin-bottom: 6px; font-size: 14px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.topStats { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  gap: 10px;
}
.sidebar { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(22, 32, 58, 0.10);
  backdrop-filter: blur(12px);
}
.compact { padding: 10px; border-radius: 14px; }
.searchLabel { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
}

.handList { min-height: 0; flex: 1; overflow: auto; padding-right: 4px; }
.handItem {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.handItem:hover, .handItem.active { border-color: rgba(37, 99, 235, 0.45); background: #fff; }
.handItem.active { box-shadow: inset 4px 0 0 var(--blue); }
.handTime { font-weight: 800; }
.handSummary { min-width: 0; }
.handCards { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.handSub { margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


.replay {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}
.heroPanel {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.handMeta { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.stackLine { margin-top: 0; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.currentActionTop { align-self: flex-start; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}
.badge.green { background: rgba(22, 163, 74, 0.12); color: var(--green); }
.badge.red { background: rgba(220, 38, 38, 0.1); color: var(--red); }
.badge.gold { background: rgba(217, 119, 6, 0.12); color: var(--gold); }
.badge.gray { background: rgba(102, 112, 133, 0.12); color: var(--muted); }


.tablePanel {
  min-height: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 50% 44%, rgba(22, 101, 52, 0.10), transparent 42%),
    linear-gradient(160deg, rgba(255,255,255,0.88), rgba(236,253,245,0.82));
}
.feltStage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.pokerTable {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(660px, 56%);
  height: min(300px, 52%);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.16), transparent 44%),
    linear-gradient(145deg, var(--felt), var(--felt2));
  border: 12px solid #7c4a26;
  box-shadow: inset 0 0 0 8px rgba(255,255,255,0.08), 0 18px 42px rgba(0,0,0,0.16);
}
.seatLayer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.boardWrap {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  width: min(450px, 42%);
  text-align: center;
  pointer-events: none;
}
.streetName { display: inline-block; margin-bottom: 8px; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,0.94); font-weight: 900; color: var(--felt2); }
.board { display: flex; justify-content: center; gap: 7px; min-height: 62px; }
.card {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 58px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 7px 18px rgba(0,0,0,0.15);
  font-weight: 950;
  font-size: 18px;
}
.card.red { color: var(--red); }
.card.unknown { color: var(--muted); background: #eef2f7; }
.currentActionTop {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.potRow {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}
.metric {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 6px 16px rgba(0,0,0,0.10);
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}
.metric b { color: var(--felt2); }

.seat {
  position: absolute;
  z-index: 8;
  width: 122px;
  transform: translate(-50%, -50%);
  padding: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  border: 2px solid transparent;
  box-shadow: 0 9px 22px rgba(0,0,0,0.12);
  pointer-events: auto;
}
.seat.hero { border-color: #f59e0b; background: rgba(255,255,255,0.98); }
.seat.active { border-color: #60a5fa; box-shadow: 0 0 0 5px rgba(96,165,250,0.28), 0 9px 22px rgba(0,0,0,0.14); }
.seat.opponent {
  width: auto;
  min-width: 58px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 8px 18px rgba(0,0,0,0.10);
}
.seat.opponent .seatPos { justify-content: center; font-size: 14px; }
.seat.opponent .seatCards,
.seat.opponent .seatStack { display: none; }
.seat.opponent .seatAction { min-height: 0; margin-top: 2px; max-width: 120px; text-align: center; font-size: 11px; }
.seatPos { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); font-weight: 900; }
.seatCards { display: flex; gap: 4px; margin-top: 5px; min-height: 35px; }
.seatCards .card { width: 24px; height: 34px; border-radius: 6px; font-size: 12px; box-shadow: 0 3px 8px rgba(0,0,0,0.12); }
.seatStack { margin-top: 4px; color: var(--felt2); font-size: 13px; font-weight: 950; white-space: nowrap; }
.seatAction { min-height: 17px; margin-top: 3px; font-size: 13px; font-weight: 900; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chipStack {
  position: absolute;
  z-index: 9;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 248, 220, 0.97);
  border: 1px solid rgba(217, 119, 6, 0.35);
  color: #92400e;
  font-size: 12px;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(0,0,0,0.15);
  pointer-events: none;
}
.chipStack.active { background: rgba(239, 246, 255, 0.98); border-color: rgba(37, 99, 235, 0.55); color: var(--blue); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14), 0 8px 18px rgba(0,0,0,0.15); }
.chipDot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background:
    radial-gradient(circle, #fff 0 25%, transparent 27%),
    repeating-conic-gradient(#dc2626 0 16deg, #fff 16deg 32deg);
  border: 2px solid #dc2626;
}

.controls {
  display: grid;
  grid-template-columns: auto auto minmax(120px, 1fr) auto auto auto;
  gap: 8px;
  padding: 8px;
  align-items: center;
}
button {
  border: 0;
  border-radius: 12px;
  padding: 9px 12px;
  background: #172033;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  font-size: 14px;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
input[type="range"] { width: 100%; accent-color: var(--blue); }

.infoBar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 2px;
}
.infoItem { position: relative; }
.infoTab { padding: 8px 12px; background: rgba(255,255,255,0.92); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 8px 18px rgba(0,0,0,0.08); }
.popover {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: min(560px, 70vw);
  max-height: 42vh;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.96);
  box-shadow: 0 18px 60px rgba(0,0,0,0.22);
  backdrop-filter: blur(12px);
}
.infoItem:hover .popover,
.infoItem.open .popover { display: block; }
.infoHint { color: var(--muted); font-size: 12px; }
.actionLog { margin: 0; padding-left: 20px; min-height: 0; overflow: auto; }
.actionLog li { padding: 4px 6px; border-radius: 8px; color: var(--muted); }
.actionLog li.current { color: var(--ink); background: rgba(37,99,235,0.1); font-weight: 900; }
.resultBox { color: var(--muted); line-height: 1.45; overflow: auto; min-height: 0; }
pre { margin: 0; white-space: pre-wrap; line-height: 1.35; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; color: #283041; overflow: auto; min-height: 0; font-size: 14px; }

@media (max-width: 980px) {
  html, body { overflow: auto; }
  #app { padding: 12px; height: auto; min-height: 100vh; display: block; }
  .layout { grid-template-columns: 1fr; }
  .handList { height: 250px; flex: none; }
  .replay { display: flex; flex-direction: column; }
  .tablePanel { min-height: 62vh; }
  .seat { width: 120px; }
  .pokerTable { width: min(640px, 62%); height: min(300px, 50%); }
  .boardWrap { width: 52%; }
  .popover { width: calc(100vw - 28px); max-height: 55vh; }
}

@media (max-width: 640px) {
  .topbar, .handMeta { display: block; }
  .topStats, .badges { justify-content: flex-start; margin-top: 8px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .controls input { grid-column: 1 / -1; order: -1; }
  .layout { gap: 8px; }
  .handList { height: 170px; }
  .heroPanel { padding: 10px; }
  .tablePanel { min-height: 66vh; }
  .pokerTable {
    left: 50%;
    top: 47%;
    width: 66%;
    height: 42%;
    transform: translate(-50%, -50%);
    border-width: 8px;
  }
  .seat { width: 104px; padding: 7px; border-radius: 12px; }
  .seat.opponent { width: auto; min-width: 50px; padding: 6px 8px; border-radius: 999px; }
  .seatCards .card { width: 21px; height: 29px; font-size: 10px; }
  .seatStack, .seatAction, .seatPos { font-size: 11px; }
  .boardWrap { top: 43%; width: 54%; }
  .card { width: 34px; height: 48px; font-size: 15px; }
  .currentActionTop { font-size: 13px; padding: 4px 8px; }
  .chipStack { font-size: 11px; padding: 4px 6px; }
  .chipDot { width: 13px; height: 13px; }
  .infoHint { display: none; }
}

@media (max-width: 520px) {
  .topbar { display: block; }
  .topStats { justify-content: flex-start; margin-top: 6px; }
  .layout { display: flex; flex-direction: column; }
  .sidebar { order: 2; }
  .replay { order: 1; }
  .handList { display: none; }
  .compact { display: none; }
  .tablePanel { min-height: 68vh; }
  .pokerTable { top: 46%; width: 68%; height: 40%; }
  .seat { width: 92px; }
  .seat.opponent { width: auto; min-width: 46px; }
  .boardWrap { top: 42%; width: 52%; }
}
