/* /watch/: a game in spectator mode, full screen, with a broadcast overlay on top.
   Everything is sized to read from across a room. */

:root {
  --bg: #0b0a18;
  --panel: rgb(16 13 38 / 0.82);
  --panel-solid: #14112b;
  --text: #f4f1ff;
  --muted: #b9b3d6;
  --accent: #f5cf47;
  --red: #ff5a5f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
body.idle-mouse { cursor: none; }

#stage { position: fixed; inset: 0; }
#stage iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
  background: var(--bg);
  transition: opacity 0.6s ease;
}
#stage iframe.incoming { opacity: 0; pointer-events: none; }

/* The overlay never takes clicks, except its buttons: a click anywhere else goes to the
   game below, which is what lets it start its sound. */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#ui button, #ui a { pointer-events: auto; }
[hidden] { display: none !important; }

kbd {
  display: inline-block; min-width: 1.6em; padding: 0.1em 0.4em; border-radius: 0.35em;
  background: rgb(255 255 255 / 0.12); border: 1px solid rgb(255 255 255 / 0.2);
  font: 700 0.85em/1.2 inherit; text-align: center;
}

/* ---------------------------------------------------------------- the bug */

.bug {
  position: absolute; top: clamp(12px, 2.2vh, 28px); left: clamp(12px, 1.8vw, 32px);
  display: flex; align-items: stretch; border-radius: 10px; overflow: hidden;
  font-weight: 800; font-size: clamp(14px, 1.35vw, 26px); letter-spacing: 0.02em;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
}
.bug__live { background: var(--red); color: #fff; padding: 0.35em 0.7em; text-transform: uppercase; display: flex; align-items: center; gap: 0.45em; }
.bug__live::before { content: ""; width: 0.55em; height: 0.55em; border-radius: 50%; background: #fff; animation: blink 1.6s ease-in-out infinite; }
.bug__where { background: var(--panel); padding: 0.35em 0.8em; }
@keyframes blink { 50% { opacity: 0.25; } }

.home {
  position: absolute; top: clamp(12px, 2.2vh, 28px); right: clamp(12px, 1.8vw, 32px);
  padding: 7px 13px; border-radius: 999px; background: var(--panel); color: var(--text);
  font: 600 14px/1.2 inherit; text-decoration: none; border: 1px solid rgb(255 255 255 / 0.18);
  transition: opacity 0.4s;
}

/* ---------------------------------------------------------------- scoreboard */

.board {
  position: absolute; top: clamp(12px, 2.2vh, 28px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 0;
  font-size: clamp(18px, 2.1vw, 44px); font-weight: 800;
  filter: drop-shadow(0 8px 26px rgb(0 0 0 / 0.45));
  max-width: calc(100vw - 2 * clamp(12px, 1.8vw, 32px) - 22vw);
}
.board__side {
  display: flex; align-items: center; gap: 0.5em; background: var(--panel); padding: 0.3em 0.7em;
  min-width: 0; white-space: nowrap;
}
.board__side:first-child { border-radius: 14px 0 0 14px; }
.board__side:last-child { border-radius: 0 14px 14px 0; }
.board__side:only-child { border-radius: 14px; }
.board__side.right { flex-direction: row-reverse; }
.board__chip { width: 0.5em; align-self: stretch; border-radius: 4px; flex: none; }
.board__name { overflow: hidden; text-overflow: ellipsis; }
.board__detail { font-size: 0.55em; color: var(--muted); font-weight: 700; }
.board__score {
  min-width: 1.7em; text-align: center; padding: 0.05em 0.3em; border-radius: 8px;
  background: rgb(255 255 255 / 0.1); font-variant-numeric: tabular-nums;
}
.board__score.bump { animation: bump 0.6s ease; }
@keyframes bump { 30% { transform: scale(1.35); background: var(--accent); color: #1b1606; } }
.board__out { opacity: 0.45; }
.board__mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel-solid); padding: 0.2em 0.8em; min-width: 4.5em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.board__round { font-size: 0.5em; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.board__timer { font-size: 0.95em; }
.board__status { font-size: 0.55em; color: var(--muted); font-weight: 700; }
.board--many { flex-wrap: wrap; justify-content: center; gap: 0.3em; }
.board--many .board__side { border-radius: 12px; }

/* ---------------------------------------------------------------- moments */

.banner {
  position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%) scale(0.8);
  padding: 0.3em 1.1em; border-radius: 18px; white-space: nowrap;
  background: var(--accent); color: #1b1606; font-weight: 900; font-size: clamp(30px, 4.8vw, 96px);
  letter-spacing: -0.01em; text-transform: none; opacity: 0;
  box-shadow: 0 16px 60px rgb(0 0 0 / 0.45);
}
.banner.show { animation: banner 2.4s cubic-bezier(.2,.9,.25,1) forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(-3deg); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05) rotate(0); }
  20% { transform: translate(-50%, -50%) scale(1); }
  82% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.95); }
}

.winner {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  background: radial-gradient(60% 50% at 50% 50%, rgb(11 10 24 / 0.55), transparent 75%);
  animation: fadein 0.5s ease;
}
.winner__label { font-size: clamp(20px, 2.4vw, 48px); font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.2em; }
.winner__name { font-size: clamp(56px, 10vw, 200px); font-weight: 900; line-height: 1; letter-spacing: -0.03em; text-shadow: 0 10px 50px rgb(0 0 0 / 0.6); }
@keyframes fadein { from { opacity: 0; transform: scale(0.94); } }

