/* ============================================================
   우리의 고등학교 생활기
   ============================================================ */
:root {
  --bg: #0b1020;
  --glass: rgba(18, 24, 46, 0.55);
  --glass-br: rgba(150, 175, 255, 0.28);
  --neon: #5ce1e6;
  --neon2: #a98bff;
  --hp: #39e67e;
  --sp: #a98bff;
  --coin: #ffd24d;
  --dm: #ff5d6d;
  --txt: #eef2ff;
  --txt-dim: #a6b4d8;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #000;
  color: var(--txt);
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.glass {
  background: var(--glass); border: 1px solid var(--glass-br); border-radius: 14px;
  backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 8px 28px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08);
}

/* ===== 게임 루트 ===== */
#game { position: fixed; inset: 0; overflow: hidden; }

/* 배경(장소 이미지) */
.vn-bg {
  position: absolute; inset: 0; background-size: cover;
  background-position: 50% 50%; background-repeat: no-repeat;
  transition: opacity .4s;
}
.vn-bg-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(5,8,20,.35) 0%, rgba(5,8,20,.1) 30%, rgba(5,8,20,.35) 62%, rgba(5,8,20,.9) 100%);
}
/* 정문 간판 오버레이 — 원본 간판을 덮어 '청춘고등학교'로 */
.gate-sign {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%,-50%); z-index: 2;
  font-size: clamp(18px, 3.4vw, 40px); font-weight: 900; letter-spacing: 3px; color: #3a4252;
  background: linear-gradient(180deg, #e9ecf2, #c9cfdb);
  padding: 6px clamp(18px, 5vw, 60px); border-radius: 6px;
  border: 2px solid #aeb6c4; box-shadow: 0 6px 16px rgba(0,0,0,.3);
  text-shadow: 0 1px 0 #fff; white-space: nowrap; pointer-events: none;
}

/* 컷신 캐릭터 */
.vn-char {
  position: absolute; left: 50%; bottom: 30vh; transform: translateX(-50%);
  font-size: 30vh; line-height: 1; filter: drop-shadow(0 12px 24px rgba(0,0,0,.5));
  pointer-events: none; z-index: 3;
}
/* 이미지 캐릭터일 때(친구 등): 바닥에서 올라온 전신 */
.vn-char.img-mode { bottom: 150px; font-size: 0; }
.vn-char #vn-char-img { display: none; height: min(62vh, 520px); width: auto; object-fit: contain; filter: drop-shadow(0 14px 28px rgba(0,0,0,.55)); }
.vn-char.img-mode #vn-char-img { display: block; }
.vn-char.img-mode #vn-char-emoji { display: none; }
.vn-char.pop { animation: charPop .45s cubic-bezier(.2,1.5,.4,1); }
@keyframes charPop { 0% { transform: translateX(-50%) translateY(30px) scale(.7); opacity: 0; } 100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; } }

