/* ============================================================
   微时夜语 · Whisper Nights — Styles
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
  --paper:        #f6efe2;
  --paper-deep:   #ede4d2;
  --ink:          #1d1611;
  --ink-soft:     #4a3f33;
  --ink-mute:     #8a7c6a;
  --gold:         #b08a4e;
  --gold-soft:    #d9be8c;
  --line:         rgba(29, 22, 17, 0.12);

  --l1-from: #7FCB7E;  --l1-to: #E5EC8A;  --l1-ink: #1f3a1c;
  --l2-from: #F2A98A;  --l2-to: #EE8AA8;  --l2-ink: #5a1a2c;
  --l3-from: #5BBFC5;  --l3-to: #1E2A5E;  --l3-ink: #f5f8ff;
  --l4-from: #4A2570;  --l4-to: #0E0218;  --l4-ink: #f3e9ff;

  --lvl-from: var(--l1-from);
  --lvl-to:   var(--l1-to);
  --lvl-ink:  var(--l1-ink);

  --f-zh:    "Noto Serif SC", "Songti SC", "STSong", serif;
  --f-en:    "Fraunces", "Cormorant Garamond", Georgia, serif;
  --f-sans:  "Geist", "DM Sans", -apple-system, sans-serif;

  --card-w: clamp(220px, 30vw, 300px);
  --card-h: calc(var(--card-w) * 1.42);
  --card-radius: 14px;

  --drawn-w: clamp(130px, 20vw, 185px);
  --drawn-h: calc(var(--drawn-w) * 1.42);

  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* ---------- BASE ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: var(--f-zh);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(29,22,17,0.04) 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 65%, rgba(29,22,17,0.03) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 80%, rgba(29,22,17,0.025) 50%, transparent 51%);
  background-size: 240px 240px, 380px 380px, 520px 520px;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- SCENES ---------- */
.scene {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .55s var(--ease), transform .55s var(--ease);
  overflow-y: auto;
}
.scene.active {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

/* ============================================================
   SCENE 1 – WELCOME
   ============================================================ */
.welcome-frame {
  margin: auto;
  max-width: 540px;
  text-align: center;
  padding: 40px 8px;
}

.brand-bar {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-family: var(--f-sans);
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-bottom: 56px;
}
.brand-bar span:nth-child(even) { opacity: 0.4; }

.welcome-eye {
  width: 78px;
  margin: 0 auto 28px;
  color: var(--ink);
  animation: eye-breath 4.5s ease-in-out infinite;
}
.welcome-eye svg { width: 100%; height: auto; display: block; }

@keyframes eye-breath {
  0%, 100% { transform: scale(1);   opacity: 0.95; }
  50%      { transform: scale(0.97); opacity: 0.75; }
}

.welcome-title {
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 400;
}
.welcome-title-zh {
  font-family: var(--f-zh);
  font-size: clamp(38px, 5.6vw, 56px);
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--ink);
}
.welcome-title-en {
  font-family: var(--f-en);
  font-size: clamp(15px, 1.7vw, 18px);
  font-weight: 300;
  letter-spacing: 0.32em;
  color: var(--ink-mute);
  text-transform: lowercase;
}
.welcome-title-en em { font-style: italic; font-weight: 400; }

.welcome-tagline {
  font-family: var(--f-zh);
  font-weight: 300;
  font-size: 16px;
  line-height: 2.05;
  color: var(--ink-soft);
  margin: 0 auto 18px;
  max-width: 380px;
  letter-spacing: 0.04em;
}
.welcome-tagline-en {
  font-family: var(--f-en);
  font-weight: 300;
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-mute);
  margin: 0 auto 48px;
  max-width: 380px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 38px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: var(--f-zh);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.2em;
  transition: background .35s var(--ease), color .35s var(--ease), transform .35s var(--ease);
  position: relative;
}
.btn-primary:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}
.btn-primary .btn-divider { opacity: 0.45; font-weight: 300; }
.btn-primary .en {
  font-family: var(--f-en);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.welcome-meta {
  margin-top: 36px;
  font-family: var(--f-en);
  font-size: 12px;
  font-style: italic;
  color: var(--ink-mute);
  letter-spacing: 0.05em;
}
.welcome-meta strong {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-soft);
  font-family: var(--f-zh);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 4px 32px;
}
.top-bar-title {
  margin: 0;
  text-align: center;
  font-family: var(--f-zh);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.22em;
  color: var(--ink);
}
.top-bar-title em {
  font-family: var(--f-en);
  font-size: 12px;
  font-weight: 300;
  font-style: italic;
  color: var(--ink-mute);
  letter-spacing: 0.18em;
  margin-left: 6px;
}
.top-bar-spacer { display: block; }

