:root {
  --bg-deep: #040814;
  --bg-mid: #0b1836;
  --gold: #f5d061;
  --gold-bright: #ffe89e;
  --ruby: #d93848;
  --pine: #145a3a;
  --glass-bg: rgba(9, 17, 38, 0.56);
  --glass-border: rgba(255, 232, 168, 0.16);
  --text-main: #f7f4ec;
  --text-muted: rgba(242, 236, 224, 0.72);
  --font-display: 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-script: 'Great Vibes', 'Brush Script MT', 'Segoe Script', cursive;
  --font-sans: 'Plus Jakarta Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

body.theme-day {
  --glass-bg: rgba(18, 36, 68, 0.48);
  --glass-border: rgba(255, 255, 255, 0.28);
}

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

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  touch-action: manipulation;
}

#scene-canvas,
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#scene-canvas {
  z-index: 1;
  cursor: default;
  touch-action: none;
}

#scene-canvas.pointer-hover {
  cursor: pointer;
}

#fx-canvas {
  z-index: 2;
  pointer-events: none;
}

#blackout-veil {
  position: fixed;
  inset: 0;
  background: #02040a;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity 0.38s ease;
}

#blackout-veil.active {
  opacity: 0.96;
}

#cinematic-vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(circle at 50% 48%, transparent 48%, rgba(2, 5, 14, 0.62) 100%);
  transition: opacity 1.2s ease;
}

body.theme-day #cinematic-vignette {
  background: radial-gradient(circle at 50% 48%, transparent 55%, rgba(16, 32, 64, 0.25) 100%);
}

/* Electron Custom Frameless Titlebar */
#electron-titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  background: linear-gradient(180deg, rgba(4, 8, 20, 0.72), rgba(4, 8, 20, 0));
  -webkit-app-region: drag;
}

#electron-titlebar.hidden {
  display: none;
}

.titlebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 244, 214, 0.86);
}

.titlebar-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.titlebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-app-region: no-drag;
}

.win-btn {
  width: 28px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.18s ease;
}

.win-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.win-btn.win-close:hover {
  background: #d93848;
}

