/* ── Coaster Park UI — 모던 다크 글래스 테마 ── */
:root {
  --panel: rgba(20, 24, 38, 0.86);
  --panel-light: rgba(255, 255, 255, 0.07);
  --panel-lighter: rgba(255, 255, 255, 0.13);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e9edf5;
  --text-dim: #9aa3b8;
  --accent: #ffd34d;
  --green: #5fd068;
  --red: #ff6b5e;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #141828;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  image-rendering: pixelated;
  cursor: default;
  touch-action: none;   /* 브라우저 스크롤/줌 제스처 차단 — 게임이 직접 처리 */
}

/* ── 패널 (글래스) ── */
.rct-panel {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  z-index: 10;
}

#topbar   { top: 10px; left: 50%; transform: translateX(-50%); }
#moneybar {
  bottom: 10px; left: 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.3px;
}
#toolbar  {
  bottom: 10px; left: 50%; transform: translateX(-50%);
  flex-wrap: wrap;
  justify-content: center;
  max-width: min(96vw, 600px);
}

.sep { width: 1px; height: 20px; background: var(--line); }

/* ── 버튼 ── */
.rct-btn, .rct-tool {
  width: 36px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-light);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  transition: background .12s, border-color .12s, transform .06s;
}

.rct-btn:hover, .rct-tool:hover { background: var(--panel-lighter); }
.rct-btn:active, .rct-tool:active { transform: scale(0.94); }

.rct-tool.active, .rct-btn.active {
  background: rgba(255, 211, 77, 0.16);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(255, 211, 77, 0.25);
}

#btnAttractions {
  background: linear-gradient(135deg, rgba(255,211,77,0.22), rgba(255,150,77,0.18));
  border-color: rgba(255, 211, 77, 0.5);
  font-weight: 700;
}
#btnAttractions:hover { background: linear-gradient(135deg, rgba(255,211,77,0.32), rgba(255,150,77,0.26)); }

/* ── 토스트 ── */
#toast {
  position: fixed;
  top: 56px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.toast-msg {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  animation: toastfade 3s forwards;
}

@keyframes toastfade {
  0% { opacity: 0; transform: translateY(-8px); }
  10%, 80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

/* ── 목표 바 ── */
#objbar {
  top: 56px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 5px 12px;
}

/* ── 손님/직원 패널 ── */
#guestPanel {
  top: 124px; right: 10px;
  align-items: flex-start;
  max-width: 250px;
  font-size: 12.5px;
}
#guestPanel .gthought { font-weight: 400; font-size: 11.5px; color: var(--text-dim); }
#guestPanel .grow { display: flex; align-items: center; gap: 6px; width: 195px; font-size: 11px; color: var(--text-dim); }
#guestPanel .gbar {
  flex: 1; height: 7px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
}
#guestPanel .gbar i { display: block; height: 100%; border-radius: 4px; }
#guestPanel #btnCloseGuest { width: 26px; height: 24px; font-size: 12px; }

/* ── 라이드 패널 ── */
#ridePanel {
  top: 124px; left: 10px;
  flex-direction: column;
  align-items: flex-start;
  max-width: 300px;
  font-size: 12.5px;
  gap: 8px;
}
.ride-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ride-controls .rct-btn { font-size: 12px; }

/* ── 연구 패널 ── */
#researchPanel {
  top: 100px; left: 50%; transform: translateX(-50%);
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
#researchPanel .gbar {
  height: 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
}
#researchPanel .gbar i { display: block; height: 100%; border-radius: 4px; }

/* ── 재정 패널 ── */
#finPanel {
  top: 100px; left: 50%; transform: translateX(-50%);
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
}
#finChart {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.finrow { display: flex; justify-content: space-between; width: 240px; font-size: 12px; color: var(--text-dim); }
.finrow b { font-weight: 700; }
.fin-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── 모달 ── */
#winOverlay, .modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 18, 0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

