/* ============ Magic question: a wooden sign with a paper face ============ */
.quiz-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 45%, rgba(20, 60, 100, .2), rgba(10, 30, 60, .55));
  animation: fade-in .3s ease;
}

/* ☰ stays reachable above the question (it is positioned in game.css) */
.pause-btn { z-index: 30; }

.scroll {
  position: relative;
  width: min(560px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-radius: var(--radius-big);
  background:
    repeating-linear-gradient(176deg, rgba(0, 0, 0, .07) 0 2px, transparent 2px 15px),
    linear-gradient(180deg, var(--wood-hi), var(--wood) 55%, var(--wood-lo));
  border: 5px solid var(--wood-edge);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .3), inset 0 -6px 0 rgba(0, 0, 0, .2), 0 10px 0 #3a1e0a, 0 22px 40px rgba(0, 0, 0, .45);
}

/* Turned to face the player's edge of the screen (a tablet lying flat between several players).
   `rotate` stacks with the swing-in animation, which uses `transform`. Sideways, the sign is laid
   out in the screen's height and fits in its width. */
.quiz-layer[data-side="top"] .scroll { rotate: 180deg; }
.quiz-layer[data-side="left"] .scroll { rotate: 90deg; }
.quiz-layer[data-side="right"] .scroll { rotate: -90deg; }

.quiz-layer[data-side="left"] .scroll,
.quiz-layer[data-side="right"] .scroll {
  width: min(560px, calc(100vh - 32px));
  width: min(560px, calc(100dvh - 32px));
  max-height: calc(100vw - 32px);
  flex: none;
}

/* Turning it with ↻ is animated (opening a question never is: the layer is hidden then) */
.scroll { transition: rotate .4s var(--ease-bounce); }

/* ↻ on the sign's top-left corner, so it turns along with the sign */
.quiz-rotate {
  position: absolute;
  top: -20px;
  left: -20px;
  z-index: 2;
  width: 48px;
  height: 48px;
  border-width: 3px;
}

.quiz-rotate svg { width: 62%; height: 62%; fill: #fff; }

/* Corner nails */
.scroll::before,
.scroll::after {
  content: '';
  position: absolute;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f1e2c8, #8a7556);
}

.scroll::before { left: 6px; }
.scroll::after { right: 6px; }

.scroll-paper {
  position: relative;
  overflow-y: auto;
  padding: .9rem clamp(.9rem, 4vw, 1.6rem) 1rem;
  border: 3px solid #c9a46f;
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, .8), transparent 60%),
    linear-gradient(180deg, #fffaf0, #fbefd6);
  color: var(--ink);
  text-align: center;
  box-shadow: inset 0 2px 6px rgba(120, 80, 30, .25);
}

.scroll.unroll { animation: sign-swing .6s var(--ease-bounce); }

@keyframes sign-swing {
  0% { opacity: 0; transform: translateY(-80px) rotate(-8deg) scale(.85); }
  55% { opacity: 1; transform: translateY(8px) rotate(3deg); }
  80% { transform: translateY(-3px) rotate(-1deg); }
  100% { transform: none; }
}

.scroll.roll-up { animation: roll-up .38s ease-in forwards; }

@keyframes roll-up {
  to { opacity: 0; transform: translateY(-40px) scale(.85); }
}

.scroll.wobble { animation: wobble-sign .6s ease; }

@keyframes wobble-sign {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(-3deg) translateX(-6px); }
  30% { transform: rotate(2.5deg) translateX(5px); }
  45% { transform: rotate(-2deg) translateX(-4px); }
  60% { transform: rotate(1.5deg) translateX(3px); }
  75% { transform: rotate(-.5deg); }
}

.quiz-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 64px;
  text-align: left;
}

.quiz-avatar {
  flex: none;
  display: grid;
  place-items: end center;
  width: 54px;
  height: 58px;
  padding-bottom: 2px;
  border: 3px solid var(--pc, var(--wood-edge));
  border-radius: 14px;
  background: #fff;
}

.quiz-avatar .pawn-svg { width: 34px; }

.quiz-title {
  flex: 1;
  font-size: clamp(1.05rem, 3.6vw, 1.3rem);
  font-weight: 700;
  line-height: 1.2;
  color: #6b3a17;
}

/* Timer ring */
.timer-ring {
  --ring: #1f86ea;
  position: relative;
  flex: none;
  width: 66px;
  height: 66px;
  filter: drop-shadow(0 0 6px var(--ring));
}

.timer-ring[data-stage="orange"] { --ring: #f58a14; }
.timer-ring[data-stage="red"] { --ring: #e8382d; }
.timer-ring.ticking { animation: ring-tick 1s ease-in-out infinite; }

@keyframes ring-tick {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.12); }
}

.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: #fff;
  stroke: rgba(107, 58, 23, .15);
  stroke-width: 7;
}

.ring-fill {
  fill: none;
  stroke: var(--ring);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke .3s ease, stroke-dashoffset .1s linear;
}

.ring-seconds {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ring);
}

/* Question */
.quiz-visual {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .4rem .8rem;
  margin: .8rem 0 .2rem;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  line-height: 1.25;
}

.emoji-group {
  padding: .1em .3em;
  border-radius: .6em;
  background: rgba(31, 134, 234, .1);
  letter-spacing: .08em;
  word-break: break-all;
}

.emoji-plus {
  font-weight: 700;
  color: #6b3a17;
}

.quiz-question {
  margin: .6rem 0 1rem;
  font-family: var(--font-body);
  font-size: clamp(2.1rem, 9vw, 3.1rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .02em;
  color: var(--ink);
}

.quiz-answers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(.5rem, 2.5vw, 1rem);
}

.answer-btn {
  min-height: 74px;
  padding: .2em .2em;
  font-family: var(--font-body);
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  font-weight: 900;
}

/* Locked answers keep their colors (not the grey disabled look) */
.answer-btn:disabled { filter: none; opacity: 1; cursor: default; }
.answer-btn:disabled:not(.right):not(.reveal):not(.wrong) { opacity: .55; }

.answer-btn.right,
.answer-btn.reveal {
  --c1: #7be36a;
  --c2: #2fbf2f;
  --c3: #13801b;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .16), 0 6px 0 var(--c3), 0 0 0 4px #fff, 0 0 26px 8px rgba(255, 224, 102, .9);
  animation: tap-bounce .5s var(--ease-bounce);
}

.answer-btn.wrong {
  --c1: #d5d9df;
  --c2: #9aa1ab;
  --c3: #646b75;
  animation: wiggle .5s ease;
}

.quiz-feedback {
  min-height: 1.6em;
  margin: .9rem 0 0;
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  font-weight: 700;
  color: var(--ink-soft);
}

.quiz-feedback.good { color: #13801b; animation: pop-in .4s var(--ease-bounce); }
.quiz-feedback.oops { color: #c2255c; animation: pop-in .4s var(--ease-bounce); }

/* Sparkle burst */
.spark {
  position: absolute;
  z-index: 5;
  font-size: 1.3rem;
  color: #f7c21b;
  text-shadow: 0 0 6px #fff, 0 0 12px #ffe066;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: spark .85s ease-out forwards;
}

@keyframes spark {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(.4); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(120deg); }
}

.stat-stars { display: inline-block; }
.stat-stars.bump { animation: tap-bounce .5s var(--ease-bounce); }

@media (max-height: 560px) {
  .quiz-head { min-height: 0; }
  .quiz-question { margin: .3rem 0 .6rem; font-size: 1.8rem; }
  .answer-btn { min-height: 54px; }
}
