/* PracticeOS — Apple HIG–inspired: clear hierarchy, grouped lists, soft dark chrome */

:root {
  color-scheme: dark;
  --bg: #000000;
  --grouped: #1c1c1e;
  --grouped-elevated: #2c2c2e;
  --separator: rgba(84, 84, 88, 0.65);
  --label: #ffffff;
  --secondary: rgba(235, 235, 245, 0.6);
  --tertiary: rgba(235, 235, 245, 0.3);
  --tint: #0a84ff;
  --tint-press: #409cff;
  --fill: rgba(120, 120, 128, 0.32);
  --fill-secondary: rgba(120, 120, 128, 0.24);
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--label);
}

body {
  overflow-x: hidden;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(0.75rem + var(--safe-top)) 1rem calc(1.5rem + var(--safe-bottom));
  min-height: 100vh;
}

/* —— tvOS room board: full viewport width (HIG: 10ft UI, large type, overscan margin) —— */
html.tv-mode,
body.tv-mode {
  background: #000;
  overflow: hidden;
}

body.tv-mode #app {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

body.tv-mode .nav-bar {
  display: none; /* board has its own top bar */
}

body.tv-mode .screen-board {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  /* tvOS-style safe margin from bezel / overscan */
  padding: clamp(0.85rem, 2.2vh, 1.75rem) clamp(1.25rem, 3.5vw, 3rem) clamp(0.75rem, 2vh, 1.5rem);
  gap: clamp(0.5rem, 1.2vh, 1rem);
  box-sizing: border-box;
  max-width: none;
}

body.tv-mode .tv-hero {
  flex: 0 0 auto;
}

body.tv-mode .tv-ritual {
  flex: 0 0 auto;
}

/* Top bar: brand · agenda · join code */
.tv-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}

