:root {
  --bg: #f5efe5;
  --ink: #172126;
  --muted: #5d6a72;
  --panel: #fffdf8;
  --line: #d8d0c4;
  --brand: #12343b;
  --brand-soft: #d9eef0;
  --accent: #e56b4f;
  --accent-soft: #ffe2d9;
  --good: #27785f;
  --warn: #946300;
  --gold: #c8913a;
  --felt: #2f5f5b;
  --shadow: 0 18px 40px rgba(18, 52, 59, 0.14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(200, 145, 58, 0.22), transparent 16rem),
    radial-gradient(circle at 82% 8%, rgba(47, 95, 91, 0.2), transparent 18rem),
    linear-gradient(135deg, rgba(130, 192, 204, 0.24), transparent 32rem),
    linear-gradient(315deg, rgba(229, 107, 79, 0.14), transparent 28rem),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hub-link {
  order: 2;
  color: var(--brand);
  border: 1px solid rgba(18, 52, 59, 0.22);
  border-radius: 999px;
  padding: 9px 12px;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.85rem;
  background: rgba(255, 253, 248, 0.78);
}

.kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 9vw, 3.4rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 9px;
  font-size: clamp(1.45rem, 6vw, 2.2rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.app-panel {
  min-height: 0;
  border: 1px solid rgba(18, 52, 59, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(250, 246, 238, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.app-panel.is-card-screen {
  min-height: calc(100svh - 83px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  overflow: hidden;
}

.screen {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 15px;
}

.card-screen {
  min-height: inherit;
}

.lead {
  color: var(--muted);
  line-height: 1.45;
}

.game-screen {
  gap: 12px;
  padding-bottom: 96px;
}

.setup-grid {
  display: grid;
  gap: 14px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.label {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-count {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  align-items: center;
}

.count-display {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 1.25rem;
  font-weight: 900;
}

.icon-button,
.primary-button,
.secondary-button,
.quiet-button,
.option-button {
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.icon-button {
  background: var(--brand);
  color: #ffffff;
  font-size: 1.4rem;
}

.primary-button {
  width: 100%;
  color: #ffffff;
  background: var(--brand);
}

.secondary-button {
  width: 100%;
  color: var(--brand);
  background: var(--brand-soft);
  border-color: rgba(18, 52, 59, 0.22);
}

.quiet-button {
  width: 100%;
  color: var(--muted);
  background: #ffffff;
  border-color: var(--line);
}

.danger-button {
  color: #ffffff;
  background: #9f2d20;
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-button {
  width: 100%;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(255, 250, 240, 0.96)),
    #ffffff;
  border-color: var(--line);
  display: grid;
  gap: 4px;
  box-shadow: 0 8px 18px rgba(18, 52, 59, 0.08);
}

.option-button span {
  font-size: 1rem;
}

.option-button small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.3;
}

.option-button.is-active {
  border-color: var(--accent);
  background:
    linear-gradient(145deg, rgba(255, 226, 217, 0.92), rgba(255, 253, 248, 0.96)),
    var(--accent-soft);
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #ffffff;
}

.name-list {
  display: grid;
  gap: 8px;
}

.name-row {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 8px;
  align-items: center;
}

.name-index {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 900;
  font-size: 0.82rem;
}

.error {
  margin: 0;
  color: #8c1d12;
  font-weight: 700;
}

.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(18, 52, 59, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 240, 0.95)),
    #ffffff;
  box-shadow: 0 10px 24px rgba(18, 52, 59, 0.1);
  padding: 16px;
}

.table-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--felt), var(--gold), var(--accent));
}

.section-heading {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.section-heading h3,
.reader-card h3 {
  margin: 0;
}

.pill {
  border: 1px solid rgba(18, 52, 59, 0.18);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 800;
  font-size: 0.82rem;
}

.pass-card,
.secret-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
}

.pass-card,
.secret-card {
  min-height: 42svh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.secret-card {
  touch-action: none;
  user-select: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.card-screen .secret-card {
  min-height: inherit;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 22px 18px;
  background:
    linear-gradient(180deg, rgba(217, 238, 240, 0.92), rgba(255, 253, 248, 0.98) 38%),
    #ffffff;
  cursor: pointer;
}

.is-holding-card .secret-card {
  border-color: var(--good);
  box-shadow: inset 0 0 0 6px rgba(39, 120, 95, 0.2);
  transform: none;
}

.countdown-card {
  min-height: 55svh;
}

.card-back {
  width: min(54vw, 172px);
  aspect-ratio: 2.5 / 3.5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border-radius: 8px;
  color: #fffdf8;
  background:
    linear-gradient(135deg, rgba(200, 145, 58, 0.5), transparent 42%),
    linear-gradient(160deg, var(--brand), var(--felt));
  box-shadow: 0 18px 32px rgba(18, 52, 59, 0.22);
}

.card-back span {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
}

.card-back small {
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.countdown-number {
  margin: 0;
  color: var(--accent);
  font-size: clamp(6rem, 34vw, 12rem);
  font-weight: 900;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.big-name {
  margin: 0;
  color: var(--brand);
  font-size: clamp(2rem, 12vw, 4.4rem);
  line-height: 1;
  word-break: break-word;
}

.secret-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.secret-word {
  margin: 0;
  color: var(--good);
  font-size: clamp(2rem, 11vw, 4.2rem);
  line-height: 1;
  text-align: center;
  word-break: break-word;
}

.imposter-word {
  color: #9f2d20;
}

.auto-hide {
  width: min(100%, 320px);
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.timer-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--accent-soft);
}

.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
  animation: drain 10s linear forwards;
}

.hold-hint {
  margin: 4px 0 0;
  max-width: 340px;
  border: 2px dashed rgba(18, 52, 59, 0.28);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--brand);
  background: rgba(217, 238, 240, 0.72);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.35;
}

.is-holding-card .hold-hint {
  color: var(--good);
  border-color: rgba(39, 120, 95, 0.55);
  background: rgba(39, 120, 95, 0.12);
}

.category-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(217, 238, 240, 0.96), rgba(255, 253, 248, 0.92)),
    var(--brand-soft);
}

.category-banner p {
  margin-bottom: 4px;
}

.category-banner strong {
  font-size: clamp(1.7rem, 8vw, 3rem);
  line-height: 1;
}

.table-token {
  width: 56px;
  height: 72px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fffdf8;
  background:
    linear-gradient(160deg, rgba(18, 52, 59, 0.98), rgba(47, 95, 91, 0.95));
  box-shadow: 0 8px 18px rgba(18, 52, 59, 0.22);
  font-size: 2rem;
  font-weight: 900;
}

.order-list,
.rules-list,
.steps-list {
  margin: 0;
  padding-left: 1.35rem;
  line-height: 1.5;
}

.order-list li,
.rules-list li,
.steps-list li {
  margin-bottom: 6px;
}

.player-order-list {
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.player-order-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  border: 1px solid rgba(18, 52, 59, 0.12);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(217, 238, 240, 0.36);
  font-weight: 800;
}

.player-order-list span {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--brand);
  font-size: 0.85rem;
}

.clue-host-card {
  display: grid;
  gap: 12px;
  background:
    linear-gradient(145deg, rgba(18, 52, 59, 0.95), rgba(47, 95, 91, 0.92)),
    var(--brand);
  color: #fffdf8;
}

.clue-host-card::before {
  background: linear-gradient(90deg, var(--gold), var(--accent));
}

.clue-host-card .secret-label,
.clue-host-card p {
  color: rgba(255, 253, 248, 0.76);
}

.clue-host-card h3 {
  margin: 0;
  font-size: clamp(1.3rem, 7vw, 2rem);
}

.current-player-token {
  border: 1px solid rgba(255, 253, 248, 0.22);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 253, 248, 0.12);
  font-size: clamp(1.7rem, 10vw, 3rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  word-break: break-word;
}

.clue-controls {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
}

.clue-host-card .quiet-button {
  color: #fffdf8;
  background: rgba(255, 253, 248, 0.1);
  border-color: rgba(255, 253, 248, 0.28);
}

.clue-host-card .secondary-button {
  color: var(--brand);
  background: #fffdf8;
}

.steps-list {
  padding-left: 1.1rem;
}

.rules-card {
  background:
    linear-gradient(145deg, rgba(255, 253, 248, 0.98), rgba(255, 244, 212, 0.5)),
    #ffffff;
}

.top-rules {
  padding-left: 1.15rem;
}

.rules-drawer {
  margin-top: 12px;
  border-top: 1px solid rgba(18, 52, 59, 0.12);
  padding-top: 10px;
}

.rules-drawer summary,
.more-actions summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 900;
}

