/* ============================================================
   AnyaDuku — Dark Cinematic Edition
   Design: Deep space noir · Nebula glows · Unified dark canvas
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --bg:           #07070f;
  --bg-card:      rgba(14, 12, 24, 0.85);
  --bg-surface:   #0f0d1a;
  --border-dark:  rgba(255, 255, 255, 0.07);
  --border-glow:  rgba(139, 92, 246, 0.35);

  --text-light:   #f0eeff;
  --text-dark:    #16151a;
  --text-muted:   #6b6882;
  --text-soft:    #9d9bb5;

  --accent:       #8b5cf6;
  --accent-rgb:   139, 92, 246;
  --accent-glow:  rgba(139, 92, 246, 0.2);
  --accent-2:     #ec4899;
  --accent-2-rgb: 236, 72, 153;

  --win:          #10b981;
  --win-rgb:      16, 185, 129;
  --error:        #ef4444;
  --error-rgb:    239, 68, 68;

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    20px;

  --shadow:       0 30px 80px rgba(0, 0, 0, 0.7);
  --shadow-sm:    0 4px 12px rgba(0, 0, 0, 0.05);
  --glow-accent:  0 0 60px rgba(139, 92, 246, 0.25);

  --font-display: 'Cinzel', Georgia, serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
}

#home-screen {
  position: relative;
  overflow: hidden;
}

/* Fullscreen video behind content */
.video-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translate(-50%, -50%);
  z-index: 0;
}

/* Dark transparent overlay to emphasize foreground text */
.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 5, 18, 0.65); /* Adjust opacity (0.65) to change darkness */
  z-index: 1;
}

/* Ensure foreground content sits above video and overlay layers */
.home-inner, .orb {
  position: relative;
  z-index: 2;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-light);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.01em;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ─── Screens ───────────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
}
.screen.active { display: flex; flex-direction: column; }

/* ══════════════════════════════════════════════════════════════
   HOME SCREEN — Dark Cinematic
══════════════════════════════════════════════════════════════ */
#home-screen {
  position: relative;
  isolation: isolate;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem;
  overflow: hidden;
}

/* ── Deep Space Background ── */
#home-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(139, 92, 246, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(236, 72, 153, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse 50% 50% at 10% 80%,  rgba(99, 102, 241, 0.1) 0%, transparent 55%),
    #07070f;
}

/* ── Star field ── */
#home-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 8%,  rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 57% 25%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 74% 12%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 33%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 22% 55%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 63% 70%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 91% 78%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 45% 90%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 8%  90%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 78% 55%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 31% 38%, rgba(255,255,255,0.2) 0%, transparent 100%);
  pointer-events: none;
}

/* ── Floating ambient orbs ── */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: -1;
  animation: driftOrb 14s ease-in-out infinite alternate;
}
.orb-1 {
  width: 400px; height: 400px;
  top: -120px; left: -80px;
  background: rgba(139, 92, 246, 0.13);
  animation-duration: 16s;
}
.orb-2 {
  width: 320px; height: 320px;
  bottom: -100px; right: -60px;
  background: rgba(236, 72, 153, 0.10);
  animation-duration: 12s;
  animation-delay: -6s;
}
.orb-3 {
  width: 200px; height: 200px;
  top: 40%; left: 60%;
  background: rgba(99, 102, 241, 0.08);
  animation-duration: 18s;
  animation-delay: -9s;
}
@keyframes driftOrb {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

/* ── Main Card ── */
.home-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.2rem;
  padding: 3.5rem 2.8rem;
  max-width: 440px;
  width: 100%;
  background: rgba(12, 10, 22, 0.7);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 24px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 40px 100px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(139, 92, 246, 0.1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: riseIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
}

/* Subtle inner top highlight */
.home-inner::before {
  content: "";
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.5), transparent);
  border-radius: 50%;
}

/* ── Title Block ── */
.home-title-wrap {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

/* Eyebrow tag */
.title-eyebrow {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.25rem 0.9rem;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 30px;
  background: rgba(139, 92, 246, 0.08);
}

/* Main title */
.home-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 11vw, 4.2rem);
  font-weight: 700;
  color: transparent;
  background: linear-gradient(135deg, #e8e0ff 0%, #c4b5fd 40%, #a78bfa 70%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  line-height: 1.05;
  letter-spacing: 0.04em;
  position: relative;
  text-shadow: none;
  filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.35));
}

/* Shimmer sweep on title */
.home-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  animation: shimmer 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0%   { background-position: -100% 0; }
  60%, 100% { background-position: 200% 0; }
}

/* Tagline */
.title-sub {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-top: 0.2rem;
}