/* Opening Experience Overlay */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.intro-overlay.fade-out {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.intro-content {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.intro-eyebrow {
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.intro-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.2vw, 3.35rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.18;
  color: #fffaf0;
  text-shadow: 0 4px 32px rgba(245, 208, 97, 0.35), 0 2px 14px rgba(0, 0, 0, 0.85);
}

.intro-subtitle {
  font-size: clamp(1rem, 1.8vw, 1.24rem);
  color: rgba(240, 238, 250, 0.86);
  font-weight: 400;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.intro-prompt {
  margin-top: 4px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(245, 208, 97, 0.45);
}

/* Realistic Tactile Light Switch */
.switch-stage {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.light-switch {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.light-switch:hover {
  transform: translateY(-2px) scale(1.03);
}

.light-switch:active {
  transform: scale(0.97);
}

.switch-plate {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 82px;
  height: 124px;
  border-radius: 16px;
  background: linear-gradient(145deg, #d7b46a 0%, #9b7332 48%, #5e4219 100%);
  box-shadow:
    0 22px 44px rgba(0, 0, 0, 0.7),
    inset 0 1px 2px rgba(255, 248, 220, 0.7),
    inset 0 -3px 8px rgba(34, 20, 4, 0.7);
  border: 1px solid rgba(255, 231, 166, 0.35);
}

.screw {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3cc, #7d5b24);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.65);
}

.screw::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 1px;
  right: 1px;
  height: 1px;
  background: rgba(40, 26, 8, 0.75);
  transform: rotate(32deg);
}

.screw-top { top: 10px; }
.screw-bottom { bottom: 10px; }

.switch-well {
  width: 34px;
  height: 62px;
  border-radius: 10px;
  background: linear-gradient(180deg, #131826, #080b14);
  box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.9), 0 1px 1px rgba(255, 240, 190, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.switch-paddle {
  position: relative;
  width: 24px;
  height: 48px;
  border-radius: 7px;
  background: linear-gradient(180deg, #f9f3e4 0%, #cfc1a6 55%, #8a7c64 100%);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.7), inset 0 1px 2px #fff;
  transform: perspective(180px) rotateX(-24deg) translateY(3px);
  transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.26s ease;
}

.light-switch.is-on .switch-paddle {
  background: linear-gradient(180deg, #fffbe8 0%, #f5d061 60%, #c8962e 100%);
  transform: perspective(180px) rotateX(24deg) translateY(-3px);
}

.switch-indicator {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff4f5e;
  box-shadow: 0 0 8px rgba(255, 79, 94, 0.8);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.light-switch.is-on .switch-indicator {
  bottom: auto;
  top: 7px;
  background: #67ff9a;
  box-shadow: 0 0 14px rgba(103, 255, 154, 0.95);
}

.switch-glow-ring {
  position: absolute;
  inset: -10px;
  border-radius: 26px;
  pointer-events: none;
  border: 1px solid rgba(245, 208, 97, 0.32);
  animation: pulseRing 2.6s ease-in-out infinite;
}

.switch-caption {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(255, 236, 185, 0.72);
}

/* HUD Visibility */
.hidden-during-intro {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}

body.phase-interactive .hidden-during-intro,
body.phase-revealing .hud-layer {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Top HUD */
.hud-layer {
  position: fixed;
  top: 42px;
  left: 18px;
  right: 18px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

body.is-browser .hud-layer {
  top: 18px;
}

.hud-left,
.hud-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.glass-pill,
.icon-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-pill,
.secrets-pill {
  cursor: pointer;
}

.icon-pill:hover,
.secrets-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(245, 208, 97, 0.45);
}

.icon-pill.active {
  border-color: rgba(245, 208, 97, 0.48);
  background: rgba(245, 208, 97, 0.14);
}

.countdown-pill {
  padding: 6px 14px;
}

.countdown-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.countdown-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.countdown-clock {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Signature Action Buttons */
.magic-actions {
  position: fixed;
  right: 20px;
  bottom: 108px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.magic-cta {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.11em;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.magic-cta:hover {
  transform: translateY(-2px) scale(1.02);
}

.cta-snow {
  background: linear-gradient(135deg, rgba(41, 128, 185, 0.72), rgba(109, 213, 250, 0.56));
}

.cta-gold {
  background: linear-gradient(135deg, rgba(196, 42, 59, 0.85), rgba(245, 176, 65, 0.82));
  border-color: rgba(255, 235, 166, 0.52);
}

.cta-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.32) 50%, transparent 75%);
  transform: translateX(-100%);
  animation: sheenSweep 4.5s infinite;
}

/* Music Player Dock */
.music-player {
  position: fixed;
  left: 20px;
  bottom: 42px;
  z-index: 22;
  width: min(460px, calc(100vw - 40px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.52);
}

.player-art-wrap {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
}

.player-art {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255, 232, 166, 0.35);
}

.music-player.playing .player-art {
  animation: gentleBob 3.6s ease-in-out infinite;
}

.player-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.player-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.track-title {
  font-size: 13px;
  font-weight: 700;
  color: #fffaf0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.equalizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  flex-shrink: 0;
}

.equalizer span {
  width: 3px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gold-bright), var(--ruby));
  transition: height 0.08s linear;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.time-label {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.seek-bar,
.volume-bar {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}

.seek-bar {
  flex: 1;
}

.volume-bar {
  width: 52px;
}

.seek-bar::-webkit-slider-thumb,
.volume-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(245, 208, 97, 0.8);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, transform 0.18s ease;
}

.ctrl-btn:hover {
  background: rgba(245, 208, 97, 0.22);
  transform: scale(1.07);
}

.ctrl-play {
  width: 35px;
  height: 35px;
  background: linear-gradient(135deg, var(--gold), #d98e2b);
  color: #161006;
  font-weight: 700;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Playlist Drawer */
.playlist-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  max-height: 270px;
  border-radius: 18px;
  background: rgba(7, 13, 30, 0.92);
  backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.65);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.playlist-drawer.open {
  display: flex;
}

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-close-sm {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}

.playlist-items {
  list-style: none;
  overflow-y: auto;
  padding: 6px;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.16s ease;
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.playlist-item.active {
  background: rgba(245, 208, 97, 0.16);
  color: var(--gold-bright);
}

.playlist-item-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Final Handwritten Card */
.final-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -44%) scale(0.92);
  z-index: 30;
  width: min(500px, calc(100vw - 36px));
  padding: 30px 28px 24px;
  border-radius: 24px;
  text-align: center;
  background: rgba(7, 14, 34, 0.72);
  backdrop-filter: blur(22px);
  border: 1px solid rgba(245, 208, 97, 0.36);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.68), 0 0 60px rgba(245, 208, 97, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.85s ease, transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.final-card.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.card-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  cursor: pointer;
}

.final-card-ornament {
  font-size: 16px;
  letter-spacing: 0.3em;
  color: var(--gold);
  margin-bottom: 6px;
}

.final-heading {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  color: var(--gold-bright);
  text-shadow: 0 2px 20px rgba(245, 208, 97, 0.4);
  margin-bottom: 12px;
}

.final-body {
  font-family: var(--font-script);
  font-size: clamp(1.65rem, 3.2vw, 2.25rem);
  line-height: 1.3;
  color: #fffdf7;
  margin-bottom: 14px;
}

.final-signature {
  font-family: var(--font-script);
  font-size: clamp(1.45rem, 2.6vw, 1.95rem);
  color: var(--gold-bright);
  line-height: 1.28;
}

.final-tip {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Secret Modal */
.secret-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 6, 16, 0.62);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.secret-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.secret-card {
  position: relative;
  width: min(440px, 100%);
  padding: 28px 24px;
  border-radius: 22px;
  text-align: center;
  background: rgba(11, 20, 46, 0.92);
  border: 1px solid rgba(245, 208, 97, 0.4);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.72);
}

.secret-emoji {
  font-size: 42px;
  margin-bottom: 8px;
}

.secret-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold-bright);
  margin-bottom: 8px;
}

.secret-body {
  font-size: 0.96rem;
  line-height: 1.55;
  color: var(--text-main);
}

.secret-checklist {
  margin-top: 14px;
  text-align: left;
  max-height: 230px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.secret-checklist.hidden,
.secret-code-bar.hidden {
  display: none;
}

.secret-code-bar {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.secret-code-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(245, 208, 97, 0.32);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.secret-code-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--gold), #d98e2b);
  color: #161006;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}

.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.secret-row.found {
  background: rgba(103, 255, 154, 0.11);
  color: #b7ffcf;
}

/* Toast Stack */
.toast-stack {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast-msg {
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(8, 16, 38, 0.86);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(245, 208, 97, 0.42);
  color: #fffaf0;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.52);
  animation: toastIn 0.35s ease forwards;
}

/* Permanent Stylish Watermark */
.creator-watermark {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(245, 208, 97, 0.22);
  background: rgba(5, 10, 24, 0.46);
  backdrop-filter: blur(10px);
  color: rgba(255, 240, 198, 0.85);
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.creator-watermark:hover {
  color: var(--gold-bright);
  border-color: rgba(245, 208, 97, 0.6);
  transform: translateX(-50%) translateY(-1px);
}

.watermark-dot {
  color: var(--gold);
  font-size: 10px;
}
