/*
 * Reef Room table. Every colour is a --pk-* token from the theme file (painted into the page by the theme style), so a
 * new theme restyles the table without touching this sheet. Motion lives in the page script (Web Animations API,
 * transform and opacity only); this sheet only adds hover and focus states.
 */
[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.story {
  margin: 0;
  background: var(--pk-sky);
  color: var(--pk-ink);
  font: 400 15px / 1.5 var(--lt-font-ui);
  -webkit-font-smoothing: antialiased;
}

.story-main {
  display: block;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--pk-accent);
}

:focus-visible {
  outline: 2px solid var(--pk-accent);
  outline-offset: 2px;
}

.pk-app {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 560px;
}

/* Top bar: brand, badge, hand info, stack and two icons. It never wraps; the least useful item hides first. */
.pk-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--pk-panel-line);
  background: var(--pk-panel);
  white-space: nowrap;
  min-width: 0;
}

.pk-brand,
.pk-brand-line {
  margin: 0;
  font: 700 18px / 1 var(--lt-font-ui);
  letter-spacing: -0.01em;
}

.pk-brand a,
.pk-brand-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--pk-ink);
  text-decoration: none;
}

.pk-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 5px solid var(--pk-accent);
  background: var(--pk-chip-3);
  flex: none;
}

.pk-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--pk-sky-deep);
  color: var(--pk-ink);
  font-size: 12px;
  font-weight: 600;
}

.pk-hand-info {
  margin: 0 auto;
  color: var(--pk-ink-muted);
  font-size: 14px;
}

.pk-stack {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 0 auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pk-hand-info + .pk-stack {
  margin-left: 0;
}

/* Read by screen readers, not shown: the play page does not load the shared component sheet. */
.pk-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pk-chip-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--pk-chip-1);
  background: var(--pk-chip-3);
}

.pk-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.pk-icon:hover {
  background: var(--pk-sky);
}

/* Stage: the table over the controls. */
.pk-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pk-table {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 8px 16px 0;
}

.pk-felt {
  position: absolute;
  inset: 4% 8% 12%;
  border: 10px solid var(--pk-rim);
  border-radius: 999px;
  background: var(--pk-felt);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
}

.pk-felt::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid var(--pk-felt-edge);
  border-radius: 999px;
  pointer-events: none;
}

.pk-pot {
  margin: 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--pk-felt-edge);
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  z-index: 1;
}

.pk-board {
  display: flex;
  gap: 6px;
  z-index: 1;
}

.pk-slot {
  width: var(--pk-card-w);
  height: var(--pk-card-h);
  border: 1px solid var(--pk-felt-edge);
  border-radius: 6px;
}

/* Cards. */
.pk-table {
  --pk-card-w: 42px;
  --pk-card-h: 58px;
}

.pk-card {
  position: relative;
  width: var(--pk-card-w);
  height: var(--pk-card-h);
  border-radius: 6px;
  background: var(--pk-card-face);
  color: var(--pk-card-black);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  font-weight: 700;
  line-height: 1;
}

.pk-card[data-suit="h"],
.pk-card[data-suit="d"] {
  color: var(--pk-card-red);
}

.pk-rank {
  position: absolute;
  top: 5px;
  left: 6px;
  font-size: calc(var(--pk-card-w) * 0.38);
}

.pk-suit {
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-size: calc(var(--pk-card-w) * 0.5);
}

.pk-back {
  background: var(--pk-card-back);
  border: 2px solid var(--pk-card-back-line);
}

.pk-card-sm {
  --pk-card-w: 26px;
  --pk-card-h: 36px;
}

.pk-card-sm .pk-rank {
  top: 3px;
  left: 4px;
}

.pk-card-sm .pk-suit {
  right: 3px;
  bottom: 2px;
}

/* Seats. Seat 0 is the person at the bottom; seats 1 to 5 go round clockwise. */
.pk-seats {
  position: absolute;
  inset: 0;
}