/* Decorative divider */
.title-divider {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.3rem;
}
.title-divider span {
  height: 1px;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.4));
}
.title-divider span:last-child {
  background: linear-gradient(90deg, rgba(139,92,246,0.4), transparent);
}
.title-divider-gem {
  font-size: 0.6rem;
  color: var(--accent);
  letter-spacing: 0.15em;
}

/* ── Romantic Note ── */
.romantic-note {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.4rem;
  font-family: var(--font-body);
  font-weight: 300;
  font-style: italic;
  color: var(--text-soft);
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.6;
  position: relative;
}

.romantic-note::before {
  content: "✦";
  position: absolute;
  top: -0.55rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1430;
  color: var(--accent);
  font-size: 0.6rem;
  padding: 0.1rem 0.5rem;
  border-radius: 30px;
  border: 1px solid rgba(139,92,246,0.25);
}

/* ── Stats row ── */
.home-stats {
  display: flex;
  gap: 0;
  width: 100%;
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.stat-item {
  flex: 1;
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: rgba(139, 92, 246, 0.04);
}

.stat-item + .stat-item {
  border-left: 1px solid rgba(139, 92, 246, 0.12);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-light);
  line-height: 1;
}

.stat-label {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Buttons ── */
.btn-group {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.9rem 1.5rem;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all 0.22s ease;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: linear-gradient(135deg, #a493cb, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 24px rgba(16, 11, 27, 0.35), 0 0 0 1px rgba(255,255,255,0.05) inset;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #a493cb, #7c3aed);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  box-shadow: 0 8px 32px rgba(214, 213, 218, 0.5);
}
.btn-primary:active { transform: translateY(0); }

.btn-primary span { position: relative; z-index: 1; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover {
  border-color: rgba(139, 92, 246, 0.35);
  color: var(--text-soft);
  background: rgba(139, 92, 246, 0.06);
}

/* Music indicator */
.music-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.music-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.music-bar {
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
  animation: musicPulse 1.2s ease-in-out infinite;
  opacity: 0.7;
}
.music-bar:nth-child(1) { height: 4px;  animation-delay: 0s;    animation-duration: 0.9s; }
.music-bar:nth-child(2) { height: 10px; animation-delay: 0.2s;  animation-duration: 1.1s; }
.music-bar:nth-child(3) { height: 6px;  animation-delay: 0.4s;  animation-duration: 0.8s; }
.music-bar:nth-child(4) { height: 12px; animation-delay: 0.1s;  animation-duration: 1.3s; }
.music-bar:nth-child(5) { height: 5px;  animation-delay: 0.3s;  animation-duration: 1.0s; }

@keyframes musicPulse {
  0%, 100% { transform: scaleY(0.4); }
  50%       { transform: scaleY(1); }
}

.music-indicator.paused .music-bar {
  animation-play-state: paused;
  opacity: 0.25;
}

/* ── Goodbye Screen ── */
.goodbye-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}
.goodbye-heart  { font-size: 2.5rem; color: var(--accent); }
.goodbye-title  { font-family: var(--font-display); font-size: 2rem; color: var(--text-light); }
.goodbye-msg    { color: var(--text-muted); font-size: 0.95rem; max-width: 300px; line-height: 1.6; }

/* ══════════════════════════════════════════════════════════════
   GAME SCREEN
══════════════════════════════════════════════════════════════ */
#game-screen { flex-direction: column; min-height: 100vh; }

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  padding-top: max(1.2rem, env(safe-area-inset-top));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-dark);
}
.hud-level {
  font-size: 0.95rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.hud-center { text-align: center; }
.hud-anya-label {
  font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted);
}
.hud-anya-count { font-size: 1.2rem; font-weight: 700; color: var(--text-light); }

.lives-container { display: flex; gap: 0.25rem; }
.life-icon { font-size: 1.1rem; transition: opacity 0.2s ease; }
.life-lost { opacity: 0.15; }

.info-bar {
  display: flex; gap: 0.5rem;
  justify-content: center;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-dark);
}
.info-box {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
  color: var(--text-muted);
  background: var(--bg-surface);
}

.grid-area {
  flex: 1; display: flex;
  align-items: center; justify-content: center;
  padding: 2rem;
}

#puzzle-grid {
  display: grid; gap: 6px;
  width: min(88vw, 88vh - 180px, 500px);
  height: min(88vw, 88vh - 180px, 500px);
  background: var(--bg-surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow);
}

.cell {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.cell:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.3);
}
.cell:active { transform: scale(0.97); }

.cell-cross { background: transparent; opacity: 0.3; }
.cross-mark { font-size: 0.8rem; color: var(--text-light); }