.tv-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.tv-logo {
  font-size: clamp(1.15rem, 1.6vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tv-live {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(48, 209, 88, 0.18);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: capitalize;
}

/* Single-row phase track: overflow scrolls, scrollbar hidden; JS keeps active chip in view */
.tv-agenda {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  background: var(--grouped);
  border-radius: 999px;
  min-width: 0; /* grid child must shrink so overflow-x can engage */
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

.tv-agenda::-webkit-scrollbar {
  display: none; /* Chromium / Safari */
  width: 0;
  height: 0;
}

.tv-agenda li {
  flex: 0 0 auto;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: clamp(0.85rem, 1.1vw, 1.05rem);
  font-weight: 600;
  color: var(--secondary);
  white-space: nowrap;
}

.tv-agenda li.active {
  background: #fff;
  color: #000;
}

.tv-agenda li.done {
  opacity: 0.4;
  text-decoration: line-through;
}

.tv-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-self: end;
}

.tv-leave {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tv-leave:hover,
.tv-leave:focus-visible {
  color: var(--label);
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}

.tv-code {
  padding: 0.55rem 1rem;
  border-radius: 14px;
  background: var(--grouped);
  font-size: clamp(1rem, 1.4vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--tint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Hero: phase + giant clock (primary focus from 10ft) */
.tv-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  width: 100%;
  padding: clamp(1.25rem, 2.5vh, 2rem) clamp(1.5rem, 2.5vw, 2.5rem);
  border-radius: 28px;
  background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.tv-hero-copy {
  min-width: 0;
  flex: 1;
}

.tv-kicker {
  margin: 0 0 0.25rem;
  font-size: clamp(0.85rem, 1.1vw, 1.05rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--secondary);
}

.tv-phase {
  margin: 0;
  font-size: clamp(2rem, 4.2vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tv-next {
  margin: 0.5rem 0 0;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  color: var(--secondary);
}

.tv-hero-clock {
  flex: 0 0 auto;
  font-size: clamp(4.5rem, 12vw, 9rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
  line-height: 1;
  color: #fff;
}

.tv-time-up {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 159, 10, 0.2);
  color: var(--orange);
  font-size: clamp(0.9rem, 1.2vw, 1.1rem);
  font-weight: 700;
}

/* Main: stations + creature (left) | activity log full height (right) */
.tv-main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(20rem, 32vw);
  gap: clamp(0.85rem, 1.6vw, 1.5rem);
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  align-items: stretch;
  height: 0; /* flex child trick: fill remaining viewport */
  flex-grow: 1;
}

.tv-stations {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.tv-section-label {
  margin: 0;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
}

.tv-station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: clamp(0.75rem, 1.5vw, 1.25rem);
  width: 100%;
}

.tv-station-card {
  background: var(--grouped);
  border-radius: 20px;
  padding: clamp(0.85rem, 1.4vw, 1.25rem);
  /* Compact stations — leave vertical room for creature + right log */
  min-height: clamp(5.5rem, 11vh, 8.5rem);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  outline: 2px solid transparent;
  transition:
    outline-color 0.15s ease,
    transform 0.15s ease;
}

.tv-station-card:hover,
.tv-station-card:focus-within {
  outline-color: rgba(10, 132, 255, 0.55);
  transform: scale(1.01);
}

.tv-station-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.tv-station-card h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tv-station-status {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tertiary);
}

.tv-station-card .time {
  font-size: clamp(2.25rem, 4.5vw, 3.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.tv-station-card .who {
  margin-top: 0.65rem;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  color: var(--secondary);
  font-weight: 500;
}

.tv-assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.tv-assign-card {
  background: var(--grouped);
  border-radius: 16px;
  padding: 0.85rem 1rem;
}

.tv-assign-card h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
}

.tv-assign-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--secondary);
  font-size: 0.95rem;
}

.tv-assign-card .empty {
  list-style: none;
  margin-left: -1.1rem;
  color: var(--tertiary);
}

/* Right column: activity log only (team lives on ritual row with QR) */
.tv-side {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
}

.tv-panel {
  background: var(--grouped);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.tv-panel-activity {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.tv-team {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tv-chip {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--fill);
  font-size: clamp(0.75rem, 0.95vw, 0.9rem);
  font-weight: 600;
  color: var(--label);
}

.tv-activity {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  /* Smooth scroll on TV remotes / trackpads */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.tv-activity:empty::after {
  content: 'Shout-outs and notes appear here — scan the QR to celebrate';
  color: var(--tertiary);
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 0.5rem 0.15rem;
}

.tv-activity .activity-item {
  background: var(--fill-secondary);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  flex-shrink: 0;
}

.tv-activity .activity-body {
  font-size: clamp(0.9rem, 1.15vw, 1.1rem);
  line-height: 1.35;
}

/* Rainforest creature reveal (under stations) */
.tv-creature {
  margin-top: auto;
  flex: 1 1 auto;
  min-height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(20, 60, 40, 0.55), rgba(10, 20, 16, 0.9));
  border: 1px solid rgba(48, 209, 88, 0.18);
  cursor: pointer;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.tv-creature:hover,
.tv-creature:focus-visible {
  border-color: rgba(48, 209, 88, 0.45);
  box-shadow: 0 0 28px rgba(48, 209, 88, 0.15);
}

.tv-creature.locked .creature-silhouette {
  opacity: 0.55;
  filter: blur(1px) brightness(0.45);
}

.tv-creature.revealed {
  border-color: rgba(255, 214, 10, 0.35);
  box-shadow: 0 0 32px rgba(255, 214, 10, 0.12);
}

.tv-creature-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
}

.creature-sprite {
  position: relative;
  width: clamp(7rem, 14vw, 11rem);
  height: clamp(7rem, 14vw, 11rem);
}

.creature-silhouette {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, rgba(120, 220, 160, 0.35), transparent 55%),
    radial-gradient(circle at 50% 60%, #1a3d2a 0%, #0a1610 70%);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.45);
}

.creature-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}

.creature-img.hidden {
  display: none;
}

.creature-caption {
  margin: 0;
  max-width: 22rem;
  text-align: center;
  font-size: clamp(0.8rem, 1.05vw, 0.95rem);
  font-weight: 600;
  color: var(--secondary);
  line-height: 1.35;
}

.tv-creature.revealed .creature-caption {
  color: var(--label);
}

/* Hint dialog (tvOS modal card) */
.tv-hint {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  padding: 2rem;
}

.tv-hint.hidden {
  display: none;
}

.tv-hint-card {
  width: min(28rem, 100%);
  background: var(--grouped);
  border-radius: 22px;
  padding: 1.5rem 1.35rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.tv-hint-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tint);
}

.tv-hint-title {
  margin: 0 0 0.65rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tv-hint-body {
  margin: 0 0 1.15rem;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--secondary);
}

/* Display-name sheet — phone-first HIG modal (REQ-UI-007) */
.name-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom));
}

.name-sheet.hidden {
  display: none;
}

.name-sheet-card {
  width: min(26rem, 100%);
  background: var(--grouped);
  border-radius: 22px;
  padding: 1.35rem 1.25rem 1.25rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.name-sheet-kicker {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tint);
}

.name-sheet-title {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--label);
  line-height: 1.2;
}

