/* ==========================================================================
   smy-system.css — SmyFamilyGames design system (Apple-native)

   Single source of truth for tokens: type, color, radius, material, motion.
   System fonts only. Loaded BEFORE styles.css; context classes
   (.smy-controller / .smy-display) carry enough specificity to win over the
   legacy global body styles that ship later in the cascade.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — light (default)
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Fonts ---------------------------------------------------------------- */
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro",
    system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro",
    system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", "SF Compact Rounded",
    -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Type scale ----------------------------------------------------------- */
  --size-large-title: 34px;
  --leading-large-title: 41px;
  --tracking-large-title: -0.4px;

  --size-title1: 28px;
  --leading-title1: 34px;
  --tracking-title1: -0.34px;

  --size-title2: 22px;
  --leading-title2: 28px;
  --tracking-title2: -0.26px;

  --size-title3: 20px;
  --leading-title3: 25px;
  --tracking-title3: 0px;

  --size-headline: 17px;
  --leading-headline: 22px;
  --tracking-headline: 0px;

  --size-body: 17px;
  --leading-body: 22px;

  --size-callout: 16px;
  --leading-callout: 21px;

  --size-subhead: 15px;
  --leading-subhead: 20px;

  --size-footnote: 13px;
  --leading-footnote: 18px;

  --size-caption1: 12px;
  --leading-caption1: 16px;

  --size-caption2: 11px;
  --leading-caption2: 13px;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-heavy: 800;

  /* System colors -------------------------------------------------------- */
  --accent: #007AFF;
  --accent-pressed: #0062CC;
  --accent-tint: rgba(0, 122, 255, 0.12);

  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFCC00;
  --indigo: #5856D6;
  --pink: #FF2D55;
  --teal: #30B0C7;
  --mint: #00C7BE;

  /* Labels --------------------------------------------------------------- */
  --label-primary: #000000;
  --label-secondary: rgba(60, 60, 67, 0.60);
  --label-tertiary: rgba(60, 60, 67, 0.30);
  --label-quaternary: rgba(60, 60, 67, 0.18);
  --label-on-accent: #FFFFFF;

  /* Backgrounds ---------------------------------------------------------- */
  --bg-grouped: #F2F2F7;
  --bg-grouped-secondary: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-base: #FFFFFF;

  /* Fills ---------------------------------------------------------------- */
  --fill-primary: rgba(120, 120, 128, 0.20);
  --fill-secondary: rgba(120, 120, 128, 0.16);
  --fill-tertiary: rgba(118, 118, 128, 0.12);
  --fill-quaternary: rgba(116, 116, 128, 0.08);

  /* Separators ----------------------------------------------------------- */
  --separator: rgba(60, 60, 67, 0.29);
  --separator-opaque: #C6C6C8;
  --hairline: 0.5px;

  /* Materials ------------------------------------------------------------ */
  --material-thin: rgba(255, 255, 255, 0.72);
  --material-regular: rgba(255, 255, 255, 0.82);
  --material-thick: rgba(255, 255, 255, 0.94);
  --material-blur: saturate(180%) blur(20px);

  /* Player seat colors --------------------------------------------------- */
  --player-0: #007AFF;
  --player-1: #34C759;
  --player-2: #FF9500;
  --player-3: #FF2D55;
  --player-4: #5856D6;
  --player-5: #30B0C7;
  --player-6: #FF3B30;
  --player-7: #FFCC00;

  /* Radii ---------------------------------------------------------------- */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Elevation ------------------------------------------------------------ */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-sheet: 0 -2px 12px rgba(0, 0, 0, 0.08), 0 -24px 60px rgba(0, 0, 0, 0.16);

  /* Motion --------------------------------------------------------------- */
  --ease-smy: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-fast: 200ms;
  --dur-med: 300ms;
  --dur-slow: 400ms;
  --press-scale: 0.96;

  /* Layout --------------------------------------------------------------- */
  --gutter: 20px;
  --stack-gap: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --tap-min: 44px;
}

