/* ============================================================
   포켓스톱 : 서연이의 작은 정원 — Visual Novel Stylesheet
   ============================================================ */

:root {
  --font-serif: 'Noto Serif KR', 'Noto Serif JP', Georgia, serif;
  --font-sans: 'Noto Sans KR', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-hand: 'Gaegu', 'Noto Serif JP', cursive, sans-serif;

  --accent-pink: #f48fb1;
  --accent-sakura: #ffb7c5;
  --accent-sky: #7ec8e3;
  --accent-gold: #ffd54f;
  --accent-mint: #80cbc4;

  --glass-bg: rgba(14, 20, 34, 0.78);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text-main: #f7f9fc;
  --text-sub: #c6d0e3;
}

html[lang="ja"] {
  --font-serif: 'Noto Serif JP', 'Noto Serif KR', Georgia, serif;
  --font-sans: 'Noto Sans JP', 'Noto Sans KR', sans-serif;
}

html[lang="en"] .dialogue-text {
  word-break: normal;
  overflow-wrap: break-word;
}

html[lang="ja"] .letter-body,
html[lang="en"] .letter-body {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.8;
}

html[lang="ja"] .sketchbook-text,
html[lang="en"] .sketchbook-text {
  font-family: var(--font-sans);
  font-size: clamp(1.35rem, 3.2vw, 1.8rem);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #090d16;
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

/* ==================== Screens ==================== */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

.hidden {
  display: none !important;
}

.particle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* ==================== Title & Ending Screens ==================== */
.title-bg {
  position: absolute;
  inset: -20px;
  background-size: cover;
  background-position: center;
  filter: brightness(0.82) saturate(1.08);
  animation: gentlePan 26s ease-in-out infinite alternate;
  z-index: 1;
}

@keyframes gentlePan {
  0%   { transform: scale(1.04) translate(0, 0); }
  100% { transform: scale(1.1) translate(-1.5%, -1%); }
}

.title-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(10, 16, 28, 0.25) 0%, rgba(10, 16, 28, 0.78) 100%);
  z-index: 2;
}

.title-content, .ending-content {
  position: relative;
  z-index: 20;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.title-badge, .ending-badge {
  font-size: 0.78rem;
  letter-spacing: 0.35em;
  color: var(--accent-sakura);
  padding: 6px 18px;
  border: 1px solid rgba(255, 183, 197, 0.45);
  border-radius: 999px;
  background: rgba(15, 22, 38, 0.55);
  backdrop-filter: blur(8px);
  margin-bottom: 18px;
}

.game-title {
  font-family: var(--font-serif);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.65);
  margin-bottom: 18px;
}

.title-sub {
  font-size: clamp(1.15rem, 2.2vw, 1.65rem);
  font-weight: 400;
  color: var(--accent-sakura);
  letter-spacing: 0.14em;
}

.title-main {
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.04em;
}

.title-quote {
  font-family: var(--font-serif);
  font-size: clamp(0.9rem, 1.5vw, 1.08rem);
  line-height: 1.85;
  color: rgba(245, 248, 255, 0.9);
  max-width: 580px;
  margin-bottom: 34px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.menu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(18, 26, 44, 0.68);
  backdrop-filter: blur(12px);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.menu-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(34, 48, 76, 0.85);
  border-color: var(--accent-sakura);
  box-shadow: 0 10px 28px rgba(244, 143, 177, 0.25);
}

.menu-btn.primary {
  background: linear-gradient(135deg, rgba(244, 143, 177, 0.9), rgba(126, 200, 227, 0.88));
  border-color: rgba(255, 255, 255, 0.45);
  color: #101727;
  font-weight: 700;
}

.menu-btn.primary:hover {
  filter: brightness(1.07);
  box-shadow: 0 12px 32px rgba(244, 143, 177, 0.42);
}

.menu-btn.small {
  padding: 11px 12px;
  font-size: 0.88rem;
}

.menu-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.menu-sub {
  font-size: 0.76rem;
  opacity: 0.8;
}

