/* ============================================================
   Leo Tháp Kiến Thức — theme mỹ thuật Việt Nam
   ============================================================ */

:root {
  --red: #b91c1c;
  --red-dark: #7c1d1d;
  --cream: #f5ead6;
  --cream-light: #fdf7ea;
  --gold: #d4a24e;
  --brown: #3b2416;
  --ink: #2b1a10;
}

* {
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1c100a;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--cream);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- texture & ornaments ---------- */
.paper-bg {
  background-color: var(--cream);
  background-image:
    radial-gradient(
      circle at 20% 10%,
      rgba(212, 162, 78, 0.14),
      transparent 45%
    ),
    radial-gradient(circle at 85% 90%, rgba(185, 28, 28, 0.1), transparent 40%);
}

.cloud-divider {
  height: 14px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--red) 0 10px,
    transparent 10px 16px
  );
  opacity: 0.25;
}

.frame-ornate {
  border: 3px solid var(--red);
  outline: 1.5px solid var(--gold);
  outline-offset: -7px;
  border-radius: 18px;
}

/* ---------- buttons ---------- */
.btn-primary {
  background: linear-gradient(180deg, #d63426, var(--red) 55%, var(--red-dark));
  color: #fff;
  border: 2px solid #f3c96b;
  border-radius: 999px;
  padding: 14px 32px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  box-shadow:
    0 5px 0 #5c1212,
    0 10px 18px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}
.btn-primary:active {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 #5c1212,
    0 4px 8px rgba(0, 0, 0, 0.3);
}
.btn-primary:disabled {
  filter: grayscale(0.7);
  opacity: 0.6;
}

.btn-ghost {
  background: var(--cream-light);
  border: 2px solid var(--red);
  color: var(--red-dark);
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 600;
  transition: transform 0.12s;
}
.btn-ghost:active {
  transform: scale(0.95);
}

/* ---------- hearts & HUD ---------- */
.hud-chip {
  background: rgba(253, 247, 234, 0.94);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--red-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.heart {
  font-size: 1rem;
  transition: transform 0.3s;
}
.heart.lost {
  filter: grayscale(1);
  opacity: 0.35;
  transform: scale(0.8);
}
.heart.pop {
  animation: heartPop 0.5s;
}
@keyframes heartPop {
  0% {
    transform: scale(0);
  }
  60% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- home / tower map ---------- */
.tower-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tower-stack {
  position: relative;
  display: flex;
  flex-direction: column;
}
.tower-strip {
  position: relative;
  line-height: 0;
}
.tower-strip img {
  width: 100%;
  display: block;
}
.tower-strip.current::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(243, 201, 107, 0.35),
    transparent 70%
  );
  animation: stripGlow 1.6s infinite;
  pointer-events: none;
}
@keyframes stripGlow {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}
.floor-marker {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(253, 247, 234, 0.95);
  border: 2.5px solid var(--red);
  border-radius: 999px;
  padding: 5px 12px 5px 7px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--red-dark);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  transition: transform 0.15s;
  z-index: 3;
  line-height: 1.25;
  text-align: left;
}
.floor-marker:active {
  transform: translate(-50%, -50%) scale(0.93);
}
.floor-marker .badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  background: var(--red);
  color: #fff;
}
.floor-marker.locked {
  filter: grayscale(1);
  opacity: 0.75;
  border-color: #78716c;
}
.floor-marker.locked .badge {
  background: #78716c;
}
.floor-marker.done {
  border-color: #15803d;
}
.floor-marker.done .badge {
  background: #15803d;
}
.floor-marker.current {
  animation: markerPulse 1.6s infinite;
  border-color: var(--gold);
}
@keyframes markerPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(212, 162, 78, 0.7);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(212, 162, 78, 0);
  }
}

/* ---------- quiz screen ---------- */
.quiz-bg {
  position: absolute;
  inset: 0;
  background-image: url("../assets/interior.png");
  background-size: cover;
  background-position: center;
}
.quiz-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(28, 16, 10, 0.55),
    rgba(28, 16, 10, 0.82)
  );
}

.timer-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f3c96b, var(--gold));
  transition: width 0.1s linear;
}
.timer-fill.danger {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
}

.card-paper {
  background: var(--cream-light);
  border: 2.5px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.option-btn {
  width: 100%;
  text-align: left;
  background: var(--cream-light);
  border: 2.5px solid #d8c49a;
  border-radius: 14px;
  padding: 13px 14px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  transition:
    transform 0.1s,
    background 0.2s,
    border-color 0.2s;
  box-shadow: 0 3px 0 rgba(59, 36, 22, 0.25);
}
.option-btn:active {
  transform: scale(0.97);
}
.option-btn .opt-key {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
}
.option-btn.correct {
  background: #dcfce7;
  border-color: #16a34a;
}
.option-btn.correct .opt-key {
  background: #16a34a;
}
.option-btn.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  animation: shake 0.4s;
}
.option-btn.wrong .opt-key {
  background: #dc2626;
}
.option-btn.dim {
  opacity: 0.45;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
}

/* ---------- letter tiles ---------- */
.tile {
  width: 46px;
  height: 52px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff8ea, var(--cream));
  border: 2px solid var(--gold);
  border-bottom-width: 4px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--red-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.12s,
    opacity 0.2s;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}