/* --------------------------------------------------------------------------
   2. Tokens — dark
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0A84FF;
    --accent-pressed: #0A6FD1;
    --accent-tint: rgba(10, 132, 255, 0.22);

    --green: #30D158;
    --red: #FF453A;
    --orange: #FF9F0A;
    --yellow: #FFD60A;
    --indigo: #5E5CE6;
    --pink: #FF375F;
    --teal: #40C8E0;
    --mint: #63E6E2;

    --label-primary: #FFFFFF;
    --label-secondary: rgba(235, 235, 245, 0.60);
    --label-tertiary: rgba(235, 235, 245, 0.30);
    --label-quaternary: rgba(235, 235, 245, 0.18);
    --label-on-accent: #FFFFFF;

    --bg-grouped: #000000;
    --bg-grouped-secondary: #1C1C1E;
    --bg-elevated: #1C1C1E;
    --bg-base: #000000;

    --fill-primary: rgba(120, 120, 128, 0.36);
    --fill-secondary: rgba(120, 120, 128, 0.32);
    --fill-tertiary: rgba(118, 118, 128, 0.24);
    --fill-quaternary: rgba(118, 118, 128, 0.18);

    --separator: rgba(84, 84, 88, 0.65);
    --separator-opaque: #38383A;

    --material-thin: rgba(30, 30, 32, 0.72);
    --material-regular: rgba(28, 28, 30, 0.82);
    --material-thick: rgba(24, 24, 26, 0.94);

    --player-0: #0A84FF;
    --player-1: #30D158;
    --player-2: #FF9F0A;
    --player-3: #FF375F;
    --player-4: #5E5CE6;
    --player-5: #40C8E0;
    --player-6: #FF453A;
    --player-7: #FFD60A;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-sheet: 0 -2px 12px rgba(0, 0, 0, 0.6), 0 -24px 60px rgba(0, 0, 0, 0.7);
  }
}

/* --------------------------------------------------------------------------
   3. Contexts — controller (phone) and display (TV)
   -------------------------------------------------------------------------- */

body.smy-controller,
body.smy-display {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-text);
  font-size: var(--size-body);
  line-height: var(--leading-body);
  font-weight: var(--weight-regular);
  color: var(--label-primary);
  background: var(--bg-grouped);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body.smy-controller {
  padding:
    calc(var(--safe-top) + 12px)
    calc(var(--safe-right) + var(--gutter))
    calc(var(--safe-bottom) + 12px)
    calc(var(--safe-left) + var(--gutter));
  box-sizing: border-box;
}

body.smy-display {
  padding:
    calc(var(--safe-top) + 32px)
    calc(var(--safe-right) + 40px)
    calc(var(--safe-bottom) + 32px)
    calc(var(--safe-left) + 40px);
  box-sizing: border-box;
  /* TV is read-only furniture: nothing here should invite a tap. */
  cursor: default;
  user-select: none;
}

body.smy-controller *,
body.smy-display * {
  box-sizing: border-box;
}

/* The display sits further away, so everything scales up. */
body.smy-display {
  font-size: clamp(20px, 1.6vw, 28px);
  line-height: 1.35;
}

.smy-controller-main {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(var(--safe-bottom) + 8px);
}

.smy-display-main {
  display: block;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.smy-display-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.smy-display-header > * {
  margin: 0;
}

.smy-stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
}

.smy-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   4. Type utilities
   -------------------------------------------------------------------------- */

.smy-large-title,
.smy-title1,
.smy-title2 {
  font-family: var(--font-display);
}

.smy-large-title {
  font-size: var(--size-large-title);
  line-height: var(--leading-large-title);
  letter-spacing: var(--tracking-large-title);
  font-weight: var(--weight-bold);
  margin: 0;
}

.smy-title1 {
  font-size: var(--size-title1);
  line-height: var(--leading-title1);
  letter-spacing: var(--tracking-title1);
  font-weight: var(--weight-bold);
  margin: 0;
}

