:root {
  --navy: #0b2545; --navy2: #13315c; --ink: #0a1a33;
  --orange: #ff8a1f; --orange2: #ffb25e; --cream: #fff6e9;
  --sea: #1b98e0; --green: #2bb673; --red: #ef3e4a;
  --oL: #3a86ff; --oR: #ff8a1f; --oB: #8f5cf7; --oN: #22b59c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #050d1c; }
body { font-family: 'Pretendard Variable', Pretendard, 'Malgun Gothic', sans-serif; color: #fff; }
.display { font-family: 'Black Han Sans', 'Pretendard Variable', sans-serif; font-weight: 400; letter-spacing: -0.5px; }

#stage { position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px; transform-origin: center; overflow: hidden;
  background: radial-gradient(ellipse at 50% -10%, #1d4e89 0%, var(--navy) 55%, #061632 100%); }
#bg { position: absolute; inset: 0; pointer-events: none; transition: opacity 1.2s; }
#bg .wave { position: absolute; left: -5%; width: 110%; bottom: 0; height: 180px; }
#bg .dot { position: absolute; border-radius: 50%; background: var(--orange); opacity: .12; animation: floaty 9s ease-in-out infinite alternate; }
@keyframes floaty { to { transform: translateY(-40px) translateX(20px); } }
#scene { position: absolute; inset: 0; }

/* ---------- 공통 조각 ---------- */
.header { position: absolute; left: 60px; right: 60px; top: 40px; display: flex; align-items: center; gap: 24px; }
.qbadge { background: var(--orange); color: var(--ink); border-radius: 18px; padding: 10px 26px; font-size: 40px; }
.htitle { font-size: 52px; }
.hsub { font-size: 30px; opacity: .8; margin-left: 6px; }
.spacer { flex: 1; }
.timer { width: 130px; height: 130px; position: relative; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 54px; font-weight: 800; }
.timer.hurry .num { color: #ff6b6b; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.18); } }
/* 5초 남으면 타이머가 들썩들썩 춤추며 재촉 */
.timer.hurry { animation: hurryDance .5s ease-in-out infinite; }
.timer.hurry #ring { stroke: #ff4d5a; }
.timer.hurry::after { content: '서둘러요!'; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 6px; white-space: nowrap; font-size: 26px; font-weight: 900; color: #ff6b6b; animation: pulse .25s infinite alternate; }
@keyframes hurryDance {
  0%   { transform: translateY(0) rotate(0) scale(1); }
  20%  { transform: translateY(-14px) rotate(-14deg) scale(1.12); }
  40%  { transform: translateY(0) rotate(0) scale(1); }
  60%  { transform: translateY(-14px) rotate(14deg) scale(1.12); }
  80%  { transform: translateY(0) rotate(0) scale(1); }
  100% { transform: translateY(0) rotate(0) scale(1); }
}

.char { width: 100%; height: 100%; }
.char svg { width: 100%; height: 100%; overflow: visible; }
.dance-bounce { animation: dBounce .5s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.dance-sway { animation: dSway 1s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.dance-hop { animation: dHop .6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes dBounce { 0% { transform: translateY(0) scale(1.04, .96); } 100% { transform: translateY(-22px) scale(.97, 1.03); } }
@keyframes dSway { 0% { transform: rotate(-9deg); } 100% { transform: rotate(9deg); } }
@keyframes dHop { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-26px) rotate(-8deg); } 50% { transform: translateY(0) rotate(0); } 75% { transform: translateY(-26px) rotate(8deg); } }

.parade { position: absolute; left: 0; right: 0; bottom: 8px; height: 190px; display: flex; justify-content: center; gap: 46px; }
.parade .pc { width: 150px; height: 180px; position: relative; }
.parade .pc .nm { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 17px; opacity: .75; }

.corner-char { position: absolute; left: 40px; bottom: 14px; width: 180px; height: 215px; z-index: 5; }
.corner-char .bubble { position: absolute; left: 150px; top: 10px; background: #fff; color: var(--ink); border-radius: 20px; padding: 10px 18px; font-size: 22px; font-weight: 700; white-space: nowrap; }
.corner-char .bubble::before { content: ''; position: absolute; left: -10px; top: 18px; border: 8px solid transparent; border-right-color: #fff; }

/* ---------- 타이틀 ---------- */
.title-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding-top: 120px; }
.title-kicker { font-size: 34px; color: var(--orange2); letter-spacing: 6px; font-weight: 700; }
.title-main { font-size: 150px; line-height: 1.05; text-align: center; margin-top: 14px; text-shadow: 0 8px 0 rgba(0,0,0,.25); }
.title-main em { font-style: normal; color: var(--orange); }
.title-sub { font-size: 44px; margin-top: 26px; opacity: .9; }
.title-hero { width: 300px; height: 360px; margin-top: 10px; }
.press { position: absolute; bottom: 230px; left: 0; right: 0; text-align: center; font-size: 26px; opacity: .6; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- 대기실 ---------- */
.lobby { position: absolute; inset: 0; display: grid; grid-template-columns: 640px 1fr; gap: 60px; padding: 70px 70px 220px; }
.qrcard { background: #fff; color: var(--ink); border-radius: 36px; padding: 40px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.qrcard .qr { width: 440px; height: 440px; }
.qrcard .qr svg { width: 100%; height: 100%; }
.qrcard .step { font-size: 30px; font-weight: 800; margin-top: 18px; }
.qrcard .url { font-size: 22px; color: #4a5568; margin-top: 8px; word-break: break-all; text-align: center; }
.joined { position: relative; display: flex; flex-direction: column; }
.joined .cnt { display: flex; align-items: baseline; gap: 16px; }
.joined .cnt b { font-size: 140px; color: var(--orange); line-height: 1; }
.joined .cnt span { font-size: 44px; }
.cloud { position: relative; flex: 1; margin-top: 20px; }
.chip { position: absolute; padding: 12px 24px; border-radius: 999px; font-size: 30px; font-weight: 700; color: var(--ink); white-space: nowrap; animation: chipIn .6s cubic-bezier(.2, 1.6, .4, 1) both, chipFloat 4s ease-in-out infinite alternate; }
@keyframes chipIn { from { transform: scale(0); opacity: 0; } }
@keyframes chipFloat { to { translate: 0 -10px; } }

/* ---------- 문제 ---------- */
.qarea { position: absolute; left: 60px; top: 200px; width: 1400px; height: 660px; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.imgbox { position: relative; border-radius: 28px; background: rgba(255,255,255,.06); display: grid; place-items: center; overflow: hidden; }
.imgbox .tag { position: absolute; top: 16px; left: 16px; z-index: 3; padding: 8px 22px; border-radius: 14px; font-size: 30px; font-weight: 800; }
.imgbox.L .tag { background: var(--oL); } .imgbox.R .tag { background: var(--oR); color: var(--ink); }
.imgfit { position: relative; display: inline-block; max-width: 100%; max-height: 100%; line-height: 0; }
.imgfit img { max-width: 680px; max-height: 660px; display: block; border-radius: 20px; }
.placeholder { width: 640px; height: 600px; border: 4px dashed rgba(255,255,255,.25); border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 30px; opacity: .7; text-align: center; line-height: 1.4; }
.placeholder .big { font-size: 90px; }
.stamp { position: absolute; right: 22px; bottom: 22px; z-index: 6; transform: rotate(-10deg); padding: 8px 28px; border: 8px solid; border-radius: 20px; font-size: 70px; background: rgba(255,255,255,.92); animation: stampIn .45s cubic-bezier(.3, 1.8, .5, 1) both; white-space: nowrap; }
.stamp.ai { color: var(--red); border-color: var(--red); }
.stamp.real { color: var(--green); border-color: var(--green); font-size: 58px; }
@keyframes stampIn { from { transform: rotate(-10deg) scale(2.6); opacity: 0; } }
.imgbox.dim .imgfit { filter: grayscale(.4) brightness(.65); }
.mark { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border: 7px solid #ff3040; border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,255,255,.7), 0 0 30px rgba(255,48,64,.7); z-index: 5; animation: markIn .5s ease-out both; }
@keyframes markIn { from { transform: scale(2.5); opacity: 0; } }
.countdown { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(6,22,50,.82); }
.countdown b { font-size: 360px; color: var(--orange); animation: cd 1s ease-out infinite; }
@keyframes cd { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(.9); } }

.legend { position: absolute; left: 290px; right: 520px; bottom: 50px; display: flex; gap: 16px; justify-content: center; }
.legend span { padding: 12px 22px; border-radius: 16px; font-size: 26px; font-weight: 800; }
.oL { background: var(--oL); } .oR { background: var(--oR); color: var(--ink); } .oB { background: var(--oB); } .oN { background: var(--oN); }

.panel { position: absolute; right: 60px; top: 200px; width: 400px; height: 820px; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.1); border-radius: 28px; padding: 28px; display: flex; flex-direction: column; }
.panel h3 { font-size: 28px; opacity: .8; }
.panel .big { font-size: 96px; font-weight: 900; line-height: 1.1; }
.panel .big small { font-size: 40px; opacity: .6; }
.bar { height: 18px; border-radius: 9px; background: rgba(255,255,255,.12); overflow: hidden; margin: 10px 0 20px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--orange2)); transition: width .4s; }
.feed { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.feed div { background: rgba(255,255,255,.1); border-radius: 14px; padding: 12px 18px; font-size: 26px; animation: feedIn .4s ease-out both; }
.feed div::after { content: ' ✔'; color: var(--green); }
@keyframes feedIn { from { transform: translateX(60px); opacity: 0; } }

.dist { display: flex; flex-direction: column; gap: 16px; margin-top: 10px; }
.dist .row { display: grid; grid-template-columns: 1fr 56px; align-items: center; gap: 4px 10px; font-size: 24px; font-weight: 700; }
.dist .row > span:first-child { grid-column: 1 / -1; }
.dist .row > span:last-child { text-align: right; font-size: 30px; }
.dist .track { height: 40px; border-radius: 12px; background: rgba(255,255,255,.08); overflow: hidden; }
.dist .fill { height: 100%; width: 0; border-radius: 12px; transition: width 1.2s cubic-bezier(.2, .8, .2, 1); }
.dist .row.ok { color: #7dffb5; }
.dist .row.ok .track { outline: 4px solid #7dffb5; }
.dist .row:not(.ok) { opacity: .55; }
.rate { margin-top: 26px; font-size: 30px; }
.rate b { font-size: 64px; color: var(--orange); }
.tip { position: absolute; left: 290px; right: 520px; bottom: 34px; background: var(--cream); color: var(--ink); border-radius: 24px; padding: 20px 30px; font-size: 30px; font-weight: 700; line-height: 1.35; animation: feedIn .5s .4s both; }
.tip b { color: #d6600a; }
/* 문제 중 남은 10초에 나타나는 판별 포인트 */
.qtip { display: none; z-index: 4; }
.qtip.show { display: block; animation: tipPop .6s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes tipPop { from { transform: translateY(40px) scale(.9); opacity: 0; } }
.legend.hide { display: none; }

/* ---------- 순위 ---------- */
.board { position: absolute; left: 330px; top: 190px; width: 1000px; height: 800px; }
.brow { position: absolute; left: 0; right: 0; height: 70px; display: grid; grid-template-columns: 90px 1fr 120px 200px; align-items: center; padding: 0 28px; border-radius: 20px; background: rgba(255,255,255,.08); font-size: 34px; font-weight: 700; transition: transform 1.3s cubic-bezier(.3, .9, .3, 1), opacity .6s; }
.brow .rk { font-size: 40px; color: var(--orange2); }
.brow .sc { text-align: right; font-variant-numeric: tabular-nums; }
.brow .mv { font-size: 24px; text-align: center; }
.brow .mv.up { color: #7dffb5; } .brow .mv.down { color: #ff8b8b; }
.brow.top1 { background: linear-gradient(90deg, #ffcf3f, #ff9f1c); color: var(--ink); }
.brow.top1 .rk { color: var(--ink); }
.brow.top2 { background: rgba(220,230,245,.28); } .brow.top3 { background: rgba(205,127,50,.35); }
.side-note { position: absolute; right: 70px; top: 230px; width: 440px; text-align: center; }
.side-note .lbl { font-size: 26px; opacity: .75; }
.side-note .who { font-size: 48px; font-weight: 900; color: var(--orange2); margin-top: 6px; }
.side-note .sec { font-size: 26px; opacity: .8; }
.side-char { width: 300px; height: 360px; margin: 40px auto 0; }

/* ---------- 초성 ---------- */
.cho { position: absolute; left: 60px; width: 1400px; top: 260px; display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; }
.cho .tile { width: 170px; height: 190px; border-radius: 26px; background: var(--cream); color: var(--ink); display: grid; place-items: center; font-size: 120px; font-weight: 900; box-shadow: 0 12px 0 #d8c7ad; animation: tileIn .5s cubic-bezier(.3, 1.7, .5, 1) both; }
.cho .gap { width: 60px; }
.cho .tile.ans { background: var(--orange); color: #fff; box-shadow: 0 12px 0 #c35f00; animation: flip .6s both; font-family: 'Pretendard Variable', Pretendard, 'Malgun Gothic', sans-serif; font-weight: 800; letter-spacing: 0; }
@keyframes tileIn { from { transform: translateY(-80px) scale(.5); opacity: 0; } }
@keyframes flip { from { transform: rotateY(90deg); } }
.hint { position: absolute; left: 60px; width: 1400px; top: 520px; text-align: center; font-size: 38px; opacity: .9; }
.hint b { color: var(--orange2); }
.x2 { display: inline-block; background: var(--red); color: #fff; padding: 6px 18px; border-radius: 12px; font-size: 30px; margin-left: 12px; animation: pulse .6s infinite alternate; }
.wide .cho, .wide .hint { width: 1800px; }
.judge-area { position: absolute; left: 60px; width: 1800px; top: 600px; bottom: 60px; display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 14px; overflow: hidden; }
.judge-area .ok { background: var(--green); padding: 12px 24px; border-radius: 999px; font-size: 30px; font-weight: 800; animation: chipIn .5s both; }
.judge-area .wrong { background: rgba(255,255,255,.1); border: 3px solid rgba(255,255,255,.2); padding: 14px 26px; border-radius: 18px; font-size: 34px; font-weight: 700; cursor: pointer; animation: chipIn .5s both; }
.judge-area .wrong small { font-size: 22px; opacity: .6; margin-left: 8px; }
.judge-area .wrong.accepted { background: var(--green); border-color: #7dffb5; }
.judge-area .wrong:hover { border-color: var(--orange); }
.judge-msg { width: 100%; text-align: center; font-size: 32px; opacity: .8; }
/* 오답 보기: 정답은 왼쪽 위에 작게, 오답은 크게 */
.ans-mini { position: absolute; left: 60px; top: 175px; display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.18); border-radius: 16px; padding: 10px 22px; font-size: 26px; font-weight: 700; }
.ans-mini b { color: #fff; background: var(--orange); border-radius: 10px; padding: 4px 14px; font-size: 32px; font-weight: 800; }
.wrongview .hint { top: 182px; left: auto; right: 60px; width: auto; text-align: right; font-size: 30px; }
.wrongview .judge-area { top: 270px; gap: 22px; align-content: flex-start; }
.wrongview .judge-area .wrong { font-size: 64px; padding: 20px 40px; border-radius: 24px; }
.wrongview .judge-area .wrong small { font-size: 36px; }

/* ---------- 최종 ---------- */
.podium { position: absolute; left: 160px; bottom: 60px; width: 1080px; height: 860px; display: flex; align-items: flex-end; justify-content: center; gap: 30px; }
.pod { width: 320px; display: flex; flex-direction: column; align-items: center; animation: podIn .9s cubic-bezier(.3, 1.4, .5, 1) both; }
.pod .pc { width: 190px; height: 228px; }
.pod .nick { font-size: 44px; font-weight: 900; margin: 8px 0 4px; text-align: center; }
.pod .pts { font-size: 28px; opacity: .85; margin-bottom: 12px; }
.pod .block { width: 100%; border-radius: 22px 22px 0 0; display: grid; place-items: start center; padding-top: 18px; font-size: 90px; color: var(--ink); }
.pod.p1 .block { height: 330px; background: linear-gradient(#ffd84d, #ffaa1c); }
.pod.p2 .block { height: 230px; background: linear-gradient(#eef3fa, #b9c6d8); }
.pod.p3 .block { height: 160px; background: linear-gradient(#f0b27a, #c97c3d); }
@keyframes podIn { from { transform: translateY(400px); opacity: 0; } }
.crown { font-size: 80px; margin-bottom: -10px; animation: dBounce .5s infinite alternate; }
.rest { position: absolute; right: 70px; top: 180px; width: 520px; display: flex; flex-direction: column; gap: 12px; animation: feedIn .6s 4.6s both; }
.rest div { display: flex; justify-content: space-between; background: rgba(255,255,255,.08); border-radius: 16px; padding: 14px 24px; font-size: 30px; font-weight: 700; }
.stand { position: absolute; top: 60px; left: 0; right: 520px; text-align: center; font-size: 56px; animation: feedIn .6s 4.4s both; }
.stand b { color: var(--orange2); }
#confetti { position: absolute; inset: 0; pointer-events: none; z-index: 30; }

/* ---------- 마무리 ---------- */
.end-q { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding-top: 70px; }
.end-q h1 { font-size: 96px; } .end-q h2 { font-size: 44px; opacity: .85; margin-top: 10px; }
.grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; margin-top: 50px; width: 1700px; }
.grid .ph { position: relative; width: 400px; height: 270px; border-radius: 20px; overflow: hidden; background: #222 center/cover; box-shadow: 0 12px 30px rgba(0,0,0,.4); animation: chipIn .6s both; }
.grid .ph b { position: absolute; left: 12px; top: 10px; width: 54px; height: 54px; border-radius: 50%; background: var(--orange); color: var(--ink); display: grid; place-items: center; font-size: 30px; }
.slide { position: absolute; inset: 0; background: #000 center/cover no-repeat; opacity: 0; transition: opacity 1.2s; }
.slide.on { opacity: 1; animation: kenburns 6s linear both; }
@keyframes kenburns { from { transform: scale(1.0); } to { transform: scale(1.12); } }
.slide-cap { position: absolute; left: 0; right: 0; bottom: 70px; text-align: center; font-size: 40px; text-shadow: 0 3px 14px rgba(0,0,0,.8); z-index: 3; }
.collage { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); grid-auto-rows: 270px; filter: brightness(.35) saturate(.8); }
.collage div { background: center/cover; }
.answer-none { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.answer-none .a1 { font-size: 64px; opacity: .9; animation: feedIn .6s both; }
.answer-none .a2 { font-size: 190px; color: var(--orange); margin: 10px 0; animation: stampIn2 .7s .6s cubic-bezier(.3, 1.6, .5, 1) both; }
.answer-none .a3 { font-size: 72px; animation: fadeUp 1s 1.6s both; }
@keyframes stampIn2 { from { transform: scale(2.4); opacity: 0; } }
@keyframes fadeUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sunrise { position: absolute; inset: 0; background: linear-gradient(180deg, #1a2a6c 0%, #4b3a8c 30%, #c9658f 58%, #ffa86b 78%, #ffd98a 88%, #2f7fb5 88.2%, #1b5d8a 100%); }
.sunrise .sun { position: absolute; left: 50%; top: 88%; width: 380px; height: 380px; margin: -190px 0 0 -190px; border-radius: 50%; background: radial-gradient(circle, #fff4c8 0%, #ffd36b 45%, rgba(255,170,80,0) 70%); animation: sunUp 8s ease-out both; }
@keyframes sunUp { from { transform: translateY(140px); } }
.sunrise .isle { position: absolute; left: 0; right: 0; top: calc(88% - 96px); height: 98px; }
.sunrise .glit { position: absolute; left: 50%; top: 88.4%; width: 260px; height: 12%; margin-left: -130px; background: repeating-linear-gradient(180deg, rgba(255,230,160,.7) 0 4px, transparent 4px 16px); filter: blur(1px); opacity: .7; }
.msg { position: absolute; left: 0; right: 0; top: 54px; text-align: center; padding: 0 140px; text-shadow: 0 3px 18px rgba(20,10,50,.6); }
.msg .head { font-size: 84px; line-height: 1.18; }
.msg .head em { font-style: normal; color: #ffe08a; }
.msg .body { font-size: 38px; line-height: 1.55; margin-top: 30px; font-weight: 600; }
.msg .body p { opacity: 0; animation: fadeUp 1.2s both; min-height: .6em; }
.msg .closing { font-size: 96px; margin-top: 24px; color: #fff; opacity: 0; animation: fadeUp 1.6s both; text-shadow: 0 4px 30px rgba(255,160,60,.8); }
.msg .sign { font-size: 30px; margin-top: 10px; opacity: 0; animation: fadeUp 1.2s both; }
.ending-chars { position: absolute; bottom: 210px; left: 0; right: 0; display: flex; justify-content: center; gap: 30px; opacity: 0; animation: fadeUp 1.4s both; }
.ending-chars div { width: 110px; height: 132px; }

/* ---------- 조작 버튼 ---------- */
#controls { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 8px; z-index: 100; opacity: .1; transition: opacity .3s; flex-wrap: wrap; justify-content: flex-end; max-width: 90vw; }
#controls:hover, body.active #controls { opacity: 1; }
#controls button { font: inherit; font-size: 15px; font-weight: 700; padding: 10px 16px; border-radius: 12px; border: 0; background: rgba(255,255,255,.92); color: var(--ink); cursor: pointer; }
#controls button.primary { background: var(--orange); color: #fff; }
#controls .mode { align-self: center; color: #fff; font-size: 13px; background: rgba(0,0,0,.5); padding: 6px 10px; border-radius: 8px; }
#soundHint { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: rgba(255,255,255,.95); color: var(--ink); padding: 10px 22px; border-radius: 999px; font-weight: 700; z-index: 101; cursor: pointer; }
