/* ============================================================
   紫薔薇の夜会 〜メイド・あびむと秘密のお茶会〜
   Mobile-First Gothic Velvet & Antique Gold Stylesheet
   ============================================================ */

:root {
  --bg-void: #0d0914;
  --bg-surface: #171124;
  --bg-elevated: #231936;
  --bg-glass: rgba(20, 14, 32, 0.84);
  --border-subtle: rgba(196, 174, 232, 0.18);
  --border-gold: rgba(226, 199, 153, 0.38);
  --accent-amethyst: #b694ff;
  --accent-violet: #7c3aed;
  --accent-violet-deep: #4c1d95;
  --accent-gold: #e4caa0;
  --accent-rose: #f472b6;
  --text-primary: #f6f1fc;
  --text-secondary: #c5b8d9;
  --text-muted: #9282ad;
  --nav-height: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font-serif: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', Georgia, serif;
  --font-sans: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-glow: 0 10px 30px rgba(88, 28, 135, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  background-color: #07040c;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

/* ==================== APP SHELL ==================== */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background: radial-gradient(circle at top, #211636 0%, var(--bg-void) 60%);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Subtle floating amethyst petals */
.ambient-layer {
  position: fixed;
  inset: 0;
  max-width: 440px;
  margin: 0 auto;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.petal {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 60% 40% 60% 40% / 50% 60% 40% 50%;
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.55), rgba(109, 40, 217, 0.15));
  filter: blur(0.4px);
  animation: petalFall linear infinite;
}

.p1 { left: 12%; animation-duration: 13s; animation-delay: 0s; }
.p2 { left: 36%; animation-duration: 16s; animation-delay: 3s; width: 8px; height: 11px; }
.p3 { left: 62%; animation-duration: 14s; animation-delay: 6s; }
.p4 { left: 82%; animation-duration: 18s; animation-delay: 2s; width: 9px; height: 12px; }
.p5 { left: 48%; animation-duration: 15s; animation-delay: 9s; width: 7px; height: 10px; }

@keyframes petalFall {
  0% {
    transform: translateY(-20px) translateX(0) rotate(0deg);
    opacity: 0;
  }
  12% { opacity: 0.7; }
  85% { opacity: 0.45; }
  100% {
    transform: translateY(105dvh) translateX(28px) rotate(320deg);
    opacity: 0;
  }
}

/* ==================== VIEWS ==================== */
.view-container {
  flex: 1;
  position: relative;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  z-index: 3;
}

.view {
  display: none;
  min-height: calc(100dvh - var(--nav-height) - var(--safe-bottom));
}

.view.active {
  display: block;
}

/* ==================== BUTTON SYSTEM (>= 44px Tap Targets) ==================== */
.btn-primary,
.btn-secondary,
.btn-danger-outline,
.chip-action-btn,
.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn-primary:active,
.btn-secondary:active,
.chip-action-btn:active,
.choice-btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #ffffff;
  border: 1px solid rgba(226, 199, 153, 0.5);
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.45);
}

.btn-primary:hover {
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.55);
}

.btn-secondary {
  background: rgba(35, 25, 54, 0.88);
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
}

.btn-lg {
  width: 100%;
  min-height: 52px;
  font-size: 1rem;
}

.btn-sm {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.88rem;
}

.btn-danger-outline {
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.55);
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.2);
  font-size: 0.85rem;
}

.icon-pill-btn {
  min-height: 44px;
  padding: 0 14px;
  background: rgba(18, 12, 28, 0.72);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  font-size: 0.82rem;
}

.icon-circle-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(25, 18, 40, 0.82);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ==================== HOME VIEW ==================== */
.home-hero {
  position: relative;
  height: 43dvh;
  min-height: 265px;
  max-height: 355px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-gold);
}

.home-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 14%;
}

.home-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(13, 9, 20, 0.52) 0%,
    rgba(13, 9, 20, 0.08) 38%,
    rgba(13, 9, 20, 0.72) 78%,
    var(--bg-void) 100%
  );
}

.home-header-bar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(18, 12, 28, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(182, 148, 255, 0.35);
  color: var(--accent-amethyst);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.home-title-block {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  text-align: center;
}

.home-eyebrow {
  margin: 0 0 4px;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  color: var(--accent-gold);
  opacity: 0.92;
}

.home-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #ffffff;
  text-shadow: 0 4px 20px rgba(109, 40, 217, 0.8), 0 2px 6px rgba(0, 0, 0, 0.9);
}

