/* Quiet Library Quest — animated cozy library (kids 3–8, almost no reading) */
@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&display=swap");

body.theme-quiet-library {
  --g-accent: #f59e0b;
  --g-accent-2: #fbbf24;
  --ql-wood: #8b5a2b;
  --ql-wood-dark: #5c3a1a;
  --ql-cream: #fff7ed;
  --ql-lamp: #fde68a;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(251, 191, 36, 0.35), transparent 55%),
    radial-gradient(ellipse 40% 35% at 10% 80%, rgba(180, 83, 9, 0.25), transparent 50%),
    linear-gradient(165deg, #2a1810 0%, #3d2314 40%, #1c120c 100%);
  font-family: "Fredoka", "Noto Sans Bengali", system-ui, sans-serif;
}
body.theme-quiet-library::before {
  background: rgba(251, 191, 36, 0.35);
}
body.theme-quiet-library::after {
  background: rgba(245, 158, 11, 0.25);
}

body.theme-quiet-library .game-top {
  background: linear-gradient(180deg, rgba(91, 58, 26, 0.92), rgba(61, 35, 20, 0.88));
  border: 2px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
body.theme-quiet-library .game-top h1 {
  color: #fde68a;
  font-size: clamp(1rem, 4.2vw, 1.25rem);
}
body.theme-quiet-library .g-chip {
  background: rgba(61, 35, 20, 0.75);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
body.theme-quiet-library .hint {
  color: #fde68a;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  margin: 0.35rem 0 0.5rem;
}

.ql-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 3 / 4.2;
  border-radius: 20px;
  overflow: hidden;
  border: 4px solid rgba(251, 191, 36, 0.45);
  box-shadow:
    0 0 0 3px rgba(91, 58, 26, 0.6),
    0 20px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 60px rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #4a3220 0%, #2d1c12 100%);
  touch-action: manipulation;
  user-select: none;
}

.ql-ceiling {
  position: absolute;
  inset: 0 0 auto 0;
  height: 14%;
  background: linear-gradient(180deg, #1a100a, #3d2818);
  z-index: 2;
}
.ql-lamp {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 28px;
  z-index: 3;
}
.ql-lamp::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -18px;
  width: 4px;
  height: 18px;
  background: #5c3a1a;
  transform: translateX(-50%);
}
.ql-lamp::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 0 40px 16px rgba(251, 191, 36, 0.45);
  animation: qlLampPulse 2.8s ease-in-out infinite;
}
@keyframes qlLampPulse {
  0%, 100% { box-shadow: 0 0 28px 12px rgba(251, 191, 36, 0.35); }
  50% { box-shadow: 0 0 48px 20px rgba(251, 191, 36, 0.55); }
}

.ql-dust {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.ql-dust i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 247, 237, 0.55);
  animation: qlDust float 9s linear infinite;
}
@keyframes qlDust {
  from { transform: translateY(110%) scale(0.6); opacity: 0; }
  10% { opacity: 0.7; }
  to { transform: translateY(-20%) scale(1); opacity: 0; }
}

.ql-shelves {
  position: absolute;
  inset: 16% 6% 22% 6%;
  display: flex;
  flex-direction: column;
  gap: 4%;
  z-index: 4;
}
.ql-shelf {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 0 4px 0;
}
.ql-shelf::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 0;
  height: 10px;
  background: linear-gradient(180deg, #a67c52, #5c3a1a);
  border-radius: 3px;
  box-shadow: 0 4px 0 #3d2314, 0 6px 10px rgba(0, 0, 0, 0.35);
  z-index: 0;
}

.ql-book {
  position: relative;
  z-index: 1;
  width: clamp(22px, 7.5vw, 34px);
  height: clamp(52px, 16vw, 78px);
  border-radius: 3px 3px 2px 2px;
  border: 1.5px solid rgba(0, 0, 0, 0.25);
  box-shadow:
    inset -4px 0 0 rgba(0, 0, 0, 0.15),
    inset 2px 0 0 rgba(255, 255, 255, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.9);
  -webkit-tap-highlight-color: transparent;
}
.ql-book:active { transform: scale(0.92) translateY(2px); }
.ql-book .ql-spine {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.55rem;
  font-weight: 700;
  opacity: 0.85;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.ql-book.is-target {
  animation: qlGlow 1.1s ease-in-out infinite;
  z-index: 5;
  filter: brightness(1.15);
}
.ql-book.is-target::before {
  content: "✨";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  animation: qlStarBounce 0.9s ease-in-out infinite;
  filter: drop-shadow(0 0 6px #fbbf24);
  pointer-events: none;
}
@keyframes qlGlow {
  0%, 100% {
    box-shadow:
      inset -4px 0 0 rgba(0, 0, 0, 0.15),
      0 0 0 3px rgba(251, 191, 36, 0.85),
      0 0 22px 6px rgba(251, 191, 36, 0.55);
    transform: translateY(-4px) scale(1.06);
  }
  50% {
    box-shadow:
      inset -4px 0 0 rgba(0, 0, 0, 0.15),
      0 0 0 4px rgba(253, 224, 71, 1),
      0 0 32px 10px rgba(251, 191, 36, 0.75);
    transform: translateY(-8px) scale(1.1);
  }
}
@keyframes qlStarBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

.ql-book.is-noisy {
  animation: qlShake 0.35s ease-in-out infinite;
  filter: saturate(1.2) brightness(0.95);
}
.ql-book.is-noisy::after {
  content: "💥";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  opacity: 0.9;
  pointer-events: none;
}
@keyframes qlShake {
  0%, 100% { transform: rotate(-3deg) translateX(-1px); }
  50% { transform: rotate(3deg) translateX(1px); }
}

.ql-book.fly-out {
  animation: qlFlyBag 0.65s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
  pointer-events: none;
  z-index: 20;
}
@keyframes qlFlyBag {
  0% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
  40% { transform: translateY(-40%) scale(1.35) rotate(-8deg); opacity: 1; }
  100% { transform: translate(40px, 120%) scale(0.3) rotate(25deg); opacity: 0; }
}
.ql-book.pop-bad {
  animation: qlBad 0.45s ease;
}
@keyframes qlBad {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.15) rotate(-8deg); filter: hue-rotate(-20deg); }
  60% { transform: scale(0.9) rotate(8deg); }
}

