* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #1a1538 0%, #2d1f5c 60%, #3d2670 100%);
  color: #fff;
  position: relative;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(255,200,230,0.18) 0%, transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(180,200,255,0.15) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}
.screen {
  position: absolute; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 2;
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 420ms cubic-bezier(0.2, 0.85, 0.3, 1) 240ms,
    transform 420ms cubic-bezier(0.2, 0.85, 0.3, 1) 240ms;
}
/* Hidden / waiting offstage to the right (for incoming animation) */
.screen.hidden {
  display: block !important;
  opacity: 0;
  transform: translateX(80px);
  pointer-events: none;
  z-index: 1;
  transition:
    opacity 220ms cubic-bezier(0.4, 0.05, 0.7, 0.2) 0s,
    transform 220ms cubic-bezier(0.4, 0.05, 0.7, 0.2) 0s;
}
/* Outgoing: slides off to the left (right→left motion) */
.screen.is-leaving {
  display: block !important;
  opacity: 0;
  transform: translateX(-80px);
  pointer-events: none;
  z-index: 1;
  transition:
    opacity 220ms cubic-bezier(0.4, 0.05, 0.7, 0.2) 0s,
    transform 220ms cubic-bezier(0.4, 0.05, 0.7, 0.2) 0s;
}
.hidden { display: none !important; }