.tile:active {
  transform: scale(0.9);
}
.tile.used {
  opacity: 0.18;
  pointer-events: none;
  transform: scale(0.85);
}

.slot-box {
  width: 42px;
  height: 50px;
  border-radius: 10px;
  border: 2.5px dashed #b0926a;
  background: rgba(255, 255, 255, 0.4);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--red-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.slot-box.filled {
  border-style: solid;
  border-color: var(--red);
  background: #fff;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.18);
}
.slot-box.locked {
  border-style: solid;
  border-color: var(--gold);
  background: #fef3c7;
}
.slot-box.good {
  border-color: #16a34a;
  background: #dcfce7;
}
.slot-box.bad {
  border-color: #dc2626;
  background: #fee2e2;
  animation: shake 0.4s;
}

/* ---------- quick assemble ---------- */
.assemble-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1774 / 887;
  border-radius: 12px;
  border: 3px solid var(--gold);
  background-size: 100% 100%;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}
.assemble-hole {
  position: absolute;
  background: rgba(20, 12, 6, 0.72);
  border: 2.5px dashed var(--gold);
  border-radius: 8px;
  backdrop-filter: blur(1px);
  transition:
    background 0.2s,
    border-color 0.2s;
}
.assemble-hole.target {
  border-color: #fff;
  background: rgba(212, 162, 78, 0.35);
}
.assemble-hole.filled {
  border: 2.5px solid #16a34a;
  background-repeat: no-repeat;
}
.piece-tile {
  border-radius: 10px;
  border: 2.5px solid var(--gold);
  background-repeat: no-repeat;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.12s,
    opacity 0.2s,
    border-color 0.15s;
  aspect-ratio: 1;
}
.piece-tile:active {
  transform: scale(0.92);
}
.piece-tile.selected {
  border-color: #fff;
  transform: scale(1.07);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.5),
    0 6px 14px rgba(0, 0, 0, 0.4);
}
.piece-tile.used {
  opacity: 0.15;
  pointer-events: none;
}

/* ---------- matching ---------- */
.match-item {
  border: 2.5px solid #d8c49a;
  background: var(--cream-light);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  transition:
    transform 0.12s,
    border-color 0.2s,
    background 0.2s;
  position: relative;
  z-index: 2;
}
.match-item:active {
  transform: scale(0.96);
}
.match-item.selected {
  border-color: var(--red);
  background: #fef2f2;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.25);
}
.match-item.paired {
  border-color: var(--gold);
  background: #fef9e7;
}
.match-item.good {
  border-color: #16a34a;
  background: #dcfce7;
}
.match-item.bad {
  border-color: #dc2626;
  background: #fee2e2;
  animation: shake 0.4s;
}
#match-svg {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
#match-svg line {
  stroke: var(--red);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.8;
}

/* ---------- modal ---------- */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 10, 5, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 50;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  width: 100%;
  max-width: 360px;
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--cream-light);
  border: 3px solid var(--red);
  outline: 2px solid var(--gold);
  outline-offset: -8px;
  border-radius: 20px;
  padding: 22px;
  text-align: center;
  transform: translateY(24px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.show .modal-card {
  transform: translateY(0) scale(1);
}

/* ---------- wheel ---------- */
.wheel-disc {
  width: 270px;
  height: 270px;
  border-radius: 50%;
  border: 8px solid var(--red-dark);
  outline: 3px solid var(--gold);
  position: relative;
  margin: 0 auto;
  transition: transform 4s cubic-bezier(0.15, 0.9, 0.25, 1);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.45),
    inset 0 0 30px rgba(0, 0, 0, 0.2);
}
.wheel-label {
  position: absolute;
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
  width: 88px;
  line-height: 1.25;
}
.wheel-pointer {
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid var(--red);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  margin: 0 auto -6px;
  position: relative;
  z-index: 5;
}
.wheel-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--gold) 70%);
  border: 3px solid var(--red-dark);
  z-index: 4;
}

/* ---------- inventory ---------- */
.fab {
  position: absolute;
  right: 14px;
  bottom: 70px;
  z-index: 30;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(180deg, #d63426, var(--red) 55%, var(--red-dark));
  border: 2.5px solid #f3c96b;
  box-shadow:
    0 5px 0 #5c1212,
    0 10px 18px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}
.fab:active {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 #5c1212,
    0 4px 8px rgba(0, 0, 0, 0.3);
}
.fab-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f3c96b;
  color: var(--red-dark);
  border: 2px solid var(--red-dark);
  font-size: 0.72rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.inventory-card {
  background: var(--cream);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 86px;
  justify-content: center;
}
.inventory-card.locked {
  opacity: 0.6;
  border-style: dashed;
}

/* ---------- misc anim ---------- */
.fade-up {
  animation: fadeUp 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.mascot-bob {
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-9px) rotate(2deg);
  }
}
.confetti {
  position: absolute;
  top: -12px;
  font-size: 1.2rem;
  animation: confettiFall linear forwards;
  pointer-events: none;
  z-index: 60;
}
@keyframes confettiFall {
  to {
    transform: translateY(105dvh) rotate(720deg);
    opacity: 0.2;
  }
}

::-webkit-scrollbar {
  display: none;
}