.name-sheet-body {
  margin: 0 0 1rem;
  font-size: 0.98rem;
  line-height: 1.4;
  color: var(--secondary);
}

.name-sheet-row {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
  align-items: stretch;
}

.name-sheet-input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 12px;
  background: var(--fill);
  color: var(--label);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.85rem 0.95rem;
  outline: none;
}

.name-sheet-input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 45%, transparent);
}

.name-sheet-shuffle {
  flex: 0 0 auto;
  min-width: 5.5rem;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font-weight: 600;
}

@media (min-width: 600px) {
  .name-sheet {
    align-items: center;
  }
}

/* Ultra-wide TV: wider activity rail */
@media (min-width: 1400px) {
  body.tv-mode .screen-board {
    padding-left: clamp(2rem, 5vw, 4rem);
    padding-right: clamp(2rem, 5vw, 4rem);
  }

  .tv-main {
    grid-template-columns: minmax(0, 1.1fr) minmax(24rem, 36vw);
  }
}

/* Short TVs / 720p: shrink chrome so activity log stays readable */
@media (max-height: 800px) {
  body.tv-mode .screen-board {
    padding-top: 0.65rem;
    padding-bottom: 0.5rem;
    gap: 0.4rem;
  }

  body.tv-mode .tv-hero {
    padding: 0.55rem 1rem;
  }

  body.tv-mode .tv-hero-clock,
  body.tv-mode #phase-remaining {
    font-size: clamp(2.5rem, 8vh, 3.75rem) !important;
  }

  body.tv-mode .tv-phase {
    font-size: clamp(1.35rem, 3.2vh, 1.85rem);
  }

  body.tv-mode .tv-qr {
    width: 5.5rem;
    height: 5.5rem;
  }

  body.tv-mode .mascot {
    width: 3.75rem;
    height: 3.75rem;
  }

  body.tv-mode .tv-ritual-team {
    max-height: none;
    padding: 0.55rem 0.75rem;
  }

  body.tv-mode .tv-ritual-team .tv-chip {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  body.tv-mode .tv-qr {
    width: 5.25rem;
    height: 5.25rem;
  }

  body.tv-mode .creature-sprite {
    width: clamp(5rem, 12vh, 7rem);
    height: clamp(5rem, 12vh, 7rem);
  }
}

/* Portrait / narrow cast: stack side under stations */
@media (max-width: 900px) {
  .tv-main {
    grid-template-columns: 1fr;
  }

  .tv-topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .tv-agenda {
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
  }

  .tv-hero {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* —— Nav —— */
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  min-height: 2rem;
}

.nav-title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-nav-logout {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--tint);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn-nav-logout:hover {
  background: var(--fill-secondary);
}

.btn-nav-logout:active {
  opacity: 0.85;
}

.status-chip {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary);
  text-transform: capitalize;
}

/* TV board keeps a single Log out (leave-display in .tv-topbar).
   Do not re-show .nav-bar here — an earlier rule hides it; a fixed nav
   logout was stacking on top of the board chrome (double Log out). */

/* —— Screens —— */
.screen {
  animation: fade-in 0.22s ease;
}

.screen-board {
  max-width: none;
}

/* —— Quiet root landing —— */
.screen-landing {
  padding-top: 0.5rem;
}

.landing-hero {
  margin-bottom: 1.75rem;
}

.landing-lede {
  margin: 0.75rem 0 0;
  max-width: 28rem;
  font-size: 1.0625rem;
  line-height: 1.45;
  color: var(--secondary);
  font-weight: 400;
}

.landing-card {
  background: var(--grouped);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.2rem 1.2rem;
  margin-bottom: 1.5rem;
}

.landing-card-title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.landing-card-body {
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--secondary);
}

.landing-points {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.landing-points li {
  position: relative;
  padding: 0.45rem 0 0.45rem 1.15rem;
  font-size: 0.9375rem;
  color: var(--secondary);
  border-bottom: 1px solid var(--separator);
}

.landing-points li:last-child {
  border-bottom: none;
}

.landing-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.85rem;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--tint);
}

