/* CHUNCHEON RAIL TRIP - style.css */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --navy: #0d2137;
  --navy2: #13304f;
  --sky: #35a7e0;
  --spring: #7fc24a;
  --accent: #ffcf4d;
  --text: #eaf2f8;
}
html, body { height: 100%; width: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--navy);
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#webgl-root { position: fixed; inset: 0; z-index: 0; }
#webgl-root canvas { display: block; }

.screen { position: fixed; inset: 0; z-index: 10; display: none; }
.screen.active { display: block; }

.btn {
  font-size: 16px; font-weight: 700; padding: 12px 22px;
  border: none; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,0.12); color: var(--text);
  backdrop-filter: blur(6px); transition: transform .12s, background .12s;
}
.btn:hover { transform: translateY(-2px); background: rgba(255,255,255,0.22); }
.btn-primary { background: linear-gradient(135deg, var(--sky), var(--spring)); color: #06243a; }
.btn-ghost { background: rgba(255,255,255,0.08); }
.btn-wide { width: calc(100% - 32px); margin: 10px 16px 18px; }

/* ===== 메인 화면 ===== */
.main-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(53,167,224,.5), transparent 60%),
    linear-gradient(180deg, #0a1b2e 0%, #13304f 45%, #1c4a39 100%);
}
.main-bg::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40%;
  background: linear-gradient(180deg, transparent, rgba(53,167,224,.15));
  clip-path: polygon(0 60%, 15% 40%, 30% 55%, 45% 30%, 60% 50%, 75% 28%, 90% 48%, 100% 35%, 100% 100%, 0 100%);
}
.main-inner {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
}
.logo {
  font-size: clamp(38px, 9vw, 86px); line-height: .95; letter-spacing: 2px;
  font-weight: 900; text-shadow: 0 6px 30px rgba(0,0,0,.5);
}
.logo span { color: var(--accent); }
.slogan { margin-top: 18px; font-size: clamp(15px, 3.5vw, 22px); opacity: .92; }
.main-buttons { margin-top: 36px; display: flex; flex-direction: column; gap: 12px; width: min(340px, 86vw); }
.main-buttons .btn { font-size: 18px; padding: 15px; }
.data-basis { margin-top: 26px; font-size: 11px; opacity: .55; max-width: 90vw; }

/* ===== 캐릭터 선택 ===== */
#screen-select { background: linear-gradient(180deg, #0a1b2e, #16213a); display: none; flex-direction: column; }
#screen-select.active { display: flex; }
.select-top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.select-top h2 { font-size: 20px; }
#select-stage { flex: 1; min-height: 0; position: relative; }
#select-stage canvas { display: block; width: 100%; height: 100%; }
.select-info { text-align: center; padding: 4px 16px; }
.select-info h3 { font-size: 24px; color: var(--accent); }
.select-info p { font-size: 13px; opacity: .85; margin-top: 3px; }
.select-info .hint { opacity: .5; font-size: 11px; margin-top: 6px; }
.char-cards {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
  padding: 10px 16px; overflow-x: auto;
}
.char-card {
  background: rgba(255,255,255,.08); border: 2px solid transparent; border-radius: 12px;
  padding: 8px 4px; text-align: center; cursor: pointer; transition: all .15s;
}
.char-card:hover { background: rgba(255,255,255,.16); }
.char-card.selected { border-color: var(--accent); background: rgba(255,207,77,.18); box-shadow: 0 0 20px rgba(255,207,77,.4); }
.char-card .swatch { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 4px; border: 2px solid rgba(255,255,255,.5); }
.char-card .cname { font-size: 12px; font-weight: 700; }
@media (max-width: 560px) {
  .char-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ===== 게임 HUD ===== */
#screen-game { background: transparent; }
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 12; }
#hud button { pointer-events: auto; }
.hud-top-left { position: absolute; top: 12px; left: 12px; }
#hud-location { background: rgba(13,33,55,.72); padding: 8px 14px; border-radius: 10px; font-weight: 700; }
.hud-mode { margin-top: 6px; font-size: 12px; background: rgba(53,167,224,.5); padding: 4px 10px; border-radius: 8px; display: inline-block; }
.hud-top-right { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }
.hud-btn { background: rgba(13,33,55,.72); color: var(--text); border: none; border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.hud-btn:hover { background: rgba(53,167,224,.6); }
#hud-stamps { position: absolute; bottom: 12px; left: 12px; background: rgba(13,33,55,.72); padding: 8px 14px; border-radius: 10px; font-weight: 700; }
#interact-hint {
  position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #06243a; padding: 10px 20px; border-radius: 30px;
  font-weight: 800; z-index: 13; box-shadow: 0 4px 18px rgba(0,0,0,.4); animation: bob 1s infinite;
}
@keyframes bob { 0%,100%{ transform: translate(-50%,0);} 50%{ transform: translate(-50%,-6px);} }