.badge-pill {
  font-size: 0.74rem;
  background: rgba(255, 183, 197, 0.25);
  color: var(--accent-sakura);
  padding: 2px 7px;
  border-radius: 999px;
}

.title-footer {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: 620px;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(10, 16, 28, 0.45);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}

.title-credit {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent-sakura);
  letter-spacing: 0.03em;
}

.title-disclaimer {
  font-size: 0.76rem;
  color: rgba(240, 245, 255, 0.85);
  line-height: 1.5;
  word-break: keep-all;
}

.title-controls {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.56);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

/* Language Switcher on Title Screen */
.lang-switcher {
  position: absolute;
  top: 20px;
  right: 22px;
  z-index: 50;
  pointer-events: auto;
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(14, 20, 34, 0.78);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.lang-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  color: #fff;
}

.lang-btn.active {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-sky));
  color: #0e1422;
  font-weight: 700;
}

/* ==================== Game Background & Effects ==================== */
.bg-layer {
  position: absolute;
  inset: -12px;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.1s ease, transform 8s ease;
  z-index: 1;
}

.bg-layer.active {
  opacity: 1;
}

.bg-filter {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(8, 12, 22, 0.35) 0%, rgba(8, 12, 22, 0.05) 35%, rgba(8, 12, 22, 0.58) 100%);
  pointer-events: none;
  z-index: 3;
  transition: background 0.8s ease;
}

.bg-filter.sad {
  background: linear-gradient(to bottom, rgba(10, 14, 24, 0.55) 0%, rgba(15, 20, 35, 0.32) 45%, rgba(8, 10, 18, 0.78) 100%);
}

.bg-filter.golden {
  background: radial-gradient(circle at center, rgba(255, 213, 79, 0.24) 0%, rgba(14, 18, 32, 0.65) 100%);
}

.bg-filter.whiteout {
  background: rgba(255, 255, 255, 0.88);
}

.screen-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  transition: opacity 0.45s ease;
}

.screen-flash.flash-on {
  opacity: 0.92;
}

.screen-flash.flash-gold {
  background: radial-gradient(circle, #fff8d6 0%, #ffd54f 60%, rgba(255, 213, 79, 0) 100%);
  opacity: 0.85;
}

.shake {
  animation: screenShake 0.45s ease-in-out;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(6px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}

.gps-error-banner {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(211, 47, 47, 0.92);
  color: #fff;
  padding: 9px 26px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 6px 24px rgba(211, 47, 47, 0.5);
  animation: gpsBlink 1.3s ease-in-out infinite;
}

@keyframes gpsBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.52; }
}

.ecg-canvas {
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  height: 150px;
  width: 100%;
  z-index: 25;
  pointer-events: none;
}

/* ==================== Chapter Banner ==================== */
.chapter-banner {
  position: absolute;
  inset: 0;
  z-index: 55;
  background: rgba(8, 12, 22, 0.86);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.6s ease;
}

.chapter-banner-inner {
  text-align: center;
  padding: 32px;
}

.chapter-num {
  font-size: 0.95rem;
  letter-spacing: 0.35em;
  color: var(--accent-sakura);
  margin-bottom: 12px;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.6vw, 2.5rem);
  font-weight: 600;
  color: #fff;
  margin-bottom: 18px;
}

.chapter-line {
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-sakura), transparent);
  margin: 0 auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==================== Top HUD ==================== */
