* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #19060f; }
body {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: #fff3ea; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#c { position: fixed; inset: 0; z-index: 0; }
.hidden { display: none !important; }

/* ---------- 상단 유틸리티 바 & 성장 노트 토스트 ---------- */
#top-bar {
  position: fixed; top: 12px; right: 14px; z-index: 45;
  display: flex; gap: 8px;
}
.btn-pill {
  margin: 0; padding: 7px 14px; font-size: 13px;
  color: #ffe8d8; background: rgba(34, 10, 22, 0.65);
  border: 1px solid rgba(255, 205, 185, 0.28);
  border-radius: 999px; box-shadow: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#btn-note-toast {
  position: fixed; bottom: 18vh; right: 16px; z-index: 38;
  margin: 0; padding: 10px 18px; font-size: 13.5px;
  color: #4a1426; background: linear-gradient(#fff2c6, #ffd4a8);
  border: 1px solid rgba(255, 240, 200, 0.7);
  border-radius: 999px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  animation: fadeIn 0.4s ease;
}
#btn-skip-game {
  position: fixed; bottom: 20px; right: 16px; z-index: 38;
  margin: 0; padding: 9px 16px; font-size: 13px;
  color: #fff3da; background: rgba(45, 14, 28, 0.85);
  border: 1px solid rgba(255, 224, 175, 0.55);
  border-radius: 999px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.5s ease;
}
#btn-skip-game:hover {
  background: rgba(85, 28, 52, 0.92);
  border-color: rgba(255, 240, 200, 0.9);
}
.sound-banner {
  margin: 0 auto 14px; padding: 10px 14px;
  font-size: 13px; line-height: 1.45; color: #fff4d2;
  background: linear-gradient(135deg, rgba(255, 215, 150, 0.20), rgba(255, 165, 185, 0.16));
  border: 1px solid rgba(255, 225, 175, 0.45);
  border-radius: 14px;
}
.sound-banner span {
  font-size: 12px; color: #ffd9c4; opacity: 0.92;
}
.lang-row {
  display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
}
.btn-lang-opt {
  margin: 0; padding: 5px 12px; font-size: 12px;
  color: #ffe8d8; background: rgba(255, 225, 205, 0.10);
  border: 1px solid rgba(255, 205, 185, 0.28);
  border-radius: 999px; box-shadow: none;
}
.btn-lang-opt.active {
  color: #4a1426; background: linear-gradient(#ffe9d6, #ffc7b2);
  border-color: rgba(255, 240, 210, 0.85); font-weight: 700;
}

/* ---------- 화면(안내/편지/모달) ---------- */
.screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 4, 12, 0.62);
  animation: fadeIn 0.5s ease;
  padding: 14px;
}
.panel {
  width: min(92vw, 440px); max-height: 90vh; overflow-y: auto;
  padding: 30px 24px; text-align: center;
  background: rgba(52, 16, 30, 0.82); border: 1px solid rgba(255, 200, 180, 0.22);
  border-radius: 24px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  line-height: 1.68;
}
.panel p { margin-bottom: 12px; font-size: 16px; }
.panel p.small { font-size: 13.5px; opacity: 0.78; }
.logo {
  font-family: "Nanum Myeongjo", "Batang", serif;
  font-size: 52px; letter-spacing: 6px; margin-bottom: 14px;
  color: #ffd9c4; text-shadow: 0 0 24px rgba(255, 160, 140, 0.7);
  animation: beat 1.1s infinite;
}
button {
  margin-top: 8px; padding: 12px 28px; font-size: 15.5px; font-family: inherit;
  color: #4a1426; background: linear-gradient(#ffe6d6, #ffc4ae);
  border: none; border-radius: 999px; cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 170, 150, 0.38);
}
button:active { transform: scale(0.96); }
.btn-sub {
  color: #ffe8d8; background: rgba(255, 200, 180, 0.15);
  border: 1px solid rgba(255, 200, 180, 0.32); box-shadow: none;
}
.btn-link {
  margin-top: 4px; padding: 6px 12px; font-size: 13px;
  color: rgba(255, 225, 210, 0.82); background: transparent;
  border: none; box-shadow: none; text-decoration: underline;
}
.start-actions {
  display: flex; flex-direction: column; gap: 8px; margin: 12px 0 10px;
}
.start-actions button { width: 100%; margin-top: 0; }
.opt-section {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255, 200, 180, 0.14);
}
.opt-box { margin-top: 8px; }
.chap-picker {
  margin-top: 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
}
.btn-chap {
  margin-top: 0; padding: 6px 11px; font-size: 12.5px;
  color: #ffe6d6; background: rgba(255, 200, 180, 0.14);
  border: 1px solid rgba(255, 200, 180, 0.28); box-shadow: none;
}
.btn-chap.done {
  border-color: rgba(255, 235, 170, 0.65);
  color: #fff2b8;
}