.idle {
  position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%);
  width: min(900px, calc(100vw - 32px)); text-align: center; padding: 1.2em 1.6em; border-radius: 20px;
  background: var(--panel);
}
.idle h1 { margin: 0 0 0.3em; font-size: clamp(24px, 3vw, 56px); }
.idle p { margin: 0; color: var(--muted); font-size: clamp(16px, 1.5vw, 28px); line-height: 1.4; }

.sound {
  position: absolute; left: 50%; bottom: clamp(90px, 15vh, 170px); transform: translateX(-50%);
  padding: 0.5em 1.1em; border-radius: 999px; background: var(--panel); border: 1px solid rgb(255 255 255 / 0.25);
  font-size: clamp(14px, 1.2vw, 22px); font-weight: 700; animation: blink 2.4s ease-in-out infinite;
}

/* ---------------------------------------------------------------- also playing */

.strip {
  position: absolute; left: clamp(12px, 1.8vw, 32px); bottom: clamp(12px, 2.2vh, 28px);
  display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; max-width: 58vw;
  font-size: clamp(13px, 1.1vw, 22px); font-weight: 700;
}
.strip__label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8em; background: var(--panel); padding: 0.45em 0.7em; border-radius: 999px; }
.strip button {
  display: inline-flex; align-items: center; gap: 0.5em; cursor: pointer;
  padding: 0.35em 0.8em 0.35em 0.4em; border-radius: 999px; border: 1px solid rgb(255 255 255 / 0.2);
  background: var(--panel); color: var(--text); font: inherit;
}
.strip button:hover, .strip button:focus-visible { border-color: var(--accent); outline: none; }
.strip kbd { font-size: 0.85em; }
.strip .dots { display: inline-flex; gap: 0.2em; }
.strip .dot { width: 0.7em; height: 0.7em; border-radius: 50%; }

/* ---------------------------------------------------------------- views */

.views {
  position: absolute; right: clamp(12px, 1.8vw, 32px); bottom: clamp(12px, 2.2vh, 28px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.5em;
  font-size: clamp(13px, 1vw, 20px); font-weight: 700;
  transition: opacity 0.5s ease;
}
.views__modes, .views__players { display: flex; gap: 0.4em; flex-wrap: wrap; justify-content: flex-end; }
.views button {
  cursor: pointer; padding: 0.45em 0.85em; border-radius: 999px; border: 1px solid rgb(255 255 255 / 0.2);
  background: var(--panel); color: var(--text); font: inherit; display: inline-flex; align-items: center; gap: 0.45em;
}
.views button[aria-pressed="true"] { background: var(--accent); color: #1b1606; border-color: var(--accent); }
.views button[aria-pressed="true"] kbd { background: rgb(0 0 0 / 0.12); border-color: rgb(0 0 0 / 0.2); }
.views button .dot { width: 0.7em; height: 0.7em; border-radius: 50%; }
.views__keys { color: var(--muted); font-weight: 600; background: var(--panel); padding: 0.4em 0.8em; border-radius: 999px; }
body.idle-mouse .views__keys, body.idle-mouse .views__modes, body.idle-mouse .home { opacity: 0; }
body.idle-mouse .views__players:not(.pov) { opacity: 0; }

/* "Jon is playing" name in player view */
.views__players.pov button[aria-pressed="true"] { font-size: 1.35em; }

/* ---------------------------------------------------------------- title card */

.card {
  position: fixed; inset: 0; z-index: 8; display: grid; align-items: end; overflow: hidden;
  background: var(--bg);
  animation: fadein 0.45s ease;
}
.card.out { opacity: 0; transition: opacity 0.6s ease; }
.card__bg {
  position: absolute; inset: -4%; background-size: cover; background-position: center;
  filter: saturate(1.1) brightness(0.62); animation: kenburns 9s ease-out forwards;
}
.card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgb(8 7 20 / 0.95) 0%, rgb(8 7 20 / 0.55) 40%, rgb(8 7 20 / 0.1) 75%);
}
@keyframes kenburns { from { transform: scale(1.08); } to { transform: scale(1); } }
.card__text { position: relative; z-index: 1; padding: 0 6vw 10vh; }
.card__kicker { font-size: clamp(22px, 2.8vw, 56px); font-weight: 800; color: var(--accent); animation: rise 0.6s 0.1s ease both; }
.card__title { font-size: clamp(56px, 9vw, 190px); font-weight: 900; line-height: 0.95; letter-spacing: -0.035em; animation: rise 0.7s 0.2s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(30px); } }

/* ---------------------------------------------------------------- start */

.start {
  position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; text-align: center;
  background: var(--bg); transition: opacity 0.6s ease;
}
.start.out { opacity: 0; pointer-events: none; }
.start__logo { font-size: clamp(48px, 8vw, 150px); font-weight: 900; letter-spacing: -0.035em; }
.start__logo span {
  background: linear-gradient(90deg, var(--red), #ff9a5a 45%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.start p { color: var(--muted); font-size: clamp(16px, 1.6vw, 30px); margin: 0.4em 0 0; }

@media (prefers-reduced-motion: reduce) {
  .card__bg, .banner.show, .bug__live::before, .sound { animation: none; }
  .banner.show { opacity: 1; transform: translate(-50%, -50%); }
}
