/* TV screens. 1rem = 1 % of the stage height (set by render.js), so the whole
   layout scales with the 16:9 stage: 720p, 1080p and the debug preview alike.
   Performance on weak TVs: only transform/opacity are animated; no filters,
   no backdrop-filter, no big shadows, no bitmaps. */

@font-face {
  font-family: 'Nunito';
  src: url('../fonts/nunito-regular.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Nunito';
  src: url('../fonts/nunito-700.woff2') format('woff2');
  font-weight: 700;
  font-display: block;
}
@font-face {
  font-family: 'Nunito';
  src: url('../fonts/nunito-800.woff2') format('woff2');
  font-weight: 800;
  font-display: block;
}

:root {
  --wall: #E2B659;
  --wall-dark: #C99A3E;
  --line: #3A2E28;
  --ink: #1E2B47;
  --stamp: #C3303A;
  --green: #2F7A63;
  --paper: #FBF3E0;
  --paper-edge: #E9DDC0;
  --folder: #D9A441;
  --night: #1B2336;
}

.tv-root {
  margin: 0;
  background: #111622;
  overflow: hidden;
  font-family: 'Nunito', 'Arial Rounded MT Bold', 'Segoe UI', sans-serif;
}

.stage {
  position: relative;
  overflow: hidden;
  background: var(--wall);
  color: var(--ink);
  font-size: 3.6rem;
  line-height: 1.25;
  font-weight: 700;
}

.screen {
  position: absolute;
  inset: 0;
}

/* Safe area: at least 5 % from every edge (TV overscan). */
.safe {
  position: absolute;
  inset: 5rem 8.9rem;
}

/* ------------------------------------------------------------------ wall */

.wall {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(to top, transparent 0, transparent 9.6rem, rgba(58, 46, 40, 0.55) 9.6rem, rgba(58, 46, 40, 0.55) 10rem),
    var(--wall);
}

.wall::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 17rem;
  background: var(--wall-dark);
  border-top: 0.6rem solid var(--line);
}

.wall-scale {
  position: absolute;
  top: 0;
  bottom: 17rem;
  left: 3.2rem;
  width: 4rem;
  font-size: 2rem;
  color: rgba(58, 46, 40, 0.8);
}

.wall-scale span {
  position: absolute;
  left: 0;
  transform: translateY(50%);
}

/* ----------------------------------------------------------------- common */

.paper {
  background: var(--paper);
  border: 0.5rem solid var(--line);
  border-radius: 2.4rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 2rem 0.6rem 0.8rem;
  border-radius: 5rem;
  background: var(--paper);
  border: 0.4rem solid var(--line);
  font-size: 3.4rem;
}

.badge .dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  border: 0.4rem solid var(--line);
  color: #fff;
  font-weight: 800;
  font-size: 2.8rem;
}

.badge.off {
  opacity: 0.45;
}

.badge .host {
  font-size: 2.4rem;
  color: var(--green);
}

.badge .check {
  width: 3.6rem;
  height: 3.6rem;
}

.score {
  display: inline-flex;
  align-items: center;
  gap: 1.2rem;
  font-size: 3rem;
}

.star {
  width: 4rem;
  height: 4rem;
  vertical-align: middle;
}

.muted {
  color: rgba(30, 43, 71, 0.72);
}

/* ------------------------------------------------------------------ lobby */

.lobby-card {
  position: absolute;
  top: 7rem;
  left: 50%;
  width: 136rem;
  margin-left: -68rem;
  padding: 4rem 5rem;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 4rem;
}

.lobby-main {
  flex: 1;
  min-width: 0;
}

.lobby-qr {
  flex: none;
  width: 30rem;
  text-align: center;
  font-size: 2.6rem;
  line-height: 1.25;
}

.lobby-qr .qr {
  display: block;
  width: 30rem;
  height: 30rem;
  border: 0.5rem solid var(--line);
  border-radius: 1.6rem;
}

.lobby-qr p {
  margin: 1.2rem 0 0;
}

.lobby-qr .url {
  margin-top: 0.4rem;
  font-size: 2rem;
  color: rgba(30, 43, 71, 0.7);
  overflow-wrap: anywhere;
}

.lobby-qr .code {
  font-size: 3rem;
}

.lobby-qr .code b {
  display: block;
  font-size: 6.5rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  margin-right: -0.25em; /* letter-spacing after the last letter */
  line-height: 1.1;
}

/* Outside the stage: connection problems and the one-time start button (sound and
   full screen need a click or a key press in the browser). */
.net-status,
.start-button {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 1.2rem 3rem;
  border: 0.4rem solid var(--line);
  border-radius: 3rem;
  font: inherit;
  font-size: 2.6rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  z-index: 10;
}

.net-status {
  top: 2rem;
  background: #FFE08A;
}