.rules-drawer .rules-list {
  margin-top: 10px;
}

.reader-card {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(47, 95, 91, 0.24);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(47, 95, 91, 0.13), rgba(217, 238, 240, 0.74)),
    #ffffff;
  box-shadow: 0 10px 22px rgba(18, 52, 59, 0.08);
}

.reader-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.35;
}

.reader-actions {
  display: grid;
  gap: 8px;
}

.two-actions {
  display: grid;
  gap: 9px;
}

.sticky-actions {
  position: sticky;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  border: 1px solid rgba(18, 52, 59, 0.14);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 14px 30px rgba(18, 52, 59, 0.18);
  backdrop-filter: blur(10px);
  overflow: visible;
}

.more-actions {
  position: relative;
}

.more-actions summary {
  min-height: 46px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #ffffff;
  text-align: center;
}

.more-actions summary::-webkit-details-marker {
  display: none;
}

.more-actions[open] {
  min-width: min(220px, 44vw);
}

.more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(260px, 82vw);
  display: grid;
  gap: 8px;
  border: 1px solid rgba(18, 52, 59, 0.16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 16px 34px rgba(18, 52, 59, 0.2);
}

.reveal-warning {
  border-left: 5px solid var(--warn);
  border-radius: 8px;
  padding: 13px;
  background: #fff4d4;
}

.result-grid {
  display: grid;
  gap: 10px;
}

.result-card p {
  margin-bottom: 5px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.result-card strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1.1;
  word-break: break-word;
}

.noscript {
  margin: 16px;
  color: #8c1d12;
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

@media (min-width: 680px) {
  .app-shell {
    padding-inline: 20px;
  }

  .app-panel {
    padding: 22px;
  }

  .app-panel.is-card-screen {
    padding: 0;
  }

  .setup-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .wide {
    grid-column: 1 / -1;
  }

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

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

  .reader-card {
    grid-template-columns: 1fr 220px;
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@keyframes drain {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}