.home-subtitle {
  margin: 4px 0 0;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

.home-body {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  background: linear-gradient(180deg, rgba(38, 27, 58, 0.78), rgba(23, 17, 36, 0.9));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--accent-gold);
}

.stat-value small {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-intro-card {
  background: rgba(25, 18, 40, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.card-heading {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  color: var(--accent-gold);
  letter-spacing: 0.06em;
}

.card-text {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.card-text strong {
  color: var(--accent-amethyst);
}

.home-quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chip-action-btn {
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: rgba(124, 58, 237, 0.16);
  border: 1px solid rgba(182, 148, 255, 0.35);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ==================== STORY / PLAY VIEW ==================== */
#view-play.active {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--nav-height) - var(--safe-bottom));
  min-height: 520px;
  overflow: hidden;
}

.novel-stage {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: #0b0712;
}

.stage-visual-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.stage-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 12%;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.stage-img.active {
  opacity: 1;
}

.stage-img.pulse {
  animation: gentleShake 0.45s ease;
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px) scale(1.015); }
  55% { transform: translateX(5px) scale(1.015); }
  80% { transform: translateX(-2px); }
}

.stage-top-scrim {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: linear-gradient(180deg, rgba(10, 6, 18, 0.82) 0%, rgba(10, 6, 18, 0) 100%);
  pointer-events: none;
}

.stage-bottom-scrim {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52%;
  background: linear-gradient(0deg, rgba(10, 6, 18, 0.94) 0%, rgba(10, 6, 18, 0.56) 55%, rgba(10, 6, 18, 0) 100%);
  pointer-events: none;
}

/* Novel HUD */
.novel-hud {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-left {
  flex: 1;
  min-width: 0;
  background: rgba(15, 10, 25, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(226, 199, 153, 0.25);
  border-radius: 12px;
  padding: 7px 10px;
}

.chapter-badge {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-violet), var(--accent-gold));
  border-radius: 999px;
  transition: width 0.35s ease;
}

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

.hud-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  background: rgba(15, 10, 25, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(196, 174, 232, 0.28);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hud-btn:active {
  transform: scale(0.94);
}

.hud-btn[aria-pressed='true'] {
  border-color: var(--border-gold);
  color: var(--accent-gold);
}

.hud-btn[aria-pressed='false'] {
  color: var(--text-muted);
  opacity: 0.62;
}

.mood-bar {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 12px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}

.mood-chip {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(16, 11, 26, 0.72);
  border: 1px solid rgba(182, 148, 255, 0.3);
  color: var(--text-secondary);
  backdrop-filter: blur(6px);
}

/* Choices Overlay */
.choices-overlay {
  position: relative;
  z-index: 7;
  padding: 0 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slideUpChoices 0.24s ease-out;
}

@keyframes slideUpChoices {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.choice-btn {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(35, 24, 58, 0.94), rgba(22, 15, 38, 0.96));
  border: 1px solid var(--border-gold);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  transition: transform 0.14s ease, border-color 0.2s ease, background 0.2s ease;
}

.choice-btn:hover {
  border-color: var(--accent-amethyst);
  background: linear-gradient(135deg, rgba(56, 36, 92, 0.96), rgba(32, 20, 56, 0.98));
}

.choice-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.choice-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
}

.choice-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.choice-visited {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(228, 202, 160, 0.15);
  border: 1px solid rgba(228, 202, 160, 0.4);
  padding: 3px 7px;
  border-radius: 999px;
}

/* Ending Result Card */
.ending-card {
  position: relative;
  z-index: 8;
  margin: 0 12px 10px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(18, 12, 30, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-gold);
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  animation: slideUpChoices 0.35s ease-out;
}

.ending-card-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.ending-card-num {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
}

.ending-card-title {
  margin: 4px 0 8px;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--accent-gold);
}

.ending-card-new {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.08em;
}

.ending-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Dialogue Box */
.dialogue-area {
  position: relative;
  z-index: 6;
  margin: 0 10px 10px;
  padding: 14px 15px 10px;
  min-height: 138px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.speaker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  margin-bottom: 6px;
}

.speaker-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.85), rgba(168, 85, 247, 0.65));
  border: 1px solid rgba(226, 199, 153, 0.45);
  color: #ffffff;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.autosave-dot {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.dialogue-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  line-height: 1.72;
  color: var(--text-primary);
  min-height: 68px;
}

.dialogue-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.tap-hint {
  font-size: 0.75rem;
  color: var(--accent-gold);
  animation: pulseHint 1.4s ease-in-out infinite;
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.55; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(2px); }
}