.start-button {
  bottom: 2rem;
  background: var(--paper);
  cursor: pointer;
}

.start-button:focus-visible {
  outline: 0.5rem solid #2E7CD6;
  outline-offset: 0.3rem;
}

.net-status[hidden],
.start-button[hidden] {
  display: none;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  font-size: 11rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.2rem;
}

.logo svg {
  width: 11rem;
  height: 11rem;
}

.lobby-card .lead {
  margin: 2.6rem 0 3rem;
  font-size: 3.8rem;
}

.lobby-card .badges {
  justify-content: center;
  min-height: 7rem;
}

.lobby-meta {
  display: flex;
  justify-content: center;
  gap: 5rem;
  margin-top: 3.4rem;
  font-size: 3.4rem;
}

.lobby-meta b {
  color: var(--green);
}

.lobby-cast {
  position: absolute;
  bottom: 3rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 9rem;
}

.lobby-cast .suspect-svg {
  height: 30rem;
  width: auto;
}

.waiting-dots span {
  display: inline-block;
  animation: bounce 1.4s infinite;
}

.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-1rem); }
}

/* ------------------------------------------------------------------ intro */

.intro {
  background: var(--night);
}

.folder {
  position: absolute;
  top: 9rem;
  left: 50%;
  width: 120rem;
  height: 78rem;
  margin-left: -60rem;
}

.folder-back {
  position: absolute;
  inset: 0;
  background: var(--folder);
  border: 0.5rem solid var(--line);
  border-radius: 1.6rem;
}

.folder-back::before {
  content: '';
  position: absolute;
  top: -5rem;
  left: 6rem;
  width: 30rem;
  height: 6rem;
  background: var(--folder);
  border: 0.5rem solid var(--line);
  border-bottom: 0;
  border-radius: 1.6rem 1.6rem 0 0;
}

.folder-paper {
  position: absolute;
  inset: 3rem 4rem;
  padding: 5rem 7rem;
  background: var(--paper);
  border: 0.4rem solid var(--paper-edge);
  border-radius: 0.8rem;
}

.folder-paper .case-no {
  font-size: 3.2rem;
  color: var(--stamp);
  font-weight: 800;
}

.folder-paper h1 {
  margin: 1rem 0 3rem;
  font-size: 8.4rem;
  line-height: 1.05;
  font-weight: 800;
}

.folder-paper .story {
  font-size: 4.6rem;
  line-height: 1.35;
  font-weight: 700;
}

.folder-paper .secret {
  position: absolute;
  top: 5rem;
  right: 6rem;
  padding: 0.6rem 2.4rem;
  border: 0.7rem double var(--stamp);
  border-radius: 1rem;
  color: var(--stamp);
  font-size: 4rem;
  font-weight: 800;
  transform: rotate(8deg);
  opacity: 0.85;
}

.folder-paper .facts {
  display: flex;
  gap: 5rem;
  margin-top: 4rem;
  font-size: 3.6rem;
}

.folder-paper .facts b {
  color: var(--green);
}

.folder-paper .next {
  position: absolute;
  left: 7rem;
  right: 7rem;
  bottom: 4rem;
  font-size: 3.2rem;
}

