:root {
  --felt: #1e6e4c;
  --felt-dark: #124a32;
  --ink: #16211c;
  --ink-muted: #57685e;
  --paper: #f6f7f5;
  --surface: #ffffff;
  --rule: #dde3de;
  --bad: #a5372e;
  --bad-soft: #f6e3e0;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

body.has-hero {
  position: relative;
  min-height: 100vh;
}

body.has-hero::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/img/hero.jpg") center / cover no-repeat;
  opacity: 0.5;
}

body.has-hero .wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px -16px rgba(22, 33, 28, 0.35);
  margin-top: 64px;
  margin-bottom: 64px;
}

.wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 64px 24px;
}

.wrap.wide {
  max-width: 880px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
  text-decoration: none;
  color: inherit;
  width: fit-content;
  padding: 4px 8px 4px 4px;
  margin-left: -4px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

a.brand:hover,
a.brand:focus-visible {
  background: rgba(30, 110, 76, 0.1);
}

.brand .dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--felt);
}

.brand span {
  font-weight: 700;
  font-size: 36px;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 24px;
  margin: 0 0 6px;
}

p.lead {
  color: var(--ink-muted);
  margin: 0 0 28px;
  font-size: 14.5px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 5px;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
}

input:focus {
  outline: 2px solid var(--felt);
  outline-offset: -1px;
}

/* The blanket `input` rule above is sized for text/email/password fields
   — a checkbox/radio inheriting width:100%+padding+border stretches into
   a large rectangle that overlaps whatever text sits next to it. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

/* Same problem, different shape — a color swatch stretched to
   width:100% by the blanket `input` rule is unusable. */
input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

button, a.btn {
  background: var(--felt);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

button:hover, a.btn:hover { background: var(--felt-dark); }
button:disabled { opacity: 0.6; cursor: default; }

button.ghost, a.btn.ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
}

.msg {
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 4px;
}

.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: #e4efe8; color: var(--felt-dark); }

.foot-links {
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
}

.foot-links a {
  color: var(--felt);
  text-decoration: none;
}

/* games page */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.topbar button.ghost {
  padding: 7px 12px;
  font-size: 13px;
  margin-top: 0;
}

/* Shared nav-link style for the topbar (see renderTopbar() in api.js) —
   also usable standalone wherever a page needs a topbar-style link. */
.navlink {
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-muted);
}

.topbar-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.navlink.active {
  background: var(--felt);
  border-color: var(--felt);
  color: #fff;
}

.game-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.game-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.game-card .meta b { color: var(--ink); font-size: 15px; }

.shot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  font-size: 13.5px;
}

.shot-row:first-of-type { border-top: none; }

.shot-row button {
  margin: 0;
  padding: 5px 10px;
  font-size: 12.5px;
}

.empty {
  text-align: center;
  color: var(--ink-muted);
  padding: 60px 0;
  font-size: 14.5px;
}

/* Video tile grid — every shot is a slot, whether or not it has a video
   yet. A wireframe placeholder is a real, intentional state (loading, no
   shots, no games at all), not an error and not a blank void. */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.video-tile {
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1.5px dashed var(--rule);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 11.5px;
  cursor: default;
  position: relative;
  padding: 6px;
  text-align: center;
}

.video-tile.has-shot {
  border-style: solid;
  border-color: var(--rule);
  background: var(--surface);
  cursor: pointer;
  color: var(--ink);
}

.video-tile.has-shot:hover {
  border-color: var(--felt);
}

.video-tile .tile-play {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent var(--ink-muted);
  opacity: 0.35;
}

.video-tile.has-shot .tile-play {
  border-color: transparent transparent transparent var(--felt);
  opacity: 1;
}

.video-tile.has-shot:disabled,
.video-tile.has-shot[aria-busy="true"] {
  opacity: 0.6;
  cursor: default;
}

.video-tile .tile-label {
  font-weight: 600;
  color: inherit;
}

/* Real thumbnail, when the Nano saved one for this shot — fills the tile,
   play icon + label float on top of a bottom scrim for legibility. Falls
   back to the plain wireframe tile automatically (has-thumb just never
   gets added) when no thumbnail exists — not every shot gets one. */