.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(to bottom, rgba(8, 12, 22, 0.72), transparent);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-tag {
  background: rgba(255, 183, 197, 0.22);
  border: 1px solid rgba(255, 183, 197, 0.45);
  color: var(--accent-sakura);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.hud-loc {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-btn {
  background: rgba(14, 20, 34, 0.62);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e9effa;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: rgba(34, 48, 76, 0.85);
  border-color: var(--accent-sakura);
}

.hud-btn.active {
  background: var(--accent-pink);
  color: #101727;
  border-color: #fff;
  font-weight: 700;
}

/* ==================== Character Portrait ==================== */
.portrait-stage {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 225px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}

.portrait-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: portraitPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes portraitPop {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.portrait-ring {
  width: clamp(130px, 18vw, 190px);
  height: clamp(130px, 18vw, 190px);
  border-radius: 50%;
  padding: 5px;
  background: linear-gradient(135deg, rgba(255, 183, 197, 0.9), rgba(126, 200, 227, 0.9));
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 28px rgba(255, 183, 197, 0.28);
  overflow: hidden;
}

.portrait-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.portrait-label {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  background: rgba(14, 20, 34, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 3px 14px;
  border-radius: 999px;
  color: #fff;
}

/* ==================== Dialogue Box ==================== */
.dialogue-container {
  position: absolute;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(920px, calc(100% - 28px));
  z-index: 30;
  cursor: pointer;
}

.speaker-box {
  display: inline-block;
  margin-left: 16px;
  margin-bottom: -1px;
  padding: 6px 20px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(135deg, rgba(244, 143, 177, 0.92), rgba(126, 200, 227, 0.9));
  color: #0e1422;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.22);
}

.dialogue-box {
  position: relative;
  min-height: 152px;
  padding: 24px 30px 26px;
  border-radius: 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.52);
}

.dialogue-text {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 1.75vw, 1.16rem);
  line-height: 1.85;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: keep-all;
}

.dialogue-text.thought {
  color: #d6e4ff;
  font-style: italic;
}

.next-indicator {
  position: absolute;
  right: 22px;
  bottom: 14px;
  color: var(--accent-sakura);
  font-size: 0.9rem;
  animation: bounceArrow 0.9s ease-in-out infinite;
}

@keyframes bounceArrow {
  0%, 100% { transform: translateY(0); opacity: 0.65; }
  50% { transform: translateY(4px); opacity: 1; }
}

/* ==================== Choices ==================== */
.choice-container {
  position: absolute;
  inset: 0;
  bottom: 195px;
  z-index: 38;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  background: rgba(8, 12, 22, 0.35);
}

.choice-btn {
  width: min(560px, 92%);
  padding: 16px 24px;
  border-radius: 14px;
  border: 1px solid rgba(255, 183, 197, 0.55);
  background: rgba(16, 24, 42, 0.88);
  backdrop-filter: blur(12px);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  gap: 12px;
}

.choice-btn::before {
  content: '✦';
  color: var(--accent-sakura);
  font-size: 0.9rem;
}

.choice-btn:hover {
  transform: translateY(-2px) scale(1.01);
  background: linear-gradient(135deg, rgba(244, 143, 177, 0.28), rgba(126, 200, 227, 0.28));
  border-color: #fff;
}

/* ==================== Interactive Overlays (Minigames & Phone UI) ==================== */
.interactive-layer {
  position: absolute;
  inset: 0;
  z-index: 42;
  background: rgba(7, 11, 20, 0.62);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.35s ease;
}

.phone-frame {
  width: min(370px, 94vw);
  max-height: 82vh;
  border-radius: 32px;
  border: 4px solid #2b354b;
  background: linear-gradient(180deg, #1b2845 0%, #10182b 100%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-notch {
  height: 22px;
  background: #0d1322;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-notch::after {
  content: '';
  width: 64px;
  height: 5px;
  border-radius: 999px;
  background: #27324a;
}

.phone-body {
  padding: 22px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  overflow-y: auto;
}

.phone-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: #fff;
}

.phone-sub {
  font-size: 0.86rem;
  color: var(--text-sub);
  line-height: 1.55;
}

/* Pokestop Disc */
.pokestop-disc-wrap {
  position: relative;
  width: 176px;
  height: 176px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pokestop-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid #4fc3f7;
  box-shadow: 0 0 24px rgba(79, 195, 247, 0.55);
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

.pokestop-ring.spun {
  border-color: #ce93d8;
  box-shadow: 0 0 28px rgba(206, 147, 216, 0.7);
}

.pokestop-ring.lured {
  border-color: #f48fb1;
  box-shadow: 0 0 34px rgba(244, 143, 177, 0.85);
}

.pokestop-disc {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 3px solid #fff;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.pokestop-disc.spinning {
  transform: rotateY(720deg);
}

.item-drops {
  display: flex;
  gap: 10px;
  justify-content: center;
  min-height: 44px;
}

.drop-pill {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  animation: dropPop 0.4s ease forwards;
}

@keyframes dropPop {
  from { opacity: 0; transform: translateY(12px) scale(0.7); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Catch Minigame */
.catch-stage {
  position: relative;
  width: 100%;
  height: 230px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1b2d4f 0%, #2d5a4c 65%, #3c7a57 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
}

.pokemon-sprite {
  font-size: 3.8rem;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.4));
  animation: pokeBounce 1.8s ease-in-out infinite;
  transition: all 0.4s ease;
}

@keyframes pokeBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.pokeball-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #1e2430;
  background: linear-gradient(180deg, #ef5350 0%, #ef5350 47%, #1e2430 47%, #1e2430 53%, #ffffff 53%, #ffffff 100%);
  position: relative;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease;
}

.pokeball-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #1e2430;
}

.pokeball-btn:hover {
  transform: scale(1.1);
}

.pokeball-btn.wobble {
  animation: ballWobble 0.55s ease-in-out 3;
}

@keyframes ballWobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-18deg); }
  75% { transform: rotate(18deg); }
}