.folder-cover {
  position: absolute;
  inset: 0;
  background: var(--folder);
  border: 0.5rem solid var(--line);
  border-radius: 1.6rem;
  transform-origin: left center;
  backface-visibility: hidden;
  animation: folder-open 1.3s 0.5s cubic-bezier(0.5, 0, 0.3, 1) forwards;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-cover .label {
  padding: 2rem 6rem;
  background: var(--paper);
  border: 0.4rem solid var(--line);
  font-size: 6rem;
  font-weight: 800;
}

@keyframes folder-open {
  to { transform: perspective(300rem) rotateY(-100deg); opacity: 0; }
}

/* --------------------------------------------------------- investigation */

.topbar {
  position: absolute;
  top: 4rem;
  left: 8.9rem;
  right: 8.9rem;
  height: 11rem;
  display: flex;
  align-items: center;
  gap: 3rem;
  padding: 0 3rem;
}

.topbar .title {
  flex: 1;
  min-width: 0;
  font-size: 4.4rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.counters {
  display: flex;
  align-items: center;
  gap: 3.4rem;
  font-size: 3.4rem;
}

.counters .icons {
  display: inline-flex;
  gap: 0.6rem;
  vertical-align: middle;
}

.counters svg {
  width: 4.6rem;
  height: 4.6rem;
}

.counters .used {
  opacity: 0.25;
}

.accusers {
  position: absolute;
  top: 16.5rem;
  left: 8.9rem;
  right: 8.9rem;
  display: flex;
  align-items: center;
  gap: 1.6rem;
  font-size: 3.2rem;
}

.accusers .badge {
  font-size: 3rem;
  padding: 0.4rem 1.6rem 0.4rem 0.6rem;
}

.accusers .badge .dot {
  width: 4.2rem;
  height: 4.2rem;
  font-size: 2.4rem;
}

.accusers .badge.waiting {
  opacity: 0.55;
}

.lineup {
  position: absolute;
  left: 8.9rem;
  right: 8.9rem;
  bottom: 4.5rem;
  top: 24rem;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
}

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
}

.figure-wrap {
  position: relative;
}

.figure {
  transition: opacity 0.4s;
}

/* Figure height + the cross above it + the plate must fit the lineup's 71.5rem. */
.lineup.n4 .figure .suspect-svg { height: 47rem; }
.lineup.n6 .figure .suspect-svg { height: 46rem; }
.lineup.n8 .figure .suspect-svg { height: 38rem; }

.suspect-svg {
  display: block;
  width: auto;
  overflow: visible;
}

.figure.marked { opacity: 0.4; }
.figure.locked { opacity: 0.3; }

/* A player's cross hangs in the free space above the head. The top 9 % of the
   viewBox holds nothing over the head column (only a raised balloon beside it),
   so the cross may dip into it. */
.mark {
  position: absolute;
  left: 50%;
  bottom: 91%;
  width: 11rem;
  height: 11rem;
  margin-left: -5.5rem;
  animation: pop 0.35s ease-out;
}

.lineup.n8 .mark {
  width: 10rem;
  height: 10rem;
  margin-left: -5rem;
}

.mark .who {
  position: absolute;
  right: -1.6rem;
  top: -1.6rem;
  width: 5.4rem;
  height: 5.4rem;
  border-radius: 50%;
  border: 0.4rem solid var(--line);
  color: #fff;
  font-weight: 800;
  font-size: 3.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mark svg {
  width: 100%;
  height: 100%;
}

@keyframes pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tag {
  position: absolute;
  top: 80%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
  padding: 0.4rem 1.8rem;
  border: 0.5rem solid var(--green);
  border-radius: 1rem;
  background: var(--paper);
  color: var(--green);
  font-size: 3.2rem;
  font-weight: 800;
  white-space: nowrap;
  animation: tag-in 0.4s ease-out;
}

.lineup.n8 .tag {
  font-size: 2.6rem;
  padding: 0.3rem 1.2rem;
}

@keyframes tag-in {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1.8); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
}

.tag.wrong {
  border-color: var(--stamp);
  color: var(--stamp);
}

.plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
  height: 14rem;
  max-width: 100%;
}

.plate .num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  background: var(--paper);
  border: 0.5rem solid var(--line);
  font-size: 4.6rem;
  font-weight: 800;
  line-height: 1;
}

.plate .name {
  margin-top: 0.8rem;
  font-size: 3.6rem;
  font-weight: 800;
  color: var(--paper);
  white-space: nowrap;
}

.lineup.n8 .plate .name {
  font-size: 3.1rem;
}

.alibi-strip {
  position: absolute;
  left: 8.9rem;
  right: 8.9rem;
  top: 16rem;
  display: flex;
  justify-content: flex-end;
  gap: 1.6rem;
  font-size: 2.8rem;
  pointer-events: none;
}

/* ---------------------------------------------------------------- notices */

.notice-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 35, 54, 0.55);
  animation: fade 0.25s ease-out;
}

.notice {
  display: flex;
  align-items: center;
  gap: 4rem;
  max-width: 130rem;
  padding: 4.5rem 6rem;
  animation: rise 0.35s ease-out;
}

.notice .suspect-svg {
  height: 36rem;
  flex: none;
}

.notice h2 {
  margin: 0 0 2rem;
  font-size: 6.4rem;
  line-height: 1.1;
  font-weight: 800;
}

.notice p {
  margin: 0;
  font-size: 4.2rem;
  line-height: 1.35;
}

.notice.disagree h2 {
  color: var(--stamp);
  font-size: 8rem;
  margin: 0;
}

.notice.hint h2 {
  color: var(--green);
}