/* ---------- 편지 & 허브 & 별 모달 ---------- */
.letter-panel, .hub-panel {
  width: min(92vw, 490px); text-align: left;
  background: rgba(34, 12, 26, 0.88);
}
.hub-panel { text-align: center; }
.hub-actions {
  display: flex; flex-direction: column; gap: 9px;
}
.hub-actions button { width: 100%; margin-top: 0; }

.letter-title {
  font-family: "Nanum Myeongjo", "Batang", serif;
  font-size: 20px; color: #ffe6c8; text-align: center; margin-bottom: 12px;
}
.letter-body {
  font-size: 15px; line-height: 1.75; color: #fff3ea;
  padding: 16px 18px; border-radius: 16px;
  background: rgba(255, 235, 220, 0.06);
  border: 1px solid rgba(255, 210, 190, 0.18);
  white-space: pre-line;
}
.letter-body.empty-body {
  color: rgba(255, 235, 220, 0.6); font-style: italic; text-align: center;
}
.letter-sign {
  margin-top: 12px; text-align: right; font-weight: bold;
  font-family: "Nanum Myeongjo", "Batang", serif;
  font-size: 15.5px; color: #ffd9b8;
}
.letter-actions {
  margin-top: 16px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.letter-actions button { margin-top: 0; padding: 10px 18px; font-size: 14px; }

#sky-bar {
  position: fixed; left: 50%; bottom: 3vh; transform: translateX(-50%); z-index: 35;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  width: min(94vw, 540px);
}
#sky-bar button { margin-top: 0; padding: 10px 18px; font-size: 13.5px; }

.star-modal { width: min(92vw, 450px); text-align: left; }
.star-badge {
  display: inline-block; margin: 0 auto 10px; padding: 3px 12px;
  font-size: 12px; color: #ffe9b8;
  background: rgba(255, 225, 175, 0.14);
  border: 1px solid rgba(255, 225, 175, 0.3);
  border-radius: 999px;
}
.light-notice {
  margin-bottom: 10px; padding: 8px 12px; border-radius: 10px;
  background: rgba(255, 240, 180, 0.14); border: 1px solid rgba(255, 240, 180, 0.35);
  color: #fff2b2; font-size: 13.5px; text-align: center;
}
.status-msg {
  margin-top: 8px; font-size: 13px; color: #ffe8a8; text-align: center; min-height: 18px;
}
.studio-credit {
  margin-top: 14px; font-size: 12px; color: rgba(255, 225, 210, 0.62); text-align: center;
}
.studio-credit a {
  color: #ffdcb8; text-decoration: none; border-bottom: 1px solid rgba(255, 220, 184, 0.35);
  padding-bottom: 1px; transition: opacity 0.2s, border-color 0.2s;
}
.studio-credit a:hover {
  opacity: 0.95; border-bottom-color: #ffe8c8;
}
.error-msg {
  margin-top: 8px; font-size: 13px; color: #ffb3c1; text-align: center;
}

input {
  display: block; width: 75%; margin: 6px auto 10px; padding: 9px 12px; text-align: center;
  font-size: 18px; font-family: inherit; color: #fff3ea;
  background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(255, 200, 180, 0.35);
  border-radius: 12px; outline: none; user-select: text; -webkit-user-select: text;
}
.field-label { display: block; font-size: 13px; color: #ffd9c4; margin: 8px 0 4px; opacity: 0.92; }
#modal-star-write input[type="text"], #modal-star-write input:not([type]) {
  width: 100%; margin: 0 0 8px; font-size: 15.5px; text-align: left;
}
#modal-star-write textarea {
  width: 100%; padding: 10px 12px; font-size: 14.5px; line-height: 1.55;
  font-family: inherit; color: #fff3ea;
  background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(255, 200, 180, 0.35);
  border-radius: 12px; outline: none; resize: none;
  user-select: text; -webkit-user-select: text;
}
.vis-choice {
  margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap;
}
.radio-label {
  display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer;
}
.radio-label input { width: auto; margin: 0; }
.vis-info {
  margin-top: 6px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12.5px; color: rgba(255, 235, 220, 0.8); line-height: 1.5;
}