/* ===== 상단 HUD ===== */
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; padding: 12px;
}
.loc-chip { padding: 9px 16px; font-weight: 800; font-size: 14px; }
.time-chip { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.time-label { font-size: 11px; color: var(--neon); font-weight: 800; letter-spacing: 1px; }
.time-clock { font-family: "Courier New", monospace; font-size: 22px; font-weight: 900; letter-spacing: 2px; text-shadow: 0 0 10px rgba(92,225,230,.5); }
.time-timer { font-size: 13px; font-weight: 800; color: var(--coin); display: inline-flex; align-items: center; gap: 4px; }
.time-timer i { width: 15px; height: 15px; }
.time-timer.danger { color: var(--dm); animation: blink .5s steps(1) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.coin-chip { padding: 9px 16px; font-weight: 900; font-size: 15px; color: var(--coin); display: flex; align-items: center; gap: 6px; }
.coin-chip i { width: 17px; height: 17px; }
.sfx-chip { padding: 9px 12px; font-size: 16px; cursor: pointer; border: none; line-height: 1; transition: transform .12s, background .15s; }
.sfx-chip:hover { transform: translateY(-2px); background: rgba(255,255,255,.85); }
.sfx-chip:active { transform: scale(.9); }

/* ===== 우측 스탯 대시보드 ===== */
.statpanel {
  position: absolute; top: 64px; right: 12px; z-index: 6;
  width: 210px; padding: 12px 14px; display: flex; flex-direction: column; gap: 9px;
}
.stat-line { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; }
.si { width: 17px; height: 17px; flex: none; }
.si.hp { color: var(--hp); } .si.sp { color: var(--sp); } .si.dm { color: var(--dm); }
.sbar { flex: 1; height: 12px; border-radius: 7px; background: rgba(0,0,0,.4); overflow: hidden; border: 1px solid rgba(255,255,255,.08); }
.sfill { height: 100%; width: 100%; border-radius: 7px; transition: width .45s cubic-bezier(.2,.8,.3,1); }
.sfill.hp { background: linear-gradient(90deg, #1f8f4e, var(--hp)); }
.sfill.sp { background: linear-gradient(90deg, #6a4bd6, var(--sp)); }
.sfill.dm { background: linear-gradient(90deg, #8a1f2e, var(--dm)); width: 0%; }
.stat-line span { min-width: 26px; text-align: right; }
.bag { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; min-height: 36px; align-items: center; }
.bag-empty { font-size: 11px; color: var(--txt-dim); }
.bag-item { width: 34px; height: 34px; border-radius: 9px; background: rgba(92,225,230,.12); border: 1px solid rgba(92,225,230,.3); display: grid; place-items: center; font-size: 18px; cursor: pointer; position: relative; transition: transform .12s; }
.bag-item:hover { transform: translateY(-2px); }
.bag-item:active { transform: scale(.9); }
.bag-qty { position: absolute; right: -3px; bottom: -3px; background: var(--neon2); color: #140b2e; font-size: 9px; font-weight: 900; padding: 0 4px; border-radius: 6px; }

/* ===== 하단 대화창 ===== */
.vn-box {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 7;
  width: min(900px, 94vw); padding: 16px 20px 18px;
  background: linear-gradient(180deg, rgba(12,16,32,.78), rgba(12,16,32,.92));
  border: 1.5px solid var(--glass-br); border-radius: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -6px 36px rgba(0,0,0,.5);
}
.vn-speaker { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.vn-ava { font-size: 22px; width: 38px; height: 38px; display: grid; place-items: center; background: rgba(92,225,230,.18); border-radius: 10px; border: 1px solid rgba(92,225,230,.4); }
.vn-name { font-size: 14px; font-weight: 900; color: var(--neon); }
.vn-text { font-size: 18px; font-weight: 600; line-height: 1.5; min-height: 54px; }
.vn-choices { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.vn-choice {
  text-align: left; padding: 13px 16px; cursor: pointer; font-size: 15px; font-weight: 700; color: var(--txt);
  background: rgba(34,44,74,.7); border: 1.5px solid rgba(150,175,255,.3); border-radius: 12px;
  transition: transform .12s, background .15s, border-color .15s;
}
.vn-choice::before { content: "▸ "; color: var(--neon); font-weight: 900; }
.vn-choice:hover { transform: translateX(4px); background: rgba(52,66,112,.85); border-color: var(--neon); }
.vn-choice:active { transform: scale(.98); }
.vn-choice .cost { float: right; font-size: 12px; color: var(--txt-dim); font-weight: 700; }
.vn-choice.alt::before { color: var(--coin); }
.vn-choice.alt:hover { border-color: var(--coin); }
.vn-choice.mini::before { content: "🎮 "; }
.vn-choice.mini:hover { border-color: var(--neon2); }
.vn-next {
  margin-top: 10px; width: 100%; padding: 12px; border: none; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 800; color: #06181c; background: linear-gradient(135deg, var(--neon), var(--neon2));
  transition: transform .12s;
}
.vn-next:active { transform: scale(.97); }

/* ===== 매점 모달 ===== */
.store-overlay { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; animation: fadeIn .25s; }
.store-overlay::before { content: ""; position: absolute; inset: 0; background: url("/static/image/store_bg.jpeg") center/cover; }
.store-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,8,20,.3), rgba(5,8,20,.8)); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.store-x { position: absolute; top: 14px; right: 14px; z-index: 3; width: 40px; height: 40px; border-radius: 11px; cursor: pointer; background: rgba(10,14,30,.6); border: 1px solid rgba(255,255,255,.25); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px); }
.store-x:hover { background: rgba(255,77,109,.5); }
.store-x i { width: 20px; height: 20px; }
.emo-bubble { position: relative; z-index: 2; margin-top: 56px; display: flex; align-items: center; gap: 12px; background: rgba(12,16,32,.8); border: 1.5px solid rgba(255,210,120,.5); border-radius: 16px; padding: 12px 18px; max-width: min(540px,90vw); backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.emo-avatar { font-size: 28px; width: 46px; height: 46px; flex: none; display: grid; place-items: center; background: rgba(255,210,120,.18); border-radius: 12px; border: 1px solid rgba(255,210,120,.4); }
.emo-name { font-size: 13px; font-weight: 900; color: var(--coin); }
.emo-line { font-size: 15px; font-weight: 800; margin-top: 2px; }
.showcase { position: relative; z-index: 2; width: min(880px,94vw); margin: 14px auto 3vh; padding: 16px 18px 20px; border-radius: 20px; max-height: 52vh; overflow: auto; }
.showcase-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; font-size: 15px; font-weight: 900; }
.showcase-head i { width: 17px; height: 17px; vertical-align: -3px; }
.showcase-coin { color: var(--coin); display: flex; align-items: center; gap: 5px; }
.store-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
@media (max-width: 680px) { .store-grid { grid-template-columns: repeat(2, 1fr); } }
.store-card { background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,220,150,.07)); border: 1.5px solid rgba(255,210,120,.32); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; transition: transform .15s, box-shadow .15s; }
.store-card:hover { transform: translateY(-4px); box-shadow: 0 12px 26px rgba(255,180,60,.3); }
.store-emoji { font-size: 40px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.3)); }
.store-name { font-size: 15px; font-weight: 900; }
.store-desc { font-size: 11px; color: var(--txt-dim); line-height: 1.4; flex: 1; }
.store-buy { margin-top: 6px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border: none; border-radius: 11px; font-weight: 900; font-size: 13px; color: #3a2800; cursor: pointer; background: linear-gradient(135deg, #ffe17a, var(--coin), #ffaa1e); transition: transform .12s; }
.store-buy:hover { transform: scale(1.04); }
.store-buy:active { transform: scale(.94); }
.store-buy:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }
.store-buy i { width: 15px; height: 15px; }

/* ===== 미니게임 모달 ===== */
.mini-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(5,8,20,.72); backdrop-filter: blur(6px); animation: fadeIn .25s; }
.mini-box { width: min(520px,92vw); padding: 24px; text-align: center; }
.mini-title { font-size: 22px; font-weight: 900; color: var(--neon); }
.mini-desc { font-size: 14px; color: var(--txt-dim); margin: 8px 0 18px; line-height: 1.5; }
.mini-stage { min-height: 120px; display: grid; place-items: center; gap: 12px; }
.mini-foot { margin-top: 16px; }
.mini-btn { padding: 14px 28px; border: none; border-radius: 14px; font-size: 18px; font-weight: 900; color: #06181c; cursor: pointer; background: linear-gradient(135deg, var(--neon), var(--neon2)); transition: transform .1s; }
.mini-btn:active { transform: scale(.94); }
.mini-target { width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, #ffe17a, #ffaa1e); border: none; cursor: pointer; font-size: 30px; box-shadow: 0 6px 18px rgba(255,180,60,.5); transition: transform .08s; }
.mini-target:active { transform: scale(.85); }
.mini-quiz-opt { display: block; width: 100%; margin: 7px 0; padding: 13px; border-radius: 11px; border: 1.5px solid rgba(150,175,255,.3); background: rgba(34,44,74,.7); color: var(--txt); font-size: 15px; font-weight: 700; cursor: pointer; }
.mini-quiz-opt:hover { border-color: var(--neon); }
.mini-bar-track { width: 100%; height: 26px; border-radius: 13px; background: rgba(0,0,0,.4); overflow: hidden; position: relative; border: 1px solid rgba(255,255,255,.1); }
.mini-bar-zone { position: absolute; top: 0; bottom: 0; background: rgba(57,230,126,.4); border-left: 2px solid var(--hp); border-right: 2px solid var(--hp); }
.mini-bar-cursor { position: absolute; top: 0; bottom: 0; width: 5px; background: #fff; box-shadow: 0 0 8px #fff; }
/* 카드 짝맞추기 */
.card-cell { aspect-ratio: 1; border-radius: 12px; border: none; cursor: pointer; font-size: 26px; display: grid; place-items: center; background: linear-gradient(135deg, #5c7cff, #a98bff); color: #fff; transition: transform .15s, background .2s; box-shadow: 0 4px 10px rgba(0,0,0,.3); }
.card-cell:active { transform: scale(.92); }
.card-cell.open { background: #fff; color: #222; }
.card-cell.done { background: linear-gradient(135deg, #39e67e, #1f8f4e); color: #fff; cursor: default; opacity: .85; }

/* ===== 엔딩 ===== */
.ending-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 20px;
  z-index: 1000;
}
.ending-box { text-align: center; width: min(520px,92vw); padding: 30px; }
.ending-emoji { font-size: 90px; animation: charPop .5s; }
.ending-title { font-size: 32px; font-weight: 900; margin: 10px 0; background: linear-gradient(135deg, var(--neon), var(--neon2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.ending-desc { font-size: 16px; line-height: 1.6; color: var(--txt); margin-bottom: 16px; }
.ending-stats { font-size: 13px; color: var(--txt-dim); background: rgba(0,0,0,.25); border-radius: 12px; padding: 12px; margin-bottom: 20px; line-height: 1.8; }

/* ===== 토스트 ===== */
.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 12px 22px; border-radius: 14px; font-weight: 800; font-size: 15px; background: linear-gradient(135deg, rgba(57,230,126,.95), rgba(30,150,80,.95)); color: #06240f; box-shadow: 0 12px 30px rgba(0,0,0,.4); animation: toastIn .35s; }
.toast.bad { background: linear-gradient(135deg, rgba(255,110,130,.95), rgba(200,40,70,.95)); color: #fff; }
.toast.coin { background: linear-gradient(135deg, rgba(255,210,77,.95), rgba(255,170,30,.95)); color: #3a2800; }
@keyframes toastIn { from { transform: translate(-50%,-14px); opacity: 0; } to { transform: translate(-50%,0); opacity: 1; } }

/* ===== 시작 화면 (겹침 없이 중앙 정렬) ===== */
.start-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: #e6ecf7 url("/static/image/gate.jpeg") center/cover no-repeat;
}
/* 배경 위 가독성용 옅은 막 */
.start-overlay::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.15), rgba(70,90,130,.28));
}
.start-box {
  position: relative; z-index: 1;
  text-align: center; padding: 40px 34px; max-width: min(480px, 90vw);
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(40,55,90,0.35);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.start-badge { font-size: 12px; letter-spacing: 5px; color: #3f5578; font-weight: 800; margin-bottom: 12px; }
.start-title { font-size: 42px; font-weight: 900; line-height: 1.15; color: #26324a; text-shadow: 0 1px 2px rgba(255,255,255,.6); }
.start-sub2 { font-size: 17px; font-weight: 700; color: #45597e; margin-top: 10px; }
.start-tag { font-size: 14px; color: #3f4a63; line-height: 1.7; margin: 16px 0 26px; }
.btn-start { display: inline-flex; align-items: center; gap: 8px; padding: 15px 36px; border: none; border-radius: 14px; font-size: 17px; font-weight: 900; color: #fff; cursor: pointer; background: linear-gradient(135deg, #3f7cc4, #6a7fb5); box-shadow: 0 10px 26px rgba(60,90,150,.45); transition: transform .15s; }
.btn-start i { width: 20px; height: 20px; }
.btn-start:hover { transform: translateY(-3px) scale(1.03); }
.btn-start:active { transform: scale(.95); }

/* 시작화면 접이식 메뉴 */
.start-menu { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.menu-toggle {
  padding: 9px 16px; border: 1px solid rgba(60,90,150,.35);
  border-radius: 11px; background: rgba(255,255,255,.55);
  color: #2e3d58; font-size: 14px; font-weight: 800; cursor: pointer;
  transition: background .15s, transform .12s;
}
.menu-toggle:hover { background: rgba(255,255,255,.85); transform: translateY(-2px); }
.menu-toggle[aria-expanded="true"] { background: linear-gradient(135deg,#3f7cc4,#6a7fb5); color:#fff; border-color:transparent; }
.panel { margin-top: 16px; width: 100%; animation: panelIn .2s ease; }
.panel.hidden { display: none; }
@keyframes panelIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.help-list { text-align: left; margin: 0; padding: 14px 16px; list-style: none;
  background: rgba(255,255,255,.5); border-radius: 14px; }
.help-list li { font-size: 13.5px; color: #33425e; line-height: 1.55; margin: 7px 0; }
.help-list b { color: #26324a; }
.panel-title { font-size: 15px; font-weight: 900; color: #2e3d58; margin-bottom: 8px; }

/* 화면 흔들림 */
.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translate(0,0)} 25%{transform:translate(-7px,3px)} 75%{transform:translate(7px,-3px)} }

@media (max-width: 680px) {
  /* 모바일: 요소 간소화 — 스탯패널 작게, 가방은 대화창 아래로 느낌만 */
  .statpanel { width: 132px; top: 52px; right: 8px; padding: 8px 9px; gap: 6px; }
  .statpanel .bag { display: none; }          /* 가방은 모바일에선 숨겨 간결하게 */
  .stat-line { font-size: 10px; gap: 5px; }
  .si { width: 14px; height: 14px; }
  .sbar { height: 9px; }
  .hud-top { padding: 8px; gap: 6px; }
  .loc-chip { padding: 6px 10px; font-size: 12px; }
  .time-chip { padding: 6px 10px; gap: 6px; }
  .time-clock { font-size: 17px; }
  .time-label { font-size: 9px; }
  .coin-chip { padding: 6px 10px; font-size: 13px; }
  .vn-box { bottom: 10px; padding: 12px 14px 14px; width: 96vw; }
  .vn-text { font-size: 15px; min-height: 44px; }
  .vn-choice { font-size: 13px; padding: 11px 13px; }
  .vn-char { font-size: 22vh; bottom: 26vh; }
  .start-title { font-size: 36px; }
}
@media (max-width: 680px) and (orientation: portrait) {
  /* 세로 전용 배경 처리는 아래 !important 블록에서 일괄 적용(충돌 방지) */
}

/* ===== 엔딩 중 기존 게임 UI 숨김 (겹침 방지) ===== */
.ending-active .hud-top,
.ending-active .statpanel,
.ending-active .vn-box,
.ending-active .vn-char { display: none !important; }

/* ===== 엔딩 박스 모바일 반응형 (잘림 방지) ===== */
.ending-overlay { padding: 16px; box-sizing: border-box; }
.ending-box {
  width: min(90%, 460px); max-height: 80vh; overflow-y: auto;
  box-sizing: border-box; margin: 0 auto;
}
@media (max-width: 680px) {
  .ending-emoji { font-size: 60px; }
  .ending-title { font-size: 22px; line-height: 1.3; word-break: keep-all; }
  .ending-desc { font-size: 14px; line-height: 1.6; word-break: keep-all; }
  .ending-stats { font-size: 12px; }
}

/* ===== 시작 화면 모바일 줄바꿈/가독성 ===== */
@media (max-width: 680px) {
  .start-box { width: 90%; max-width: 90%; padding: 26px 20px; box-sizing: border-box; }
  .start-title { font-size: 30px; line-height: 1.25; word-break: keep-all; }
  .start-sub2 { font-size: 15px; word-break: keep-all; }
  .start-tag { font-size: 13px; line-height: 1.6; word-break: keep-all; }
  .start-tag br { display: none; }
  .btn-start { width: 100%; justify-content: center; }
}
@media (max-width: 680px) {
    /* 모바일 공통: 가로 배경을 꽉 채우되(cover) 인물·사물이 있는 중앙 상단으로 맞춘다.
       contain(전체 축소)은 인물이 작아지고 여백이 생겨서 쓰지 않는다. */
    .vn-bg {
      background-size: cover !important;
      background-position: 50% 32% !important;
      background-repeat: no-repeat !important;
      background-color: #0b1020;
    }
    /* 시험 장면(exam_good/exam_bad): 오른쪽에 있는 선생님이 잘리지 않게 가로 기준을 오른쪽으로 민다 */
    .vn-bg.exam-view {
      background-position: 72% 30% !important;
    }
    /* 입학식 장면: 사진 든 선배들이 중앙 왼쪽에 모여 있어 가로를 왼쪽으로 당겨 잘리지 않게 한다 */
    .vn-bg.admission-view {
      background-position: 31% 60% !important;
    }
  }
  /* 세로(폰) 화면: cover로 세로를 꽉 채워 가로 이미지가 크게 보이게 하고,
     인물·사물이 있는 중앙 상단(50% 30%)으로 맞춰 얼굴이 잘리지 않게 한다. */
@media (max-width: 680px) and (orientation: portrait) {
    .vn-bg {
      background-size: cover !important;
      background-position: 50% 30% !important;
    }
    /* 입학식: 세로 화면에선 선배들 상반신이 중심에 오도록 가로 왼쪽·세로 중앙으로 맞춘다 */
    .vn-bg.admission-view {
      background-position: 31% 62% !important;
    }
  }

/* ===== 엔딩 도감 (시작 화면) ===== */
.ending-dex { margin-top: 22px; width: 100%; }
.ending-dex-title {
  font-size: 13px; font-weight: 700; letter-spacing: 1px; color: #cbd3e6;
  margin-bottom: 10px; text-align: center; opacity: .9;
}
.ending-dex-title span { color: #ffd76a; margin-left: 4px; }
.ending-dex-grid { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dex-item {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.14); position: relative;
  transition: transform .15s;
}
.dex-item.found { background: rgba(255,215,106,.14); border-color: rgba(255,215,106,.5); }
.dex-item.locked { filter: grayscale(1); opacity: .45; }
.dex-item:hover { transform: translateY(-2px); }
.dex-item .dex-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 200px; max-width: 70vw; white-space: normal; word-break: keep-all; line-height: 1.45;
  font-size: 11px; color: #e8ecf6; text-align: center;
  background: rgba(10,14,30,.97); padding: 7px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12); box-shadow: 0 6px 18px rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 20;
}
.dex-item .dex-tip b { color: #ffd76a; }
.dex-hint { color: #b9c2d9; font-size: 10.5px; }
.dex-item:hover .dex-tip, .dex-item:focus .dex-tip, .dex-item:focus-visible .dex-tip { opacity: 1; }
@media (max-width: 680px) {
  .dex-item { width: 46px; height: 46px; font-size: 22px; }
}

/* ===== 예상 엔딩 힌트 (스탯 패널) ===== */
.stat-hint {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex; flex-direction: column; gap: 3px;
}
.stat-hint .hint-label {
  font-size: 10px; letter-spacing: 1px; color: #9aa4bd; text-transform: uppercase;
}
.stat-hint .hint-val {
  font-size: 13px; font-weight: 700; color: #ffe08a;
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.stat-hint .hint-val #hint-emoji { font-size: 15px; }
/* 값이 바뀔 때 살짝 반짝 */
.stat-hint.flash .hint-val { animation: hintFlash .5s ease; }
@keyframes hintFlash {
  0% { transform: scale(1); } 40% { transform: scale(1.12); color: #fff; } 100% { transform: scale(1); }
}

/* ===== 리더보드 (명예의 전당) ===== */
.leaderboard {
  margin-top: 20px; width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px; padding: 14px 16px;
}
.lb-title {
  font-size: 13px; font-weight: 800; letter-spacing: .5px; color: #ffe08a;
  text-align: center; margin-bottom: 10px;
}
.lb-title .lb-sub { color: #9aa4bd; font-weight: 600; font-size: 11px; margin-left: 4px; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lb-list li {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #e8ecf6;
  padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.04);
}
.lb-list li .lb-rank { font-weight: 800; width: 24px; text-align: center; color: #cbd3e6; }
.lb-list li .lb-nick { font-weight: 700; color: #e8ecf6; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list li .lb-score { margin-left: auto; font-weight: 700; color: #ffd76a; }
.lb-list li .lb-date { font-size: 11px; color: #8b93a9; }

/* 엔딩: 명예의 전당 닉네임 입력 */
.name-entry { margin: 14px 0 6px; text-align: center; }
.name-entry.hidden { display: none; }
.name-entry-label { display: block; font-size: 14px; font-weight: 700; color: #e8ecf6; margin-bottom: 10px; }
.name-entry-row { display: flex; gap: 8px; justify-content: center; }
.nick-input {
  flex: 1; max-width: 220px; padding: 11px 14px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #fff; font-size: 15px; font-weight: 600; outline: none;
}
.nick-input::placeholder { color: #9aa4bd; font-weight: 500; }
.nick-input:focus-visible { border-color: #6a9fe0; box-shadow: 0 0 0 3px rgba(106,159,224,.3); }
.btn-nick-save {
  padding: 11px 20px; border: none; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #3f7cc4, #6a7fb5);
  box-shadow: 0 6px 16px rgba(60,90,150,.4); transition: transform .15s;
}
.btn-nick-save:hover { transform: translateY(-2px); }
.btn-nick-save:active { transform: scale(.95); }
.btn-nick-save:disabled { opacity: .6; cursor: default; transform: none; }

/* 엔딩: 선택 돌아보기(성찰) */
.reflection {
  margin: 16px 0; padding: 16px 18px; border-radius: 16px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.12); text-align: left;
}
.reflection-title { font-size: 15px; font-weight: 800; color: #ffe08a; margin-bottom: 10px; }
.reflection-summary { font-size: 14px; color: #e8ecf6; line-height: 1.6; margin-bottom: 12px; }
.reflection-summary b { color: #fff; }
.reflection-bars { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.rf-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rf-label { width: 86px; flex-shrink: 0; color: #cbd3e6; font-weight: 700; }
.rf-track { flex: 1; height: 10px; border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden; }
.rf-fill { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #6a9fe0, #a98fd8); transition: width .5s ease; }
.rf-count { width: 22px; text-align: right; color: #ffd76a; font-weight: 800; }
.reflection-lesson {
  font-size: 13.5px; color: #dfe6f5; line-height: 1.65;
  padding: 11px 13px; border-radius: 12px; background: rgba(255,255,255,.07);
  border-left: 3px solid #ffd76a;
}

/* 엔딩 액션(공유/다시하기) */
.ending-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.btn-share {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 15px 28px; border: 1px solid rgba(255,255,255,.3); border-radius: 14px;
  font-size: 16px; font-weight: 800; color: #fff; cursor: pointer;
  background: rgba(255,255,255,.12); transition: transform .15s, background .15s;
}
.btn-share i { width: 20px; height: 20px; }
.btn-share:hover { transform: translateY(-3px); background: rgba(255,255,255,.2); }
.btn-share:active { transform: scale(.95); }
.btn-share:disabled { opacity: .6; cursor: default; transform: none; }
@media (max-width: 480px) {
  .ending-actions { flex-direction: column; }
  .btn-share { width: 100%; justify-content: center; }
}
.lb-list li.lb-1 .lb-rank { color: #ffd700; }
.lb-list li.lb-2 .lb-rank { color: #c0c8d8; }
.lb-list li.lb-3 .lb-rank { color: #d9a066; }
.lb-list li.lb-me {
  background: rgba(255,215,106,.18);
  border: 1px solid rgba(255,215,106,.5);
}
.lb-list li.lb-me .lb-score { color: #fff; }
.lb-empty { justify-content: center; color: #8b93a9 !important; }
.lb-ending { margin-top: 14px; }
.lb-ending .lb-list li { font-size: 12px; padding: 4px 7px; }
@media (max-width: 680px) {
  .lb-list li { font-size: 12px; padding: 4px 6px; }
  .lb-list li .lb-date { display: none; }
}

/* ===== 시작화면 기능 요약 배지 (빠른 체험 안내) ===== */
.start-features {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 7px;
  margin: 4px 0 18px;
}
.start-features .feat {
  font-size: 12px; font-weight: 600; color: #e8ecf6;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 20px; padding: 5px 11px; white-space: nowrap;
}
@media (max-width: 680px) {
  .start-features .feat { font-size: 11px; padding: 4px 9px; }
}

/* ===== 접근성 보강 ===== */
/* 키보드로 이동할 때 현재 초점을 또렷하게 표시 (마우스 클릭 땐 안 보이게) */
:focus-visible {
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
  border-radius: 6px;
}
/* 움직임을 줄이고 싶은 사용자(멀미·전정장애 등)를 위해 애니메이션 최소화 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 유튜브 배경 음악 ===== */
/* 숨은 플레이어: 화면 밖으로 밀어 영상은 안 보이고 소리만 */
#yt-player-wrap {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 200px;
  height: 120px;
  opacity: 0.01;        /* 거의 안 보이지만 완전 0은 아님(유튜브 재생 허용) */
  z-index: -1;          /* 다른 요소 뒤로 */
  pointer-events: none; /* 클릭 통과 */
  overflow: hidden;
}

/* 등교 시 음악 선택 */
.music-choice {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.music-q {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #e8edff;
}
.music-opts {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.music-opt {
  flex: 1;
  padding: 12px 10px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #7c5cff, #5a8dee);
  color: #fff;
  transition: transform 0.1s ease, filter 0.1s ease;
}
.music-opt:hover { filter: brightness(1.1); }
.music-opt:active { transform: scale(0.97); }
.music-opt-alt {
  background: rgba(255, 255, 255, 0.1);
  color: #cdd6f4;
}
.music-search {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.music-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 14px;
}
.music-search input:focus {
  outline: 2px solid #7c5cff;
  border-color: transparent;
}
.music-search #music-go {
  padding: 11px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}
.music-search #music-go:active { transform: scale(0.98); }
.music-hint {
  font-size: 12px;
  color: #9aa5c4;
  text-align: center;
}

/* 재생 중 플로팅 바 */
.music-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(20, 24, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  color: #e8edff;
  max-width: 72vw;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.music-bar-icon { animation: music-pulse 1.4s ease-in-out infinite; }
@keyframes music-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.music-bar-title {
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.music-bar-btn {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.music-bar-btn:hover { background: rgba(255, 255, 255, 0.22); }
@media (prefers-reduced-motion: reduce) {
  .music-bar-icon { animation: none; }
}

/* ===== 음악 검색: 결과 목록/선택 ===== */
.music-search-row { display: flex; gap: 8px; }
.music-search-row input {
  flex: 1; box-sizing: border-box; padding: 11px 13px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.25); color: #fff; font-size: 14px;
}
.music-search-row input:focus { outline: 2px solid #7c5cff; border-color: transparent; }
.music-search-row #music-go {
  padding: 11px 14px; border-radius: 10px; border: none;
  font-size: 14px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; white-space: nowrap;
}
.music-status { margin-top: 8px; font-size: 13px; color: #cbd5f5; min-height: 18px; }
.music-results {
  margin-top: 8px; display: flex; flex-direction: column; gap: 6px;
  max-height: 210px; overflow-y: auto;
}
.music-result {
  display: flex; flex-direction: row; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10,14,30,0.9); color: #ffffff; cursor: pointer; transition: background 0.1s ease;
}
.music-result:hover { background: rgba(124,92,255,0.45); }
.music-result .mr-thumb {
  width: 56px; height: 42px; flex: 0 0 auto;
  object-fit: cover; border-radius: 6px; background: #000;
}
.music-result .mr-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.music-result .mr-title {
  font-size: 13px; font-weight: 700; line-height: 1.3; color: #ffffff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.music-result .mr-ch { font-size: 11px; color: #b9c2e0; }
/* 음악 바: 대화창 위로 올려 자막을 가리지 않게 */
.music-bar { left: auto; right: 12px; bottom: auto; top: 96px; transform: none; }

/* 선택(미리듣기 중)인 곡 강조 */
.music-result.chosen {
  background: rgba(124,92,255,0.55);
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(167,139,250,0.5) inset;
}
/* 이 노래로 등교 버튼 */
.music-confirm {
  margin-top: 10px;
  width: 100%;
}

/* 조용히 확인 단계 */
.music-quiet { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.music-quiet .btn-start { width: 100%; }

/* ===== AI 회고 편지 ===== */
.ai-letter {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(42, 36, 72, 0.6), rgba(24, 28, 48, 0.6));
  border: 1px solid rgba(180, 160, 255, 0.25);
  text-align: left;
}
.ai-letter-head {
  font-weight: 800;
  font-size: 14px;
  color: #d9c9ff;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.ai-letter-tag {
  font-size: 11px;
  background: rgba(180, 160, 255, 0.25);
  padding: 2px 8px;
  border-radius: 999px;
  color: #efe6ff;
}
.ai-letter-body {
  font-size: 13.5px;
  line-height: 1.8;
  color: #eef1ff;
  white-space: pre-wrap;        /* 서버가 준 줄바꿈(\n) 유지 */
  font-family: "Nanum Myeongjo", Georgia, serif;
}

/* ===== 통계 대시보드 모달 ===== */
.btn-stats {
  border: none;
  background: rgba(130, 160, 255, 0.18);
  color: #dfe6ff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-stats:hover { background: rgba(130, 160, 255, 0.3); }
.stats-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 20, 0.72);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.stats-box {
  width: min(680px, 94vw);
  max-height: 90vh; overflow-y: auto;
  background: #11162a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.stats-title { font-size: 19px; font-weight: 800; color: #eaf0ff; margin-bottom: 12px; }
.stats-summary { font-size: 14px; line-height: 1.9; color: #cfd8f5; margin-bottom: 14px; }
.stats-summary b { color: #ffd76a; }
.stats-dist { font-size: 12.5px; color: #9fb0e0; }
.stats-chart {
  width: 100%; height: auto; border-radius: 12px;
  background: #0f1426; margin-bottom: 16px; display: block;
}
.stats-box .btn-start { width: auto; padding: 10px 28px; }
