/* Guess the Prophet! Pumpkin Party theme, built for a 16:9 TV with no scrolling. */

@font-face {
  font-family: 'Fredoka';
  src: url('fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --plum: #24092e;
  --plum-2: #3b1048;
  --grape: #5a1f6e;
  --grape-light: #7a3192;
  --pumpkin: #ff9a2e;
  --lime: #c6f36b;
  --lime-dark: #8fbf2e;
  --ink: #2a0833;
  --white: #ffffff;

  --pad: 3vh;
  --gap: 1.4vh;
  /* One card height. Fits 5 rows plus the header in the screen height,
     and shrinks if the screen is narrower than usual. */
  --u: min(calc((100vh - 2 * var(--pad) - 5 * var(--gap)) / 5.65),
           calc((100vw - 3 * var(--pad) - 5 * var(--gap) - 260px) / 7));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--plum);
  color: var(--white);
  font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', system-ui, sans-serif;
}

body {
  background:
    radial-gradient(2px 2px at 8% 18%, #fff9, transparent),
    radial-gradient(1.5px 1.5px at 22% 70%, #fff8, transparent),
    radial-gradient(2px 2px at 35% 10%, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 62% 6%, #fffa, transparent),
    radial-gradient(2px 2px at 92% 12%, #fff8, transparent),
    radial-gradient(1.5px 1.5px at 96% 88%, #fff7, transparent),
    radial-gradient(2px 2px at 14% 92%, #fff6, transparent),
    linear-gradient(160deg, var(--plum-2) 0%, var(--plum) 100%);
}

button { font-family: inherit; }

/* ---------- Main layout ---------- */

.app {
  height: 100vh;
  width: 100vw;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: var(--pad);
  padding: var(--pad);
}

.side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  gap: 2vh;
}

.brand { text-align: center; }
.brand-deco { font-size: 3.2vh; letter-spacing: 1vh; }
.brand h1 {
  margin: 1vh 0 0;
  font-weight: 700;
  font-size: clamp(28px, 7.6vh, 12vw);
  line-height: 0.95;
  color: var(--pumpkin);
  text-shadow: 0.5vh 0.5vh 0 #1a0520;
}
.subtitle { margin: 1.5vh 0 0; font-size: 3.4vh; color: var(--lime); font-weight: 600; }

.progress {
  text-align: center;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2.5vh;
  padding: 1.4vh 2vh;
}
.progress-num { font-size: 6vh; font-weight: 700; line-height: 1; color: var(--lime); }
.progress-num small { font-size: 4vh; color: var(--white); opacity: 0.8; }
.progress-label { font-size: 2.6vh; opacity: 0.85; }
.progress-bar { height: 1.6vh; border-radius: 1vh; background: rgba(255, 255, 255, 0.12); margin: 1vh 0; overflow: hidden; }
.progress-bar div { height: 100%; width: 0; background: var(--lime); border-radius: 1vh; transition: width 0.5s; }
.group-label { font-size: 2.6vh; color: var(--pumpkin); font-weight: 600; }

.side-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1vh; }
.side-buttons .btn-big { grid-column: 1 / -1; }
.side-buttons .btn { padding-left: 1vh; padding-right: 1vh; }
#modeBtn small { display: block; font-size: 0.7em; font-weight: 400; opacity: 0.8; }

/* ---------- Buttons ---------- */

.btn {
  border: 0.4vh solid transparent;
  border-radius: 999px;
  padding: 1.6vh 3vh;
  font-size: 3vh;
  font-weight: 700;
  cursor: pointer;
  color: var(--white);
  background: transparent;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-2px); }
.btn:focus { outline: none; }
.btn:focus-visible, .btn.is-focus {
  outline: 0.6vh solid var(--lime);
  outline-offset: 0.5vh;
  box-shadow: 0 0 3vh var(--lime);
}
.btn-big { font-size: 3.8vh; padding: 1.7vh 3vh; }
.btn-small { font-size: 2.4vh; padding: 1.1vh 2.4vh; }
.btn-lime { background: var(--lime); color: var(--ink); }
.btn-pumpkin { background: var(--pumpkin); color: var(--ink); }
.btn-ghost { border-color: rgba(255, 255, 255, 0.85); }
.btn[disabled] { opacity: 0.35; cursor: default; transform: none; }

/* ---------- Board ---------- */

.board-wrap { display: flex; align-items: center; justify-content: center; }

.board {
  display: grid;
  grid-template-columns: calc(var(--u) * 0.5) repeat(5, calc(var(--u) * 1.3));
  grid-template-rows: calc(var(--u) * 0.65) repeat(5, var(--u));
  gap: var(--gap);
}

.colhead {
  background: var(--pumpkin);
  color: var(--ink);
  border-radius: 1.6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(var(--u) * 0.13);
  line-height: 1.1;
  text-align: center;
  padding: 0 0.5vh;
}
.colhead b { font-size: calc(var(--u) * 0.24); line-height: 1.1; }

.rowhead {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lime);
  font-size: calc(var(--u) * 0.12);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.3vh;
}

.card {
  position: relative;
  border: 0.45vh solid var(--pumpkin);
  border-radius: 48% 48% 1.4vh 1.4vh / 40% 40% 1.4vh 1.4vh;
  background: linear-gradient(180deg, var(--grape-light), var(--grape));
  color: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card .num { font-size: calc(var(--u) * 0.36); font-weight: 700; line-height: 1; }
.card .stars { font-size: calc(var(--u) * 0.11); opacity: 0.9; margin-top: 0.4vh; }
.card .knob {
  position: absolute;
  right: 13%;
  top: 56%;
  width: calc(var(--u) * 0.07);
  height: calc(var(--u) * 0.07);
  border-radius: 50%;
  background: var(--lime);
}
.card:hover { transform: translateY(-3px); }
.card:focus { outline: none; }
.card:focus-visible, .card.is-focus {
  outline: 0.7vh solid var(--lime);
  outline-offset: 0.4vh;
  box-shadow: 0 0 4vh var(--lime);
  transform: scale(1.04);
  z-index: 1;
}

.card.done {
  background: var(--lime);
  border-color: var(--lime-dark);
  color: var(--ink);
}
.card.done .check { font-size: calc(var(--u) * 0.26); line-height: 1; }
.card.done .name {
  font-size: calc(var(--u) * 0.15);
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  padding: 0 0.8vh;
}

/* ---------- Question screen ---------- */

.question {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  gap: 2vh;
  padding: var(--pad) 5vw;
  background: inherit;
  background: linear-gradient(160deg, var(--plum-2) 0%, var(--plum) 100%);
  overflow-y: auto; /* short screens scroll instead of overlapping the choices */
  z-index: 10;
}
.question[hidden] { display: none; }

.q-top { display: flex; align-items: center; justify-content: space-between; gap: 2vw; }
.chip {
  background: var(--pumpkin);
  color: var(--ink);
  font-weight: 700;
  font-size: 3.6vh;
  padding: 1vh 3vh;
  border-radius: 999px;
}
.q-stars { font-size: 4vh; color: var(--lime); letter-spacing: 0.5vh; }
.q-center { display: flex; align-items: center; gap: 2vw; }
.q-count {
  font-size: 4.6vh;
  font-weight: 700;
  min-width: 13vh;
  text-align: center;
  padding: 0.4vh 1.6vh;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.q-count:empty { display: none; }
.q-count.warn { color: var(--pumpkin); }
.q-count.over { color: #ff6b6b; animation: blink 0.8s ease-in-out infinite; }
.q-right { display: flex; align-items: center; gap: 2vw; }
.q-door { font-size: 3.2vh; opacity: 0.85; }
.q-timer { font-size: 3.6vh; font-weight: 700; color: var(--lime); }
.q-timer.warn { color: var(--pumpkin); }
.q-timer.over { color: #ff6b6b; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

.q-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3vh;
}

.prompt { font-size: 4.4vh; color: var(--lime); font-weight: 600; margin: 0; }

.emoji-big { font-size: 20vh; line-height: 1.15; letter-spacing: 2vh; }

.hint-box {
  font-size: 4.4vh;
  background: rgba(255, 255, 255, 0.1);
  border: 0.4vh dashed var(--pumpkin);
  border-radius: 2vh;
  padding: 1.5vh 4vh;
  max-width: 80vw;
}

/* Picture reveal */
.reveal {
  position: relative;
  height: 52vh;
  aspect-ratio: 4 / 3;
  border-radius: 2.5vh;
  overflow: hidden;
  border: 0.6vh solid var(--pumpkin);
  background: #fff6e6;
}
.reveal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reveal .scene {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13vh;
  letter-spacing: 1vh;
  background: linear-gradient(180deg, #ffe2b8, #fff6e6);
}
.tiles {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
}
.tile {
  background: var(--grape);
  border: 0.3vh solid var(--plum);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7vh;
  transition: opacity 0.45s, transform 0.45s;
}
.tile.gone { opacity: 0; transform: scale(0.6) rotate(12deg); }

/* Who Am I */
.clues { display: flex; flex-direction: column; gap: 2.2vh; width: min(85vw, 150vh); }
.clue {
  display: flex;
  align-items: center;
  gap: 3vh;
  text-align: left;
  font-size: 4.6vh;
  line-height: 1.25;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2vh;
  padding: 2vh 3vh;
  animation: pop 0.35s ease-out;
}
.clue .n {
  flex: none;
  width: 7vh;
  height: 7vh;
  border-radius: 50%;
  background: var(--pumpkin);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 4vh;
}
.clue.locked { opacity: 0.35; animation: none; }

/* Riddle */
.riddle {
  font-size: 5.6vh;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3vh;
  padding: 3vh 6vh;
}
.riddle p { margin: 0; }

/* Who Said It */
.scroll {
  background: #fff1d6;
  color: var(--ink);
  border-radius: 2vh;
  padding: 4vh 6vh;
  max-width: 85vw;
  box-shadow: 0 0 0 0.6vh var(--pumpkin);
}
.scroll .quote { font-size: 6vh; font-weight: 700; line-height: 1.25; margin: 0; }
.context { font-size: 4vh; max-width: 80vw; margin: 0; opacity: 0.95; }

/* Answer panel */
.q-answer { text-align: center; animation: pop 0.4s ease-out; }
.q-answer[hidden] { display: none; }
.q-answer-label { font-size: 4vh; color: var(--lime); font-weight: 600; }
.q-answer-name { font-size: 11vh; font-weight: 700; color: var(--pumpkin); line-height: 1.05; text-shadow: 0.6vh 0.6vh 0 #1a0520; }
.q-answer-ref { font-size: 3.2vh; opacity: 0.85; margin-top: 0.5vh; }

.question.answered .q-body { transform: scale(0.8); transform-origin: center bottom; transition: transform 0.3s; }

.q-buttons { display: flex; flex-wrap: wrap; gap: 2vw; justify-content: center; }
.q-buttons .btn { font-size: 3.6vh; padding: 1.8vh 4vh; }

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

/* ---------- Door animation ---------- */

.door-anim {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  perspective: 160vh;
  pointer-events: none;
}
.door-anim[hidden] { display: none; }
.door-half {
  position: relative;
  width: 50%;
  height: 100%;
  background: linear-gradient(180deg, var(--grape-light), var(--grape));
  border: 1vh solid var(--pumpkin);
}
.door-half .knob { position: absolute; top: 50%; width: 3vh; height: 3vh; border-radius: 50%; background: var(--lime); }
.door-half.left { transform-origin: left center; border-radius: 0 0 0 0; }
.door-half.left .knob { right: 4vh; }
.door-half.right { transform-origin: right center; }
.door-half.right .knob { left: 4vh; }
.door-anim.opening .left { animation: openLeft 0.8s ease-in forwards; }
.door-anim.opening .right { animation: openRight 0.8s ease-in forwards; }
@keyframes openLeft { to { transform: rotateY(-100deg); opacity: 0.2; } }
@keyframes openRight { to { transform: rotateY(100deg); opacity: 0.2; } }

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(20, 4, 26, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--grape);
  border: 0.6vh solid var(--pumpkin);
  border-radius: 4vh;
  padding: 5vh 7vh;
  text-align: center;
  max-width: 80vw;
  animation: pop 0.3s ease-out;
}
.modal-emoji { font-size: 12vh; line-height: 1.1; }
.modal-card h2 { font-size: 7vh; margin: 1vh 0; color: var(--lime); }
.modal-card p { font-size: 3.6vh; margin: 0 0 4vh; }
.modal-buttons { display: flex; gap: 2vw; justify-content: center; flex-wrap: wrap; }
.modal-buttons .btn { font-size: 3.6vh; }

/* ---------- Confetti ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti span {
  position: absolute;
  top: -10vh;
  font-size: 5vh;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(120vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 5-second auto-reveal countdown */
.auto-bar { width: min(60vw, 90vh); height: 1.4vh; border-radius: 1vh; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.auto-bar div { height: 100%; width: 100%; background: var(--lime); transform-origin: left; animation: countdown linear forwards; }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Group timer */
.timer {
  display: block;
  width: 100%;
  margin-top: 1.2vh;
  border: 0;
  border-radius: 1.6vh;
  padding: 0.8vh 1vh;
  background: rgba(0, 0, 0, 0.25);
  color: var(--white);
  cursor: pointer;
}
.timer-time { display: block; font-size: 5vh; font-weight: 700; line-height: 1.1; }
.timer-note { display: block; font-size: 1.9vh; opacity: 0.75; }
.timer.warn .timer-time { color: var(--pumpkin); }
.timer.over .timer-time { color: #ff6b6b; }
.last-group { font-size: 2.2vh; opacity: 0.8; margin-top: 0.8vh; min-height: 2.6vh; }
.timer.over { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { background: rgba(255, 107, 107, 0.3); } }

/* Multiple choice */
.q-choices { display: flex; gap: 2.5vw; justify-content: center; animation: pop 0.35s ease-out; }
.q-choices[hidden] { display: none; }
.btn.choice {
  min-width: 22vw;
  font-size: 5vh;
  padding: 1.8vh 4vh;
  border-radius: 2.5vh;
  background: var(--white);
  color: var(--ink);
  border-color: var(--pumpkin);
}
.btn.choice.wrong { background: rgba(255, 255, 255, 0.15); color: rgba(255, 255, 255, 0.5); text-decoration: line-through; animation: shake 0.4s; }
.btn.choice.right { background: var(--lime); }
@keyframes shake { 25% { transform: translateX(-1vh); } 75% { transform: translateX(1vh); } }

/* Make room for the choices row */
.question.has-choices .emoji-big { font-size: 15vh; }
.question.has-choices .reveal { height: 40vh; }
.question.has-choices .riddle { font-size: 4.4vh; padding: 2vh 5vh; }
.question.has-choices .clue { font-size: 3.8vh; padding: 1.4vh 3vh; }
.question.has-choices .scroll .quote { font-size: 4.8vh; }
.question.has-choices .scroll { padding: 3vh 5vh; }
.question.has-choices .context { font-size: 3.4vh; }
.question.has-choices .prompt { font-size: 3.6vh; }
.question.has-choices .q-body { gap: 2vh; }

/* ---------- Phones and tablets held upright ----------
   TVs are always landscape, so none of this changes the TV layout. */

@media (orientation: portrait) {
  html, body { overflow-x: hidden; overflow-y: auto; height: auto; }

  .app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: 100vh;
    padding: 16px;
    gap: 14px;
    --gap: 6px;
    /* Five card columns across the screen width */
    --u: calc((100vw - 32px - 4 * var(--gap)) / 6.5);
  }
  .side { display: contents; }
  .brand { order: 1; }
  .board-wrap { order: 2; }
  .progress { order: 3; }
  .side-buttons { order: 4; }

  .brand-deco { display: none; }
  .brand h1 { margin: 0; font-size: 10vw; line-height: 1; }
  .subtitle { margin-top: 4px; font-size: 4.6vw; }

  .board { grid-template-columns: repeat(5, calc(var(--u) * 1.3)); grid-template-rows: auto repeat(5, var(--u)); }
  .board > div:first-child, .rowhead { display: none; }
  .colhead { font-size: 2.5vw; padding: 1.2vw 0.5vw; border-radius: 2vw; }
  .colhead b { font-size: 5.5vw; }
  .card { border-width: 2px; }
  .card .stars { font-size: 2.2vw; }
  .card.done .name { font-size: 2.7vw; padding: 0 1vw; }
  .card:focus-visible, .card.is-focus { outline-width: 3px; }

  .progress { padding: 12px 16px; border-radius: 16px; }
  .progress-num { font-size: 9vw; }
  .progress-num small { font-size: 5vw; }
  .progress-label, .group-label { font-size: 3.8vw; }
  .progress-bar { height: 8px; margin: 8px 0; }
  .timer { margin-top: 8px; padding: 8px; border-radius: 12px; }
  .timer-time { font-size: 8vw; }
  .timer-note { font-size: 3.2vw; }
  .last-group { font-size: 3.4vw; margin-top: 6px; min-height: 0; }

  .side-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .side-buttons .btn { font-size: 4vw; padding: 12px 8px; border-width: 2px; }
  .side-buttons .btn-big { grid-column: 1 / -1; font-size: 5.5vw; padding: 14px; }

  /* Question screen */
  .question { padding: 16px; gap: 12px; overflow-y: auto; grid-template-rows: auto auto auto auto auto; align-content: start; }
  .q-top { flex-wrap: wrap; gap: 8px; }
  .chip { font-size: 4.2vw; padding: 6px 14px; }
  .q-stars { font-size: 4.6vw; letter-spacing: 2px; }
  .q-center { gap: 8px; }
  .q-count { font-size: 5vw; min-width: 16vw; padding: 2px 10px; }
  .q-right { gap: 10px; }
  .q-door { font-size: 3.6vw; }
  .q-timer { font-size: 4vw; }
  .q-body, .question.has-choices .q-body { gap: 14px; padding-top: 8px; }
  .prompt, .question.has-choices .prompt { font-size: 5.4vw; }
  .emoji-big, .question.has-choices .emoji-big { font-size: 15vw; letter-spacing: 2vw; }
  .hint-box { font-size: 4.4vw; padding: 10px 16px; border-width: 2px; max-width: 100%; }
  .reveal, .question.has-choices .reveal { height: auto; width: 100%; border-width: 3px; }
  .reveal .scene { font-size: 14vw; }
  .tile { font-size: 7vw; border-width: 1px; }
  .clues { width: 100%; gap: 10px; }
  .clue, .question.has-choices .clue { font-size: 4.2vw; padding: 10px 12px; gap: 10px; }
  .clue .n { width: 8vw; height: 8vw; font-size: 4.4vw; }
  .riddle, .question.has-choices .riddle { font-size: 4.8vw; padding: 14px 18px; }
  .scroll, .question.has-choices .scroll { padding: 16px 18px; max-width: 100%; box-shadow: 0 0 0 3px var(--pumpkin); }
  .scroll .quote, .question.has-choices .scroll .quote { font-size: 5.4vw; }
  .context, .question.has-choices .context { font-size: 4.2vw; max-width: 100%; }
  .auto-bar { width: 80%; height: 8px; }
  .question.answered .q-body { transform: none; }

  .q-choices { flex-direction: column; gap: 10px; }
  .btn.choice { min-width: 0; width: 100%; font-size: 5.4vw; padding: 12px; border-radius: 14px; }

  .q-answer-label { font-size: 5vw; }
  .q-answer-name { font-size: 12vw; }
  .q-answer-ref { font-size: 4vw; }

  .q-buttons { gap: 10px; }
  .q-buttons .btn { font-size: 4.2vw; padding: 12px 16px; border-width: 2px; flex: 1 1 40%; }

  .modal-card { padding: 24px 20px; max-width: 92vw; border-radius: 20px; }
  .modal-emoji { font-size: 14vw; }
  .modal-card h2 { font-size: 7.5vw; }
  .modal-card p { font-size: 4.4vw; margin-bottom: 20px; }
  .modal-buttons { flex-direction: column; gap: 10px; }
  .modal-buttons .btn { font-size: 4.6vw; }

  .confetti span { font-size: 7vw; }
}