.smy-title2 {
  font-size: var(--size-title2);
  line-height: var(--leading-title2);
  letter-spacing: var(--tracking-title2);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.smy-title3 {
  font-size: var(--size-title3);
  line-height: var(--leading-title3);
  letter-spacing: var(--tracking-title3);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.smy-headline {
  font-size: var(--size-headline);
  line-height: var(--leading-headline);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.smy-body {
  font-size: var(--size-body);
  line-height: var(--leading-body);
  font-weight: var(--weight-regular);
  margin: 0;
}

.smy-callout {
  font-size: var(--size-callout);
  line-height: var(--leading-callout);
  margin: 0;
}

.smy-subhead {
  font-size: var(--size-subhead);
  line-height: var(--leading-subhead);
  margin: 0;
}

.smy-footnote {
  font-size: var(--size-footnote);
  line-height: var(--leading-footnote);
  margin: 0;
}

.smy-caption1 {
  font-size: var(--size-caption1);
  line-height: var(--leading-caption1);
  margin: 0;
}

.smy-caption2 {
  font-size: var(--size-caption2);
  line-height: var(--leading-caption2);
  margin: 0;
}

.smy-rounded { font-family: var(--font-rounded); }
.smy-mono { font-family: var(--font-mono); }

.smy-label-secondary { color: var(--label-secondary); }
.smy-label-tertiary { color: var(--label-tertiary); }
.smy-accent { color: var(--accent); }
.smy-positive { color: var(--green); }
.smy-negative { color: var(--red); }
.smy-center { text-align: center; }

.tabular,
.smy-tabular,
.smy-timer-label,
.smy-score-value,
.smy-scoreboard,
.smy-room-code {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --------------------------------------------------------------------------
   5. Materials
   -------------------------------------------------------------------------- */

.smy-material {
  background: var(--material-thick);
}

@supports ((-webkit-backdrop-filter: blur(20px)) or (backdrop-filter: blur(20px))) {
  .smy-material {
    background: var(--material-regular);
    -webkit-backdrop-filter: var(--material-blur);
    backdrop-filter: var(--material-blur);
  }
}

/* --------------------------------------------------------------------------
   6. Phase header, room code, QR
   -------------------------------------------------------------------------- */

.smy-phase-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 20px;
}

.smy-phase-header > div:first-child {
  min-width: 0;
}

.smy-room-code {
  font-family: var(--font-rounded);
  font-size: 52px;
  line-height: 1.04;
  letter-spacing: 0.14em;
  font-weight: var(--weight-heavy);
  text-indent: 0.14em; /* keeps the tracked block optically centered */
  color: var(--label-primary);
  margin: 2px 0 0;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-smy),
    color var(--dur-fast) var(--ease-smy);
}

.smy-room-code:active {
  transform: scale(var(--press-scale));
}

.smy-room-code.is-copied {
  color: var(--green);
}

.smy-room-code-display {
  font-size: clamp(72px, 12vw, 180px);
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  cursor: default;
}

.smy-room-code-display:active {
  transform: none;
}

.smy-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.smy-qr:empty {
  display: none;
}

.smy-qr canvas,
.smy-qr img,
.smy-qr svg {
  display: block;
  border-radius: var(--radius-sm);
}

.smy-join-url {
  word-break: break-all;
  text-align: center;
  color: var(--accent);
  font-weight: var(--weight-medium);
}

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */

.smy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-size: var(--size-headline);
  line-height: var(--leading-headline);
  font-weight: var(--weight-semibold);
  color: var(--label-primary);
  background: var(--fill-tertiary);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  transition: transform var(--dur-fast) var(--ease-smy),
    background-color var(--dur-fast) var(--ease-smy),
    opacity var(--dur-fast) var(--ease-smy);
}

.smy-btn:active:not(:disabled) {
  transform: scale(var(--press-scale));
}

.smy-btn:disabled,
.smy-btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.smy-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.smy-btn-primary {
  color: var(--label-on-accent);
  background: var(--accent);
}

.smy-btn-primary:active:not(:disabled) {
  background: var(--accent-pressed);
}

.smy-btn-secondary {
  color: var(--accent);
  background: var(--fill-tertiary);
}

.smy-btn-destructive {
  color: #FFFFFF;
  background: var(--red);
}

.smy-btn-plain {
  background: transparent;
  color: var(--accent);
  min-height: 36px;
  padding: 8px 12px;
}

.smy-btn-block {
  width: 100%;
}

/* Thumb zone: primary actions pinned within reach at the bottom. */
.smy-thumb-zone {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding: 12px 0 calc(var(--safe-bottom) + 12px);
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg-grouped) 0%, transparent),
    var(--bg-grouped) 28%
  );
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .smy-thumb-zone {
    background: var(--bg-grouped);
  }
}