.landing-card-demo {
  margin-top: 1rem;
  background: var(--grouped-elevated);
}

.demo-creds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.85rem 0 0.65rem;
}

.demo-cred {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.demo-cred-pin {
  border-color: rgba(10, 132, 255, 0.45);
  background: rgba(10, 132, 255, 0.12);
}

.demo-cred-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary);
}

.demo-cred-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--label);
  line-height: 1.2;
}

.landing-card-hint {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--secondary);
}

.landing-demo-status {
  margin: 0.85rem 0 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--secondary);
  word-break: break-word;
}

.landing-demo-status a {
  color: var(--tint);
  font-weight: 600;
  text-decoration: none;
}

.landing-demo-status a:hover {
  text-decoration: underline;
}

.landing-demo-status code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: var(--label);
}

.landing-demo-status .demo-status-pin {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  background: rgba(10, 132, 255, 0.16);
  color: var(--label);
  font-weight: 700;
}

#pin-label {
  flex-wrap: wrap;
}

.row-hint {
  flex: 1 0 100%;
  margin: 0;
  padding: 0 0 0.35rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--tint);
}

.coach-demo-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  background: rgba(10, 132, 255, 0.16);
  border: 1px solid rgba(10, 132, 255, 0.35);
  color: var(--label);
  font-size: 0.95rem;
  font-weight: 600;
}

.coach-demo-banner-kicker {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #0a84ff;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.coach-demo-banner code,
.coach-demo-banner strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05em;
  letter-spacing: 0.04em;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hidden {
  display: none !important;
}

.screen-hero {
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.display-title {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.subtitle {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--secondary);
}

.subtitle.tight {
  margin-bottom: 0.75rem;
}

.footnote {
  margin: 0.75rem 0 1rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--tertiary);
}

.section {
  margin-bottom: 1.75rem;
}

.section-title {
  margin: 0 0 0.65rem;
  padding-left: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* —— Grouped list (Settings-style) —— */
.grouped-list {
  margin-bottom: 1rem;
}

.group {
  background: var(--grouped);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-bottom: 0.5px solid var(--separator);
}

.row:last-child {
  border-bottom: none;
}

.row-label {
  flex: 0 0 auto;
  min-width: 5.5rem;
  font-size: 1rem;
  color: var(--label);
}

.row-control {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0.5rem 0;
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 1rem;
  text-align: right;
  appearance: none;
  -webkit-appearance: none;
}

.row-control.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.row-control:focus {
  outline: none;
}

select.row-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 1.1rem;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: var(--radius-md);
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    opacity 0.12s ease,
    transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  opacity: 0.75;
  transform: scale(0.98);
}

.btn-primary {
  background: var(--tint);
  color: #fff;
}

.btn-secondary {
  background: var(--fill);
  color: var(--tint);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}

.flex-1 {
  flex: 1;
}

.section-hint {
  margin: -0.25rem 0 0.65rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--secondary);
}

.coach-agenda {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.coach-agenda li {
  margin: 0;
  padding: 0;
}

.coach-agenda-item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  background: var(--grouped);
  color: var(--secondary);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.coach-agenda-item.active {
  background: #fff;
  color: #000;
}

.coach-agenda-item.done {
  opacity: 0.55;
  text-decoration: line-through;
}

.coach-agenda-item:active {
  opacity: 0.9;
}

/* —— Fields —— */
.field-area {
  width: 100%;
  min-height: 6.5rem;
  margin: 0 0 0.5rem;
  padding: 0.85rem 1rem;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--grouped);
  color: var(--label);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  resize: vertical;
}

.field-area:focus {
  outline: 2px solid var(--tint);
  outline-offset: 0;
}

/* —— Hero timer (TV + coach) —— */
.hero-timer {
  background: var(--grouped);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem 1.35rem;
  text-align: center;
}

.hero-timer-compact {
  margin-bottom: 1.5rem;
  text-align: left;
}

.hero-kicker {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero-title {
  margin: 0.2rem 0 0.35rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-clock {
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--label);
}

.time-up {
  margin-top: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 159, 10, 0.18);
  color: var(--orange);
  font-size: 0.875rem;
  font-weight: 600;
}

/* —— Board (TV) —— */
.screen-board {
  max-width: 1100px;
}

.board-top {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.board-top .hero-timer {
  flex: 1 1 16rem;
}

.code-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 9rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--grouped);
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--tint);
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0.35rem;
  background: var(--grouped);
  border-radius: var(--radius-md);
}

