/* 단독 프로젝트: 외부 이미지 없음. 폰트는 Google Fonts(Jua) — index.html에서 로드 */
:root {
  --navy: #1d3b78;
  --ink: #2a3f6b;
  --sub: #6a7fa8;
  --blue: #2f7cf6;
  --sky: #5cc6ff;
  --yellow: #ffd23f;
  --pink: #ff7eb6;
  --glass: rgba(255,255,255,.86);
  --line: #d6e6ff;
  --red-t: #ff5a6e; --blue-t: #3b8cff; --yellow-t: #ffb81a; --green-t: #2fcf7a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Jua', 'Malgun Gothic', sans-serif;
  color: var(--ink);
  /* 스타포트 하늘: 그라데이션 + 구름 + 별 (CSS만) */
  background:
    radial-gradient(ellipse 22% 9% at 12% 78%, rgba(255,255,255,.9) 60%, transparent 62%),
    radial-gradient(ellipse 16% 7% at 20% 74%, rgba(255,255,255,.9) 60%, transparent 62%),
    radial-gradient(ellipse 24% 9% at 86% 82%, rgba(255,255,255,.85) 60%, transparent 62%),
    radial-gradient(ellipse 14% 6% at 78% 77%, rgba(255,255,255,.85) 60%, transparent 62%),
    radial-gradient(circle at 88% 16%, #ffe48a 0 5%, rgba(255,228,138,.35) 5.2% 9%, transparent 9.5%),
    radial-gradient(circle at 8% 22%, #c7b4ff 0 3.2%, transparent 3.4%),
    linear-gradient(180deg, #7fc8ff 0%, #a9dcff 45%, #dff3ff 75%, #f4fbff 100%);
  background-attachment: fixed;
  overflow: hidden;
  user-select: none;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(2px 2px at 20% 12%, #fff 98%, transparent), radial-gradient(2px 2px at 35% 30%, #fff 98%, transparent),
    radial-gradient(3px 3px at 62% 8%, #fff 98%, transparent), radial-gradient(2px 2px at 74% 34%, #fff 98%, transparent),
    radial-gradient(3px 3px at 48% 18%, #fff 98%, transparent), radial-gradient(2px 2px at 92% 44%, #fff 98%, transparent);
  opacity: .9;
}
body.play { overflow: auto; }
button { font-family: inherit; cursor: pointer; border: 0; }
#app { position: relative; z-index: 1; width: 100%; height: 100%; }

/* ---------- common ---------- */
.logo {
  position: absolute; left: 22px; top: 14px; z-index: 5; display: flex; align-items: center; gap: 6px;
  font-size: 22px; line-height: .95; color: #fff; -webkit-text-stroke: 5px var(--blue); paint-order: stroke fill;
  text-shadow: 0 3px 0 #1d5fc9;
}
.logo span { font-size: 34px; -webkit-text-stroke: 0; text-shadow: none; }
.logo.sm { position: static; font-size: 16px; }
.logo.sm span { font-size: 26px; }
.card {
  background: var(--glass); border-radius: 28px;
  box-shadow: 0 10px 30px rgba(30,80,160,.18), inset 0 0 0 3px rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 30px; border-radius: 999px; font-size: 20px; color: #fff;
  background: linear-gradient(#5bb8ff, #2f7cf6);
  box-shadow: 0 5px 0 #1d5fc9, 0 10px 18px rgba(30,90,200,.3);
  transition: transform .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #1d5fc9; }
.btn.yellow { color: #6b3d00; background: linear-gradient(#ffe57a, #ffc21a); box-shadow: 0 5px 0 #d9930b, 0 10px 18px rgba(200,140,0,.3); }
.btn.pink { background: linear-gradient(#ffa3cf, #ff6aa8); box-shadow: 0 5px 0 #d84586, 0 10px 18px rgba(220,60,130,.3); }
.btn.ghost { color: var(--navy); background: #fff; box-shadow: 0 4px 0 #c3d6f5; }
.btn.sm { padding: 9px 18px; font-size: 15px; }
.btn[disabled] { filter: grayscale(.7); opacity: .55; pointer-events: none; }
.title-txt {
  font-size: 64px; color: #fff; letter-spacing: -1px; line-height: 1.1;
  -webkit-text-stroke: 10px var(--blue); paint-order: stroke fill;
  text-shadow: 0 6px 0 #1d5fc9, 0 12px 20px rgba(0,40,120,.25);
}
.title-txt.y { -webkit-text-stroke-color: #ff9f1a; color: #fff6c9; text-shadow: 0 6px 0 #d9730b, 0 12px 20px rgba(120,60,0,.25); }
.pill { display: inline-block; padding: 6px 16px; border-radius: 999px; background: #fff; color: var(--navy); font-size: 16px; box-shadow: 0 3px 0 #c3d6f5; }
.muted { color: var(--sub); }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(100px); background: rgba(29,59,120,.92); color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 16px; transition: transform .25s; z-index: 99; pointer-events: none; }
#toast.on { transform: translateX(-50%) translateY(0); }

/* ---------- HOST ---------- */
.host-wrap { position: absolute; inset: 0; padding: 80px 34px 26px; display: flex; flex-direction: column; gap: 18px; }
.host-head { position: absolute; top: 16px; right: 24px; display: flex; gap: 10px; align-items: center; z-index: 6; }
.host-title { text-align: center; }
.host-title h1 { margin: 0; font-size: 40px; color: #fff; -webkit-text-stroke: 7px var(--blue); paint-order: stroke fill; text-shadow: 0 4px 0 #1d5fc9; }
.host-title p { margin: 6px 0 0; color: var(--navy); font-size: 17px; }

/* title screen */
.cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.cover .badge { font-size: 20px; color: var(--navy); background: rgba(255,255,255,.9); padding: 8px 20px; border-radius: 999px; box-shadow: 0 3px 0 #c3d6f5; }
.cover .rocket-hero { font-size: 110px; animation: hover 2.4s ease-in-out infinite; filter: drop-shadow(0 12px 10px rgba(0,50,140,.25)); }
.cover .desc { font-size: 20px; color: var(--navy); background: rgba(255,255,255,.75); padding: 8px 18px; border-radius: 16px; }
.mascots { position: absolute; bottom: 18px; left: 0; right: 0; display: flex; justify-content: center; gap: 70px; pointer-events: none; }
.mascots span { font-size: 96px; animation: hover 2.8s ease-in-out infinite; filter: drop-shadow(0 10px 8px rgba(0,50,140,.2)); }
.mascots span:nth-child(2) { animation-delay: .4s } .mascots span:nth-child(3) { animation-delay: .8s } .mascots span:nth-child(4) { animation-delay: 1.2s }
@keyframes hover { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-12px) } }

/* lobby */
.lobby { flex: 1; display: grid; grid-template-columns: 250px 1fr 300px; gap: 18px; min-height: 0; }
.qr-box { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.qr-box #qr { background: #fff; padding: 10px; border-radius: 16px; border: 3px solid var(--line); }
.qr-box #qr img, .qr-box #qr canvas { display: block; width: 180px; height: 180px; }
.room-code { font-size: 38px; letter-spacing: 4px; color: var(--blue); }
.players-box { padding: 20px 22px; display: flex; flex-direction: column; min-height: 0; }
.players-box h3 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.team-cols { flex: 1; display: grid; gap: 12px; margin-top: 12px; min-height: 0; overflow: auto; }
.team-col { border-radius: 20px; padding: 10px; background: #f3f8ff; border: 3px dashed var(--line); min-height: 120px; }
.team-col h4 { margin: 0 0 8px; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 8px; border-radius: 999px; background: #fff; box-shadow: 0 2px 0 #c9daf5; font-size: 16px; cursor: pointer; animation: pop .3s; }
.chip.off { opacity: .45; }
.chip .x { color: #c45; font-size: 13px; margin-left: 2px; }
.chip .bot { font-size: 11px; color: #fff; background: #9aa9c7; border-radius: 6px; padding: 1px 4px; }
@keyframes pop { from { transform: scale(.4); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--sub); gap: 6px; }
.empty .empty-ico { font-size: 90px; animation: hover 2.4s ease-in-out infinite; }
.setup { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.setup h3 { margin: 0; font-size: 22px; color: var(--navy); }
.opt label { display: block; font-size: 15px; color: var(--sub); margin-bottom: 6px; }
.seg { display: flex; background: #eaf2ff; border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 999px; background: transparent; color: var(--sub); font-size: 15px; }
.seg button.on { background: #fff; color: var(--blue); box-shadow: 0 2px 0 #c3d6f5; }
.setup .btn.start { margin-top: auto; font-size: 22px; }

/* race screen */
.race-top { display: grid; grid-template-columns: 1fr 380px; gap: 18px; flex: 1; min-height: 0; }
.word-card { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; overflow: hidden; }
.word-card .round-tag { position: absolute; left: 20px; top: 16px; }
.word-card .speak { position: absolute; right: 18px; top: 14px; }
.word-pic { font-size: 120px; line-height: 1; filter: drop-shadow(0 8px 8px rgba(0,40,120,.18)); animation: pop .4s; }
.word-mean { font-size: 40px; color: var(--navy); }
.slots { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.slot { width: 62px; height: 72px; border-radius: 16px; background: #fff; border: 4px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 44px; color: var(--blue); text-transform: lowercase; }
.slot.show { border-color: var(--yellow); background: #fffbe6; animation: flip .45s both; }
@keyframes flip { from { transform: rotateY(90deg) } to { transform: rotateY(0) } }
.timer-bar { width: 80%; height: 16px; background: #e3eeff; border-radius: 999px; overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffd23f, #ff9f1a); border-radius: 999px; transition: width .2s linear; }
.timer-bar.hurry i { background: linear-gradient(90deg, #ff7e7e, #ff3d5a); }
.live { display: flex; gap: 14px; align-items: center; font-size: 18px; color: var(--sub); }
.live b { color: var(--blue); font-size: 24px; }
.side { padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.side h3 { margin: 0; font-size: 20px; color: var(--navy); display: flex; justify-content: space-between; }
.feed { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 6px; }
.feed .row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 14px; background: #f3f8ff; font-size: 16px; animation: slidein .3s; }
.feed .row .pts { margin-left: auto; color: var(--blue); }
.feed .row.miss { opacity: .6; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0 } to { transform: none; opacity: 1 } }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; }

.track-card { padding: 14px 20px 16px; }
.track-card h3 { margin: 0 0 8px; font-size: 18px; color: var(--navy); display: flex; justify-content: space-between; }
.lanes { display: flex; flex-direction: column; gap: 8px; }
.lane { position: relative; height: 46px; border-radius: 999px; background: repeating-linear-gradient(90deg, #eaf2ff 0 18px, #f6faff 18px 36px); border: 3px solid #fff; box-shadow: inset 0 2px 4px rgba(30,80,160,.12); }
.lanes.compact { gap: 5px; }
.lanes.compact .lane { height: 34px; }
.lanes.compact .lane .runner .rk { font-size: 22px; }
.lanes.compact .lane .goal { font-size: 22px; }
.race-top { min-height: 300px; }
.lane .goal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 30px; }
.lane .runner { position: absolute; top: 50%; left: 0; transform: translate(0,-50%); display: flex; align-items: center; gap: 6px; transition: left 1.2s cubic-bezier(.3,1.4,.5,1); white-space: nowrap; }
.lane .runner .rk { font-size: 32px; transform: rotate(45deg); display: inline-block; }
.lane .runner .nm { font-size: 15px; padding: 3px 10px; border-radius: 999px; color: #fff; }
.lane .runner .sc { font-size: 14px; color: var(--navy); background: #fff; padding: 2px 8px; border-radius: 999px; }
.lane .flame { position: absolute; left: -16px; font-size: 18px; opacity: 0; }
.lane.boost .flame { animation: flame .8s 2; }
@keyframes flame { 50% { opacity: 1 } }

/* intro overlay */
.intro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(20,60,140,.35); z-index: 10; }
.intro .big { font-size: 180px; animation: pop .5s; }
.intro .cnt { font-size: 110px; color: #fff; -webkit-text-stroke: 10px var(--blue); paint-order: stroke fill; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1.4); opacity: .3 } 30% { transform: scale(1); opacity: 1 } }

/* result */
.result-word { font-size: 64px; color: var(--blue); letter-spacing: 6px; }
.fastest { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.fastest .f { background: #fff; border-radius: 16px; padding: 8px 14px; box-shadow: 0 3px 0 #c9daf5; font-size: 16px; }
.next-bar { display: flex; gap: 10px; align-items: center; }

/* final */
.final { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 80px 30px 30px; }
.podium { display: flex; align-items: flex-end; gap: 18px; }
.podium .p { width: 200px; text-align: center; }
.podium .p .who { font-size: 22px; color: var(--navy); margin-bottom: 8px; }
.podium .p .who .e { font-size: 56px; display: block; animation: hover 2s infinite; }
.podium .p .stand { border-radius: 20px 20px 0 0; color: #fff; font-size: 44px; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 12px; box-shadow: inset 0 -8px 0 rgba(0,0,0,.08); }
.podium .p .stand small { font-size: 18px; opacity: .9; }
.rank-list { width: min(760px, 92vw); max-height: 26vh; overflow: auto; padding: 12px 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; }
.rank-list .r { display: flex; gap: 8px; align-items: center; font-size: 16px; padding: 4px 6px; }
.rank-list .r b { width: 28px; color: var(--blue); }
.rank-list .r span:last-child { margin-left: auto; color: var(--sub); }
.confetti { position: fixed; top: -20px; width: 12px; height: 18px; z-index: 50; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- PLAYER ---------- */
.pl { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 16px 16px 24px; gap: 14px; }
.pl-top { width: 100%; max-width: 480px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pl-top img { height: 40px; }
.me { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 999px; padding: 5px 12px 5px 6px; box-shadow: 0 3px 0 #c3d6f5; font-size: 15px; }
.me .av { font-size: 22px; }
.pl-card { width: 100%; max-width: 480px; padding: 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.pl-card h2 { margin: 0; font-size: 24px; color: var(--navy); }
.inp { width: 100%; font-family: inherit; font-size: 22px; padding: 14px 16px; border-radius: 18px; border: 3px solid var(--line); text-align: center; color: var(--navy); outline: none; background: #fff; }
.inp:focus { border-color: var(--sky); }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.avatars button { font-size: 32px; padding: 8px 0; border-radius: 16px; background: #f1f7ff; border: 3px solid transparent; }
.avatars button.on { border-color: var(--blue); background: #fff; }
.team-banner { width: 100%; border-radius: 20px; color: #fff; padding: 16px; font-size: 24px; box-shadow: inset 0 -6px 0 rgba(0,0,0,.1); }
.look { font-size: 18px; color: var(--navy); }
.look .eye { font-size: 50px; display: block; animation: hover 1.6s infinite; }
.p-slots { display: flex; gap: 6px; justify-content: center; flex-wrap: nowrap; width: 100%; }
.p-slot { flex: 0 1 46px; aspect-ratio: 46/56; max-width: 52px; border-radius: 12px; background: #fff; border: 3px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--blue); }
.p-slot.filled { border-color: var(--sky); animation: pop .15s; }
.p-slot.given { background: #fffbe6; border-color: var(--yellow); color: #c27c00; }
.p-slot.hint { background: #fff0f7; border-color: var(--pink); color: #d84586; }
.p-slots.shake { animation: shake .4s; }
.p-slots.ok .p-slot { border-color: var(--green-t); background: #e9fff3; color: #1a9a55; }
@keyframes shake { 20%,60% { transform: translateX(-10px) } 40%,80% { transform: translateX(10px) } }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.tile { aspect-ratio: 1; border-radius: 18px; font-size: 40px; color: var(--navy); background: linear-gradient(#fff, #eef5ff); box-shadow: 0 6px 0 #b9cff2; transition: transform .06s; }
.tile:active { transform: translateY(5px); box-shadow: 0 1px 0 #b9cff2; }
.tile.used { opacity: .18; pointer-events: none; }
.p-actions { display: flex; gap: 10px; width: 100%; }
.p-actions .btn { flex: 1; padding: 12px 8px; font-size: 17px; }
.p-timer { width: 100%; height: 12px; border-radius: 999px; background: #e3eeff; overflow: hidden; }
.p-timer i { display: block; height: 100%; background: linear-gradient(90deg, #ffd23f, #ff9f1a); }
.done-big { font-size: 80px; animation: pop .4s; }
.score-big { font-size: 42px; color: var(--blue); }
.err { color: #d33; font-size: 15px; min-height: 18px; }

@media (max-width: 1100px) {
  .lobby { grid-template-columns: 220px 1fr 260px; }
  .race-top { grid-template-columns: 1fr 300px; }
  .word-pic { font-size: 90px; } .word-mean { font-size: 32px; }
  .slot { width: 50px; height: 60px; font-size: 36px; }
}
.warn { font-size: 13px; line-height: 1.5; color: #9a5b00; background: #fff4d6; border: 2px solid #ffd77a; border-radius: 14px; padding: 8px 10px; }
.start-hint { margin-top: auto; font-size: 13px; line-height: 1.4; color: #c2410c; text-align: center; min-height: 18px; }
.start-hint:empty { display: none; }
.start-hint:not(:empty) + .btn.start { margin-top: 6px; }