.attr-window {
  position: static !important;
  flex-direction: column;
  align-items: stretch;
  width: min(94vw, 540px);
  max-height: 82vh;
  gap: 10px;
}
.attr-header { display: flex; align-items: center; font-size: 15px; }
.attr-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.attr-tab { width: auto !important; padding: 0 10px; font-size: 12px; height: 28px; border-radius: 8px; }
.attr-grid {
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 7px;
  padding-right: 4px;
}
.attr-grid::-webkit-scrollbar { width: 6px; }
.attr-grid::-webkit-scrollbar-thumb { background: var(--panel-lighter); border-radius: 3px; }

.attr-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--panel-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.attr-card:hover { background: var(--panel-lighter); border-color: rgba(255, 211, 77, 0.4); }
.attr-card:active { transform: scale(0.99); }
.attr-card.locked { opacity: 0.45; }
.attr-card.locked:hover { border-color: var(--line); }

.attr-icon {
  position: relative;
  font-size: 28px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex-shrink: 0;
}
.attr-badge {
  position: absolute;
  top: -7px; right: -9px;
  background: var(--red);
  color: #fff;
  font-size: 8.5px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 6px;
}
.attr-body { font-size: 13px; line-height: 1.5; }
.attr-cost { color: var(--accent); font-weight: 700; }
.attr-desc { font-weight: 400; font-size: 12px; color: var(--text); }
.attr-info { font-weight: 400; font-size: 10.5px; color: var(--text-dim); }

.win-box {
  position: static !important;
  flex-direction: column;
  gap: 12px;
  padding: 28px 44px !important;
  text-align: center;
}

/* ── 코스터 빌더 ── */
#coasterPanel {
  bottom: 62px; left: 50%; transform: translateX(-50%);
  flex-direction: column;
  gap: 7px;
  padding: 10px 14px;
}
.builder-row { display: flex; align-items: center; gap: 6px; }
.builder-info { font-weight: 400; font-size: 11.5px; color: var(--text-dim); }
.builder-main { display: flex; gap: 12px; align-items: stretch; }
.piece-preview-box {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
}
#piecePreview {
  background: linear-gradient(rgba(110,140,190,0.35), rgba(70,95,140,0.35));
  border-radius: 6px;
  image-rendering: pixelated;
}
.piece-label { font-size: 10.5px; color: var(--text-dim); }
.builder-controls { display: flex; flex-direction: column; gap: 6px; justify-content: space-between; }
.ctrl-label { font-size: 11px; width: 30px; color: var(--text-dim); }
#btnBuild {
  background: rgba(95, 208, 104, 0.18) !important;
  border-color: rgba(95, 208, 104, 0.55) !important;
  color: var(--green) !important;
}
#btnBuild:hover { background: rgba(95, 208, 104, 0.3) !important; }
#btnDone.active {
  background: rgba(255, 211, 77, 0.2);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(255, 211, 77, 0.35);
}

/* ── 미니맵 ── */
#minimap {
  position: fixed;
  top: 10px; right: 10px;
  z-index: 10;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  image-rendering: pixelated;
  cursor: pointer;
}

/* ── 터치 기기 ── */
@media (pointer: coarse) {
  .rct-btn, .rct-tool { width: 44px; height: 40px; font-size: 19px; }
  #toolbar { max-width: 98vw; }
  .rct-panel { font-size: 14px; }
}

/* ── 좁은 화면 (H3) ── */
@media (max-width: 600px) {
  #topbar { top: 6px; max-width: 96vw; flex-wrap: wrap; justify-content: center; padding: 5px 8px; font-size: 12px; gap: 4px; }
  #objbar { top: auto; bottom: 64px; font-size: 10px; max-width: 92vw; text-align: center; }
  #minimap { width: 64px; height: 64px; }
  #guestPanel { top: 84px; max-width: 200px; font-size: 11.5px; }
  #ridePanel { top: 84px; max-width: 250px; }
  #moneybar { font-size: 14px; padding: 6px 10px; }
  #coasterPanel { bottom: 56px; max-width: 96vw; padding: 8px; }
  .builder-main { gap: 8px; }
  #piecePreview { width: 70px; height: 64px; }
  #researchPanel, #finPanel { max-width: 94vw; top: 84px; }
}
