:root {
  --bg-0: #1c120a;
  --bg-1: #2a1a0f;
  --stone: #3d2a1a;
  --stone-light: #57402a;
  --accent: #ff7a1a;
  --accent-2: #ffb703;
  --good: #4caf50;
  --bad: #e63946;
  --skip: #6c757d;
  --text: #f5ead9;
  --text-dim: #cbb99a;
  --radius: 18px;
  --glass-bg: linear-gradient(160deg, rgba(255,255,255,0.16), rgba(255,255,255,0.05));
  --glass-bg-flat: rgba(255,255,255,0.08);
  --glass-border: rgba(255,255,255,0.28);
  --glass-shadow: 0 8px 32px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.18);
  --parchment-1: #f4e7c8;
  --parchment-2: #e6cd9a;
  --parchment-3: #cfab72;
  --card-border: #3b2417;
  --ink: #4a2f1c;
  --ink-dim: #8a6a45;
  --ink-stamp: #8a3324;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,122,26,0.38), transparent 45%),
    radial-gradient(circle at 88% 12%, rgba(129,92,191,0.42), transparent 50%),
    radial-gradient(circle at 50% 95%, rgba(255,183,3,0.28), transparent 55%),
    linear-gradient(160deg, #1a0f2e 0%, #2a1245 45%, #3a1220 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px);
}

.screen {
  display: none;
  width: 100%;
  max-width: 560px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  padding-top: 16px;
}
.screen.active { display: flex; }

/* ---------- Setup ---------- */
.hero { text-align: center; margin-bottom: 8px; }
.hero h1 {
  font-size: 2rem;
  margin: 0.2em 0 0.1em;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-shadow: 0 3px 0 rgba(0,0,0,0.4);
}
.club-logo {
  display: inline-block;
  height: 1.15em;
  width: auto;
  vertical-align: -0.2em;
  transform: rotate(-15deg);
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.4));
}

.btn-club-icon {
  display: inline-block;
  height: 1.3em;
  width: auto;
  vertical-align: -0.3em;
}

.club-flash-icon {
  display: inline-block;
  height: 4rem;
  width: auto;
  margin-left: 12px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
.tagline {
  margin: 0;
  color: var(--accent-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.85rem;
}

.card {
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
}

.setup-card h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-2);
  margin: 18px 0 8px;
}
.setup-card h2:first-of-type { margin-top: 4px; }

.setup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setup-card-header h2 { margin: 0; }
.btn-reset-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.3);
  white-space: nowrap;
}
.btn-reset-link:hover { color: var(--accent-2); }

.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 6px 6px 6px 12px;
}
.team-swatch {
  width: 14px; height: 14px; border-radius: 50%;
  flex-shrink: 0;
}
.team-row input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 4px;
  min-width: 0;
}
.team-row input[type="text"]:focus { outline: none; }
.team-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
}
.team-remove:hover { color: var(--bad); }

.setup-row { margin-top: 10px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}
.chip-active {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #1c120a;
}

.category-list { display: flex; flex-direction: column; gap: 6px; }
.category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}
.category-row input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); }
.category-row .cat-name { font-weight: 600; flex: 1; }
.category-row .cat-count { color: var(--text-dim); font-size: 0.8rem; }

.btn {
  border: none;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(160deg, rgba(255,255,255,0.35), rgba(255,255,255,0) 45%), linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #1c120a;
  box-shadow: 0 4px 0 #b35400, inset 0 1px 0 rgba(255,255,255,0.35);
}
.btn-secondary {
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.9rem;
}
.btn-lg {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  margin-top: 22px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rules-footer {
  width: 100%;
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.rules-footer summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-2);
  padding: 8px 0;
}
.rules-footer ul { padding-left: 20px; line-height: 1.5; }
.rules-footer li { margin-bottom: 6px; }

/* ---------- Handoff ---------- */
.handoff-card {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}
.handoff-label {
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0;
}
.handoff-team {
  font-size: 2.6rem;
  margin: 0;
  font-weight: 900;
}
.handoff-sub {
  color: var(--text-dim);
  max-width: 320px;
  margin: 4px 0 20px;
}

