/* ================================================================== *
 * SIDEQUEST #001 — THE INTERNET TUG OF WAR
 * Vanilla CSS. House style: near-black, Geist, one live-green accent,
 * RED vs GREEN as the two team colors. Editorial, not gamer.
 * ================================================================== */

:root {
  --bg: #080808;
  --fg: #ededed;
  --muted: #7b7b7b;
  --faint: rgba(255, 255, 255, 0.09);
  --hair: rgba(255, 255, 255, 0.06);

  --red: #ff4d5e;
  --red-dim: #b8323f;
  --green: #5df2a5;
  --green-dim: #2f9c68;

  --red-glow: rgba(255, 77, 94, 0.16);
  --green-glow: rgba(93, 242, 165, 0.14);

  --sans: "Geist", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --max: 1120px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--green);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 2px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ------------------------------------------------------------------ *
 * Texture layers (borrowed from the house globals.css)
 * ------------------------------------------------------------------ */
.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette {
  position: fixed;
  inset: 0;
  z-index: 89;
  pointer-events: none;
  background: radial-gradient(
    120% 90% at 50% -10%,
    rgba(255, 255, 255, 0.05),
    transparent 45%
  );
}

.pip {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(93, 242, 165, 0.55);
  animation: pip-pulse 2.6s ease-out infinite;
}

/* Discreet live-people counter — a green dot + a number, fixed in the corner.
   No label: it reads as ambient decoration unless you know what it is. */
.livecount {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 95;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.livecount-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
}
.livecount-dot[data-on="true"] {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(93, 242, 165, 0.55);
  animation: pip-pulse 2.6s ease-out infinite;
}
@keyframes pip-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(93, 242, 165, 0.5);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(93, 242, 165, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(93, 242, 165, 0);
  }
}

/* ------------------------------------------------------------------ *
 * Layout scaffold
 * ------------------------------------------------------------------ */
main {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ------------------------------------------------------------------ *
 * Header
 * ------------------------------------------------------------------ */
.site-header {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  transition: color 0.25s ease;
}
.wordmark:hover {
  color: var(--green);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--faint);
  border-radius: 999px;
  padding: 6px 12px;
}

/* ------------------------------------------------------------------ *
 * Hero
 * ------------------------------------------------------------------ */
.hero {
  text-align: center;
  padding: 48px 0 30px;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}
.title {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.9;
  font-size: clamp(3.5rem, 16vw, 9rem);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 0.22em;
}
.title-of {
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.02em;
  color: var(--muted);
  font-size: 0.42em;
}
.title-red {
  color: var(--red);
}
.title-green {
  color: var(--green);
}
.subhead {
  margin: 22px auto 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.5;
}

/* ------------------------------------------------------------------ *
 * Live stats strip
 * ------------------------------------------------------------------ */
.stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 0 40px;
}
.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.stat-dot {
  align-self: center;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--muted);
  transition: background 0.3s ease;
}
.stat-dot[data-on="true"] {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.stat-value {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.stat-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
}
.stat-sep {
  width: 1px;
  height: 22px;
  background: var(--faint);
}

/* ------------------------------------------------------------------ *
 * Scoreboard
 * ------------------------------------------------------------------ */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 6px 0 20px;
}
.score {
  text-align: center;
}
.score-red {
  text-align: right;
}
.score-green {
  text-align: left;
}
.score-team {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.score-red .score-team {
  color: var(--red);
}
.score-green .score-team {
  color: var(--green);
}
.score-number {
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.6rem, 11vw, 6rem);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.score-red .score-number {
  color: #ffe3e6;
}
.score-green .score-number {
  color: #dffbec;
}
.score-number.bump {
  transform: scale(1.09);
}
.score-center {
  min-width: 96px;
  text-align: center;
  padding: 0 4px;
}
.lead-line {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  white-space: nowrap;
}
.lead-line[data-team="red"] {
  color: var(--red);
}
.lead-line[data-team="green"] {
  color: var(--green);
}
.lead-by {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Proportional bar */
.bar {
  position: relative;
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 4px;
  background: #161616;
  border: 1px solid var(--hair);
}
.bar-red {
  background: linear-gradient(90deg, var(--red-dim), var(--red));
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.bar-green {
  background: linear-gradient(90deg, var(--green), var(--green-dim));
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.bar-knob {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 20px;
  background: var(--fg);
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: left 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 0 3px var(--bg);
}

/* ------------------------------------------------------------------ *
 * Play / join
 * ------------------------------------------------------------------ */
.play {
  margin: 30px auto 8px;
  max-width: 560px;
}

/* --- join form --- */
.join {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  border: 1px solid var(--faint);
  border-radius: 18px;
  padding: 28px 22px;
  background: rgba(255, 255, 255, 0.015);
}
.join-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.join-input {
  width: 100%;
  max-width: 320px;
  background: #101010;
  border: 1px solid var(--faint);
  border-radius: 12px;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.15rem;
  text-align: center;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s ease;
}
.join-input::placeholder {
  color: #555;
}
.join-input:focus {
  border-color: var(--green);
}
.join-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.team-btn {
  border: 1px solid;
  border-radius: 12px;
  padding: 15px 10px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  background: transparent;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.team-btn:active {
  transform: translateY(1px);
}
.team-btn-red {
  color: var(--red);
  border-color: rgba(255, 77, 94, 0.4);
}
.team-btn-red:hover {
  background: var(--red-glow);
  box-shadow: 0 0 0 1px var(--red) inset;
}
.team-btn-green {
  color: var(--green);
  border-color: rgba(93, 242, 165, 0.4);
}
.team-btn-green:hover {
  background: var(--green-glow);
  box-shadow: 0 0 0 1px var(--green) inset;
}
.join-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.join-input.shake {
  animation: shake 0.35s ease;
  border-color: var(--red);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* --- play panel --- */
.playpanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.you {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.you-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.you-team {
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  line-height: 1;
}
.you-team[data-team="red"] {
  color: var(--red);
}
.you-team[data-team="green"] {
  color: var(--green);
}
.you-name {
  font-size: 13px;
  color: var(--muted);
}
.you-name b {
  color: var(--fg);
  font-weight: 600;
}

.pull-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pull-btn {
  position: relative;
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 26px 20px;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  color: #0a0a0a;
  overflow: hidden;
  transition: transform 0.1s ease, filter 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.pull-btn[data-team="red"] {
  background: linear-gradient(180deg, #ff6472, var(--red));
  box-shadow: 0 14px 40px -14px var(--red);
}
.pull-btn[data-team="green"] {
  background: linear-gradient(180deg, #78ffbb, var(--green));
  box-shadow: 0 14px 40px -14px var(--green);
}
.pull-btn:hover {
  filter: brightness(1.05);
}
.pull-btn:active {
  transform: scale(0.985);
}
.pull-btn.is-cooling {
  cursor: not-allowed;
}
/* While cooling, the label text itself becomes the countdown — style it as a
   timer. One text element, so nothing can overlap. */
.pull-btn.is-cooling .pull-btn-label {
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: rgba(10, 10, 10, 0.8);
}
/* the cooldown drain overlay */
.pull-btn::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 100%;
  width: var(--cool, 0%);
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none;
  transition: width 0.1s linear;
}

.pull-feedback {
  height: 20px;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.pull-feedback.show {
  opacity: 1;
}
.pull-feedback[data-team="red"] {
  color: var(--red);
}
.pull-feedback[data-team="green"] {
  color: var(--green);
}

.play-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--faint);
  background: var(--fg);
  color: #0a0a0a;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.12s ease, filter 0.2s ease;
}
.share-btn:hover {
  filter: brightness(0.92);
}
.share-btn:active {
  transform: translateY(1px);
}
.switch-btn {
  border: 1px solid var(--faint);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.switch-btn:hover {
  color: var(--fg);
  border-color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Columns: feed + leaderboard
 * ------------------------------------------------------------------ */
.columns {
  margin-top: 46px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.col-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--faint);
}

.feed,
.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--hair);
  font-size: 0.9rem;
}
.feed-plus {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  width: 26px;
}
.feed-row[data-team="red"] .feed-plus {
  color: var(--red);
}
.feed-row[data-team="green"] .feed-plus {
  color: var(--green);
}
.feed-name {
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-verb {
  color: var(--muted);
  font-size: 0.85rem;
}
.feed-team {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.feed-row[data-team="red"] .feed-team {
  color: var(--red);
}
.feed-row[data-team="green"] .feed-team {
  color: var(--green);
}
.feed-time {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: #5a5a5a;
  font-variant-numeric: tabular-nums;
}
.feed-row.is-me {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}
.feed-row.enter {
  animation: feed-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes feed-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.feed-empty,
.board-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 4px;
}

/* leaderboard */
.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--hair);
}
.board-rank {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  width: 22px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.board-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.board-row[data-team="red"] .board-dot {
  background: var(--red);
}
.board-row[data-team="green"] .board-dot {
  background: var(--green);
}
.board-name {
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-row.is-me .board-name {
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-underline-offset: 3px;
}
.board-pulls {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.board-pulls b {
  color: var(--fg);
  font-weight: 500;
}

/* ------------------------------------------------------------------ *
 * Creed
 * ------------------------------------------------------------------ */
.creed {
  margin: 60px 0 10px;
  text-align: center;
}
.creed p {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  line-height: 1.35;
}
.creed-dim {
  color: var(--muted);
}

/* ------------------------------------------------------------------ *
 * Footer
 * ------------------------------------------------------------------ */
.site-footer {
  width: 100%;
  max-width: var(--max);
  margin: 40px auto 0;
  padding: 30px 20px 40px;
  border-top: 1px solid var(--faint);
}
.foot-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}
.foot-name {
  margin: 0;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.foot-sub {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.foot-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
}
.foot-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}
.foot-links a:first-child {
  color: var(--fg);
}
.foot-links a:hover {
  color: var(--green);
}
.foot-copy {
  margin: 26px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: #4d4d4d;
}

/* ------------------------------------------------------------------ *
 * Floating +1 particles
 * ------------------------------------------------------------------ */
.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}
.fx-plus {
  position: fixed;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.1rem;
  transform: translate(-50%, -50%);
  animation: fx-rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.fx-plus[data-team="red"] {
  color: var(--red);
}
.fx-plus[data-team="green"] {
  color: var(--green);
}
@keyframes fx-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.8);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1);
  }
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 620px) {
  .columns {
    grid-template-columns: 1fr;
    gap: 34px;
  }
  .stat-sep {
    height: 16px;
  }
  .score-center {
    min-width: 74px;
  }
  .feed-verb {
    display: none;
  }
  .play-actions {
    width: 100%;
    max-width: 420px;
  }
  .share-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  .stats {
    gap: 12px;
  }
  .join-buttons {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ *
 * Reduced motion
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .pip {
    animation: none !important;
  }
}