/* ---------- 성장 노트 & 운영자 모달 ---------- */
.gn-tabs {
  display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px;
}
.gn-tab { padding: 5px 10px; font-size: 12px; }
.gn-tab.active {
  background: linear-gradient(#ffe6d6, #ffc4ae); color: #4a1426; font-weight: bold;
}
.gn-canvas {
  display: block; width: 100%; max-width: 280px; height: 140px;
  margin: 8px auto 10px; border-radius: 14px;
  border: 1px solid rgba(255, 210, 190, 0.25);
}
.gn-card-title {
  font-weight: bold; font-size: 16px; color: #ffe6c8; margin-bottom: 8px; text-align: center;
}
.review-badge {
  margin-top: 10px; padding: 7px 10px; border-radius: 8px;
  background: rgba(255, 200, 150, 0.1); border: 1px dashed rgba(255, 200, 150, 0.35);
  font-size: 11.5px; color: rgba(255, 225, 195, 0.78); line-height: 1.45;
}
.admin-list { max-height: 45vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 200, 180, 0.18);
  font-size: 13px;
}
.admin-info { flex: 1; }

/* ---------- 대화창 ---------- */
#dialog {
  position: fixed; left: 50%; bottom: 4vh; transform: translateX(-50%); z-index: 10;
  width: min(92vw, 640px); min-height: 118px; padding: 22px 24px 26px;
  background: rgba(30, 8, 18, 0.74); border: 1px solid rgba(255, 200, 180, 0.22);
  border-radius: 20px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.4s ease;
}
#dlg-name {
  position: absolute; top: -14px; left: 20px; padding: 3px 14px;
  font-size: 14px; font-weight: bold; border-radius: 999px;
  background: #ffd9c4; color: #5a1a2e;
}
#dlg-text { font-size: 17.5px; line-height: 1.7; white-space: pre-line; }
#dlg-next { position: absolute; right: 18px; bottom: 8px; font-size: 12px; opacity: 0.6; animation: bob 1s infinite; }
#dlg-next::before { content: '클릭 · Enter '; font-size: 11px; letter-spacing: 0.02em; }
@media (hover: none), (pointer: coarse) {
  #dlg-next::before { content: '화면 터치 '; }
}
.sp-mom #dlg-name { background: #ffb3c1; }
.sp-dad #dlg-name { background: #b9d4ff; color: #1b2e55; }
.sp-doc #dlg-name { background: #d6d6d6; color: #333; }
.sp-nar #dlg-name { display: none; }
.sp-nar #dlg-text { font-style: italic; opacity: 0.88; text-align: center; }
.sp-mom #dlg-text, .sp-dad #dlg-text, .sp-doc #dlg-text { color: #f1f1f1; }

/* ---------- 힌트 ---------- */
#hint {
  position: fixed; top: 8vh; left: 50%; transform: translateX(-50%); z-index: 10;
  max-width: 92vw; text-align: center;
  padding: 10px 20px; font-size: 14.5px; border-radius: 999px;
  background: rgba(30, 8, 18, 0.68); border: 1px solid rgba(255, 200, 180, 0.25);
  animation: fadeIn 0.5s ease;
  pointer-events: none;
}

/* ---------- 모바일 / 터치 호환 ---------- */
html, body { overscroll-behavior: none; -webkit-touch-callout: none; }
/* 게임 화면에서 드래그·스와이프 시 스크롤/당겨서 새로고침/핀치줌이 끼어들지 않도록 */
#c, #dialog, #hint, #fade, #card { touch-action: none; }
@media (max-width: 600px) {
  #dialog { bottom: max(3vh, env(safe-area-inset-bottom)); padding: 20px 18px 24px; min-height: 104px; }
  #dlg-text { font-size: 15.5px; line-height: 1.6; }
  #hint { top: max(7vh, calc(env(safe-area-inset-top) + 44px)); font-size: 12.5px; padding: 8px 14px; border-radius: 16px; }
  #top-bar { top: max(10px, env(safe-area-inset-top)); right: 10px; }
  .btn-pill { padding: 6px 11px; font-size: 12px; }
}

/* ---------- 페이드 & 타이틀 카드 ---------- */
#fade { position: fixed; inset: 0; z-index: 20; background: #000; opacity: 0; pointer-events: none; }
#card {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.9s ease;
}
#card.show { opacity: 1; }
#card-sub { font-size: 15px; letter-spacing: 4px; opacity: 0.75; margin-bottom: 14px; }
#card-title {
  font-family: "Nanum Myeongjo", "Batang", serif; font-size: 34px; letter-spacing: 4px;
  color: #ffe2d2; text-shadow: 0 0 20px rgba(255, 160, 140, 0.6);
}
#card.big #card-title { font-size: 72px; letter-spacing: 10px; animation: beat 0.55s infinite; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bob { 50% { transform: translateY(3px); } }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.06); } 26% { transform: scale(1.0); } 38% { transform: scale(1.04); } }
