/* 픽셀 판타지 테마 (5판). 겉모습만 바꾸는 파일: 지우면 원래 모양으로 돌아간다.
   배경 그림 art/title.webp(선생님이 ChatGPT로 만든 그림)의 색에 맞췄다: 하늘 파랑 · 풀밭 초록 · 섬 흙 갈색 · 굵은 검은 테두리 */

@font-face {
  font-family: 'DungGeunMo';
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/DungGeunMo.woff') format('woff');
  font-display: swap;
}

:root {
  --ink: #1f1a2e;
  --line: #1f1a2e;
  --paper: #fff8e6;
  --muted: #6b5d4f;
  --sky: #6fa8ff;
  --grass-1: #7cc950;
  --grass-2: #69b844;
  --dirt: #8a5a34;
  --dirt-dark: #5e3a20;
  --gold: #ffc93c;
  --water: #bfe3ff;
  --empty: #7cc950;
  --shadow: 5px 5px 0 rgba(31, 26, 46, 0.55);
  --pixel: 'DungGeunMo', 'Galmuri11', 'Malgun Gothic', monospace;
}

/* 배경: 선생님 그림을 화면 가득. 놀이 화면은 그림을 살짝 어둡게 깔아 땅판이 잘 보이게 */
body {
  font-family: var(--pixel);
  background: var(--sky) url('./art/title.webp') center / cover fixed no-repeat;
  image-rendering: pixelated;
}
/* 게임 고르기(홈) 화면은 여러 게임으로 가는 문이 모인 놀이 광장 그림 (spec 43절) */
body.hub { background-image: url('./art/hub.webp'); }
body.dim::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 46, 0.35);
  z-index: -1;
}
input, textarea, select, button { font-family: var(--pixel); }

/* 제목 글자: 팀 색 글자 + 굵은 검은 외곽선 + 아래 그림자 */
.title {
  font-size: clamp(40px, 9vw, 84px);
  letter-spacing: 0.02em;
  margin: clamp(16px, 6vh, 60px) 0 6px;
  line-height: 1.05;
  word-break: keep-all; /* '땅따 / 먹기' 처럼 낱말 가운데서 끊기지 않게 */
  text-shadow:
    -4px 0 0 var(--ink), 4px 0 0 var(--ink), 0 -4px 0 var(--ink), 0 4px 0 var(--ink),
    -4px -4px 0 var(--ink), 4px -4px 0 var(--ink), -4px 4px 0 var(--ink), 4px 4px 0 var(--ink),
    0 10px 0 rgba(31, 26, 46, 0.45);
}
.title span { color: #ff6b81; }
.title span + span { color: var(--gold); }
.sub {
  color: #fff;
  font-size: clamp(16px, 2.6vw, 22px);
  text-shadow: -2px 0 0 var(--ink), 2px 0 0 var(--ink), 0 -2px 0 var(--ink), 0 2px 0 var(--ink);
}

/* 카드: 양피지 색 판 + 각진 굵은 테두리 + 픽셀 그림자 */
.card {
  background: var(--paper);
  border: 4px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow), inset 0 -6px 0 rgba(138, 90, 52, 0.18);
}
.team-col, .chip, .badge, .score, .map-opt, .qr-btn, input, textarea, select, .timer-bar, .bar { border-radius: 0; }

/* 단추: 각진 금색 블록 + 아래쪽 어두운 면 (눌리면 내려감) */
.btn {
  border-radius: 0;
  border: 4px solid var(--line);
  box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.22), inset 4px 4px 0 rgba(255, 255, 255, 0.45), 0 5px 0 var(--line);
  letter-spacing: 0.02em;
}
.btn:active { transform: translateY(5px); box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.22), 0 0 0 var(--line); }
.btn.ghost { background: #fff8e6; }
.btn.big { font-size: 24px; }
.btn.sm { border-width: 3px; box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.15), 0 3px 0 var(--line); }

input, textarea, select { border-width: 3px; background: #fffdf5; }

/* 땅판: 떠 있는 섬처럼 흙 테두리 + 바둑판 풀밭 */
.board {
  background: var(--dirt);
  border: 4px solid var(--line);
  border-bottom-width: 14px;
  border-bottom-color: var(--dirt-dark);
  border-radius: 0;
  gap: 3px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.cell { border-radius: 0; background: var(--grass-1); font-family: var(--pixel); }
.cell.alt { background: var(--grass-2); }
.cell.star, .cell.star.alt { background: #ffe58a; }
.cell.t0 { background: var(--t0); }
.cell.t1 { background: var(--t1); }
.cell.t2 { background: var(--t2); }
.cell.t3 { background: var(--t3); }
.cell.t0, .cell.t1, .cell.t2, .cell.t3 { box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2), inset 0 3px 0 rgba(255, 255, 255, 0.3); }
.cell.base { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6), inset 0 -5px 0 rgba(0, 0, 0, 0.25); }
/* ───── 움직이는 그림 조각 (spec 16절) ─────
   board.js 가 칸 안에 <img class="spr k-종류"> 를 세운다. --d 는 칸마다 다른 박자 */
.cell { position: relative; }
.cell .spr { position: absolute; pointer-events: none; image-rendering: auto; user-select: none; }
.cell .txt { position: relative; z-index: 2; }
.cell.has-art { font-size: clamp(10px, 1.6vw, 18px); }

/* 큰 그림: 칸 가운데 */
.spr.k-castle, .spr.k-flag, .spr.k-chest, .spr.k-star, .spr.k-hourglass { left: 50%; top: 50%; translate: -50% -50%; }
.spr.k-castle { width: 94%; animation: breathe 2.8s ease-in-out infinite var(--d); transform-origin: 50% 90%; }
.spr.k-flag { height: 80%; animation: wave 1.5s ease-in-out infinite var(--d); transform-origin: 30% 92%; }
.spr.k-star { width: 66%; animation: float 2.2s ease-in-out infinite var(--d), twinkle 1.6s ease-in-out infinite var(--d); }
.spr.k-chest { width: 76%; animation: hop 1.1s ease-in-out infinite; transform-origin: 50% 100%; }
.spr.k-hourglass { height: 74%; animation: flip 2s ease-in-out infinite; }

/* 작은 그림: 구석에 */
.spr.k-shield { width: 38%; right: 2%; top: 2%; z-index: 1; animation: pulse 1.2s ease-in-out infinite; }
.spr.k-sparkle { width: 40%; left: 1%; top: 1%; z-index: 1; animation: glitter 1.4s ease-in-out infinite var(--d); }

@keyframes breathe { 50% { transform: scale(1.03, 0.97); } }
@keyframes wave { 0%, 100% { transform: skewY(0deg) scaleX(1); } 30% { transform: skewY(-5deg) scaleX(0.95); } 65% { transform: skewY(3deg) scaleX(1.02); } }
@keyframes float { 50% { transform: translateY(-10%); } }
@keyframes twinkle { 50% { opacity: 0.75; } }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0) scale(1, 1); } 70% { transform: translateY(0) scale(1.1, 0.88); } 82% { transform: translateY(-16%) scale(0.95, 1.06); } }
@keyframes flip { 0%, 40% { transform: rotate(0deg); } 50%, 90% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.15); } }
@keyframes glitter { 0%, 100% { transform: scale(0.85) rotate(0deg); opacity: 0.7; } 50% { transform: scale(1.1) rotate(20deg); opacity: 1; } }

/* 땅 차지: 깃발이 위에서 떨어져 퉁 꽂힘. 폭탄: 칸이 흔들 */
.cell[data-fx='pop'] { z-index: 3; }
.cell[data-fx='pop'] .spr.k-flag { animation: plant 0.55s cubic-bezier(0.3, 0.6, 0.4, 1.4); }
.cell[data-fx='boom'] { animation: boom 0.5s ease-out; }
@keyframes plant { 0% { transform: translateY(-120%) scale(0.7); opacity: 0; } 60% { transform: translateY(6%) scale(1.1, 0.85); opacity: 1; } 100% { transform: translateY(0) scale(1); } }