.mini-scoreboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}
.mini-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 10px 14px;
}
.mini-score-row .team-swatch { width: 12px; height: 12px; }
.mini-score-row .name { flex: 1; font-weight: 700; text-align: left; }
.mini-score-row .score { font-weight: 900; font-size: 1.1rem; color: var(--accent-2); }

/* ---------- Play ---------- */
#screen-play { justify-content: flex-start; }
.play-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}
.play-team {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-dim);
  flex: 1;
}
.play-timer {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent-2);
  min-width: 70px;
  text-align: center;
}
.play-timer.urgent { color: var(--bad); animation: pulse 0.5s infinite; }
.play-score {
  font-weight: 800;
  font-size: 1.4rem;
  flex: 1;
  text-align: right;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.card-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 260px;
}

.secret-card {
  width: 100%;
  min-height: 260px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.35), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(120,80,40,0.18), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(120,80,40,0.15), transparent 40%),
    linear-gradient(160deg, var(--parchment-1), var(--parchment-2) 55%, var(--parchment-3));
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0.29  0 0 0 0 0.2  0 0 0 0 0.1  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.35), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(120,80,40,0.18), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(120,80,40,0.15), transparent 40%),
    linear-gradient(160deg, var(--parchment-1), var(--parchment-2) 55%, var(--parchment-3));
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px 24px;
  border: 10px solid var(--card-border);
  box-shadow:
    0 16px 40px rgba(0,0,0,0.5),
    inset 0 0 0 2px rgba(255,255,255,0.25),
    inset 0 0 34px rgba(59,36,23,0.35);
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.secret-card::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 46px rgba(59,36,23,0.4);
  pointer-events: none;
}
.card-mascot {
  position: absolute;
  bottom: -6px;
  right: 4px;
  height: 30%;
  max-height: 100px;
  width: auto;
  opacity: 0.9;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25));
  pointer-events: none;
}
.secret-category {
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 0.8rem;
  color: var(--ink-stamp);
  font-weight: 700;
  margin-bottom: 10px;
}

.tier {
  width: 100%;
}
.tier-label {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.7rem;
  color: var(--ink-dim);
  font-weight: 700;
  margin-bottom: 2px;
}
.tier-points {
  color: var(--ink-stamp);
  font-weight: 900;
}
.tier-top .tier-value {
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 800;
  color: var(--ink-dim);
}
.tier-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 0.75rem;
  color: var(--ink-dim);
  opacity: 0.8;
  margin: 8px 0;
  font-style: italic;
}
.tier-divider::before,
.tier-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(74,47,28,0.35), transparent);
}
.tier-phrase .tier-value {
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 900;
  line-height: 1.15;
  color: var(--ink);
}

.club-flash {
  position: absolute;
  inset: 0;
  background: var(--bad);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 900;
  border-radius: 22px;
  z-index: 5;
  text-transform: uppercase;
  letter-spacing: 2px;
  overflow: hidden;
  opacity: 0;
}
.club-flash.show {
  display: flex;
  animation: flashFade 0.75s ease forwards;
}
@keyframes flashFade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

.splat-burst {
  position: absolute;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, #fff8 0%, #fff0 65%);
  clip-path: polygon(
    50% 0%, 61% 32%, 93% 20%, 74% 48%,
    100% 50%, 74% 52%, 93% 80%, 61% 68%,
    50% 100%, 39% 68%, 7% 80%, 26% 52%,
    0% 50%, 26% 48%, 7% 20%, 39% 32%
  );
  transform: scale(0) rotate(-8deg);
  opacity: 0;
  z-index: 1;
}
.club-flash.show .splat-burst {
  animation: splatPop 0.6s cubic-bezier(.2,.9,.3,1) forwards;
  animation-delay: 0.16s;
}
@keyframes splatPop {
  0% { transform: scale(0) rotate(-14deg); opacity: 0; }
  25% { transform: scale(1.25) rotate(4deg); opacity: 1; }
  45% { transform: scale(1) rotate(0deg); opacity: 0.85; }
  100% { transform: scale(1.05) rotate(0deg); opacity: 0; }
}