/* ===== 모바일 컨트롤 ===== */
#mobile-controls { position: absolute; inset: 0; z-index: 13; pointer-events: none; }
#joystick {
  position: absolute; bottom: 30px; left: 30px; width: 120px; height: 120px;
  background: rgba(255,255,255,.12); border-radius: 50%; pointer-events: auto; touch-action: none;
}
#joy-knob { position: absolute; top: 35px; left: 35px; width: 50px; height: 50px; background: rgba(255,255,255,.5); border-radius: 50%; }
.mobile-right { position: absolute; bottom: 30px; right: 24px; display: flex; flex-direction: column; gap: 14px; }
.m-btn { width: 72px; height: 72px; border-radius: 50%; border: none; font-size: 16px; font-weight: 800; background: rgba(53,167,224,.7); color: #fff; pointer-events: auto; }

/* ===== 모달 공통 ===== */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(5,12,22,.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden, .hidden { display: none !important; }
.modal-box {
  background: var(--navy2); border: 1px solid rgba(255,255,255,.12); border-radius: 18px;
  padding: 22px; width: min(560px, 94vw); max-height: 88vh; overflow-y: auto;
}
.modal-box h3 { font-size: 22px; margin-bottom: 8px; color: var(--accent); }
.modal-sub { font-size: 13px; opacity: .8; margin-bottom: 12px; }
.modal-close { margin-top: 16px; }

/* 지도 */
#map-canvas { width: 100%; height: 340px; background: #0a1b2e; border-radius: 12px; position: relative; overflow: hidden; }
.map-station {
  position: absolute; transform: translate(-50%,-50%); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.map-dot { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--sky); transition: all .15s; }
.map-station:hover .map-dot { transform: scale(1.3); }
.map-station.current .map-dot { background: var(--accent); border-color: #fff; box-shadow: 0 0 14px var(--accent); }
.map-station.visited .map-dot { background: var(--spring); }
.map-label { font-size: 11px; font-weight: 700; white-space: nowrap; background: rgba(0,0,0,.5); padding: 1px 6px; border-radius: 6px; }
.map-itx { font-size: 9px; color: var(--accent); }

/* 대화 */
.dialog-box { width: min(520px, 94vw); }
.dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
#dialog-avatar { width: 46px; height: 46px; border-radius: 50%; border: 2px solid #fff; }
#dialog-text { font-size: 15px; line-height: 1.6; }
#dialog-quiz { margin-top: 14px; }
#quiz-q { font-weight: 700; margin-bottom: 10px; }
#quiz-choices { display: flex; flex-direction: column; gap: 8px; }
.quiz-choice { text-align: left; padding: 11px 14px; border-radius: 10px; background: rgba(255,255,255,.1); border: none; color: var(--text); cursor: pointer; font-size: 14px; }
.quiz-choice:hover { background: rgba(255,255,255,.2); }
.quiz-choice.correct { background: var(--spring); color: #06243a; }
.quiz-choice.wrong { background: #e05555; }
#dialog-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

/* 도감 */
#collection-progress { font-size: 15px; margin-bottom: 14px; }
.progress-bar { height: 12px; background: rgba(255,255,255,.12); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--sky), var(--spring)); transition: width .4s; }
#collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.coll-card { background: rgba(255,255,255,.07); border-radius: 12px; padding: 12px; }
.coll-card.got { border: 2px solid var(--spring); }
.coll-card .stamp { font-size: 28px; }
.coll-card h4 { font-size: 14px; margin: 4px 0; }
.coll-card p { font-size: 11px; opacity: .75; }
.coll-card .locked { opacity: .4; }
#collection-badge { margin-top: 16px; text-align: center; font-size: 20px; font-weight: 800; color: var(--accent); }

.help-list { list-style: none; }
.help-list li { padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 14px; }
.help-list b { color: var(--accent); }

/* 토스트 */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: rgba(13,33,55,.95); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 22px; border-radius: 30px; font-weight: 700; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}

/* 브이월드 실제 지도 */
.modal-box-wide { width: min(760px, 96vw); }
#vworld-map { width: 100%; height: 440px; max-height: 60vh; background: #0a1b2e; border-radius: 12px; overflow: hidden; }
#vworld-fallback { padding: 10px 2px; }

/* 관광지 목록/팝업 */
#spot-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.spot-row { text-align: left; background: rgba(255,255,255,.08); border: none; color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.spot-row:hover { background: rgba(53,167,224,.4); }
.spot-addr { opacity: .7; font-size: 12px; }
#spot-popup { position: relative; margin-top: 12px; background: rgba(13,33,55,.95); border: 1px solid var(--sky); border-radius: 12px; padding: 16px; }
#spot-popup-close { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; }
#spot-popup-img { max-width: 100%; border-radius: 8px; margin-bottom: 8px; max-height: 200px; object-fit: cover; }
#spot-popup-name { font-size: 17px; color: var(--accent); margin-bottom: 4px; }
#spot-popup-addr { font-size: 12px; opacity: .8; margin-bottom: 6px; }
#spot-popup-desc { font-size: 14px; line-height: 1.5; }

.realmap-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* 장면 전환 오버레이 */
#scene-transition { position: fixed; inset: 0; z-index: 60; background: #0a1b2e; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .4s; pointer-events: none; }
#scene-transition.show { opacity: 1; pointer-events: auto; }
.st-inner { text-align: center; color: var(--text); }
.st-spinner { width: 48px; height: 48px; margin: 0 auto 16px; border: 5px solid rgba(255,255,255,.2); border-top-color: var(--sky); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.st-text { font-size: 18px; font-weight: 700; }

/* 관광지 체험 HUD */
#attraction-hud { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 14; text-align: center; pointer-events: none; }
#attraction-hud > * { pointer-events: auto; }
#attraction-title { background: rgba(13,33,55,.85); color: var(--accent); font-weight: 800; padding: 8px 18px; border-radius: 12px; font-size: 16px; }
#attraction-progress { margin-top: 6px; background: rgba(13,33,55,.72); color: var(--text); padding: 6px 14px; border-radius: 10px; font-size: 13px; }
#btn-return-station { margin-top: 10px; }

/* ===== 둥근 UI + 반응형 (뿌뿌 열차) ===== */
/* 버튼/패널을 더 둥글고 부드럽게 */
.btn { border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.hud-btn { border-radius: 999px; }
.modal-box { border-radius: 24px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
#hud-location, #hud-stamps, .hud-mode { border-radius: 999px; }
.quiz-choice { border-radius: 14px; }
.coll-card, .char-card { border-radius: 16px; }

/* 팝업 등장 애니메이션 (부드럽게) */
.modal:not(.hidden) .modal-box { animation: popin .28s cubic-bezier(.34,1.56,.64,1); }
@keyframes popin { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 태블릿 */
@media (max-width: 1024px) {
  .logo { font-size: clamp(34px, 8vw, 64px); }
  .modal-box { width: min(620px, 94vw); }
}
/* 스마트폰 */
@media (max-width: 640px) {
  .main-buttons { width: min(320px, 90vw); }
  .main-buttons .btn { font-size: 16px; padding: 13px; }
  .hud-top-right { gap: 6px; }
  .hud-btn { padding: 7px 10px; font-size: 13px; }
  #hud-location { font-size: 14px; padding: 6px 12px; }
  .select-info h3 { font-size: 20px; }
  #attraction-title { font-size: 14px; }
  .modal-box { padding: 16px; border-radius: 20px; }
  .modal-box h3 { font-size: 19px; }
}
/* 가로/세로 모두 터치 조작 영역 확보 */
@media (pointer: coarse) {
  .hud-btn { min-height: 40px; }
  .btn { min-height: 44px; }
}