.btn-ghost {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 6px 8px;
  margin-left: -8px;
  color: var(--ink-soft);
  font-family: var(--f-zh);
  font-size: 13px;
  letter-spacing: 0.15em;
  transition: color .25s var(--ease);
}
.btn-ghost:hover { color: var(--ink); }

/* ============================================================
   SCENE 2 – LEVEL SELECT
   ============================================================ */
.level-grid {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
  padding: 8px 0 40px;
}

.level-card {
  position: relative;
  aspect-ratio: 0.72 / 1;
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(160deg, var(--from), var(--to));
  color: var(--ink-on);
  padding: 18px;
  display: flex;
  flex-direction: column;
  border: none;
  text-align: left;
  transition: transform .55s var(--ease), box-shadow .55s var(--ease);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    0 14px 30px -18px rgba(0,0,0,0.35);
}
.level-card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.08),
    0 26px 50px -22px rgba(0,0,0,0.45);
}
.level-card .lc-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--f-sans);
  font-size: 9.5px;
  letter-spacing: 0.28em;
  font-weight: 300;
  opacity: 0.85;
}
.level-card .lc-triangle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.level-card .lc-triangle svg {
  width: 70%;
  height: auto;
  opacity: 0.35;
  transition: opacity .6s var(--ease);
}
.level-card:hover .lc-triangle svg { opacity: 0.55; }

.level-card .lc-meta {
  margin-top: auto;
  position: relative;
  z-index: 2;
}
.level-card .lc-name {
  font-family: var(--f-zh);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.22em;
  margin: 0 0 4px;
}
.level-card .lc-name-en {
  font-family: var(--f-en);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.18em;
  opacity: 0.75;
  margin: 0 0 10px;
}
.level-card .lc-tagline {
  font-family: var(--f-zh);
  font-size: 12px;
  font-weight: 300;
  line-height: 1.7;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin: 0;
}

/* ============================================================
   SCENE 3 – FAN SPREAD
   ============================================================ */
.deck-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 0 8px;
  min-height: 0;
}

.fan-stage {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: calc(var(--card-h) * 1.12);
  overflow: visible;
}

.fan-card {
  position: absolute;
  bottom: 0;
  left: 50%;
  translate: -50% 0;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  transform-origin: 50% 100%;
  overflow: hidden;
  cursor: pointer;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.12),
    0 10px 28px -10px rgba(0,0,0,0.32);
  will-change: transform, opacity;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.5s cubic-bezier(.22,1,.36,1), opacity 0.4s ease;
}

.fan-card.selected {
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.9),
    0 6px 24px rgba(0,0,0,0.28);
  z-index: 20 !important;
}

.fan-card.selected::after {
  content: attr(data-sel-num);
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: rgba(255,255,255,0.95);
  color: #1d1611;
  border-radius: 50%;
  font-family: var(--f-sans);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.fan-card-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px 14px;
  pointer-events: none;
}

.fan-card-inner svg {
  flex: 1;
  width: 72%;
  height: auto;
  display: block;
}

.fan-card-label {
  font-family: var(--f-en);
  font-size: 11px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.3em;
  opacity: 0.82;
}

.deck-hint {
  margin-top: 24px;
  font-family: var(--f-zh);
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  text-align: center;
}

/* ============================================================
   DRAWN CARDS
   ============================================================ */
.drawn-area {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px 16px 8px;
  min-height: 0;
}

.drawn-row {
  display: flex;
  gap: clamp(10px, 2.5vw, 22px);
  align-items: flex-start;
  justify-content: center;
}

.drawn-card-wrapper {
  width: var(--drawn-w);
  height: var(--drawn-h);
  perspective: 900px;
  flex-shrink: 0;
}

.drawn-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.72s cubic-bezier(.22,1,.36,1);
  cursor: pointer;
}

.drawn-card.flipped { transform: rotateY(180deg); }

.drawn-card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow:
    0 4px 18px rgba(0,0,0,0.18),
    0 1px 3px rgba(0,0,0,0.08);
}

.dcb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px 10px;
}

.dcb-art {
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
}
.dcb-art svg { width: 72%; height: auto; }

.dcb-label {
  font-family: var(--f-en);
  font-size: 10px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.3em;
  opacity: 0.85;
}

.dcf {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  padding: 14px 15px 14px;
}