.smy-thumb-zone .smy-btn {
  width: 100%;
}

/* --------------------------------------------------------------------------
   8. Cards, sheets, waiting, pills
   -------------------------------------------------------------------------- */

.smy-card {
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.smy-prompt-card {
  padding: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.smy-prompt-card .smy-prompt-text {
  font-family: var(--font-display);
  font-size: var(--size-title2);
  line-height: var(--leading-title2);
  letter-spacing: var(--tracking-title2);
  font-weight: var(--weight-semibold);
  margin: 6px 0 0;
}

.smy-eyebrow {
  display: block;
  font-size: var(--size-caption1);
  line-height: var(--leading-caption1);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--label-secondary);
}

.smy-connection-pill {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  z-index: 100;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: var(--size-footnote);
  line-height: var(--leading-footnote);
  font-weight: var(--weight-semibold);
  color: var(--label-primary);
  background: var(--material-thick);
  box-shadow: var(--shadow-card);
  animation: smy-pill-in var(--dur-med) var(--ease-smy);
}

@supports ((-webkit-backdrop-filter: blur(20px)) or (backdrop-filter: blur(20px))) {
  .smy-connection-pill {
    background: var(--material-regular);
    -webkit-backdrop-filter: var(--material-blur);
    backdrop-filter: var(--material-blur);
  }
}

.smy-connection-pill[hidden] {
  display: none;
}

@keyframes smy-pill-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.smy-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--gutter);
  padding-bottom: calc(var(--safe-bottom) + var(--gutter));
  background: rgba(0, 0, 0, 0.4);
}

.smy-sheet[hidden] {
  display: none;
}

.smy-sheet-card {
  width: 100%;
  max-width: 480px;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sheet);
  animation: smy-sheet-up var(--dur-slow) var(--ease-smy);
}

.smy-sheet-card > * + * {
  margin-top: 8px;
}

@keyframes smy-sheet-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.smy-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px;
  text-align: center;
  color: var(--label-secondary);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.smy-waiting-dots {
  display: flex;
  gap: 6px;
}

.smy-waiting-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--label-tertiary);
  animation: smy-bounce 1.2s var(--ease-smy) infinite;
}

.smy-waiting-dots span:nth-child(2) { animation-delay: 0.15s; }
.smy-waiting-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes smy-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-5px); }
}

.smy-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--size-caption2);
  line-height: 18px;
  font-weight: var(--weight-semibold);
  color: var(--label-secondary);
  background: var(--fill-tertiary);
}

.smy-badge-host {
  color: var(--label-on-accent);
  background: var(--accent);
}

.smy-badge-done {
  color: #FFFFFF;
  background: var(--green);
}

.smy-error {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--size-subhead);
  color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .smy-error { background: var(--fill-tertiary); }
}

/* --------------------------------------------------------------------------
   9. Player list + avatars
   -------------------------------------------------------------------------- */

.smy-player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.smy-player {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  border-bottom: var(--hairline) solid var(--separator);
  transition: opacity var(--dur-med) var(--ease-smy);
}