.segmented li {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--secondary);
}

.segmented li.active {
  background: var(--fill);
  color: var(--label);
  font-weight: 600;
}

.segmented li.done {
  opacity: 0.45;
  text-decoration: line-through;
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.track-card {
  background: var(--grouped);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  min-height: 8.5rem;
}

.track-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.track-card .time {
  font-size: clamp(2.25rem, 5vw, 3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.track-card .who {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--secondary);
}

.track-card .muted {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.board-next {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  color: var(--secondary);
}

.board-section {
  margin-bottom: 1.25rem;
}

.assignment-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.5rem;
}

.assignment-card {
  background: var(--grouped);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.assignment-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.assignment-card ul {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--secondary);
  font-size: 0.875rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--grouped);
  font-size: 0.875rem;
  color: var(--secondary);
}

/* —— Coach —— */
.station-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.track-pick {
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--label);
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.track-pick:active {
  opacity: 0.8;
}

.export-out {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--grouped);
  white-space: pre-wrap;
  font-size: 0.8125rem;
  line-height: 1.45;
  max-height: 40vh;
  overflow: auto;
  color: var(--secondary);
}

/* —— Live practices on join —— */
.live-list {
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.live-card {
  width: 100%;
  text-align: left;
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--grouped);
  color: var(--label);
  cursor: pointer;
}

.live-card:active {
  opacity: 0.85;
}

.live-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
}

.live-card-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

.tv-mentor-label {
  display: block;
  width: 100%;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tertiary);
}

.activity-remove {
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

/* —— Toast + activity —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  z-index: 1000;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(44, 44, 46, 0.96);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast.ok {
  border: 1px solid rgba(48, 209, 88, 0.45);
}

.toast.err {
  border: 1px solid rgba(255, 69, 58, 0.5);
}

.toast-msg {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.toast-action {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 0.4rem 0.75rem;
  background: rgba(10, 132, 255, 0.95);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-action:active {
  opacity: 0.85;
}

.inline-feedback {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
}

.inline-feedback.err {
  color: var(--red);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 22rem;
  overflow: auto;
}

.activity-list:empty::after {
  content: 'No activity yet — notes and shout-outs show up here.';
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--grouped);
  color: var(--tertiary);
  font-size: 0.875rem;
}

.activity-item {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--grouped);
}

.activity-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--secondary);
}

.activity-author {
  color: var(--tint);
}

.activity-body {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
  color: var(--label);
}

.activity-kind {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tertiary);
}

/* —— Student —— */
.note-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}

.note-list li {
  padding: 0.85rem 1rem;
  margin-bottom: 0.4rem;
  border-radius: var(--radius-md);
  background: var(--grouped);
  font-size: 0.9375rem;
  color: var(--secondary);
}

.banner {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
}

.banner-warn {
  background: rgba(255, 159, 10, 0.15);
  color: var(--orange);
}

/* —— TV scale —— */
@media (min-width: 900px) {
  .screen-board {
    padding-top: 0.5rem;
  }

  .screen-board .hero-clock {
    font-size: 5rem;
  }

  .screen-board .track-card .time {
    font-size: 3.25rem;
  }
}

/* Phone coach: bigger targets */
@media (max-width: 480px) {
  .btn {
    min-height: 3rem;
  }

  .btn-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* —— Ritual row: meter | team (fills, full height of content) | QR —— */
.tv-ritual {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) auto;
  gap: 0.75rem 1rem;
  align-items: center;
  width: 100%;
  padding: 0.35rem 0 0.5rem;
  flex: 0 0 auto;
}

.tv-ritual-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex-shrink: 0;
}

.tv-meter {
  min-width: 0;
}

/* Team sits left of QR — grow to fit full roster (no fade cutoff) */
.tv-ritual-team {
  background: var(--grouped);
  border-radius: 18px;
  padding: 0.7rem 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  min-height: 0;
  justify-content: flex-start;
  /* Room for ~3 chip rows + mentors label on a 9+4 roster */
  max-height: none;
  overflow: visible;
  align-self: center;
}

.tv-ritual-team .tv-team {
  max-height: none;
  overflow: visible;
  mask-image: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
  align-content: flex-start;
}

.tv-ritual-team .tv-section-label {
  margin: 0;
}

.tv-ritual-team .tv-chip {
  padding: 0.32rem 0.65rem;
  font-size: clamp(0.78rem, 0.95vw, 0.9rem);
}