/* 첫 화면: 제목 글자가 번갈아 통통, 반짝이 가루가 하늘에 천천히 떠다님 */
.title span { display: inline-block; animation: bounce 2.4s ease-in-out infinite; }
.title span + span { animation-delay: -1.2s; }
@keyframes bounce { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
#s-join, #s-login, #s-pick { position: relative; }
#s-join::before, #s-login::before, #s-pick::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle, #fff7b0 0 2px, transparent 3px),
    radial-gradient(circle, #ffffff 0 1.5px, transparent 2.5px),
    radial-gradient(circle, #ffe27a 0 2px, transparent 3px);
  background-size: 180px 160px, 130px 210px, 260px 190px;
  background-position: 0 0, 40px 60px, 90px 20px;
  animation: drift 18s linear infinite;
  opacity: 0.85;
}
@keyframes drift { to { background-position: 180px -160px, -90px -210px, 350px -190px; } }
#join-form .btn.big, #login-form .btn.big { animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-4px); } 90% { transform: translateY(0); } }

/* 가방 속 아이템이 둥실 */
.bag .slot img.ico { animation: float-sm 1.8s ease-in-out infinite; }
.bag .slot:nth-child(3) img.ico { animation-delay: -0.9s; }
@keyframes float-sm { 50% { transform: translateY(-3px) rotate(-4deg); } }

/* 대기 화면 미리보기는 조용히 */
.preview .spr { animation: none !important; }

/* 움직임을 줄이도록 설정한 기기에서는 멈춤 */
@media (prefers-reduced-motion: reduce) {
  .spr, .title span, .bag .slot img.ico, #s-join::before, #s-login::before, #s-pick::before, .btn.big { animation: none !important; }
}
.cell.has-art.gold { box-shadow: inset 0 0 0 4px var(--gold), inset 0 -5px 0 rgba(0, 0, 0, 0.2); }
/* 별 땅·보물 상자 칸은 그림이 있으니 노란 바탕 대신 풀밭 그대로 */
.cell.has-art.star:not(.t0):not(.t1):not(.t2):not(.t3), .cell.has-art.chest:not(.t0):not(.t1):not(.t2):not(.t3) { background-color: var(--grass-1); animation: none; }
.cell.has-art.star.alt:not(.t0):not(.t1):not(.t2):not(.t3), .cell.has-art.chest.alt:not(.t0):not(.t1):not(.t2):not(.t3) { background-color: var(--grass-2); }

/* 그림 아이콘 (아이템 · 팀 성) */
img.ico { width: 1.4em; height: 1.4em; vertical-align: -0.35em; image-rendering: auto; }
img.ico.big { width: 1.9em; height: 1.9em; vertical-align: -0.5em; }
.bag .slot img.ico { width: 30px; height: 30px; }
/* 들어갈 수 없는 칸 = 섬 사이로 보이는 하늘 */
.cell.void, .cell.void.alt {
  background: var(--water);
  background-image: radial-gradient(#fff 22%, transparent 24%);
  background-size: 12px 12px;
  opacity: 1;
}
.board.maze .cell.void { background: #8b8b9b; background-image: linear-gradient(#a5a5b5 50%, #8b8b9b 50%); background-size: 100% 10px; }
.cell.pickable { box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 7px var(--ink); }
.board.golden { background: #b8860b; border-bottom-color: #7a5a08; }

/* 점수판 · 시계 */
.score { border: 4px solid var(--line); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2), 4px 4px 0 rgba(31, 26, 46, 0.5); font-family: var(--pixel); }
.clock {
  font-family: var(--pixel);
  color: #fff;
  text-shadow: -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink);
}
.clock.hurry { color: #ff6b81; }

/* 점수 칸: [성] 이름… 점수 — 점수는 절대 안 잘리게 */
.scores .score { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; }
.scores .score .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 0.72em; }
.scores .score { gap: 4px; padding-left: 6px; padding-right: 6px; }
.scores .score b { flex: none; }
.scores .score img.ico { flex: none; }

/* 방 번호 · 결과 제목 */
.code, #end-title { font-family: var(--pixel); }
.code { color: var(--ink); text-shadow: 5px 5px 0 var(--gold); }

/* 알림 띠 · 토스트 */
#banner { border-radius: 0; border-width: 4px; font-family: var(--pixel); box-shadow: var(--shadow); }
#toast { border-radius: 0; border: 3px solid #fff; font-family: var(--pixel); }

/* 문제 창 */
.quiz .q { font-size: clamp(22px, 4.8vw, 30px); line-height: 1.5; }
.choices .btn { background: #fffdf5; }
.choices .btn:hover { background: var(--gold); }
.timer-bar { border-width: 3px; height: 14px; }
.timer-bar i { background: repeating-linear-gradient(90deg, var(--gold) 0 10px, #ffb000 10px 20px); }
.overlay { background: rgba(31, 26, 46, 0.6); }

.team-col { border-width: 4px; }
.chip { border-width: 3px; }
.map-opt.on { background: var(--gold); }
#offline { font-family: var(--pixel); }

/* ───── 육각 칸 (spec 17절) ─────
   board.js 가 칸마다 자리(left·top·width·height)를 정한다.
   칸(button) 자체는 테두리 색(--ring), 안쪽 ::before 가 칸 색(--fill)을 칠한 조금 작은 육각형.
   → 고를 수 있는 칸은 흰 테두리, 문제 푸는 중은 팀 색 테두리, 황금 땅은 금 테두리가 육각형 모양 그대로 생긴다. */
.board.hex {
  display: block;
  position: relative;
  padding: 0;
  height: auto;
  border-radius: 18px;
  background: var(--dirt);
}
.board.hex .cell {
  position: absolute;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  --fill: var(--grass-1);
  --ring: rgba(31, 26, 46, 0.35);
  background: var(--ring) !important;
  box-shadow: none !important;
  outline: none !important;
  border-radius: 0;
  padding: 0;
  display: grid;
  place-items: center;
  transform: scale(0.97);
}
.board.hex .cell::before {
  content: '';
  position: absolute;
  inset: 3px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 32%, rgba(0, 0, 0, 0) 68%, rgba(0, 0, 0, 0.2)),
    var(--fill);
}
.board.hex .cell .spr, .board.hex .cell .txt { z-index: 1; }
.board.hex .cell .spr.k-shield, .board.hex .cell .spr.k-sparkle { z-index: 2; width: 34%; top: 14%; }
.board.hex .cell .spr.k-shield { right: 8%; }
.board.hex .cell .spr.k-sparkle { left: 8%; }
/* 육각형 안쪽에 쏙 들어가는 크기: 가운데 가로 약 70% · 세로 약 60% 안에 그림이 들어가게 */
.board.hex .cell .spr.k-castle { width: 68%; top: 46%; }
.board.hex .cell .spr.k-flag { height: 58%; top: 52%; }
.board.hex .cell .spr.k-star { width: 54%; }
.board.hex .cell .spr.k-chest { width: 60%; }
.board.hex .cell .spr.k-hourglass { height: 54%; }

/* 칸 색 (--fill) */
.board.hex .cell.alt { --fill: var(--grass-2); }
.board.hex .cell.star { --fill: #ffe58a; }
.board.hex .cell.has-art.star, .board.hex .cell.has-art.chest { --fill: var(--grass-1); }
.board.hex .cell.has-art.star.alt, .board.hex .cell.has-art.chest.alt { --fill: var(--grass-2); }
.board.hex .cell.t0 { --fill: var(--t0); }
.board.hex .cell.t1 { --fill: var(--t1); }
.board.hex .cell.t2 { --fill: var(--t2); }
.board.hex .cell.t3 { --fill: var(--t3); }
.board.hex .cell.void { --fill: var(--water); --ring: transparent; }
.board.hex .cell.void::before { background-image: radial-gradient(#fff 22%, transparent 24%); background-size: 12px 12px; background-color: var(--water); }
.board.hex.maze .cell.void { --fill: #8b8b9b; }
.board.hex.maze .cell.void::before { background: linear-gradient(#a5a5b5 50%, #8b8b9b 50%) 0 0 / 100% 10px; }

/* 테두리 색 (--ring): 본진 · 황금 땅 · 문제 푸는 중 · 고를 수 있는 칸 */
.board.hex .cell.base { --ring: #fff8e6; }
.board.hex .cell.gold { --ring: var(--gold); }
.board.hex .cell.locked.lk0 { --ring: var(--t0); }
.board.hex .cell.locked.lk1 { --ring: var(--t1); }
.board.hex .cell.locked.lk2 { --ring: var(--t2); }
.board.hex .cell.locked.lk3 { --ring: var(--t3); }
.board.hex .cell.pickable { --ring: #ffffff; cursor: pointer; animation: hex-glow 0.9s ease-in-out infinite alternate; }
.board.hex .cell.pickable::before { inset: 5px; }
.board.hex .cell.pickable:hover { transform: scale(1.04); z-index: 2; }
.board.hex.aiming .cell.pickable { --ring: var(--gold); }
@keyframes hex-glow { from { filter: brightness(1); } to { filter: brightness(1.18); } }
.board.hex .cell.locked { animation: none; }
.board.hex .cell[data-fx='boom'] { animation: boom 0.5s ease-out; }

.board.hex.golden { background: #b8860b; }

/* ───── 땅 무늬 (spec 20절) ─────
   art/tiles.webp 의 네모 무늬를 육각 칸 모양으로 오려 깐다. board.js 가 --tex-grass · flower · sky · stone 을 넘겨 준다.
   층: 위아래 입체감 · 팀 색 덮개(--tint) · 무늬 · 칸 색(--fill, 무늬가 없을 때) */
.board.hex.textured .cell { --tex: var(--tex-grass); --tint: rgba(0, 0, 0, 0); }
.board.hex.textured .cell.fl { --tex: var(--tex-flower); }
.board.hex.textured .cell.alt { --tint: rgba(0, 40, 0, 0.07); }
.board.hex.textured .cell::before {
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.22)),
    linear-gradient(var(--tint), var(--tint)),
    var(--tex) center / 150% auto,
    var(--fill);
  image-rendering: pixelated;
}
/* 왕국 땅: 풀밭 무늬의 '색'만 왕국 색으로 바꾼다 (밝고 어두운 풀잎 무늬는 그대로).
   그냥 덮으면 빨강+초록이 섞여 흙색이 되므로 color 섞기 + 살짝 밝게 */
.board.hex.textured .cell.t0 { --tint: #ff4f6d; }
.board.hex.textured .cell.t1 { --tint: #3f7bff; }
.board.hex.textured .cell.t2 { --tint: #ffc21a; }
.board.hex.textured .cell.t3 { --tint: #22c46e; }
.board.hex.textured .cell.t0::before, .board.hex.textured .cell.t1::before, .board.hex.textured .cell.t2::before, .board.hex.textured .cell.t3::before {
  background-blend-mode: normal, color, normal, normal;
  filter: brightness(1.12) saturate(1.15);
}
/* 별 땅(그림이 아직 없을 때만 노란빛) */
.board.hex.textured .cell.star:not(.has-art) { --tint: rgba(255, 220, 90, 0.55); }
/* 들어갈 수 없는 칸: 하늘(물) · 미로는 돌담 */
.board.hex.textured .cell.void { --tex: var(--tex-sky); --tint: rgba(0, 0, 0, 0); }
.board.hex.textured .cell.void::before { background: var(--tex) center / 160% auto; }
.board.hex.textured.maze .cell.void { --tex: var(--tex-stone); }
.board.hex.textured.maze .cell.void::before { background: var(--tex) center / 120% auto; }

/* ───── 살아 있는 땅 (spec 23절 → 47절에서 가볍게) ─────
   예전: 칸마다 풀 무늬·구름을 움직였더니(칸 117개 × 매 순간 다시 그리기) 크롬북이 초당 5장밖에 못 그렸다.
   지금: 땅판 전체 위로 바람 빛 한 줄기만 지나간다 (transform 만 움직여서 그래픽 칩이 처리 → 거의 공짜) */
.board .wind { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.board .wind::before {
  content: ''; position: absolute; top: -10%; bottom: -10%; left: -35%; width: 30%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.13) 50%, rgba(255, 255, 255, 0));
  animation: wind-pass 7s linear infinite; will-change: transform;
}
@keyframes wind-pass { from { transform: translateX(0) skewX(-12deg); } to { transform: translateX(480%) skewX(-12deg); } }
.preview .wind { display: none; }

/* ───── 성 효과 층 (spec 23절) ─────
   board.js 가 성 칸 자리에 .fx.fx-t(왕국) 를 띄운다. 안의 <i>·<b> 가 효과 조각. cqw = 효과 칸 너비의 1% */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.fx { position: absolute; pointer-events: none; container-type: size; }
.fx i, .fx b { position: absolute; display: block; pointer-events: none; }

/* 🔥 플레임하트: 몇 초마다 성 꼭대기에서 불기둥이 화르륵 + 불씨가 튐 */
.fx-t0 i {
  left: 32%; width: 36%; bottom: 62%; height: 120%;
  transform-origin: 50% 100%;
  clip-path: polygon(50% 0, 62% 18%, 58% 30%, 76% 26%, 70% 48%, 92% 46%, 78% 72%, 100% 82%, 70% 100%, 30% 100%, 0 82%, 22% 72%, 8% 46%, 30% 48%, 24% 26%, 42% 30%, 38% 18%);
  background: linear-gradient(to top, #fff6b0 0%, #ffd23a 25%, #ff8a1e 55%, #ff3b1e 80%, rgba(255, 59, 30, 0) 100%);
  animation: fire-breath 5.5s infinite; animation-delay: var(--d, 0s);
}
@keyframes fire-breath {
  0%, 62% { transform: scaleY(0) scaleX(0.6); opacity: 0; }
  66% { transform: scaleY(1.15) scaleX(1); opacity: 1; }
  70% { transform: scaleY(0.85) scaleX(1.1); }
  74% { transform: scaleY(1.1) scaleX(0.95); }
  78% { transform: scaleY(0.9) scaleX(1.05); }
  84% { transform: scaleY(0.6) scaleX(0.8); opacity: 0.8; }
  90%, 100% { transform: scaleY(0) scaleX(0.5); opacity: 0; }
}
.fx-t0 b {
  left: 48%; top: 20%; width: 5cqw; height: 5cqw; background: #ffd23a;
  box-shadow: -14cqw -6cqw 0 #ff8a1e, 12cqw -10cqw 0 #ffe066, -6cqw -22cqw 0 #ff5a1e, 16cqw -26cqw 0 #ffd23a, -18cqw -30cqw 0 #ffb02e;
  opacity: 0; animation: embers 5.5s infinite; animation-delay: var(--d, 0s);
}
@keyframes embers { 0%, 64% { transform: translateY(0); opacity: 0; } 68% { opacity: 1; } 90% { transform: translateY(-40cqw); opacity: 0; } 100% { opacity: 0; } }

/* 🌊 아쿠아리스: 분수에서 물줄기가 솟고 물방울이 튐 */
/* 효과 조각에 그림들처럼 진한 외곽선 (픽셀 그림 느낌) */
.fx-t1 i, .fx-t1 b, .fx-t2 b, .fx-t3 i, .fx-t3 b { --ol: #1b2a4a; filter: drop-shadow(1px 0 0 var(--ol)) drop-shadow(-1px 0 0 var(--ol)) drop-shadow(0 1px 0 var(--ol)) drop-shadow(0 -1px 0 var(--ol)); }
.fx-t1 i {
  left: 37%; width: 26%; bottom: 50%; height: 70%;
  transform-origin: 50% 100%; border-radius: 45% 45% 0 0;
  background: linear-gradient(to top, #2f7dff, #4fb4ff 35%, #a8e6ff 75%, #ffffff);
  animation: fountain 4.2s infinite; animation-delay: var(--d, 0s);
}
@keyframes fountain { 0%, 55% { transform: scaleY(0); opacity: 0; } 62% { transform: scaleY(1.1); opacity: 1; } 75% { transform: scaleY(0.9); opacity: 1; } 85%, 100% { transform: scaleY(0); opacity: 0; } }
.fx-t1 b {
  left: 44%; top: -22%; width: max(6px, 12cqw); height: max(6px, 12cqw); border-radius: 50%; background: #7fd2ff;
  box-shadow: -22cqw 8cqw 0 #4fb4ff, 22cqw 6cqw 0 #a8e6ff, -34cqw 26cqw 0 #7fd2ff, 34cqw 24cqw 0 #4fb4ff;
  opacity: 0; animation: splash 4.2s infinite; animation-delay: var(--d, 0s);
}
@keyframes splash { 0%, 60% { transform: translateY(6cqw) scale(0.4); opacity: 0; } 68% { transform: translateY(-8cqw) scale(1); opacity: 1; } 86% { transform: translateY(18cqw) scale(0.9); opacity: 0; } 100% { opacity: 0; } }

/* ⚡ 볼테리아: 가끔 번개가 내리치며 번쩍 */
/* b = 번개(외곽선은 b 에, 번개 모양은 b::before 에: 모양 오리기가 외곽선까지 잘라 먹지 않게) · i = 번쩍 빛 */
.fx-t2 b {
  left: 18%; width: 64%; top: -100%; height: 135%; --ol: #3a2a00;
  opacity: 0; animation: bolt 6.5s infinite; animation-delay: var(--d, 0s);
}
.fx-t2 b::before {
  content: ''; position: absolute; inset: 0;
  clip-path: polygon(52% 0, 18% 50%, 46% 50%, 22% 100%, 84% 40%, 56% 40%, 86% 0);
  background: linear-gradient(to bottom, #ffffff, #fff27a 40%, #ffd21a);
}
@keyframes bolt { 0%, 78% { opacity: 0; } 79%, 81% { opacity: 1; } 82%, 84% { opacity: 0; } 85%, 87% { opacity: 1; } 88%, 100% { opacity: 0; } }
.fx-t2 i {
  inset: -30%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 250, 200, 0.85) 0, rgba(255, 230, 80, 0.4) 35%, rgba(255, 230, 80, 0) 65%);
  opacity: 0; animation: flash 6.5s infinite; animation-delay: var(--d, 0s);
}
@keyframes flash { 0%, 78% { opacity: 0; } 80% { opacity: 1; } 83% { opacity: 0; } 86% { opacity: 0.8; } 92%, 100% { opacity: 0; } }

/* 🌱 리프리아: 나무 성 둘레를 반딧불이 반짝이며 맴돎 */
.fx-t3 i, .fx-t3 b {
  left: 44%; top: 6%; width: max(7px, 12cqw); height: max(7px, 12cqw); border-radius: 50%; background: #fffb8a;
  --ol: #2c4a00; --g: max(4px, 7cqw);
  box-shadow: 0 0 var(--g) 2px rgba(255, 255, 140, 0.95), -36cqw 24cqw 0 #fffb8a, -36cqw 24cqw var(--g) 2px rgba(255, 255, 140, 0.9), 36cqw 20cqw 0 #f0ff6e, 36cqw 20cqw var(--g) 2px rgba(255, 255, 140, 0.9);
  animation: firefly 3.4s ease-in-out infinite alternate; animation-delay: var(--d, 0s);
}
.fx-t3 b {
  top: 62%;
  box-shadow: 0 0 var(--g) 2px rgba(255, 255, 140, 0.95), 36cqw -28cqw 0 #fffb8a, 36cqw -28cqw var(--g) 2px rgba(255, 255, 140, 0.9), -40cqw -8cqw 0 #f0ff6e, -40cqw -8cqw var(--g) 2px rgba(255, 255, 140, 0.9);
  animation-duration: 4.3s; animation-direction: alternate-reverse;
}
@keyframes firefly {
  0% { transform: translate(0, 0); opacity: 0.3; }
  30% { transform: translate(6cqw, -8cqw); opacity: 1; }
  60% { transform: translate(-6cqw, -4cqw); opacity: 0.5; }
  100% { transform: translate(4cqw, 6cqw); opacity: 1; }
}

/* 대기 화면 미리보기·움직임 줄이기 설정에서는 조용히 */
.preview .fx-layer { display: none; }
@media (prefers-reduced-motion: reduce) {
  .fx-layer { display: none; }
  .board .wind { display: none; }
}

/* ───── 학생 놀이 화면 배치 (spec 22절) ─────
   화면 높이를 다 쓰는 세로 줄: 점수판(고정) · 땅판 창(가득, 밀어서 움직임) · 가방·안내(고정) */
.play { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 1100px; margin: 0 auto; padding: 8px 8px 6px; box-sizing: border-box; position: relative; }
.play .scorebar { flex: none; margin-bottom: 6px; }
.board-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 18px;
  scrollbar-width: thin;
}
.board-wrap { display: grid; position: relative; } /* grid + margin:auto → 작으면 가운데, 크면 밀어서 보기 */
.board-wrap .board { margin: auto; }
.board-wrap.zoomed { cursor: grab; }

/* 가방: 아이템 단추 = 큰 그림 + 작은 이름 */
.bag .slot { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; }
.bag .slot .nm { font-size: 15px; }
.bag .ready, .bag .fire { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: #fff; text-shadow: -2px 0 0 var(--ink), 2px 0 0 var(--ink), 0 -2px 0 var(--ink), 0 2px 0 var(--ink); }
.bag .bag-ic { font-size: 22px; }

/* 아이템을 고른 중: 땅판 위 큰 안내 띠 */
.aim-msg {
  position: absolute; left: 50%; top: 58px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px);
  background: var(--gold); border: 4px solid var(--line); box-shadow: var(--shadow); padding: 6px 8px 6px 14px;
  font-weight: 800; font-size: clamp(15px, 3.2vw, 20px); animation: blink 0.6s infinite alternate;
}
.aim-msg .btn { font-size: 16px; padding: 6px 12px; background: #fff8e6; }

/* 휴대폰 세로: 놀이 중이면 '가로로 돌려 주세요' (그냥 세로로 할래요를 누르면 닫힘) */
.rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) and (pointer: coarse) {
  body.playing:not(.portrait-ok) .rotate {
    display: flex; position: fixed; inset: 0; z-index: 40; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: rgba(31, 26, 46, 0.92); color: #fff; text-align: center; font-size: 20px; padding: 24px;
  }
}
.rotate-icon { font-size: 72px; animation: turn 1.6s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }
.rotate .btn { font-size: 16px; }

/* ───── 휴대폰 가로 (높이가 낮은 가로 화면) ─────
   [시계·점수] [땅판 가득] [확대·아이템 큰 단추] 세 줄 */
@media (orientation: landscape) and (max-height: 520px) {
  .play {
    display: grid; height: 100vh; height: 100dvh; padding: 6px; gap: 6px;
    grid-template-columns: minmax(120px, 17vw) 1fr 88px;
    grid-template-rows: auto 1fr;
    grid-template-areas: 'side board zoom' 'side board bag';
  }
  .play .scorebar { grid-area: side; display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin: 0; }
  .play .scorebar .clock { order: 0; font-size: 26px; text-align: center; }
  .play .scores { flex: none; flex-direction: column; gap: 6px; }
  .play .scores .score img.ico { width: 26px; height: 26px; }
  .play .scores .score { justify-content: space-between; padding: 6px 8px; font-size: 14px; }
  .board-wrap { grid-area: board; }
  .zoom-ctl { grid-area: zoom; position: static; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .zoom-ctl .btn { width: 40px; height: 40px; font-size: 18px; }
  .play-bottom { grid-area: bag; padding: 0; display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; }
  .play-bottom .bag { flex-direction: column; flex-wrap: nowrap; gap: 6px; }
  .play-bottom .bag .bag-ic { display: none; }
  .play-bottom .bag .slot { flex-direction: column; justify-content: center; gap: 0; width: 84px; min-width: 0; height: 74px; padding: 2px; }
  .play-bottom .bag .slot img.ico { width: 40px; height: 40px; }
  .play-bottom .bag .slot .nm { font-size: 12px; }
  .play-bottom .bag .ready .nm { display: none; }
  .play-bottom .sub { display: none; }
  .aim-msg { top: 8px; }
  body.dim #sound-btn { top: auto; bottom: 8px; left: 8px; right: auto; width: 40px; height: 40px; padding: 0; font-size: 18px; }
  /* 문제 창이 낮은 화면에 다 들어가게 */
  .overlay { padding: 6px; }
  .quiz { max-height: calc(100dvh - 12px); overflow: auto; padding: 10px 14px; }
  .quiz .q { font-size: 20px; margin: 4px 0 8px; }
  .choices .btn { font-size: 17px; padding: 8px 10px; }
}
.play-bottom { flex: none; padding-top: 6px; }
.play-bottom .bag { margin-top: 0; }
.play-bottom .sub { margin: 6px 0 0; font-size: clamp(13px, 3.4vw, 18px); line-height: 1.4; }
.zoom-ctl { position: absolute; right: 16px; top: 64px; display: flex; flex-direction: column; gap: 6px; z-index: 4; }
.zoom-ctl .btn { width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.15), 0 3px 0 var(--line); border-width: 3px; }
/* 휴대폰: 효과음 단추는 확대 단추 아래로 (가방과 겹치지 않게) */
@media (max-width: 700px) {
  body.dim #sound-btn { top: 222px; bottom: auto; right: 16px; width: 44px; height: 44px; padding: 0; }
  .play .clock { font-size: 22px; min-width: 2.8em; }
  .play .scores .score { padding: 4px 6px; font-size: 15px; }
  .play .scores .score b { font-size: 1.2em; }
}

/* 🏰 포위당하기 직전인 성 (spec 19절): 빨간 테두리가 깜빡이고 성이 덜덜 */
.board.hex .cell.base.danger { --ring: #ff2b4a; animation: hex-alarm 0.5s steps(2) infinite; z-index: 2; }
.board.hex .cell.base.danger .spr.k-castle { animation: shiver 0.3s linear infinite; }
@keyframes hex-alarm { 50% { --ring: #ffffff; filter: brightness(1.2); } }
@keyframes shiver { 25% { transform: translateX(-3%); } 75% { transform: translateX(3%); } }

/* 알림 띠: 포위 경고 · 포위 승리 */
#banner.danger { background: #ff2b4a; color: #fff; border-color: #fff; animation: banner-shake 0.4s ease-in-out 3; }
#banner.siege { background: var(--gold); color: var(--ink); font-size: clamp(20px, 4vw, 34px); }
@keyframes banner-shake { 25% { margin-left: -6px; } 75% { margin-left: 6px; } }
.preview.board.hex .cell::before { inset: 1px; }

/* ───── 결과 발표 슬롯머신 (spec 25절, reveal.js) ───── */
.reveal {
  position: fixed; inset: 0; z-index: 40; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 3vh, 26px);
  background: radial-gradient(circle at 50% 45%, #3c286e, #140e28); /* 꽉 막아서 뒤의 결과 화면이 미리 안 보이게 */
  font-family: var(--pixel); color: #fff; text-align: center; padding: 16px;
  transition: opacity 0.4s;
}
.reveal.out { opacity: 0; pointer-events: none; }
.rv-head { margin: 0; font-size: clamp(26px, 6vw, 56px); text-shadow: 4px 4px 0 #1f1a2e; animation: rv-beat 0.45s steps(2) infinite; }
.reveal.stopped .rv-head { animation: none; color: var(--gold); }
@keyframes rv-beat { 50% { transform: scale(1.06); } }
/* 기계: 금빛 틀 + 둘레에 깜빡이는 전구 */
.rv-machine {
  --h: clamp(110px, 26vh, 200px);
  position: relative; padding: 18px; background: #ffcf3a;
  border: 6px solid #1f1a2e; box-shadow: inset 0 -8px 0 #d99a10, 8px 8px 0 rgba(0, 0, 0, 0.45);
}
.rv-machine::before, .rv-machine::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 8px;
  background: radial-gradient(circle, #fff 0 3px, transparent 4px) 0 0 / 22px 8px repeat-x;
  animation: rv-lights 0.5s steps(1) infinite;
}
.rv-machine::before { top: 4px; }
.rv-machine::after { bottom: 4px; animation-delay: -0.25s; }
@keyframes rv-lights { 50% { background-position: 11px 0; filter: hue-rotate(180deg); opacity: 0.5; } }
.reveal.stopped .rv-machine::before, .reveal.stopped .rv-machine::after { animation-duration: 0.18s; }
.rv-window {
  position: relative; width: clamp(240px, 52vw, 460px); height: var(--h); overflow: hidden; box-sizing: content-box; /* 안쪽이 칸 하나 높이 그대로 */
  background: #fff8e6; border: 5px solid #1f1a2e;
}
/* 위아래 그늘: 둥근 원통이 도는 느낌 */
.rv-window::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent 28%, transparent 72%, rgba(0, 0, 0, 0.45));
}
.rv-strip { will-change: transform; }
.rv-item {
  height: var(--h); display: flex; align-items: center; justify-content: center; gap: 0.5em;
  font-size: clamp(24px, 5vw, 46px); color: #fff; text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
  border-bottom: 4px solid rgba(0, 0, 0, 0.2);
}
.rv-item.t0 { background: var(--t0); }
.rv-item.t1 { background: var(--t1); }
.rv-item.t2 { background: var(--t2); }
.rv-item.t3 { background: var(--t3); }
.rv-item.tie { background: #b48cff; }
.rv-ico { width: calc(var(--h) * 0.72); height: calc(var(--h) * 0.72); object-fit: contain; filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.35)); }
.rv-emoji { font-size: 1.6em; }
.rv-item.win { animation: rv-win 0.5s steps(3) 3; }
@keyframes rv-win { 50% { filter: brightness(1.35); } }
.rv-name { margin: 0; min-height: 1.3em; word-break: keep-all; font-size: clamp(26px, 6vw, 54px); text-shadow: 4px 4px 0 #1f1a2e; }
.reveal.stopped .rv-name { animation: rv-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes rv-pop { from { transform: scale(0.3); opacity: 0; } }
.rv-skip { margin: 0; font-size: 14px; opacity: 0.6; }
/* 낮은 가로 휴대폰 화면 */
@media (max-height: 520px) {
  .reveal { gap: 6px; }
  .rv-machine { --h: 34vh; padding: 12px; }
  .rv-head, .rv-name { font-size: clamp(22px, 8vh, 36px); }
  .rv-item { font-size: clamp(22px, 9vh, 40px); }
}

/* ───── 승리 목표 안내 (spec 33절, goal.js) ───── 게임 시작 때 4.5초 떴다가 사라짐 */
.goal { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 16px; background: rgba(20, 14, 40, 0.55); cursor: pointer; animation: goal-in 0.35s ease-out; transition: opacity 0.5s; }
.goal.out { opacity: 0; pointer-events: none; }
.goal-card {
  width: min(640px, 100%); padding: clamp(14px, 3vw, 26px) clamp(16px, 4vw, 32px);
  background: #fff8e6; border: 6px solid #1f1a2e; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08), 8px 8px 0 rgba(0, 0, 0, 0.45);
  font-family: var(--pixel); color: var(--ink, #1f1a2e); animation: goal-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.goal-head { margin: 0 0 10px; text-align: center; font-size: clamp(26px, 5vw, 44px); color: #e0402e; text-shadow: 3px 3px 0 #ffd23a; }
.goal-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; font-size: clamp(17px, 2.8vw, 26px); line-height: 1.35; word-break: keep-all; }
.goal-row img.ico.big { flex: none; width: 2.2em; height: 2.2em; }
.goal-emo { flex: none; width: 2.2em; text-align: center; font-size: 1.3em; }
@keyframes goal-in { from { opacity: 0; } }
@keyframes goal-pop { from { transform: scale(0.6); opacity: 0; } }
/* 맵 칸의 승리 조건 (spec 33절) */
.win-rule { margin: 10px 0 0; padding: 8px 10px; font-size: 14px; line-height: 1.45; background: #fff3c4; border: 3px solid #e0b020; }
@media (max-height: 520px) { .goal-row { font-size: 16px; } .goal-head { font-size: 24px; margin-bottom: 4px; } }

/* ───── 게임 고르기 (spec 34절) ───── 카드 위쪽은 표지 그림(art/cover-*.webp, 가로 3:2) */
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; margin-top: 10px; }
.game-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 0 0 18px; overflow: hidden;
  font: inherit; color: var(--ink, #1f1a2e); text-align: center; background: #fff8e6;
  border: 5px solid #1f1a2e; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08), 7px 7px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.game-cover { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-bottom: 5px solid #1f1a2e; margin-bottom: 8px; transition: filter 0.15s; }
.game-card:hover { transform: translateY(-6px) rotate(-0.5deg); box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08), 10px 12px 0 rgba(0, 0, 0, 0.45); }
.game-card:hover .game-cover { filter: brightness(1.08) saturate(1.1); }
.game-card:active { transform: translateY(1px); box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08), 3px 3px 0 rgba(0, 0, 0, 0.45); }
.game-card b { font-size: 28px; padding: 0 12px; }
.game-card small { font-size: 15px; color: #6a6474; padding: 0 12px; }
/* 아직 없는 게임: 물음표 카드 (그림 없이) */
.game-card.soon { cursor: default; background: #e9e5f0; border-style: dashed; color: #8a8494; box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.25); }
.game-card.soon:hover { transform: none; box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.25); }
.soon-cover {
  display: grid; place-items: center; font-size: 110px; font-weight: 900; color: #c9c2d6;
  background: repeating-linear-gradient(45deg, #ddd7e6 0 18px, #e6e1ee 18px 36px); border-bottom-style: dashed; border-bottom-color: #b9b2c6;
}
.game-card.soon b { letter-spacing: 1px; }
/* 게임 고르기 아래 만든 사람 (spec 34절) */
.maker {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 18px;
  width: fit-content; max-width: 100%; margin: 26px auto 0; padding: 10px 18px;
  background: rgba(255, 248, 230, 0.92); border: 4px solid #1f1a2e; box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.35);
  font-size: 16px; color: var(--ink, #1f1a2e);
}
.maker .yt { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: inherit; text-decoration: none; padding: 2px 6px; border: 2px solid transparent; transition: transform 0.12s; }
/* 마우스를 올리면 빨갛게 강조 → 누르면 새 탭으로 채널 */
.maker .yt:hover, .maker .yt:focus-visible { color: #d40000; border-color: #ff0000; background: #fff0f0; transform: translateY(-2px); }
.maker .yt:hover .yt-ico { transform: scale(1.15); }
.yt-ico { transition: transform 0.12s; }
.yt-ico { width: 28px; height: 20px; flex: none; }

/* 불꽃놀이 (spec 36절, teacher.js fireworks) */
.fireworks { position: fixed; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.fw { position: absolute; width: 0; height: 0; }
.fw i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; opacity: 0; animation: fw-pop 1.3s ease-out forwards; box-shadow: 0 0 6px rgba(255, 255, 255, 0.8); }
@keyframes fw-pop {
  0% { transform: translate(0, 0) scale(1.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--x), calc(var(--y) + 40px)) scale(0.6); opacity: 0; }
}

/* ───── 수호신 능력 (spec 39절) ───── */
/* 점수판 아래 힘 막대 (왕국 칸 안 맨 아래 띠) */
.score { position: relative; }
.score .pw { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 5px; background: rgba(0, 0, 0, 0.25); }
.score .pw::after { content: ''; position: absolute; inset: 0; width: calc(var(--p, 0) * 100%); background: #fff8c4; transition: width 0.4s; }
.score .pw.full::after { background: #ffe14a; animation: pw-blink 0.6s steps(2) infinite; }
@keyframes pw-blink { 50% { background: #ffffff; } }
/* 학생 가방의 수호신 단추 */
.bag .slot.power { position: relative; overflow: hidden; }
.bag .slot.power img.ico { filter: grayscale(0.7) brightness(0.9); }
.bag .slot.power .pw { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, 0.2); }
.bag .slot.power .pw::after { content: ''; position: absolute; inset: 0; width: calc(var(--p, 0) * 100%); background: var(--gold, #ffcf3a); }
.bag .slot.power.ready { animation: power-glow 0.8s ease-in-out infinite alternate; }
.bag .slot.power.ready img.ico { filter: none; }
.bag .slot.power.t0.ready { background: #ffd9de; }
.bag .slot.power.t1.ready { background: #d6e3ff; }
.bag .slot.power.t2.ready { background: #fff0b8; }
.bag .slot.power.t3.ready { background: #d2f5dd; }
@keyframes power-glow { from { box-shadow: 0 0 0 0 rgba(255, 225, 74, 0.9); } to { box-shadow: 0 0 0 6px rgba(255, 225, 74, 0); transform: translateY(-2px); } }
/* 능력을 썼을 때 가운데 크게 */
.power-pop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; pointer-events: none; animation: goal-in 0.2s ease-out; transition: opacity 0.5s; }
.power-pop.out { opacity: 0; }
.power-pop.t0 { background: radial-gradient(circle, rgba(255, 90, 40, 0.45), rgba(255, 90, 40, 0) 70%); }
.power-pop.t1 { background: radial-gradient(circle, rgba(60, 150, 255, 0.45), rgba(60, 150, 255, 0) 70%); }
.power-pop.t2 { background: radial-gradient(circle, rgba(255, 230, 60, 0.55), rgba(255, 230, 60, 0) 70%); }
.power-pop.t3 { background: radial-gradient(circle, rgba(60, 200, 110, 0.45), rgba(60, 200, 110, 0) 70%); }
.power-card { text-align: center; font-family: var(--pixel); color: #fff; text-shadow: 3px 3px 0 #1f1a2e, -2px -2px 0 #1f1a2e, 2px -2px 0 #1f1a2e, -2px 2px 0 #1f1a2e; animation: goal-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
.power-ico { width: clamp(120px, 26vmin, 240px); height: clamp(120px, 26vmin, 240px); object-fit: contain; filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.4)); animation: power-bob 0.5s ease-in-out infinite alternate; }
@keyframes power-bob { to { transform: translateY(-10px) scale(1.05); } }
.power-name { margin: 6px 0 0; font-size: clamp(28px, 6vmin, 56px); }
.power-who { margin: 4px 0 0; font-size: clamp(16px, 3vmin, 24px); }
#banner.power, #banner.power-ready { background: #6b3fd6; color: #fff; border-color: #fff; }

/* ───── 땅판 = 떠 있는 섬 (spec 40절) ─────
   칸 사이 · 가장자리는 진한 풀밭(풀 무늬를 어둡게), 둘레는 흙 테두리, 아래는 돌 섞인 절벽이 매달린 모양 */
.board.hex.textured:not(.golden) {
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 240, 160, 0.5) 0 2px, transparent 3px) 0 0 / 46px 52px,
    radial-gradient(circle at 70% 60%, rgba(255, 190, 220, 0.55) 0 2px, transparent 3px) 0 0 / 58px 44px,
    linear-gradient(rgba(18, 60, 14, 0.5), rgba(18, 60, 14, 0.5)),
    var(--tex-grass) 0 0 / 110px auto,
    #3e7a2c;
  image-rendering: pixelated;
  border: 5px solid #1f1a2e;
  border-radius: 22px;
  box-shadow: inset 0 0 0 5px #6b4423, inset 0 0 0 8px #4a2d16, 6px 6px 0 rgba(0, 0, 0, 0.35);
  margin-bottom: 58px; /* 아래 절벽 자리 */
}
/* 섬 아래 절벽: 흙 줄무늬 + 돌 + 들쭉날쭉한 아래 끝 */
.board.hex.textured::after {
  content: '';
  position: absolute;
  left: 3%;
  right: 3%;
  top: calc(100% + 1px);
  height: 56px;
  pointer-events: none;
  background:
    linear-gradient(#4f8a2e 0 6px, #2f5a1c 6px 9px, transparent 9px), /* 위쪽 풀 가장자리 */
    radial-gradient(circle at 30% 40%, #a99d91 0 5px, #6e645b 6px, transparent 7px) 0 10px / 74px 30px,
    radial-gradient(circle at 75% 55%, #9a8f86 0 4px, #5f564e 5px, transparent 6px) 20px 14px / 56px 26px,
    repeating-linear-gradient(180deg, #7a4e2a 0 8px, #6a4223 8px 16px, #5e3a20 16px 24px);
  border: 4px solid #1f1a2e;
  border-top: 0;
  /* 위는 넓고 아래로 갈수록 좁아지며 들쭉날쭉 (떠 있는 섬의 밑동) */
  clip-path: polygon(0 0, 100% 0, 98% 30%, 94% 55%, 89% 45%, 84% 75%, 77% 60%, 70% 92%, 62% 70%, 55% 100%, 47% 72%, 40% 95%, 32% 66%, 25% 85%, 17% 58%, 11% 72%, 6% 48%, 2% 30%);
}
.preview.board.hex.textured::after { display: none; }
.preview.board.hex.textured:not(.golden) { margin-bottom: 0; }

/* ───── 오늘의 MVP (spec 41절) ───── */
.mvp { margin-top: 16px; padding: 14px 16px 18px; background: #fff8e6; border: 5px solid #1f1a2e; box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.35); }
.mvp-head { margin: 0 0 12px; text-align: center; font-family: var(--pixel); font-size: 28px; color: #b8860b; text-shadow: 2px 2px 0 #ffe9a6; }
.mvp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.mvp-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 14px; background: #fffdf5; border: 4px solid #1f1a2e; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.06); font-family: var(--pixel); text-align: center; animation: mvp-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.mvp-card:nth-child(2) { animation-delay: 0.15s; }
.mvp-card:nth-child(3) { animation-delay: 0.3s; }
.mvp-card:nth-child(4) { animation-delay: 0.45s; }
@keyframes mvp-pop { from { transform: scale(0.5) translateY(20px); opacity: 0; } }
.mvp-icon { font-size: 44px; line-height: 1; animation: mvp-bob 1.8s ease-in-out infinite; }
/* 기울지 않고 위아래로만 둥실 (float-sm 은 살짝 기울어서 한쪽만 들려 보였다) */
@keyframes mvp-bob { 50% { transform: translateY(-5px); } }
.mvp-title { font-size: 20px; font-weight: 800; }
.mvp-names { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.mvp-name { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 18px; font-weight: 800; color: #fff; text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4); }
.mvp-name.t0 { background: var(--t0); }
.mvp-name.t1 { background: var(--t1); }
.mvp-name.t2 { background: var(--t2); }
.mvp-name.t3 { background: var(--t3); }
.mvp-rec { font-size: 14px; color: #6a6474; }
.end-award { margin: 10px 0 0; padding: 10px 12px; font-family: var(--pixel); font-size: 20px; font-weight: 800; background: #fff3c4; border: 3px solid #e0b020; animation: mvp-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.mvp-img { width: 64px; height: 64px; object-fit: contain; }
.mvp-medal { width: 40px; height: 40px; vertical-align: -10px; object-fit: contain; }

/* ───── 학생 정리 (spec 44절) ───── */
.pick-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; margin: -4px 0 10px; padding: 4px 10px; font-size: 14px; color: #6a6474; background: rgba(0, 0, 0, 0.04); border: 2px dashed rgba(43, 42, 51, 0.2); }
.pick-bar.on { color: #1f1a2e; font-weight: 800; background: #fff3c4; border: 2px solid #e0b020; }
.chip.sel { border-color: #e0b020 !important; background: #fff3c4 !important; box-shadow: 0 0 0 3px #ffd23a; transform: translateY(-2px); }
.team-col.drop { cursor: pointer; outline: 3px dashed rgba(43, 42, 51, 0.35); outline-offset: -6px; }
.team-col.drop:hover { outline-color: #e0b020; filter: brightness(1.04); }
#banner.rare { background: linear-gradient(90deg, #ff6bd6, #ffd23a, #6bdcff); color: #1f1a2e; border-color: #fff; }

/* ───── 학생 기기 모드 (spec 48절) ───── */
.perf-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.perf-pick .btn.on { background: var(--gold, #ffcf3a); }
.perf-pick small { font-size: 12px; opacity: 0.75; }
/* 가벼운 모드: 학생 화면에서 계속 도는 꾸밈 움직임을 끈다 (차지 톡·흔들, 포위 경고, 문제 창은 그대로) */
body.lite .board .wind,
body.lite .fx-layer { display: none !important; }
body.lite .board .cell .spr { animation: none !important; }
body.lite .board .cell[data-fx='pop'] .spr.k-flag { animation: plant 0.55s cubic-bezier(0.3, 0.6, 0.4, 1.4) !important; }
body.lite .board.hex .cell.pickable { animation: none; }
body.lite .board.hex .cell.base.danger .spr.k-castle { animation: shiver 0.3s linear infinite !important; }
body.lite .bag .slot img.ico,
body.lite .power-ico,
body.lite .score .pw.full::after,
body.lite .bag .slot.power.ready { animation: none !important; }

/* ───── ❄️ 얼음 마법 (spec 51절) ───── */
.score.frozen { filter: saturate(0.4) brightness(1.15); box-shadow: inset 0 0 0 3px #bfe9ff, 0 0 10px #8fd8ff; }
.score.frozen::before { content: '❄️'; position: absolute; top: -10px; right: -6px; font-size: 18px; }
.board-wrap { position: relative; }
.board-wrap.frozen::after {
  content: attr(data-ice); position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: none;
  font-family: var(--pixel); font-size: clamp(20px, 5vw, 34px); font-weight: 800; color: #0d3b66; text-shadow: 2px 2px 0 #fff;
  background: repeating-linear-gradient(135deg, rgba(200, 235, 255, 0.55) 0 14px, rgba(230, 248, 255, 0.45) 14px 28px);
  border: 4px solid #bfe9ff;
}
.freeze-pick { margin: 2px; }
.maker .support { flex-basis: 100%; text-align: center; font-size: 14px; color: #d4317a; font-weight: 800; }

/* 홈 제목 (spec 52절): 큰 "퀴즈 킹덤" + 왼쪽 위에 비스듬히 걸친 "개풀's" */
.hub-title .hub-main { position: relative; display: inline-block; color: var(--gold); }
.hub-title .hub-tag {
  position: absolute; z-index: 1; left: -0.4em; top: -0.42em; transform: rotate(-16deg); transform-origin: left bottom; /* "퀴"의 ㅋ 왼쪽 위를 살짝 덮는다 */
  font-size: 0.46em; color: #ff6b81; white-space: nowrap; pointer-events: none;
  text-shadow: -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink);
}
.hub-title { margin-top: clamp(30px, 8vh, 80px); }
.maker .mail { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: inherit; text-decoration: none; padding: 2px 6px; border: 2px solid transparent; }
.maker .mail:hover, .maker .mail:focus-visible { color: #1d5fbf; border-color: #6ea8ff; background: #eef4ff; }
.maker .mail-row { flex-basis: 100%; display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: -4px; font-size: 14px; }
.maker .mail-row .ask { font-weight: 800; color: #6b3fa0; }

/* ───── 홈 배경 움직임 (spec 53절) ─────
   그림을 화면을 꽉 채우는 16:9 틀(.hub-scene)에 고정 → 폭포·꽃 자리가 어느 화면에서도 같다.
   움직이는 것은 몇 개뿐이고 transform·opacity·작은 칸의 무늬만 움직여서 가볍다 (선생님 TV 화면만) */
body.hub { background-image: none; }
.hub-scene { display: none; }
body.hub .hub-scene {
  display: block; position: fixed; z-index: -2; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(100vw, 177.69vh); height: max(56.28vw, 100vh);
  background: url('./art/hub.webp') center / 100% 100% no-repeat; image-rendering: pixelated; overflow: hidden; pointer-events: none;
}
.hub-scene i { position: absolute; display: block; }
/* 💧 폭포 (spec 56절): 배경 그림 속 물줄기를 잘라 이어 붙인 무늬가 아래로 흐른다. 물 모양대로만 보이게 mask */
.hub-scene .wf { overflow: hidden; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; opacity: 0.3; } /* 원래 그림 위에 옅게 → 살짝 일렁이는 정도 */
.hub-scene .wf b {
  position: absolute; left: 0; top: 0; width: 100%; height: var(--h);
  background-size: 100% calc(100% / 3); background-repeat: repeat-y; image-rendering: pixelated;
  animation: wf-flow var(--t) linear infinite; will-change: transform;
}
@keyframes wf-flow { from { transform: translateY(-33.3333%); } to { transform: translateY(0); } }
/* ⛲ 분수: 물방울이 퐁퐁 */
.hub-scene .fountain { width: 1.6%; height: 4%; transform: translate(-50%, -100%); }
.hub-scene .fountain::before, .hub-scene .fountain::after {
  content: ''; position: absolute; left: 50%; bottom: 0; width: 6px; height: 6px; background: #dff6ff; box-shadow: 0 0 0 2px #6cc8ff;
  animation: drop 1.4s ease-out infinite;
}
.hub-scene .fountain::after { animation-delay: -0.7s; }
@keyframes drop { 0% { transform: translate(-50%, 0); opacity: 0; } 20% { opacity: 1; } 60% { transform: translate(-50%, -260%); } 100% { transform: translate(-50%, 0); opacity: 0; } }
/* ✨ 꽃밭 반짝이 */
.hub-scene .tw {
  width: 14px; height: 14px; background: #fffbe0;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 3px #fff6a0); opacity: 0; animation: tw 2.4s ease-in-out infinite; animation-delay: var(--d);
}
@keyframes tw { 0%, 100% { transform: scale(0.2) rotate(0); opacity: 0; } 40% { transform: scale(1) rotate(45deg); opacity: 1; } 60% { opacity: 0.6; } }
/* ☁️ 구름: 하늘을 천천히 가로질러 흘러감 */
.hub-scene .cl {
  left: 0; width: 13%; height: 4.5%; border-radius: 0; opacity: 0.85;
  background:
    radial-gradient(ellipse 26% 42% at 26% 62%, #fff 96%, transparent 100%),
    radial-gradient(ellipse 30% 55% at 50% 45%, #fff 96%, transparent 100%),
    radial-gradient(ellipse 24% 40% at 74% 62%, #fff 96%, transparent 100%),
    radial-gradient(ellipse 46% 26% at 50% 78%, #fff 96%, transparent 100%);
  filter: drop-shadow(0 4px 0 #f4c8e6);
  animation: cl-drift var(--dur) linear infinite; animation-delay: var(--d);
}
.hub-scene .cl1 { width: 9%; height: 3.4%; opacity: 0.7; }
@keyframes cl-drift { from { transform: translateX(-120%); } to { transform: translateX(860%); } }
/* 🦋 나비: 꽃밭 근처를 팔랑팔랑 */
.hub-scene .bf { width: 18px; height: 14px; animation: bf-path 9s ease-in-out infinite; animation-delay: var(--d); }
.hub-scene .bf b { position: absolute; inset: 0; animation: bf-flap 0.25s steps(2) infinite; }
.hub-scene .bf b::before, .hub-scene .bf b::after { content: ''; position: absolute; top: 0; width: 8px; height: 10px; border: 2px solid #1f1a2e; border-radius: 50% 50% 40% 40%; }
.hub-scene .bf b::before { left: 0; background: #ff8fc8; }
.hub-scene .bf b::after { right: 0; background: #ff8fc8; }
.hub-scene .bf1 b::before, .hub-scene .bf1 b::after { background: #ffe14a; }
.hub-scene .bf2 b::before, .hub-scene .bf2 b::after { background: #8fd8ff; }
@keyframes bf-flap { 50% { transform: scaleX(0.4); } }
@keyframes bf-path {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(60px, -40px); }
  50% { transform: translate(120px, 0); }
  75% { transform: translate(50px, 30px); }
}
@media (prefers-reduced-motion: reduce) { .hub-scene i, .hub-scene i::before, .hub-scene i::after, .hub-scene b { animation: none !important; } }

/* ───── 홈 배경 그림 조각 (spec 55절) ───── 배경 속 같은 자리에 덮어 얹고 움직인다 */
.hub-scene .hs { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%); }
.hub-scene .hs img { width: 100%; height: 100%; display: block; image-rendering: pixelated; animation-delay: var(--d); }
/* 🍄 버섯: 가끔 통통 */
.hub-scene .hs-mush img { transform-origin: 50% 80%; animation: hs-hop 3.2s ease-in-out infinite; animation-delay: var(--d); }
@keyframes hs-hop { 0%, 70%, 100% { transform: translateY(0) scale(1, 1); } 76% { transform: translateY(0) scale(1.12, 0.86); } 84% { transform: translateY(-14%) scale(0.94, 1.08); } 92% { transform: translateY(0) scale(1.05, 0.95); } }
/* 🌼 꽃 덤불: 바람에 살랑 */
.hub-scene .hs-flower img { transform-origin: 50% 85%; animation: hs-sway 2.6s ease-in-out infinite alternate; animation-delay: var(--d); }
@keyframes hs-sway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
/* ☁️ 구름: 하늘을 천천히 가로질러 */
.hub-scene .hs-cloud { left: 0 !important; opacity: 0.95; animation: hs-cloud 90s linear infinite; animation-delay: var(--d); }
.hub-scene .hs-cloud + .hs-cloud, .hub-scene .hs-cloud:nth-of-type(2) { animation-duration: 120s; }
@keyframes hs-cloud { from { transform: translate(-120%, -50%); } to { transform: translate(1000%, -50%); } }
/* 🎈 열기구: 둥실둥실 */
.hub-scene .hs-balloon img { animation: hs-bob 3.6s ease-in-out infinite alternate; }
@keyframes hs-bob { from { transform: translateY(-6%); } to { transform: translateY(8%); } }
/* 🐉 아기 용: 제자리에서 둥실 날갯짓 */
.hub-scene .hs-dragon img { transform-origin: 40% 50%; animation: hs-fly 2.4s ease-in-out infinite; }
@keyframes hs-fly { 0%, 100% { transform: translate(0, 0) rotate(-2deg); } 50% { transform: translate(6%, -10%) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .hub-scene .hs, .hub-scene .hs img { animation: none !important; } }

/* ───── 만든 사람 작은 표시 (spec 57절) ───── */
.credit {
  position: fixed; left: 8px; bottom: 8px; z-index: 5; display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; font-size: 12px; line-height: 1.2; color: #3a2d50; background: rgba(255, 250, 240, 0.85);
  border: 2px solid #1f1a2e; box-shadow: 2px 2px 0 rgba(31, 26, 46, 0.35); pointer-events: none; opacity: 0.85;
}
.credit a { pointer-events: auto; display: inline-flex; align-items: center; gap: 3px; font-weight: 800; color: inherit; text-decoration: none; }
.credit a:hover, .credit a:focus-visible { color: #d40000; }
.credit .yt-ico { width: 18px; height: 13px; }
body:has(#s-pick:not([hidden])) .credit { display: none; } /* 큰 만든 사람 띠가 있는 화면 */
body:has(.play#s-play:not([hidden])) .credit { display: none; } /* 학생 놀이 화면: 단추·가방을 가리지 않게 */
@media (max-width: 600px) { .credit { font-size: 10px; padding: 2px 6px; left: 4px; bottom: 4px; } .credit .yt-ico { width: 14px; height: 10px; } }