/* ── Updated Anya Icon State ── */
.cell-anya { 
  background: #0f0d1a; /* Matches the dark surface color */
  border-color: var(--accent); /* Electric violet border wrapper */
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4); /* Subtle cosmic glow */
}
.anya-marker {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.anya-img { 
  width: 85%; /* Adds a sleek modern inner margin inside the grid square */
  height: 85%; 
  object-fit: cover; 
  border-radius: var(--radius-sm); /* Matches your global rounded corners */
  content: url('assets/anya.jpeg'); /* 👈 Direct path to your JPEG file */
}
.anya-emoji { font-size: 1.2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
.cell-error { animation: pulseError 0.4s ease both; }
.cell-win   { animation: pulseWin  0.4s ease both; }

@keyframes pulseError {
  0%, 100% { border-color: var(--border-dark); }
  50% { background: rgba(239,68,68,0.2); border-color: var(--error); }
}
@keyframes pulseWin {
  0%, 100% { border-color: var(--border-dark); }
  50% { background: rgba(16,185,129,0.2); border-color: var(--win); }
}

.end-overlay {
  position: fixed; inset: 0;
  background: rgba(7, 7, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; opacity: 0;
  transition: opacity 0.25s ease;
}
.end-overlay.overlay-visible { opacity: 1; }

.end-card {
  background: rgba(14, 12, 24, 0.95);
  color: var(--text-light);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  max-width: 360px; width: 90%;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 1.2rem;
  box-shadow: var(--shadow), 0 0 60px rgba(139,92,246,0.15);
}
.end-icon   { font-size: 2.5rem; }
.end-title  { font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; }
.end-msg    { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.confetti-row { font-size: 1rem; letter-spacing: 0.1em; }
.end-buttons { display: flex; gap: 0.5rem; width: 100%; margin-top: 0.5rem; }

.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-light);
  z-index: 100; opacity: 0;
  transition: all 0.2s ease;
}
.toast-show  { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-error { border-color: var(--error); color: #fca5a5; }
.toast-win   { border-color: var(--win); color: #6ee7b7; }

/* ── Animations ── */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .home-inner { padding: 2.5rem 1.5rem; gap: 1.8rem; }
  .hud { padding: 1rem; }
  #puzzle-grid {
    width: min(92vw, 92vh - 180px);
    height: min(92vw, 92vh - 180px);
    gap: 4px; padding: 6px;
  }
  .btn-group { flex-direction: column; }
}   

/* Container adjustment to handle tall cards safely */
.end-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto; /* Allows the whole screen to scroll if on a tiny device */
}

/* The fixed, compact Love Letter Card */
.completion-love-letter {
  background: linear-gradient(135deg, #fff5f7 0%, #ffe3e8 100%) !important;
  border: 2px solid #ffb3c1 !important;
  width: 100%;
  max-width: 400px;
  max-height: 85vh; /* Prevents the card from ever leaving the screen bounds */
  padding: 20px;
  box-shadow: 0 10px 30px rgba(255, 179, 193, 0.4);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Internal Scroll Container for the text areas */
.love-letter-body {
  font-family: 'Dancing Script', 'Courier New', cursive, serif;
  font-size: 1.05rem;
  color: #4a3b32;
  line-height: 1.5;
  margin: 10px 0;
  text-align: center;
  
  /* The Secret Sauce: Makes just the long text scrollable if it runs out of space */
  overflow-y: auto; 
  padding-right: 5px;
}

/* Custom, pretty pink scrollbar for the text */
.love-letter-body::-webkit-scrollbar {
  width: 5px;
}
.love-letter-body::-webkit-scrollbar-thumb {
  background-color: #ffb3c1;
  border-radius: 10px;
}

/* More compact layout for the upcoming info box */
.upcoming-update-box {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 10px;
  margin: 10px 0;
  border: 1px dashed #ffb3c1;
  font-size: 0.85rem;
  color: #6c584c;
  text-align: center;
}

.upcoming-update-box h4 {
  margin: 0 0 4px 0;
  color: #ff4d6d;
  font-size: 0.95rem;
}

/* Compact Secret Code Box */
.code-share-box {
  margin: 10px 0;
  background: #ff4d6d;
  color: white;
  padding: 10px;
  border-radius: 12px;
  text-align: center;
}

.code-instructions {
  font-size: 0.8rem;
  margin: 0 0 5px 0;
  opacity: 0.9;
}

.secret-code {
  font-family: 'Courier New', monospace;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 2px;
  background: rgba(0, 0, 0, 0.15);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}

/* Tighten up buttons */
.end-buttons {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  justify-content: center;
}