.ql-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 20%;
  background:
    repeating-linear-gradient(90deg, #6b4423 0 28px, #5c3a1a 28px 56px);
  z-index: 5;
  border-top: 3px solid #8b5a2b;
}
.ql-rug {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 8%;
  height: 28%;
  background: radial-gradient(ellipse, #b45309 0%, #92400e 55%, #78350f 100%);
  border-radius: 50%;
  opacity: 0.85;
  box-shadow: inset 0 0 0 4px rgba(253, 230, 138, 0.25);
  z-index: 6;
}

.ql-hero {
  position: absolute;
  bottom: 11%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35));
  transition: left 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
  animation: qlTipToe 1.4s ease-in-out infinite;
  pointer-events: none;
}
.ql-hero.happy { animation: qlJump 0.55s ease; }
.ql-hero.oops { animation: qlOops 0.5s ease; }
@keyframes qlTipToe {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}
@keyframes qlJump {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  40% { transform: translateX(-50%) translateY(-18px) scale(1.08); }
}
@keyframes qlOops {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  25% { transform: translateX(-50%) rotate(-12deg); }
  75% { transform: translateX(-50%) rotate(12deg); }
}

.ql-bag {
  position: absolute;
  right: 8%;
  bottom: 10%;
  z-index: 9;
  width: 52px;
  height: 48px;
  background: linear-gradient(180deg, #92400e, #78350f);
  border-radius: 6px 6px 10px 10px;
  border: 2px solid #fbbf24;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 4px 3px 3px;
  pointer-events: none;
}
.ql-bag::before {
  content: "👜";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
}
.ql-bag .mini {
  width: 8px;
  height: 14px;
  border-radius: 1px;
  animation: qlMiniIn 0.35s ease;
}
@keyframes qlMiniIn {
  from { transform: scale(0) translateY(-20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.ql-quiet-meter {
  position: absolute;
  top: 16%;
  right: 3%;
  z-index: 12;
  width: 14px;
  height: 28%;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  border: 2px solid rgba(251, 191, 36, 0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
}
.ql-quiet-meter i {
  display: block;
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, #f87171, #34d399);
  background: #34d399;
  transition: height 0.35s ease, background 0.35s ease;
}
.ql-quiet-meter.warn i { background: #fbbf24; }
.ql-quiet-meter.loud i { background: #f87171; }

.ql-shush {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) scale(0);
  z-index: 30;
  font-size: 3.5rem;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}
.ql-shush.show {
  animation: qlShush 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes qlShush {
  0% { transform: translateX(-50%) scale(0); opacity: 0; }
  30% { transform: translateX(-50%) scale(1.25); opacity: 1; }
  70% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.6); opacity: 0; }
}

.ql-spark {
  position: absolute;
  z-index: 25;
  font-size: 1.6rem;
  pointer-events: none;
  animation: qlSpark 0.7s ease forwards;
}
@keyframes qlSpark {
  from { transform: scale(0.4) translateY(0); opacity: 1; }
  to { transform: scale(1.4) translateY(-40px); opacity: 0; }
}

.ql-cue {
  position: absolute;
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(61, 35, 20, 0.88);
  border: 2px solid rgba(251, 191, 36, 0.55);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fef3c7;
  white-space: nowrap;
  pointer-events: none;
}
.ql-cue .glow-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #f59e0b;
  box-shadow: 0 0 10px #fbbf24;
  animation: qlGlow 1.1s ease-in-out infinite;
}

.ql-win-books {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 0.5rem 0 0.75rem;
  font-size: 1.6rem;
  animation: qlWinBounce 0.8s ease;
}
@keyframes qlWinBounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 380px) {
  .ql-wrap { aspect-ratio: 3 / 4.4; }
  .ql-book { width: 20px; }
}