.smy-player:last-child {
  border-bottom: none;
}

.smy-player-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-medium);
}

.smy-player-status {
  color: var(--label-tertiary);
}

.smy-player.is-away {
  opacity: 0.5;
}

.smy-player.is-me .smy-player-name {
  color: var(--accent);
}

.smy-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-family: var(--font-rounded);
  font-size: var(--size-footnote);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  color: #FFFFFF;
  background: var(--seat-color, var(--accent));
  text-transform: uppercase;
}

.smy-avatar-away {
  color: var(--label-secondary);
  background: var(--fill-secondary);
  box-shadow: inset 0 0 0 var(--hairline) var(--separator);
}

.smy-avatar-lg {
  width: 56px;
  height: 56px;
  font-size: var(--size-title3);
}

/* --------------------------------------------------------------------------
   10. Timers
   -------------------------------------------------------------------------- */

.smy-timer-bar {
  position: relative;
  flex: 0 0 auto;
  width: 120px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--fill-tertiary);
  overflow: hidden;
}

.smy-timer-bar[hidden] {
  display: none;
}

.smy-timer-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width var(--dur-fast) linear,
    background-color var(--dur-med) var(--ease-smy);
}

.smy-timer-bar.is-urgent .smy-timer-fill {
  background: var(--red);
}

.smy-timer-bar .smy-timer-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--size-footnote);
  font-weight: var(--weight-bold);
  color: var(--label-primary);
  mix-blend-mode: normal;
}

.smy-timer-ring {
  position: relative;
  flex: 0 0 auto;
  width: 140px;
  height: 140px;
}

.smy-timer-ring[hidden] {
  display: none;
}

.smy-timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.smy-ring-bg,
.smy-ring-fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.smy-ring-bg {
  stroke: var(--fill-tertiary);
}

.smy-ring-fg {
  stroke: var(--accent);
  stroke-dasharray: 339.292;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--dur-fast) linear,
    stroke var(--dur-med) var(--ease-smy);
}

.smy-timer-ring.is-urgent .smy-ring-fg {
  stroke: var(--red);
}

.smy-timer-ring .smy-timer-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: var(--weight-bold);
  color: var(--label-primary);
}

/* --------------------------------------------------------------------------
   11. Inputs
   -------------------------------------------------------------------------- */

.smy-input {
  display: block;
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 16px;
  border: var(--hairline) solid var(--separator);
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-size: var(--size-body); /* 17px keeps iOS from zooming on focus */
  line-height: var(--leading-body);
  color: var(--label-primary);
  background: var(--bg-elevated);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur-fast) var(--ease-smy),
    box-shadow var(--dur-fast) var(--ease-smy);
}

.smy-input::placeholder {
  color: var(--label-tertiary);
}

.smy-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

textarea.smy-input {
  min-height: 110px;
  resize: vertical;
  line-height: 1.4;
}

.smy-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.smy-field-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.smy-field-row .smy-input {
  flex: 1 1 auto;
}

.smy-input-number {
  flex: 0 0 84px;
  text-align: center;
}

.smy-char-count {
  align-self: flex-end;
  color: var(--label-tertiary);
}

/* Join screen: one box per room-code character. */
.smy-code-digits {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.smy-code-digits input,
.smy-code-digit {
  width: 60px;
  height: 72px;
  padding: 0;
  border: var(--hairline) solid var(--separator);
  border-radius: var(--radius-md);
  font-family: var(--font-rounded);
  font-size: 36px;
  font-weight: var(--weight-bold);
  text-align: center;
  text-transform: uppercase;
  color: var(--label-primary);
  background: var(--bg-elevated);
  caret-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur-fast) var(--ease-smy),
    transform var(--dur-fast) var(--ease-smy),
    box-shadow var(--dur-fast) var(--ease-smy);
}

.smy-code-digits input:focus,
.smy-code-digit:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
  transform: scale(1.04);
}

