/*
 * Dark by default and on purpose: this runs on phones held in dimly-lit rooms,
 * where a white screen wrecks night vision and gives away where every player
 * is standing.
 */
:root {
  --background: #0b0d12;
  --surface: #141821;
  --surface-raised: #1c212d;
  --border: #2a3040;
  --foreground: #e8eaf0;
  --muted: #949cb0;
  --accent: #ffb648;
  --accent-strong: #ff9f14;
  --accent-ink: #241a05;
  --danger: #ff6b6b;
  --success: #56d38a;
  --info: #6fa8ff;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* Codes and countdowns are read at a glance and often photographed —
   tabular figures stop the layout jittering as digits change. */
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ------------------------------------------------------------------ layout */

.center-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 1.5rem;
  text-align: center;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header-inner,
.app-main {
  margin: 0 auto;
  width: 100%;
  max-width: 72rem;
  padding: 0 1rem;
}

.app-header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.app-main {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.brand {
  font-weight: 600;
}

.nav {
  display: flex;
  flex: 1;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.nav a {
  border-radius: 8px;
  padding: 0.375rem 0.75rem;
  color: var(--muted);
}

.nav a:hover {
  background: var(--surface-raised);
  color: var(--foreground);
}

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

.stack.tight {
  gap: 0.5rem;
}

.stack.loose {
  gap: 2rem;
}

.stack.center {
  align-items: center;
  text-align: center;
}

.stack.narrow,
.form-column {
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
}

.form-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: left;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

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

.row-gap.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.spacer {
  flex: 1;
}

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

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

.span-2 {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .grid-2,
  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hide-sm {
    display: inline;
  }
}

@media (max-width: 639px) {
  .hide-sm {
    display: none;
  }
}

/* ---------------------------------------------------------------- surfaces */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
}

.card.full-height {
  height: 100%;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.alert {
  border: 1px solid;
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
}

.alert.error {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

.alert.success {
  border-color: rgba(86, 211, 138, 0.4);
  background: rgba(86, 211, 138, 0.1);
  color: var(--success);
}

.alert.info {
  border-color: rgba(111, 168, 255, 0.4);
  background: rgba(111, 168, 255, 0.1);
  color: var(--info);
}

.alert.warning {
  border-color: rgba(255, 182, 72, 0.4);
  background: rgba(255, 182, 72, 0.1);
  color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  padding: 0.125rem 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge.accent {
  border-color: rgba(255, 182, 72, 0.3);
  background: rgba(255, 182, 72, 0.15);
  color: var(--accent);
}

.badge.success {
  border-color: rgba(86, 211, 138, 0.3);
  background: rgba(86, 211, 138, 0.15);
  color: var(--success);
}

.badge.danger {
  border-color: rgba(255, 107, 107, 0.3);
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.badge.info {
  border-color: rgba(111, 168, 255, 0.3);
  background: rgba(111, 168, 255, 0.15);
  color: var(--info);
}

/* ------------------------------------------------------------------ inputs */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.625rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button.secondary {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--foreground);
}

.button.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button.ghost:hover:not(:disabled) {
  color: var(--foreground);
}

.button.danger {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.button.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.button.block,
.block {
  display: flex;
  width: 100%;
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.625rem 0.75rem;
  color: var(--foreground);
  font: inherit;
  font-size: 1rem;
}

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

.input:disabled {
  opacity: 0.5;
}

.code-input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.field-hint {
  display: block;
  margin-top: 0.375rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* --------------------------------------------------------------- utilities */

.title-xl {
  font-size: 1.875rem;
  font-weight: 600;
}
.title-lg {
  font-size: 1.5rem;
  font-weight: 600;
}
.title-md {
  font-size: 1.25rem;
  font-weight: 600;
}
.section-title {
  font-size: 0.875rem;
  font-weight: 500;
}
.strong {
  font-weight: 500;
}
.muted {
  color: var(--muted);
}
.accent {
  color: var(--accent);
}
.info {
  color: var(--info);
}
.danger {
  color: var(--danger);
}
.small {
  font-size: 0.875rem;
}
.tiny {
  font-size: 0.75rem;
}
.center {
  text-align: center;
}
.measure {
  max-width: 32rem;
}
.emoji {
  font-size: 2.25rem;
}
.break {
  word-break: break-all;
}
.link:hover {
  color: var(--accent);
}
.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bullets {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.pre-wrap {
  white-space: pre-wrap;
  line-height: 1.6;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.meta dt,
.meta dd {
  display: inline;
  margin: 0;
}

.meta dd {
  color: var(--foreground);
}

.meta.two-columns {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .meta.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.divided > li {
  border-top: 1px solid var(--border);
}

.divided > li:first-child {
  border-top: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
}

.row-duration {
  width: 4rem;
  text-align: right;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .stat-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stat {
  padding: 0.75rem;
  text-align: center;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
}

.join-code {
  color: var(--accent);
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.recap {
  margin: 0 auto;
  display: flex;
  width: 100%;
  max-width: 42rem;
  flex: 1;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem 1rem;
}

/* ------------------------------------------------------------- player app */

.player-app {
  display: flex;
  min-height: 100%;
  flex: 1;
  flex-direction: column;
}

.player-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 24, 33, 0.95);
  backdrop-filter: blur(8px);
}

.player-header-inner {
  margin: 0 auto;
  display: flex;
  width: 100%;
  max-width: 42rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.player-clock {
  font-size: 1.5rem;
  font-weight: 600;
}

.player-clock.urgent {
  color: var(--danger);
}

.player-banner {
  padding: 0.25rem 1rem;
  text-align: center;
  font-size: 0.75rem;
}

.player-banner.offline {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.player-banner.paused {
  background: rgba(255, 182, 72, 0.15);
  color: var(--accent);
}

.player-main {
  margin: 0 auto;
  display: flex;
  width: 100%;
  max-width: 42rem;
  flex: 1;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1rem;
}

.node-card.locked {
  opacity: 0.6;
}

.node-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.node-toggle:disabled {
  cursor: default;
}

.node-title {
  flex: 1;
  font-weight: 500;
}

.node-body {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashed-note {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
}

/* -------------------------------------------------------------- gm console */

.gm-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .gm-layout {
    grid-template-columns: 320px 1fr;
  }
}

.team-button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.team-button.selected {
  border-color: var(--accent);
}

.progress-track {
  margin: 0.5rem 0;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-raised);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.timeline li {
  display: flex;
  gap: 0.75rem;
}

.strike {
  color: var(--muted);
  text-decoration: line-through;
}

.link-button {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

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

/* --------------------------------------------------------------------- QR */

.qr {
  margin: 0 auto;
  width: 10rem;
  border-radius: 10px;
  background: #ffffff;
  padding: 0.5rem;
}

.qr svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Players tap these with gloves on, in the dark. */
@media (pointer: coarse) {
  button,
  [role="button"],
  a.tap {
    min-height: 44px;
  }
}

/* The app is dark by design; paper is not. Printing the tag sheet on a dark
   background would flood a page with ink and render the QR codes unscannable. */
@media print {
  :root {
    --background: #ffffff;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --border: #999999;
    --foreground: #000000;
    --muted: #444444;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  /* Site chrome is noise on a printed sheet. */
  .app-header,
  .nav,
  .no-print {
    display: none !important;
  }

  .app-main {
    max-width: none;
    padding: 0;
  }

  .unbroken {
    break-inside: avoid;
  }

  .tag-card {
    border-color: #000000;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