/* Sketchbook & Letter */
.sketchbook-card {
  width: min(460px, 92vw);
  background: #fffdf7;
  color: #222;
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  border-top: 12px solid #37474f;
  text-align: center;
}

.sketchbook-text {
  font-family: var(--font-hand);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  color: #1a237e;
  margin: 16px 0 22px;
  line-height: 1.4;
}

.letter-card {
  width: min(500px, 92vw);
  background: linear-gradient(180deg, #fffdf5 0%, #fbf4e4 100%);
  color: #3a3228;
  border-radius: 14px;
  padding: 30px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  border: 1px solid #e6d7be;
  text-align: left;
}

.letter-body {
  font-family: var(--font-hand);
  font-size: 1.32rem;
  line-height: 1.75;
  margin-bottom: 22px;
  white-space: pre-line;
}

/* Messenger Overlay */
.chat-window {
  width: 100%;
  background: #b2c7d9;
  border-radius: 14px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  text-align: left;
}

.chat-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #1e2430;
  animation: dropPop 0.3s ease;
}

.chat-msg.left {
  align-self: flex-start;
  background: #ffffff;
  border-top-left-radius: 4px;
}

.chat-msg.right {
  align-self: flex-end;
  background: #fef01b;
  border-top-right-radius: 4px;
}

.chat-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: #3a4a5e;
  margin-bottom: 3px;
}

/* Go Plus Button */
.goplus-device {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e53935 0%, #e53935 48%, #263238 48%, #263238 54%, #fafafa 54%, #fafafa 100%);
  border: 4px solid #37474f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  transition: transform 0.15s ease;
}

.goplus-device:active {
  transform: scale(0.94);
}

.goplus-led {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #4caf50;
  border: 4px solid #263238;
  box-shadow: 0 0 22px #4caf50;
  animation: ledPulse 1s ease-in-out infinite;
}

@keyframes ledPulse {
  0%, 100% { box-shadow: 0 0 10px #4caf50; opacity: 0.75; }
  50% { box-shadow: 0 0 30px #81c784; opacity: 1; }
}

/* Raid & Lucky Card */
.lucky-card {
  width: 100%;
  padding: 20px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff3b0 0%, #ffd54f 50%, #ffb74d 100%);
  color: #3e2723;
  box-shadow: 0 0 36px rgba(255, 213, 79, 0.65);
}

.raid-lobby-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  margin: 8px 0;
}

.raid-slot {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 213, 79, 0.45);
  border-radius: 8px;
  padding: 6px 2px;
  font-size: 0.95rem;
  animation: dropPop 0.35s ease;
}

.hp-bar-wrap {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0;
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff7043, #ffd54f, #66bb6a);
  transition: width 0.35s ease;
}