.pk-seat {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 2px;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.pk-seat[data-seat="1"] { left: 10%; top: 66%; }
.pk-seat[data-seat="2"] { left: 10%; top: 30%; }
.pk-seat[data-seat="3"] { left: 50%; top: 9%; }
.pk-seat[data-seat="4"] { left: 90%; top: 30%; }
.pk-seat[data-seat="5"] { left: 90%; top: 66%; }

.pk-seat.pk-hero {
  left: 50%;
  top: auto;
  bottom: 0;
  transform: translate(-50%, 0);
  grid-template-areas: "status status" "cards cards" "plate plate";
}

.pk-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--pk-panel);
  border: 2px solid var(--pk-panel-line);
}

.pk-avatar svg {
  width: 40px;
  height: 40px;
}

.pk-av-body {
  fill: var(--pk-member);
}

.pk-av-limbs {
  fill: none;
  stroke: var(--pk-member);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.pk-av-lines {
  fill: none;
  stroke: var(--pk-ink);
  stroke-width: 1.1;
  stroke-linecap: round;
}

.pk-av-eyes {
  fill: var(--pk-ink);
}

.pk-hero .pk-avatar {
  display: none;
}

.pk-plate {
  display: grid;
  justify-items: center;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--pk-panel);
  border: 1px solid var(--pk-panel-line);
  font-size: 12px;
  line-height: 1.3;
}

.pk-plate-name {
  font-weight: 600;
}

.pk-plate-stack {
  color: var(--pk-ink-muted);
  font-variant-numeric: tabular-nums;
}

.pk-hero .pk-plate {
  grid-area: plate;
  padding: 4px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--pk-hero);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.pk-hero .pk-plate-name {
  display: none;
}

.pk-hero .pk-plate-stack {
  color: inherit;
}

.pk-status {
  min-height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--pk-panel);
  font-size: 11px;
  font-weight: 600;
}

.pk-status:empty {
  visibility: hidden;
}

.pk-hero .pk-status {
  grid-area: status;
}

.pk-hole {
  display: flex;
  gap: 2px;
  min-height: 36px;
}

.pk-hero .pk-hole {
  grid-area: cards;
  gap: 8px;
  --pk-card-w: 62px;
  --pk-card-h: 86px;
}

.pk-seat:not(.pk-hero) .pk-hole {
  position: absolute;
  top: 18px;
  left: calc(50% + 18px);
}

/* Seats on the right edge show their cards toward the middle, so nothing passes the screen edge. */
.pk-seat[data-seat="4"] .pk-hole,
.pk-seat[data-seat="5"] .pk-hole {
  left: auto;
  right: calc(50% + 18px);
}

.pk-bet {
  position: absolute;
  padding: 2px 10px 2px 22px;
  border-radius: 999px;
  background: var(--pk-felt-edge);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pk-bet:empty {
  display: none;
}

.pk-bet::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 3px solid var(--pk-chip-1);
  background: var(--pk-chip-3);
}

.pk-seat[data-seat="0"] .pk-bet { left: calc(100% + 8px); top: 10px; }
.pk-seat[data-seat="1"] .pk-bet,
.pk-seat[data-seat="2"] .pk-bet { left: calc(100% + 4px); top: 60%; }
.pk-seat[data-seat="3"] .pk-bet { top: calc(100% + 4px); left: 50%; margin-left: -30px; }
.pk-seat[data-seat="4"] .pk-bet,
.pk-seat[data-seat="5"] .pk-bet { right: calc(100% + 4px); top: 60%; }

.pk-seat[data-button]::after {
  content: "D";
  position: absolute;
  right: -10px;
  bottom: -6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pk-card-face);
  color: var(--pk-card-black);
  font-size: 11px;
  font-weight: 700;
}

.pk-seat[data-seat="4"][data-button]::after,
.pk-seat[data-seat="5"][data-button]::after {
  right: auto;
  left: -10px;
}

.pk-seat.pk-hero[data-button]::after {
  right: -28px;
  bottom: 30px;
}