.tv-ritual-team .tv-mentor-label {
  flex-basis: 100%;
  width: 100%;
  margin: 0.35rem 0 0.1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tertiary);
}

body.tv-mode .toast {
  /* Keep toast clear of Kiko stage (bottom-left) */
  left: auto;
  right: clamp(1.25rem, 3vw, 2.5rem);
  transform: translateY(120%);
  bottom: calc(1.25rem + var(--safe-bottom));
}

body.tv-mode .toast.show {
  transform: translateY(0);
}

.tv-mascot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 7rem;
}

.mascot {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7dffb3, #0a7a4a 55%, #043d28);
  box-shadow: 0 0 24px rgba(48, 209, 88, 0.35);
  transition:
    transform 0.35s ease,
    box-shadow 0.35s ease;
}

.mascot-body {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e8fff0, #34c759 70%);
}

/* Decorative ring (not a state class — do not name mascot-glow) */
.mascot-ring {
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  border: 2px solid rgba(52, 199, 89, 0.35);
  opacity: 0.6;
  pointer-events: none;
}

/* State modifiers: mascot-state-* only (avoid colliding with .mascot-ring) */
.mascot-state-curious {
  transform: scale(1.05);
  box-shadow: 0 0 32px rgba(10, 132, 255, 0.4);
}

.mascot-state-curious .mascot-ring {
  animation: mascot-pulse 1.6s ease-in-out infinite;
  border-color: rgba(10, 132, 255, 0.45);
}

.mascot-state-glow {
  transform: scale(1.08);
  box-shadow: 0 0 40px rgba(255, 214, 10, 0.55);
  background: radial-gradient(circle at 35% 30%, #fff3a0, #ff9f0a 55%, #9a3400);
}

.mascot-state-glow .mascot-ring {
  animation: mascot-pulse 1.2s ease-in-out infinite;
  border-color: rgba(255, 214, 10, 0.55);
}

.mascot-state-dance {
  animation: mascot-dance 0.55s ease-in-out 8;
  box-shadow: 0 0 48px rgba(255, 55, 95, 0.55);
  background: radial-gradient(circle at 35% 30%, #ffd6e0, #ff375f 55%, #7a1028);
}

.mascot-state-dance .mascot-ring {
  border-color: rgba(255, 55, 95, 0.5);
}

.mascot-state-happy {
  transform: scale(1.06);
  box-shadow: 0 0 36px rgba(48, 209, 88, 0.55);
}

.mascot-state-idle .mascot-ring {
  opacity: 0.45;
}

.mascot-label {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@keyframes mascot-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@keyframes mascot-dance {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1.05);
  }
  25% {
    transform: translateY(-10px) rotate(-12deg) scale(1.12);
  }
  50% {
    transform: translateY(0) rotate(10deg) scale(1.08);
  }
  75% {
    transform: translateY(-8px) rotate(-8deg) scale(1.14);
  }
}

.cv-meter-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.cv-pip {
  margin: 0;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--tertiary);
  font-size: clamp(0.72rem, 1.05vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 1.85rem;
  display: inline-flex;
  align-items: center;
}

.cv-pip.filled {
  background: rgba(48, 209, 88, 0.22);
  color: #fff;
  border-color: rgba(48, 209, 88, 0.55);
  box-shadow: 0 0 12px rgba(48, 209, 88, 0.25);
}

.cv-meter-status {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

.tv-qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 7.5rem;
  flex-shrink: 0;
  padding: 0.35rem 0.5rem;
  background: var(--grouped);
  border-radius: 18px;
}

.tv-qr {
  width: 6.75rem;
  height: 6.75rem;
  border-radius: 12px;
  background: #fff;
  padding: 0.35rem;
  object-fit: contain;
}

.tv-qr-path {
  margin: 0;
  font-size: 0.85rem;
  color: var(--tint);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* Ensure path never looks like //CODE (j must read) */
.tv-qr-path::before {
  content: none;
}

@media (max-width: 900px) {
  .tv-ritual {
    grid-template-columns: 1fr;
    justify-items: stretch;
    text-align: center;
  }
  .tv-ritual-left {
    justify-content: center;
  }
  .tv-ritual-team {
    max-height: none;
  }
  .tv-qr-panel {
    justify-self: center;
  }
  .cv-meter-list {
    justify-content: center;
  }
}