.dcf-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--f-sans);
  font-size: 8px;
  font-weight: 300;
  letter-spacing: 0.26em;
  opacity: 0.78;
  margin-bottom: 4px;
}

.dcf-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 4px 0;
}

.dq-zh {
  font-family: var(--f-zh);
  font-weight: 400;
  font-size: clamp(13px, 1.9vw, 17px);
  line-height: 1.7;
  letter-spacing: 0.04em;
  margin: 0;
}

.dq-en {
  font-family: var(--f-en);
  font-weight: 300;
  font-size: clamp(10px, 1.1vw, 12.5px);
  line-height: 1.5;
  margin: 0;
  opacity: 0.85;
}

.dcf-footer {
  display: grid;
  place-items: center;
  opacity: 0.82;
  padding-top: 8px;
}

.drawn-hint {
  font-family: var(--f-en);
  font-size: 11px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin: 0;
  text-align: center;
}

/* ============================================================
   ACTION BUTTONS
   ============================================================ */
.card-actions {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 8px 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--f-zh);
  font-size: 13px;
  letter-spacing: 0.18em;
  transition: all .3s var(--ease);
}
.action-btn:hover {
  border-color: var(--ink);
  background: rgba(29, 22, 17, 0.04);
}
.action-btn svg { display: block; }

.action-btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  padding: 13px 28px;
}
.action-btn-primary:hover {
  background: #000;
  border-color: #000;
  transform: translateY(-1px);
}

/* ============================================================
   FOOTER
   ============================================================ */
.page-footer {
  position: fixed;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--f-en);
  font-size: 10.5px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.32em;
  color: var(--ink-mute);
  pointer-events: none;
  opacity: 0.6;
  text-transform: lowercase;
}

/* ============================================================
   MIXED MODE CARD
   ============================================================ */
.level-card--mixed {
  background: linear-gradient(
    135deg,
    #2e5e2e 0%,
    #7a3830 30%,
    #1a4a52 65%,
    #2a1545 100%
  ) !important;
  color: #f0ecff !important;
}
.level-card--mixed .lc-name,
.level-card--mixed .lc-name-en,
.level-card--mixed .lc-tagline,
.level-card--mixed .lc-header { color: #f0ecff; }

/* ============================================================
   LANGUAGE TOGGLE
   ============================================================ */
.lang-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 1000;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  font-family: var(--f-sans);
  font-size: 10.5px;
  font-weight: 300;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.lang-toggle:hover {
  color: var(--ink);
  border-color: rgba(29, 22, 17, 0.4);
  background: rgba(29, 22, 17, 0.03);
}

/* ============================================================
   ENGLISH-MODE OVERRIDES
   ============================================================ */
body.lang-en .welcome-tagline { display: none; }
body.lang-en .welcome-tagline-en {
  font-size: 15px;
  line-height: 2.0;
  color: var(--ink-soft);
  font-style: normal;
  font-weight: 300;
}
body.lang-en .welcome-tagline-en em { font-style: normal; }
body.lang-en .btn-primary .btn-divider,
body.lang-en .btn-primary .en { display: none; }
body.lang-en .dq-zh { display: none; }
body.lang-en .dq-en {
  font-size: clamp(13px, 1.9vw, 17px);
  line-height: 1.65;
  opacity: 1;
}
body.lang-en .dq-en em { font-style: normal; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  :root {
    --card-w: clamp(150px, 44vw, 210px);
    --drawn-w: clamp(100px, 26vw, 145px);
  }
  .scene { padding: 20px 18px 60px; }
  .top-bar { grid-template-columns: auto 1fr auto; gap: 6px; padding-bottom: 24px; }
  .top-bar-title { font-size: 15px; letter-spacing: 0.18em; }
  .top-bar-title em { display: block; margin: 2px 0 0; }
  .level-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .card-actions { flex-wrap: wrap; gap: 10px; padding: 0 12px 32px; }
  .action-btn { padding: 10px 16px; font-size: 12px; }
  .action-btn-primary { padding: 12px 20px; }
  .welcome-frame { padding: 16px 4px; }
  .brand-bar { margin-bottom: 36px; }
  .page-footer { display: none; }
  .lang-toggle { top: 12px; right: 14px; padding: 4px 11px; font-size: 10px; }
  .deck-hint { font-size: 11px; }
  .drawn-row { gap: 8px; }
  .fan-stage { max-width: 100%; }
}

@media (max-width: 380px) {
  .level-grid { grid-template-columns: 1fr; }
}