.video-tile .tile-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: none;
}

.video-tile.has-thumb {
  background: #000;
}

.video-tile.has-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.05) 55%, transparent 72%);
  z-index: 0;
}

.video-tile.has-thumb .tile-thumb {
  display: block;
}

.video-tile.has-thumb .tile-play,
.video-tile.has-thumb .tile-label {
  position: relative;
  z-index: 1;
}

.video-tile.has-thumb .tile-play {
  border-color: transparent transparent transparent #fff;
  opacity: 0.95;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.video-tile.has-thumb .tile-label {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.video-caption {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 8px 0 0;
}

.video-tile .tile-favorite {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 2;
  font-size: 15px;
  line-height: 1;
  color: #d9a441;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

video.player {
  width: 100%;
  border-radius: 8px;
  margin-top: 10px;
  background: #000;
}

/* Video + canvas overlay, stacked (My games) — same object-fit:contain +
   absolutely-positioned canvas pattern as Shot Review's .stage on the Nano,
   so BilliardsOverlay's draw functions map frame px to screen px identically
   in both places. Hidden until a shot with a video is actually played. */
.player-stage {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: none;
}

.player-stage video.player {
  display: block;
  width: 100%;
  height: 100%;
  margin-top: 0;
  border-radius: 0;
  object-fit: contain;
}

.player-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.overlay-toggles {
  display: none;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 12px;
}

.overlay-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--ink-muted);
}

.debug-panel {
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
  /* JSON.stringify() has no spaces, so a nested object value (shot_outcome,
     rf_analytics, etc.) can be one very long unbroken "word" -- pre-wrap only
     breaks at whitespace, and a flex item's default min-width:auto refuses
     to shrink below that word's width, blowing the whole sidebar out to
     however wide the JSON string needed to be (confirmed live: the sidebar
     grew to 2611px and the video looked "fullscreen"). Break it anywhere. */
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow-y: auto;
}

/* Games filter bar */
.games-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.games-filters input[type="text"],
.games-filters select,
.games-filters input[type="date"] {
  font-size: 13px;
  padding: 6px 8px;
  width: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.games-filters input[type="text"] {
  width: 160px;
}

.games-filters input[type="date"] {
  width: 140px;
}

.filter-date-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* My games: shots list on the left, a persistent video pane on the right
   (sticky — stays in view while scrolling the shot list) instead of a
   player at the bottom of the page that yanked scroll focus down on every
   click. Stacks below the list on narrow viewports. */
.games-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

/* Equal flex-basis 0 with equal grow -- true 50/50 of whatever width is
   left after the gap, regardless of content (a long shot-row caption or a
   wide video won't tip the split, since min-width:0 lets both shrink
   below their content's natural size). */
.games-main {
  flex: 1 1 0;
  min-width: 0;
}

.games-sidebar {
  flex: 1 1 0;
  min-width: 0;
  position: sticky;
  top: 24px;
}

@media (max-width: 1100px) {
  .games-layout {
    flex-direction: column;
  }
  .games-sidebar {
    position: static;
    width: 100%;
  }
}

/* Shot list (My games) — a row per shot instead of a small thumbnail
   grid, so the call-out text and video-availability status have room to
   read at a glance without clicking through. */
.shot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.shot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.shot-row:hover {
  border-color: var(--felt);
}

.shot-row[aria-busy="true"], .shot-row:disabled {
  opacity: 0.6;
  cursor: default;
}

.shot-row-thumb {
  position: relative;
  flex: 0 0 120px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: 1.5px dashed var(--rule);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.shot-row-thumb .tile-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.shot-row-thumb.has-thumb {
  border-style: solid;
  background: #000;
}

.shot-row-thumb.has-thumb .tile-thumb {
  display: block;
}

.shot-row-thumb .tile-play {
  position: relative;
  z-index: 1;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent var(--ink-muted);
  opacity: 0.35;
}

.shot-row-thumb.has-thumb .tile-play {
  border-color: transparent transparent transparent #fff;
  opacity: 0.95;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.shot-row-info {
  flex: 1;
  min-width: 0;
}

.shot-row-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.shot-row-duration {
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 12.5px;
}

.shot-row-novideo {
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-style: italic;
}

.shot-row-caption {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 3px 0 0;
  line-height: 1.35;
}

.shot-row-favorite {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #d9a441;
  padding: 4px;
}

.shot-row-placeholder {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1.5px dashed var(--rule);
  border-radius: 10px;
  color: var(--ink-muted);
  font-size: 13px;
}

.shot-row-placeholder .shot-row-thumb {
  flex: 0 0 120px;
}

.tab-bar {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 2px;
  margin: 0;
  cursor: pointer;
  border-radius: 0;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover { background: none; color: var(--ink); }
.tab-btn.active { color: var(--felt-dark); border-bottom-color: var(--felt); }

/* Subscription tier tiles — placeholder preview, not wired to billing yet. */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 760px) {
  .tier-grid { grid-template-columns: 1fr; }
}

.tier-tile {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* Current plan: solid border + soft glow — a statement of fact, no animation. */
.tier-tile.tier-current {
  border: 2px solid var(--felt);
  box-shadow: 0 0 0 3px rgba(30, 110, 76, 0.12);
}

.tier-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.tier-tile h3 { margin: 0 0 2px; font-size: 16px; }

.tier-tile .tier-price {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.tier-tile ul {
  font-size: 13.5px;
  color: var(--ink-muted);
  margin: 0 0 16px;
  padding-left: 18px;
  line-height: 1.85;
  flex: 1;
}

/* Same visual weight as .tier-price everywhere else -- reads as one plain
   text line by default, only the selected value gets a pill behind it. */
.interval-pills {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.interval-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.interval-pill:hover { background: var(--paper); }

.interval-pill.selected {
  background: var(--felt);
  color: #fff;
  font-weight: 700;
}

/* Once subscribed, the pill row is a status display, not a picker. */
.interval-pills.locked .interval-pill { cursor: default; }
.interval-pills.locked .interval-pill:hover { background: none; }
.interval-pills.locked .interval-pill.selected:hover { background: var(--felt); }

/* News article WYSIWYG editor (admin/news.html) — a plain contenteditable
   styled to match the rest of the form, not a third-party widget. */
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  row-gap: 6px;
  margin-bottom: 6px;
}

.rte-toolbar button {
  background: var(--surface);
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  cursor: pointer;
}

.rte-toolbar button:hover { background: var(--paper); color: var(--ink); }

.rte-toolbar select {
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}

.rte-toolbar .rte-sep {
  width: 1px;
  align-self: stretch;
  background: var(--rule);
  margin: 2px 2px;
}

.rte-toolbar label.rte-swatch {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
}

.rte-editor {
  min-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.6;
  background: var(--surface);
  color: var(--ink);
}

.rte-editor:focus { outline: 2px solid var(--felt); outline-offset: -1px; }
.rte-editor p { margin: 0 0 10px; }
.rte-editor img { max-width: 100%; border-radius: 8px; display: block; margin: 8px 0; }

/* Rendered article body on the public pages — mirrors the editor's own
   spacing so what an admin sees while writing matches what a reader sees. */
.article-body {
  font-size: 13.5px;
  color: var(--ink-muted);
}

.article-body p { margin: 0 0 10px; }
.article-body p:last-child { margin-bottom: 0; }
.article-body img { max-width: 100%; border-radius: 8px; display: block; margin: 8px 0; }
.article-body a { color: var(--felt); }
.article-body ul, .article-body ol,
.rte-editor ul, .rte-editor ol { margin: 0 0 10px; padding-left: 22px; }

.article-body h2, .rte-editor h2 { font-size: 18px; margin: 14px 0 8px; color: var(--ink); }
.article-body h3, .rte-editor h3 { font-size: 15.5px; margin: 12px 0 6px; color: var(--ink); }
.article-body h2:first-child, .article-body h3:first-child,
.rte-editor h2:first-child, .rte-editor h3:first-child { margin-top: 0; }

.article-body blockquote, .rte-editor blockquote {
  border-left: 3px solid var(--felt);
  margin: 10px 0;
  padding: 2px 0 2px 14px;
  font-style: italic;
}

.badge-future {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 16px 0;
  align-self: center;
}