/* ==================== SECTION HEADERS (GALLERY & ENDINGS) ==================== */
.section-header {
  padding: calc(18px + var(--safe-top)) 16px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.section-eyebrow {
  margin: 0 0 2px;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--accent-amethyst);
}

.section-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: #ffffff;
  letter-spacing: 0.06em;
}

.completion-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.24);
  border: 1px solid var(--border-gold);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-gold);
  white-space: nowrap;
}

/* ==================== GALLERY VIEW ==================== */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(31, 22, 48, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
}

.filter-chip.active {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  border-color: var(--border-gold);
  color: #ffffff;
}

.filter-chip-special {
  border-color: rgba(228, 202, 160, 0.45);
  color: var(--accent-gold);
}

.filter-chip-special.active {
  background: linear-gradient(135deg, #b45309, #7c3aed);
  border-color: #fde68a;
  color: #ffffff;
}

.art-mode-bar {
  margin: 0 16px 12px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(23, 17, 36, 0.85);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.art-mode-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.lightbox-desc-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.lightbox-desc-row .lightbox-desc {
  margin: 0;
}

.lightbox-edition-btn {
  width: 100%;
  min-height: 44px;
  border-color: var(--border-gold);
  color: var(--accent-gold);
  background: rgba(124, 58, 237, 0.2);
}

.special-banner {
  margin: 0 16px 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.24), rgba(226, 199, 153, 0.14));
  border: 1px solid var(--border-gold);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.special-banner strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.92rem;
  color: var(--accent-gold);
  margin-bottom: 2px;
}

.special-banner.unlocked {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.28), rgba(124, 58, 237, 0.34));
  border-color: #fde68a;
}

.gallery-card.special-card.unlocked {
  border-color: rgba(253, 230, 138, 0.55);
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.22);
}

.gallery-card.special-card .gallery-card-sub {
  color: var(--accent-gold);
}

.gallery-thumb.veiled {
  filter: blur(16px) brightness(0.42);
  transform: scale(1.08);
}

.gallery-veil-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  gap: 6px;
  background: rgba(14, 9, 24, 0.56);
}

.veil-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.65);
  color: #fde68a;
  font-size: 0.72rem;
  font-weight: 700;
}

.veil-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.special-banner-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.warning-header h3 {
  color: #fde68a;
}

.warning-body {
  gap: 12px;
}

.warning-lead {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.65;
}

.warning-lead strong {
  color: #fde68a;
}

.warning-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.warning-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.gallery-grid {
  padding: 0 16px 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.gallery-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  text-align: left;
  min-height: 220px;
  transition: transform 0.16s ease, border-color 0.2s ease;
}

.gallery-card.unlocked {
  border-color: rgba(226, 199, 153, 0.36);
}

.gallery-card.unlocked:active {
  transform: scale(0.97);
}

.gallery-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(160deg, #1d142e, #0e0a18);
  overflow: hidden;
}

.gallery-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
}

.gallery-thumb-sheet {
  object-position: center center;
}

.gallery-locked-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  gap: 8px;
  background: radial-gradient(circle at center, rgba(64, 34, 112, 0.45), rgba(14, 10, 24, 0.92));
}

.lock-emblem {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(196, 174, 232, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.lock-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.gallery-meta {
  padding: 10px 10px 12px;
}

.gallery-card-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--accent-amethyst);
  font-weight: 700;
  margin-bottom: 2px;
}

.gallery-card-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.86rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== ENDINGS & SETTINGS VIEW ==================== */
.complete-banner {
  margin: 0 16px 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(226, 199, 153, 0.2));
  border: 1px solid var(--border-gold);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.complete-crown {
  font-size: 1.8rem;
  color: var(--accent-gold);
  line-height: 1.1;
}

.complete-banner-body {
  flex: 1;
  min-width: 0;
}

.complete-banner strong {
  display: block;
  font-family: var(--font-serif);
  color: var(--accent-gold);
}