.action-btn {
  padding: 12px 24px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-sky));
  color: #0e1422;
  font-weight: 700;
  font-size: 0.94rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(244, 143, 177, 0.35);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

/* ==================== Toast ==================== */
.toast {
  position: absolute;
  top: 72px;
  right: 22px;
  z-index: 70;
  background: rgba(16, 24, 42, 0.92);
  border: 1px solid var(--accent-sakura);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 0.86rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: fadeIn 0.25s ease;
}

/* ==================== Modals ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.78);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  z-index: 2;
  width: min(520px, 95vw);
  max-height: 82vh;
  background: #141c2f;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.modal-card.wide {
  width: min(740px, 95vw);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
  font-size: 1.08rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
}

/* Chapter List */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.chapter-item:hover {
  background: rgba(255, 183, 197, 0.15);
  border-color: var(--accent-sakura);
}

.chapter-item-num {
  font-size: 0.78rem;
  color: var(--accent-sakura);
  margin-bottom: 2px;
}

.chapter-item-title {
  font-family: var(--font-serif);
  font-size: 1rem;
}

/* Album Grid */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.postcard-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.postcard-card.locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.postcard-img {
  height: 112px;
  background-size: cover;
  background-position: center;
  background-color: #1f2a42;
}

.postcard-info {
  padding: 12px;
}

.postcard-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-sakura);
  margin-bottom: 4px;
}

.postcard-desc {
  font-size: 0.78rem;
  color: var(--text-sub);
  line-height: 1.5;
}

/* Log List */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-entry {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.log-speaker {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-sakura);
  margin-bottom: 3px;
}

.log-text {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.65;
  color: #e6edf8;
}

/* Ending */
.ending-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.8vw, 2.6rem);
  margin-bottom: 18px;
}

.ending-message {
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 1.6vw, 1.12rem);
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.92);
  max-width: 560px;
  margin-bottom: 24px;
}

.ending-stats {
  font-size: 0.88rem;
  color: var(--accent-sakura);
  margin-bottom: 26px;
}

.ending-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Mobile & Small-Height Responsive */
@media (max-width: 640px) {
  .lang-switcher {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    padding: 4px;
  }
  .lang-btn {
    padding: 5px 10px;
    font-size: 0.76rem;
  }
  .title-content, .ending-content {
    padding: 64px 16px calc(22px + env(safe-area-inset-bottom, 0px));
    justify-content: center;
    overflow-y: auto;
  }
  .title-quote {
    margin-bottom: 22px;
    font-size: 0.88rem;
  }
  .title-footer {
    margin-top: 18px;
    padding: 8px 12px;
  }
  .game-hud {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
    gap: 6px;
  }
  .hud-loc { display: none; }
  .hud-right {
    gap: 4px;
    flex-wrap: nowrap;
  }
  .hud-btn {
    padding: 5px 7px;
    font-size: 0.68rem;
  }
  .dialogue-container {
    width: calc(100% - 18px);
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .speaker-box {
    margin-left: 12px;
    padding: 4px 14px;
    font-size: 0.85rem;
  }
  .dialogue-box {
    min-height: 118px;
    max-height: 36dvh;
    overflow-y: auto;
    padding: 15px 16px 24px;
    border-radius: 15px;
  }
  .dialogue-text {
    font-size: 0.94rem;
    line-height: 1.72;
  }
  .portrait-stage {
    bottom: calc(185px + env(safe-area-inset-bottom, 0px));
  }
  .portrait-ring {
    width: 116px;
    height: 116px;
  }
  .choice-container {
    bottom: calc(165px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  .choice-btn {
    padding: 13px 16px;
    font-size: 0.92rem;
  }
}

@media (max-height: 640px) {
  .dialogue-container {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .dialogue-box {
    min-height: 96px;
    max-height: 38dvh;
    overflow-y: auto;
    padding: 12px 18px 20px;
  }
  .portrait-stage {
    bottom: calc(155px + env(safe-area-inset-bottom, 0px));
  }
  .portrait-ring {
    width: 104px;
    height: 104px;
  }
}