.pk-folded .pk-avatar,
.pk-folded .pk-plate {
  opacity: 0.45;
}

.pk-turn .pk-avatar {
  border-color: var(--pk-accent);
  box-shadow: 0 0 0 3px var(--pk-glow);
}

.pk-winner .pk-avatar,
.pk-winner.pk-hero .pk-plate {
  box-shadow: 0 0 0 4px var(--pk-glow);
}

.pk-initial {
  font-weight: 700;
}

/* Controls: the odds chip, the presets, the slider and the three main buttons. */
.pk-controls {
  display: grid;
  gap: 8px;
  padding: 8px 16px 10px;
}

.pk-odds {
  justify-self: center;
  margin: 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--pk-panel);
  border: 1px solid var(--pk-panel-line);
  color: var(--pk-ink-muted);
  font-size: 13px;
}

.pk-actions {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  justify-self: center;
}

.pk-actions[data-live="false"] {
  opacity: 0.55;
}

.pk-presets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.pk-main {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.pk-actions button,
.pk-wide {
  min-height: 40px;
  border: 1px solid var(--pk-panel-line);
  border-radius: 8px;
  background: var(--pk-panel);
  cursor: pointer;
}

.pk-main button {
  min-height: 50px;
  font-size: 16px;
}

.pk-actions button:not(:disabled):hover,
.pk-wide:hover {
  border-color: var(--pk-accent);
}

.pk-actions button:disabled {
  cursor: default;
}

.pk-primary,
.pk-actions .pk-primary {
  background: var(--pk-accent);
  border-color: var(--pk-accent);
  color: var(--pk-accent-ink);
  font-weight: 600;
}

.pk-actions input[type="range"] {
  width: 100%;
  accent-color: var(--pk-accent);
}

.pk-fine {
  margin: 0;
  text-align: center;
  color: var(--pk-ink-muted);
  font-size: 12px;
}

/* The coach: a bottom sheet on phones, a right panel on wide screens. */
.pk-side {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: none;
  max-height: 82dvh;
  overflow: auto;
  padding: 20px 16px 24px;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--pk-panel-line);
  background: var(--pk-panel);
}

.pk-side[data-open] {
  display: grid;
  gap: 16px;
  align-content: start;
}

.pk-eyebrow {
  margin: 0;
  color: var(--pk-ink-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pk-note,
.pk-review {
  display: grid;
  gap: 12px;
}

.pk-note-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.pk-decisions,
.pk-leaks {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pk-decision {
  padding: 12px 14px;
  border: 1px solid var(--pk-panel-line);
  border-left-width: 4px;
  border-radius: 8px;
}

.pk-decision.pk-good { border-left-color: var(--pk-good); }
.pk-decision.pk-mistake { border-left-color: var(--pk-mistake); }

.pk-decision p {
  margin: 4px 0 0;
}

.pk-verdict {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  letter-spacing: 0;
  text-transform: none;
}

.pk-verdict.pk-good { background: var(--pk-good); }
.pk-verdict.pk-ok { background: var(--pk-ink-muted); }
.pk-verdict.pk-mistake { background: var(--pk-mistake); }

.pk-did {
  font-weight: 600;
}

.pk-line-label {
  color: var(--pk-ink-muted);
  font-weight: 600;
}

.pk-muted {
  color: var(--pk-ink-muted);
}

.pk-small {
  font-size: 13px;
}

.pk-score {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
}

.pk-score-num {
  color: var(--pk-accent);
  font: 700 56px / 1 var(--lt-font-ui);
  letter-spacing: -0.03em;
}

.pk-count {
  float: right;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--pk-sky-deep);
  font-size: 12px;
}

.pk-drill-box {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--pk-sky);
}

.pk-drill-box p:last-child {
  margin: 4px 0 0;
}

.pk-coach {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--pk-panel-line);
}

.pk-coach p {
  margin: 0;
}

.pk-review:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
  align-content: start;
  padding: 20px 16px;
  background: var(--pk-sky);
}

.pk-session {
  display: grid;
  gap: 6px;
}