.club-flash.show .club-flash-icon {
  z-index: 2;
  animation: clubSwing 0.42s cubic-bezier(.25,.7,.3,1.5) forwards;
}
@keyframes clubSwing {
  0% { transform: translate(130px, -130px) rotate(65deg) scale(0.6); opacity: 0; }
  65% { transform: translate(-4px, 4px) rotate(-16deg) scale(1.15); opacity: 1; }
  100% { transform: translate(2px, 0) rotate(-10deg) scale(1); opacity: 1; }
}

.club-flash-text {
  display: inline-block;
  z-index: 2;
  margin-left: 12px;
  transform: scale(0);
  opacity: 0;
}
.club-flash.show .club-flash-text {
  animation: textPop 0.45s ease forwards;
  animation-delay: 0.16s;
}
@keyframes textPop {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  55% { transform: scale(1.3) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.secret-card.card-hit {
  animation: cardJolt 0.45s ease;
  animation-delay: 0.16s;
}
@keyframes cardJolt {
  0% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-7px, 4px) rotate(-2deg); }
  40% { transform: translate(6px, -3px) rotate(2deg); }
  60% { transform: translate(-4px, 2px) rotate(-1deg); }
  80% { transform: translate(2px, -1px) rotate(1deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

.play-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 8px;
}
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.play-actions .btn {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.action-row-guess .btn {
  padding: 20px 8px;
  font-size: 1.05rem;
  flex-direction: column;
}
.action-row-secondary .btn {
  padding: 14px 6px;
  font-size: 0.9rem;
}
.pts {
  font-weight: 900;
  font-size: 0.85em;
  opacity: 0.85;
}
.btn-top { background: linear-gradient(160deg, rgba(255,255,255,0.3), rgba(255,255,255,0) 45%), #3d8bd4; color: white; box-shadow: 0 4px 0 #245c8f, inset 0 1px 0 rgba(255,255,255,0.3); }
.btn-phrase { background: linear-gradient(160deg, rgba(255,255,255,0.3), rgba(255,255,255,0) 45%), var(--good); color: white; box-shadow: 0 4px 0 #2e7d32, inset 0 1px 0 rgba(255,255,255,0.3); }
.btn-club { background: linear-gradient(160deg, rgba(255,255,255,0.3), rgba(255,255,255,0) 45%), var(--bad); color: white; box-shadow: 0 4px 0 #99101c, inset 0 1px 0 rgba(255,255,255,0.3); }
.btn-skip { background: linear-gradient(160deg, rgba(255,255,255,0.3), rgba(255,255,255,0) 45%), var(--skip); color: white; box-shadow: 0 4px 0 #454b50, inset 0 1px 0 rgba(255,255,255,0.3); }

/* ---------- Round end / final ---------- */
.round-end-card, .final-card {
  width: 100%;
  text-align: center;
  margin: auto 0;
}
.round-end-card h2, .final-card h2 { margin-top: 0; }
.round-end-line { color: var(--text-dim); }

.round-end-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-2);
  margin: 16px 0 8px;
  font-weight: 700;
}
.round-log-hint {
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.75rem;
}
.round-log {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.round-log-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  margin: 8px 0;
}
.log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 6px 6px 6px 12px;
}
.log-phrase {
  font-size: 0.82rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.log-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0.55;
}
.log-btn.active { opacity: 1; border-color: transparent; }
.log-btn.active[data-action="clubbed"] { background: var(--bad); }
.log-btn.active[data-action="skip"] { background: var(--skip); }
.log-btn.active[data-action="top"] { background: #3d8bd4; }
.log-btn.active[data-action="phrase"] { background: var(--good); }
.final-emoji { font-size: 3.5rem; margin: 0 0 4px; }
.final-sub { color: var(--text-dim); margin-top: 0; }

@media (min-width: 600px) {
  .hero h1 { font-size: 2.4rem; }
}