.smy-code-digits input:not(:placeholder-shown),
.smy-code-digit.is-filled {
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   12. Vote grid / choices
   -------------------------------------------------------------------------- */

.smy-vote-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 480px) {
  .smy-vote-grid.smy-vote-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.smy-vote-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 14px 16px;
  border: var(--hairline) solid var(--separator);
  border-radius: var(--radius-md);
  font-family: var(--font-text);
  font-size: var(--size-callout);
  line-height: var(--leading-callout);
  font-weight: var(--weight-medium);
  text-align: left;
  color: var(--label-primary);
  background: var(--bg-elevated);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform var(--dur-fast) var(--ease-smy),
    border-color var(--dur-fast) var(--ease-smy),
    background-color var(--dur-fast) var(--ease-smy);
}

.smy-vote-btn:active:not(:disabled) {
  transform: scale(var(--press-scale));
}

.smy-vote-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.smy-vote-btn.is-selected {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.smy-vote-btn.is-correct {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 16%, transparent);
}

.smy-vote-btn.is-wrong {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 14%, transparent);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .smy-vote-btn.is-correct,
  .smy-vote-btn.is-wrong { background: var(--fill-tertiary); }
}

.smy-vote-btn .smy-vote-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-family: var(--font-rounded);
  font-size: var(--size-footnote);
  font-weight: var(--weight-bold);
  color: #FFFFFF;
  background: var(--seat-color, var(--accent));
}

.smy-vote-btn .smy-vote-text {
  flex: 1 1 auto;
  min-width: 0;
}

.smy-vote-btn .smy-vote-meta {
  flex: 0 0 auto;
  color: var(--label-secondary);
  font-size: var(--size-footnote);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   13. Codenames guess board
   -------------------------------------------------------------------------- */

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

.smy-word-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 6px 4px;
  border: var(--hairline) solid var(--separator);
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-size: var(--size-caption1);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  text-align: center;
  word-break: break-word;
  color: var(--label-primary);
  background: var(--bg-elevated);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform var(--dur-fast) var(--ease-smy),
    opacity var(--dur-med) var(--ease-smy);
}

.smy-word-card:active:not(:disabled) {
  transform: scale(var(--press-scale));
}

.smy-word-card:disabled {
  cursor: default;
}

.smy-word-card.is-revealed {
  opacity: 0.85;
  color: #FFFFFF;
}

.smy-word-card.role-red { background: var(--red); border-color: transparent; color: #FFFFFF; }
.smy-word-card.role-blue { background: var(--accent); border-color: transparent; color: #FFFFFF; }
.smy-word-card.role-civilian { background: var(--fill-primary); border-color: transparent; color: var(--label-primary); }
.smy-word-card.role-assassin { background: var(--label-primary); border-color: transparent; color: var(--bg-elevated); }

/* Spymasters see the key as a tint so unrevealed words stay readable. */
.smy-word-card.is-key:not(.is-revealed) {
  color: var(--label-primary);
  border-width: 2px;
  border-style: solid;
  background: var(--bg-elevated);
}

.smy-word-card.is-key.role-red:not(.is-revealed) { border-color: var(--red); }
.smy-word-card.is-key.role-blue:not(.is-revealed) { border-color: var(--accent); }
.smy-word-card.is-key.role-civilian:not(.is-revealed) { border-color: var(--separator-opaque); }
.smy-word-card.is-key.role-assassin:not(.is-revealed) { border-color: var(--label-primary); }

.smy-team-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-card);
  font-variant-numeric: tabular-nums;
}

.smy-team-red { color: var(--red); font-weight: var(--weight-bold); }
.smy-team-blue { color: var(--accent); font-weight: var(--weight-bold); }

/* --------------------------------------------------------------------------
   14. Scoreboard
   -------------------------------------------------------------------------- */

.smy-scoreboard {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.smy-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  border-bottom: var(--hairline) solid var(--separator);
}

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