/* === INTRO === */
.intro-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  gap: clamp(20px, 3vh, 48px);
  padding: clamp(16px, 4vw, 64px);
}
.intro-title {
  font-size: clamp(40px, 8vw, 140px);
  font-weight: 900;
  letter-spacing: clamp(2px, 0.5vw, 8px);
  background: linear-gradient(135deg, #ff6fa8, #ffd54d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(255,150,200,0.3);
}
.intro-sub {
  font-size: clamp(14px, 1.8vw, 28px);
  opacity: 0.75;
  letter-spacing: 2px;
}
.btn-large {
  padding: clamp(16px, 2.2vh, 32px) clamp(40px, 5vw, 80px);
  font-size: clamp(18px, 2vw, 32px);
}

/* === RIDDLE === */
.riddle-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  gap: clamp(20px, 3.5vh, 56px);
  padding: clamp(20px, 4vw, 80px);
}
.riddle-badge {
  font-size: clamp(14px, 1.6vw, 24px);
  letter-spacing: clamp(3px, 0.6vw, 8px);
  text-transform: uppercase;
  color: #ffd54d;
  font-weight: 700;
  padding: clamp(8px, 1vh, 14px) clamp(20px, 2.5vw, 40px);
  border: 2px solid rgba(255, 213, 77, 0.5);
  border-radius: 999px;
  background: rgba(255, 213, 77, 0.08);
  box-shadow: 0 0 24px rgba(255, 213, 77, 0.25);
}
.riddle-question {
  font-size: clamp(28px, 4vw, 72px);
  font-weight: 600;
  line-height: 1.3;
  max-width: 90vw;
}
.riddle-accent {
  background: linear-gradient(135deg, #ff6fa8, #ffd54d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
.riddle-hint {
  font-size: clamp(16px, 1.9vw, 30px);
  font-weight: 400;
  line-height: 1.55;
  max-width: 75vw;
  opacity: 0.85;
  padding: clamp(14px, 2vh, 24px) clamp(20px, 2.5vw, 40px);
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: clamp(12px, 1.4vw, 22px);
}
.riddle-hint strong { color: #ffd54d; font-weight: 700; }
/* === Riddle: 4-digit year tiles === */
.riddle-year-tiles {
  display: flex; gap: clamp(8px, 1.2vw, 22px);
  justify-content: center;
  margin-top: clamp(8px, 1vh, 20px);
}
.riddle-tile {
  width: clamp(80px, 10vw, 180px);
  height: clamp(110px, 13.5vw, 240px);
  border-radius: clamp(12px, 1.4vw, 24px);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: clamp(64px, 8.5vw, 160px);
  background: rgba(255, 255, 255, 0.06);
  border: clamp(2px, 0.3vw, 4px) solid rgba(255, 255, 255, 0.22);
  position: relative;
  transition: background 250ms ease, border 250ms ease, transform 250ms ease, box-shadow 250ms ease;
}
.riddle-tile.is-filled {
  background: linear-gradient(135deg, #ff6fa8 0%, #7c5cff 100%);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
  box-shadow: 0 0 32px rgba(255, 150, 200, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.riddle-tile.is-target {
  border-color: #ffd54d;
  border-width: clamp(3px, 0.4vw, 6px);
  background: rgba(255, 213, 77, 0.08);
  box-shadow: 0 0 28px rgba(255, 213, 77, 0.55);
  animation: riddle-pulse 1.6s ease-in-out infinite;
  color: rgba(255, 255, 255, 0.4);
}
@keyframes riddle-pulse {
  0%, 100% { box-shadow: 0 0 28px rgba(255, 213, 77, 0.55); }
  50%      { box-shadow: 0 0 48px rgba(255, 213, 77, 0.95); }
}
.riddle-tile-secret { display: inline-block; }

.riddle-screen.revealed .riddle-tile.is-target {
  background: linear-gradient(135deg, #ffd54d 0%, #ff9a3c 100%);
  border-color: #fff;
  color: #2d1f5c;
  box-shadow: 0 0 36px rgba(255, 213, 77, 0.95);
  animation: none;
  transform: scale(1.05);
}
.riddle-screen.revealed .riddle-tile-secret {
  animation: riddle-pop 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes riddle-pop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.riddle-meaning {
  font-size: clamp(20px, 2.4vw, 38px);
  font-weight: 600;
  opacity: 0.9;
  margin-top: clamp(4px, 0.5vh, 12px);
}
.riddle-letters-num {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  font-weight: 900;
  background: linear-gradient(135deg, #ff6fa8, #ffd54d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.25em;
  letter-spacing: 1px;
}
.riddle-controls {
  display: flex; gap: clamp(12px, 1.6vw, 24px);
  flex-wrap: wrap; justify-content: center;
}

/* === STAGE LAYOUT === */
.stage {
  padding: clamp(16px, 2.5vw, 48px);
  display: flex; flex-direction: column;
  gap: clamp(12px, 1.8vh, 28px);
}

/* HEADER */
.header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.progress-text {
  font-size: clamp(12px, 1.4vw, 22px);
  letter-spacing: clamp(2px, 0.4vw, 6px);
  text-transform: uppercase; opacity: 0.75; font-weight: 600;
}
.progress-bar { flex: 1; height: clamp(4px, 0.6vh, 8px); background: rgba(255,255,255,0.12); border-radius: 999px; overflow: hidden; }
.progress-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, #ff6fa8, #ffd54d);
  box-shadow: 0 0 12px rgba(255,150,200,0.7);
  border-radius: 999px;
  transition: width 400ms ease;
}
.counter { font-size: clamp(14px, 1.5vw, 24px); font-weight: 700; color: #ffd54d; min-width: 80px; text-align: right; }

/* TÊN BÉ */
.name-section { display: flex; justify-content: center; padding: clamp(8px, 1.5vh, 24px) 0; }
.name-row {
  display: flex; gap: clamp(12px, 1.8vw, 36px); /* gap BETWEEN words */
  flex-wrap: wrap; justify-content: center;
  position: relative;
}
.name-word {
  display: flex; gap: clamp(4px, 0.6vw, 12px); /* gap BETWEEN tiles within a word */
  flex-wrap: nowrap;                            /* never break a word across lines */
}
.name-highlight {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  border: clamp(3px, 0.4vw, 6px) solid #ffd54d;
  border-radius: clamp(8px, 1vw, 18px);
  box-shadow: 0 0 32px rgba(255, 213, 77, 0.7);
  opacity: 0;
  transform: translate(0, 0);
  transition:
    transform 380ms cubic-bezier(0.45, 0.05, 0.2, 1.05),
    width 380ms cubic-bezier(0.45, 0.05, 0.2, 1.05),
    height 380ms cubic-bezier(0.45, 0.05, 0.2, 1.05),
    opacity 220ms ease;
  animation: pulse 1.6s ease-in-out infinite;
  z-index: 1;
}
.name-highlight.is-active { opacity: 1; }
.tile-big {
  width: clamp(48px, 6vw, 120px);
  height: clamp(64px, 8.5vw, 160px);
  background: rgba(255,255,255,0.06);
  border: clamp(2px, 0.25vw, 4px) solid rgba(255,255,255,0.2);
  border-radius: clamp(8px, 1vw, 18px);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: clamp(28px, 4.2vw, 78px);
  color: transparent;
  cursor: pointer; transition: all 0.2s;
  position: relative;
}
.tile-big:hover:not(.filled) { border-color: rgba(255,200,230,0.7); transform: translateY(-3px); box-shadow: 0 6px 18px rgba(255,150,200,0.35); }
.tile-big.filled {
  background: linear-gradient(135deg, #ff6fa8 0%, #7c5cff 100%);
  border-color: rgba(255,255,255,0.55); color: #fff;
  box-shadow: 0 0 28px rgba(255,150,200,0.55), inset 0 1px 0 rgba(255,255,255,0.3);
  cursor: default;
}
/* .tile-big.current visuals moved to .name-highlight overlay (animatable) */
.tile-big.is-entering {
  animation: tile-fall-in 600ms cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  animation-delay: calc(var(--enter-index, 0) * 60ms);
}
.tile-big.is-entering.current {
  animation:
    tile-fall-in 600ms cubic-bezier(0.34, 1.56, 0.64, 1) backwards,
    pulse 1.6s ease-in-out infinite calc(var(--enter-index, 0) * 60ms + 600ms);
  animation-delay: calc(var(--enter-index, 0) * 60ms);
}
@keyframes tile-fall-in {
  0%   { transform: translateY(-60px) scale(0.5) rotate(-8deg); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}
.tile-num {
  position: absolute; top: clamp(2px, 0.4vh, 8px); left: clamp(4px, 0.5vw, 10px);
  font-size: clamp(9px, 0.95vw, 16px); font-weight: 600; opacity: 0.55; color: rgba(255,255,255,0.8);
}
.tile-big.filled .tile-num { opacity: 0.8; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 32px rgba(255,213,77,0.7); }
  50%     { box-shadow: 0 0 48px rgba(255,213,77,1); }
}

.divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent); }

/* CÂU HỎI */
.q-section {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: clamp(12px, 2vh, 32px);
  overflow: hidden;
}
.q-anim-in {
  animation: q-slide-in 420ms cubic-bezier(0.22, 0.85, 0.2, 1) backwards;
}
.q-anim-out {
  animation: q-slide-out 260ms cubic-bezier(0.4, 0, 0.7, 0.2) forwards;
}
@keyframes q-slide-in {
  from { transform: translateX(80px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes q-slide-out {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-100px); opacity: 0; }
}
.q-label { font-size: clamp(12px, 1.3vw, 22px); letter-spacing: clamp(3px, 0.5vw, 8px); text-transform: uppercase; color: #ffd54d; font-weight: 700; }
.q-text { font-size: clamp(22px, 3vw, 56px); font-weight: 500; line-height: 1.35; max-width: 90vw; }

/* ĐÁP ÁN */
.a-display { display: flex; gap: clamp(6px, 0.8vw, 14px); justify-content: center; flex-wrap: wrap; }
.a-tile {
  width: clamp(36px, 4.3vw, 84px);
  height: clamp(48px, 5.8vw, 106px);
  background: rgba(255,255,255,0.06);
  border: clamp(1px, 0.2vw, 3px) solid rgba(255,255,255,0.22);
  border-radius: clamp(6px, 0.7vw, 14px);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: clamp(22px, 2.9vw, 52px);
  color: #fff;
  position: relative;
  transition: background 200ms ease, transform 200ms ease, border 200ms ease;
}
.a-tile-char {
  display: inline-block;
  opacity: 0;        /* hidden until reveal stagger */
  transform: scale(0.55);
}
.a-tile.target {
  border-color: #ffd54d;
  border-width: clamp(2px, 0.3vw, 4px);
  background: rgba(255,213,77,0.08);
  box-shadow: 0 0 18px rgba(255,213,77,0.45);
  animation: pulse-soft 1.6s ease-in-out infinite;
}
@keyframes pulse-soft {
  0%,100% { box-shadow: 0 0 18px rgba(255,213,77,0.45); }
  50%     { box-shadow: 0 0 28px rgba(255,213,77,0.75); }
}
/* When the stage is "revealed", the empty boxes stay put — only each
   character pops in (staggered) and the target tile changes its background
   in sync with its own char. */
.stage.revealed .a-tile-char {
  animation: a-char-reveal 300ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: calc(var(--reveal-index, 0) * 55ms);
}
@keyframes a-char-reveal {
  from { opacity: 0; transform: translateY(-12px) scale(0.55); }
  60%  { opacity: 1; transform: translateY(0) scale(1.18); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.stage.revealed .a-tile.target {
  color: #2d1f5c; border-color: #fff;
  background: linear-gradient(135deg, #ffd54d 0%, #ff9a3c 100%);
  box-shadow: 0 0 28px rgba(255,213,77,0.85);
  animation: a-target-pop 340ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: calc(var(--reveal-index, 0) * 55ms);
}
@keyframes a-target-pop {
  from { transform: scale(1); }
  60%  { transform: scale(1.20); }
  to   { transform: scale(1.08); }
}

/* FLYING LETTER */
.flyer {
  position: fixed; z-index: 50;
  border-radius: clamp(8px, 1vw, 18px);
  background: linear-gradient(135deg, #ffd54d, #ff9a3c);
  color: #2d1f5c;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: clamp(28px, 4.2vw, 78px);
  box-shadow: 0 0 32px rgba(255,213,77,0.9);
  transition: transform 0.9s cubic-bezier(.5,-0.3,.4,1.4), opacity 0.4s;
  pointer-events: none;
}

/* CONTROLS */
.controls { display: flex; gap: clamp(10px, 1.2vw, 20px); justify-content: center; align-items: center; flex-wrap: wrap; }
.btn {
  padding: clamp(12px, 1.5vh, 22px) clamp(22px, 2.5vw, 48px);
  border-radius: 999px; font-weight: 700;
  font-size: clamp(14px, 1.4vw, 24px); letter-spacing: 0.5px;
  cursor: pointer; transition: all 0.15s;
  border: clamp(1.5px, 0.18vw, 3px) solid transparent;
  font-family: inherit;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #ff6fa8, #7c5cff); color: #fff; box-shadow: 0 6px 22px rgba(255,150,200,0.45); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(255,150,200,0.65); }
.btn-warn { background: rgba(255,180,80,0.16); color: #ffd54d; border-color: rgba(255,213,77,0.45); }
.btn-ghost { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.28); }
.helper { text-align: center; font-size: clamp(11px, 1.05vw, 18px); opacity: 0.55; letter-spacing: 1px; }

/* FINALE */
.finale-screen {
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
.finale-name {
  font-size: clamp(40px, 9vw, 180px);
  font-weight: 900;
  letter-spacing: clamp(4px, 0.8vw, 16px);
  background: linear-gradient(135deg, #ff6fa8, #ffd54d, #7c5cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 80px rgba(255,150,200,0.4);
  padding: 0 clamp(16px, 4vw, 64px);
  line-height: 1.1;
}

/* VALIDATION BANNER */
.validation-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  background: #c0392b; color: #fff; padding: 12px 20px;
  font-family: monospace; font-size: 13px;
}