.pk-session p {
  margin: 0;
}

.pk-session progress {
  width: 100%;
  height: 8px;
  accent-color: var(--pk-accent);
}

.pk-link {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pk-accent);
  text-decoration: underline;
  cursor: pointer;
}

.pk-wide {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

/* 18+ gate and settings. */
.pk-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--pk-sky);
}

.pk-gate-card {
  display: grid;
  gap: 12px;
  width: min(100%, 420px);
  max-height: 100%;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--pk-panel-line);
  border-radius: 16px;
  background: var(--pk-panel);
}

.pk-question {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.pk-notice {
  margin: 0;
  color: var(--pk-ink-muted);
  font-size: 13px;
}

.pk-settings {
  width: min(calc(100% - 32px), 440px);
  padding: 24px;
  border: 1px solid var(--pk-panel-line);
  border-radius: 16px;
  background: var(--pk-panel);
  color: var(--pk-ink);
}

.pk-settings::backdrop {
  background: rgba(4, 20, 31, 0.5);
}

.pk-settings h2 {
  margin: 0 0 16px;
  font-size: 20px;
}

.pk-field {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.pk-theme-option,
.pk-radio {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
}

.pk-theme-option input:disabled + span {
  opacity: 0.7;
}

.pk-lock {
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--pk-sky-deep);
  font-size: 12px;
  font-weight: 600;
}

/* Below the table: how to play, the table log and the full notice. */
.pk-more {
  display: grid;
  gap: 16px;
  width: min(100% - 32px, 44rem);
  margin: 40px auto 64px;
}

.pk-more h2 {
  margin: 0;
  font-size: 22px;
}

.pk-more p {
  margin: 0;
}

.pk-log-box ol {
  max-height: 240px;
  overflow: auto;
  color: var(--pk-ink-muted);
  font-size: 13px;
}

.story-status {
  padding: 40px 16px;
  background: var(--pk-panel);
  color: var(--pk-ink-muted);
  font-size: 13px;
}

.story-status > * {
  width: min(100%, 40rem);
  margin-inline: auto;
}

.story-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--pk-ink);
  font-weight: 600;
  text-decoration: none;
}

.story-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}

.story-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--pk-ink-muted);
}

/* Phones: hide what the bar cannot fit, and keep the table portrait. */
@media (max-width: 520px) {
  .pk-badge,
  .pk-hand-info {
    display: none;
  }

  .pk-hand-info + .pk-stack {
    margin-left: auto;
  }

  .pk-felt {
    inset: 3% 9% 15%;
  }
}

/* Wide screens: the coach is a right panel and the table is landscape. */
@media (min-width: 1024px) {
  .pk-app {
    grid-template-columns: minmax(0, 1fr) 380px;
  }

  .pk-top {
    grid-column: 1 / -1;
  }

  .pk-top #pk-coach-open {
    display: none;
  }

  .pk-table {
    --pk-card-w: 62px;
    --pk-card-h: 86px;
    margin: 16px 24px 0;
  }

  .pk-felt {
    inset: 8% 8% 12%;
  }

  .pk-seat[data-seat="1"] { left: 7%; top: 50%; }
  .pk-seat[data-seat="2"] { left: 28%; top: 9%; }
  .pk-seat[data-seat="3"] { left: 72%; top: 9%; }
  .pk-seat[data-seat="4"] { left: 93%; top: 50%; }
  .pk-seat[data-seat="5"] { left: 78%; top: 86%; }

  .pk-hero .pk-hole {
    --pk-card-w: 78px;
    --pk-card-h: 108px;
  }

  .pk-side,
  .pk-side[data-open] {
    position: static;
    display: grid;
    gap: 16px;
    align-content: start;
    max-height: none;
    min-height: 0;
    overflow: auto;
    padding: 24px;
    border-radius: 0;
    border-top: 0;
    border-left: 1px solid var(--pk-panel-line);
  }

  .pk-review:not([hidden]) {
    position: static;
    padding: 0;
    background: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