.smy-score-rank {
  flex: 0 0 24px;
  font-family: var(--font-rounded);
  font-weight: var(--weight-bold);
  color: var(--label-secondary);
  font-variant-numeric: tabular-nums;
}

.smy-score-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-medium);
}

.smy-score-value {
  flex: 0 0 auto;
  font-family: var(--font-rounded);
  font-size: var(--size-title3);
  font-weight: var(--weight-bold);
}

.smy-score-row.is-leader .smy-score-value {
  color: var(--green);
}

.smy-clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.smy-clue-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-card);
}

.smy-clue-item .smy-clue-name {
  flex: 0 0 auto;
  font-weight: var(--weight-semibold);
  color: var(--label-secondary);
}

.smy-role-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  text-align: center;
  color: #FFFFFF;
  background: var(--accent);
  box-shadow: var(--shadow-card);
}

.smy-role-card.role-imposter { background: var(--red); }
.smy-role-card.role-jester { background: var(--orange); }
.smy-role-card.role-villager { background: var(--green); }

/* --------------------------------------------------------------------------
   15. Display-only layout helpers
   -------------------------------------------------------------------------- */

.smy-display .smy-display-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.smy-display .smy-card,
.smy-display .smy-prompt-card,
.smy-display .smy-waiting {
  padding: 32px;
  border-radius: 28px;
}

.smy-display .smy-prompt-card .smy-prompt-text {
  font-size: clamp(32px, 3.4vw, 64px);
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.smy-display .smy-player-list,
.smy-display .smy-scoreboard {
  border-radius: 28px;
}

.smy-display .smy-player,
.smy-display .smy-score-row {
  min-height: 76px;
  padding: 14px 28px;
}

.smy-display .smy-avatar {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.smy-display .smy-word-card {
  min-height: 96px;
  font-size: clamp(14px, 1.2vw, 24px);
}

.smy-display .smy-guess-board {
  gap: 12px;
}

/* --------------------------------------------------------------------------
   16. Motion preferences
   -------------------------------------------------------------------------- */

.smy-fade-in {
  animation: smy-fade-in var(--dur-med) var(--ease-smy);
}

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

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

  .smy-btn:active:not(:disabled),
  .smy-vote-btn:active:not(:disabled),
  .smy-word-card:active:not(:disabled),
  .smy-room-code:active {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   17. Code Breaker board + Puzzle Escape locks
   -------------------------------------------------------------------------- */

.smy-cb-slots {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.smy-cb-slot {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 0.5px var(--separator);
}

.smy-cb-slot.is-empty {
  background: var(--fill-tertiary);
  box-shadow: inset 0 0 0 1.5px var(--separator);
}

.smy-cb-draft { margin: 12px 0; }

.smy-cb-palette {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

.smy-cb-swatch {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 0.5px var(--separator), 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform var(--dur-fast, 100ms) var(--ease-smy);
  cursor: pointer;
}

.smy-cb-swatch:active { transform: scale(0.9); }

.smy-cb-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.smy-cb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--fill-quaternary);
  border-radius: var(--radius-sm);
}

.smy-cb-row .smy-cb-slot { width: 22px; height: 22px; }

.smy-cb-pegs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 96px;
  justify-content: flex-end;
}

.smy-cb-peg {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
}

.smy-cb-peg-black { background: var(--label-primary); }
.smy-cb-peg-white { background: transparent; box-shadow: inset 0 0 0 1.5px var(--label-secondary); }

.smy-solved {
  background: rgba(52, 199, 89, 0.10);
  box-shadow: inset 0 0 0 0.5px var(--green);
}

.smy-input.is-wrong {
  box-shadow: inset 0 0 0 1.5px var(--red);
  animation: smy-shake 0.4s var(--ease-smy);
}

@keyframes smy-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .smy-input.is-wrong { animation: none; }
}

/* --------------------------------------------------------------------------
   18. Art Exhibit — canvas + gallery
   -------------------------------------------------------------------------- */

.smy-draw-canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 0.5px var(--separator);
  touch-action: none;
  display: block;
  margin: 8px 0;
  cursor: crosshair;
}