.notice.wrong h2 {
  color: var(--stamp);
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise {
  from { transform: translateY(6rem) scale(0.95); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ----------------------------------------------------------------- result */

.result {
  background: var(--night);
  color: var(--paper);
}

.spotlight {
  position: absolute;
  left: 4rem;
  top: 0;
  bottom: 0;
  width: 76rem;
  background: radial-gradient(ellipse 50% 60% at 50% 62%, rgba(255, 236, 170, 0.95), rgba(255, 236, 170, 0.35) 55%, rgba(255, 236, 170, 0) 75%);
  animation: fade 0.8s ease-out;
}

.culprit {
  position: absolute;
  left: 13rem;
  bottom: 9rem;
  width: 58rem;
  text-align: center;
}

.culprit .suspect-svg {
  height: 58rem;
  margin: 0 auto;
}

.culprit .who {
  margin-top: 1rem;
  font-size: 6rem;
  font-weight: 800;
  color: var(--paper);
}

.stamp {
  position: absolute;
  left: 10rem;
  top: 10rem;
  padding: 1.2rem 4rem;
  border: 1.1rem double var(--stamp);
  border-radius: 1.6rem;
  color: var(--stamp);
  font-size: 8rem;
  font-weight: 800;
  letter-spacing: 0.5rem;
  line-height: 1;
  background: rgba(251, 243, 224, 0.92);
  transform: rotate(-12deg);
  animation: stamp 0.55s 0.4s cubic-bezier(0.3, 1.4, 0.6, 1) both;
}

.stamp.failed {
  border-color: var(--ink);
  color: var(--ink);
  font-size: 6.4rem;
}

@keyframes stamp {
  0% { opacity: 0; transform: rotate(-12deg) scale(3); }
  70% { opacity: 1; transform: rotate(-12deg) scale(0.94); }
  100% { opacity: 1; transform: rotate(-12deg) scale(1); }
}

.recap {
  position: absolute;
  right: 8.9rem;
  top: 6rem;
  width: 84rem;
  bottom: 6rem;
  padding: 3.4rem 4.4rem;
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

.recap .stars {
  display: flex;
  gap: 1.4rem;
  margin-bottom: 1.6rem;
}

.recap .stars .star {
  width: 8rem;
  height: 8rem;
  animation: pop 0.4s both;
}

.recap .stars .star:nth-child(2) { animation-delay: 0.15s; }
.recap .stars .star:nth-child(3) { animation-delay: 0.3s; }

.recap h2 {
  margin: 0 0 1.6rem;
  font-size: 4.4rem;
  font-weight: 800;
}

.recap ul {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.recap li {
  display: flex;
  align-items: baseline;
  gap: 1.6rem;
  padding: 0.9rem 0;
  border-bottom: 0.3rem dashed var(--paper-edge);
  font-size: 3.1rem;
  line-height: 1.25;
}

.recap li .owner {
  flex: none;
  min-width: 19rem;
  font-weight: 800;
}

.recap li .owner i {
  display: inline-block;
  width: 2.4rem;
  height: 2.4rem;
  margin-right: 0.9rem;
  border: 0.3rem solid var(--line);
  border-radius: 50%;
  vertical-align: -0.2rem;
}

.recap.many h2 {
  display: none;
}

.recap ul.many li {
  padding: 0.5rem 0;
  font-size: 2.7rem;
}

.recap .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.6rem;
  font-size: 3rem;
}

.corner-score {
  position: absolute;
  right: 8.9rem;
  bottom: 1.2rem;
  font-size: 2.6rem;
  color: rgba(251, 243, 224, 0.85);
}

.investigation .corner-score {
  color: var(--paper);
}

/* ---------------------------------------------------------- misc / status */

.status-line {
  position: absolute;
  left: 8.9rem;
  bottom: 1.2rem;
  font-size: 2.4rem;
  color: rgba(58, 46, 40, 0.8);
}

/* ------------------------------------------------------------------ dance */

.dance-banner {
  position: absolute;
  top: 15.5rem;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.dance-banner:empty {
  display: none;
}

.dance-bubble {
  display: inline-flex;
  align-items: center;
  gap: 1.6rem;
  padding: 1.2rem 3.6rem;
  color: var(--stamp);
  font-size: 4.6rem;
  font-weight: 800;
  animation: rise 0.35s ease-out;
}

.dance-bubble svg {
  width: 5rem;
  height: 5rem;
}

/* One animation period = two beats of the music (lobby 108 BPM, investigation 88 BPM).
   transform only – cheap on a weak TV. */
.dancing .figure-wrap,
.dancing .lobby-cast .suspect-svg,
.dancing .culprit .suspect-svg {
  transform-origin: 50% 100%;
  animation: dance-hop 1.111s ease-in-out infinite;
}

.dancing .slot:nth-child(3n + 2) .figure-wrap,
.dancing .lobby-cast .suspect-svg:nth-child(3n + 2) {
  animation-name: dance-sway;
}

.dancing .slot:nth-child(3n) .figure-wrap,
.dancing .lobby-cast .suspect-svg:nth-child(3n) {
  animation-name: dance-bounce;
}

.dancing .investigation .figure-wrap {
  animation-duration: 1.364s;
}

@keyframes dance-hop {
  0%, 50%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3rem) rotate(-8deg); }
  75% { transform: translateY(-3rem) rotate(8deg); }
}

@keyframes dance-sway {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: translateY(-1.5rem) rotate(10deg); }
}

@keyframes dance-bounce {
  0%, 50%, 100% { transform: scale(1, 1); }
  15%, 65% { transform: scale(1.12, 0.86); }
  30%, 80% { transform: translateY(-3rem) scale(0.94, 1.08); }
}