.complete-banner p {
  margin: 2px 0 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.complete-special-btn {
  width: 100%;
}

.endings-list {
  padding: 0 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ending-row {
  background: rgba(24, 17, 38, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ending-row.unlocked {
  border-color: rgba(226, 199, 153, 0.38);
}

.ending-row-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ending-mini-thumb {
  width: 54px;
  height: 70px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #120c1e;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.ending-mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
}

.ending-row-info {
  flex: 1;
  min-width: 0;
}

.ending-tag-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.ending-num-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

.ending-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}

.tag-true { background: rgba(234, 179, 8, 0.25); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.5); }
.tag-sweet { background: rgba(244, 114, 182, 0.22); color: #f9a8d4; border: 1px solid rgba(244, 114, 182, 0.45); }
.tag-teasing { background: rgba(168, 85, 247, 0.25); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.45); }
.tag-cozy { background: rgba(251, 146, 60, 0.22); color: #fdba74; border: 1px solid rgba(251, 146, 60, 0.45); }
.tag-mystery { background: rgba(99, 102, 241, 0.25); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.5); }
.tag-comedy { background: rgba(248, 113, 113, 0.22); color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.45); }
.tag-elegant { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.45); }
.tag-healing { background: rgba(45, 212, 191, 0.2); color: #5eead4; border: 1px solid rgba(45, 212, 191, 0.45); }
.tag-secret { background: rgba(192, 132, 252, 0.25); color: #e9d5ff; border: 1px solid rgba(216, 180, 254, 0.5); }
.tag-normal { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.4); }

.ending-row-title {
  margin: 0 0 3px;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  color: #ffffff;
}

.ending-row-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ending-row-actions {
  display: flex;
  justify-content: flex-end;
}

.ending-hint-btn,
.ending-cg-btn {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.ending-hint-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.ending-cg-btn {
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
}

.ending-hint-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.14);
  border: 1px dashed rgba(182, 148, 255, 0.4);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Settings Panel */
.settings-panel {
  margin: 6px 16px 28px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(23, 17, 36, 0.9);
  border: 1px solid var(--border-subtle);
}

.settings-title {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--accent-gold);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.setting-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.setting-info {
  display: flex;
  flex-direction: column;
}

.setting-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.setting-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.segmented-control {
  display: inline-flex;
  background: rgba(12, 8, 20, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.setting-row-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.segmented-full {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
}

.seg-btn {
  min-height: 44px;
  min-width: 48px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--accent-violet);
  color: #ffffff;
}

.toggle-btn {
  min-width: 68px;
  min-height: 44px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(124, 58, 237, 0.35);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
}

.toggle-btn[aria-pressed='false'] {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

/* ==================== BOTTOM NAVIGATION ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(15, 10, 24, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-gold);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 30;
}

.nav-item {
  min-height: 56px;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  position: relative;
  transition: color 0.18s ease;
}

.nav-item.active {
  color: var(--accent-gold);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--accent-amethyst), var(--accent-gold));
}

.nav-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ==================== MODALS & LIGHTBOX ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 4, 12, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-shell {
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #08050f;
}

.lightbox-top,
.lightbox-bottom {
  padding: 12px 14px;
  background: rgba(14, 10, 24, 0.9);
  transition: opacity 0.22s ease;
}

.lightbox-top {
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.lightbox-titles {
  min-width: 0;
}

.lightbox-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--accent-amethyst);
  font-weight: 700;
}

.lightbox-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--accent-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-top-actions {
  display: flex;
  gap: 8px;
}

.lightbox-canvas {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  transition: transform 0.25s ease;
  cursor: pointer;
}

.lightbox-img.zoomed {
  transform: scale(1.55);
  transform-origin: center center;
}

.lightbox-bottom {
  padding-bottom: calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border-subtle);
}

.lightbox-desc {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.lightbox-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lightbox-counter {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 700;
}

.lightbox-shell.ui-hidden .lightbox-top,
.lightbox-shell.ui-hidden .lightbox-bottom {
  opacity: 0;
  pointer-events: none;
}

/* Sheet Modal (Backlog & PWA Guide) */
.sheet-modal {
  width: calc(100% - 24px);
  max-width: 416px;
  max-height: 82dvh;
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-header h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent-gold);
}

.sheet-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.backlog-speaker {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-amethyst);
  margin-bottom: 2px;
}

.backlog-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.65;
}

.backlog-choice {
  font-size: 0.82rem;
  color: var(--accent-gold);
  background: rgba(226, 199, 153, 0.1);
  border-left: 3px solid var(--accent-gold);
  padding: 6px 10px;
  border-radius: 6px;
}

.pwa-guide-body p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.pwa-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-primary);
}

/* Toast Notification */
.toast {
  position: fixed;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 390px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(28, 18, 48, 0.96);
  border: 1px solid var(--border-gold);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  color: var(--accent-gold);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
  z-index: 90;
  pointer-events: none;
  animation: toastDrop 0.25s ease-out;
}

@keyframes toastDrop {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Narrow 360px fine-tuning */
@media (max-width: 365px) {
  .home-title {
    font-size: 1.75rem;
  }
  .dialogue-text {
    font-size: 0.93rem;
  }
  .choice-label {
    font-size: 0.88rem;
  }
  .seg-btn {
    min-width: 44px;
    padding: 0 8px;
  }
}