.smy-art-toolbar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0;
}

.smy-art-swatch { width: 34px; height: 34px; }
.smy-art-swatch.is-selected { box-shadow: inset 0 0 0 0.5px var(--separator), 0 0 0 3px var(--accent); }
.smy-art-size { min-width: 44px; padding: 8px 10px; }

.smy-exhibit-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-sm);
  display: block;
}

.smy-exhibit { padding: 12px; }

.smy-exhibit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 8px 0;
}

.smy-exhibit-pick,
.smy-vote-card-btn {
  border: none;
  background: none;
  padding: 0;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 2px transparent;
  transition: transform var(--dur-fast) var(--ease-smy), box-shadow var(--dur-fast) var(--ease-smy);
  cursor: pointer;
  width: 100%;
  display: block;
}

.smy-vote-card-btn { margin: 8px 0; }
.smy-exhibit-pick:active,
.smy-vote-card-btn:active { transform: scale(0.97); }
.smy-exhibit-pick.is-selected { box-shadow: 0 0 0 3px var(--accent); }

.smy-caption-picks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}

.smy-exhibit-versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .smy-exhibit-pick:active,
  .smy-vote-card-btn:active { transform: none; }
}

/* --------------------------------------------------------------------------
   19. Casefile — investigation documents
   -------------------------------------------------------------------------- */

.smy-casefile-content {
  white-space: pre-wrap;
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 20px;
  color: var(--label-secondary);
  margin-top: 8px;
}

.smy-casefile-doc summary {
  cursor: pointer;
  list-style: none;
}

.smy-casefile-doc summary::-webkit-details-marker { display: none; }
.smy-casefile-doc[open] summary { margin-bottom: 4px; }

.smy-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--fill-tertiary);
  color: var(--label-secondary);
  font-size: 13px;
  line-height: 18px;
}

.smy-casefile-locked { opacity: 0.72; }

.smy-casefile-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.smy-casefile-suspect,
.smy-casefile-doc,
.smy-casefile-locked { margin-bottom: 10px; }

[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   20. Base Components — Navbar, Forms, Auth, Buttons
   -------------------------------------------------------------------------- */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: var(--font-text);
  background: var(--bg-secondary);
  color: var(--label-primary);
  line-height: 1.6;
}

body {
  --bg-secondary: #F2F2F7;
  --label-primary: #000000;
  --label-secondary: #3C3C43;
  --label-tertiary: #8E8E93;
  --fill-tertiary: #D1D1D6;
  --accent: #007AFF;
}

/* Navbar */
.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--fill-tertiary);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.navbar-link {
  color: var(--label-secondary);
  text-decoration: none;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 200ms, color 200ms;
}

.navbar-link:hover {
  background: var(--fill-tertiary);
  color: var(--label-primary);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--label-primary);
}

@media (max-width: 640px) {
  .navbar-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--fill-tertiary);
    padding: 12px;
    gap: 8px;
  }
  .navbar-links.active {
    display: flex;
  }
  .navbar-toggle {
    display: block;
  }
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--label-primary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--fill-tertiary);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg-secondary);
  color: var(--label-primary);
  font-family: inherit;
  transition: border-color 200ms, box-shadow 200ms;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms, transform 100ms;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  background: var(--fill-tertiary);
  color: var(--label-primary);
}

.btn-secondary:hover {
  opacity: 0.8;
}

/* Auth Page */
.auth-container {
  max-width: 400px;
  margin: 40px auto;
  padding: 0 16px;
}

.auth-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--label-primary);
  margin-bottom: 24px;
  text-align: center;
}

.auth-footer {
  margin-top: 16px;
  font-size: 15px;
  color: var(--label-secondary);
  text-align: center;
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-link:hover {
  text-decoration: underline;
}

/* Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}
