/* ── Version: 051 - layered ground update */

/* ── Fonts ─────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;900&family=Cinzel+Decorative:wght@400;700&family=IM+Fell+English:ital@0;1&display=swap');

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --gold:       #c8943a;
  --gold-light: #e8c46a;
  --gold-dark:  #7a5a1a;
  --earth:      #2a1a0a;
  --earth-mid:  #1a1008;
  --earth-deep: #0d0806;
  --parchment:  #e8d5a3;
  --parchment2: #d4b87a;
  --ink:        #2a1a08;
  --red:        #8a2a1a;
  --shadow:     rgba(0,0,0,0.8);
  --glow:       rgba(200,148,58,0.3);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--earth-deep);
}

/* ── Sky / background layers ───────────────────────────────────────────────── */
#scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dusk sky gradient */
#sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #0d0820 0%,
    #1a0f2e 20%,
    #3a1a2a 45%,
    #6a2a1a 65%,
    #c84a0a 80%,
    #e87a1a 88%,
    #f4a030 93%,
    #e8c46a 97%,
    #f4d880 100%
  );
  z-index: 0;
}

/* Stars */
#stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; }
  50%       { opacity: var(--op, 0.8); }
}

/* ── horizon.css, ground.css ─────────────────────────────── (extracted) ─── */

/* ── Parchment panel ───────────────────────────────────────────────────────── */
#parchment {
  position: relative;
  z-index: 21;
  width: min(520px, 92vw);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(232,196,106,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(180,130,60,0.1) 0%, transparent 50%),
    linear-gradient(160deg, #2a1e0e 0%, #1e1408 40%, #160e06 100%);
  border: 1px solid var(--gold-dark);
  box-shadow:
    0 0 0 1px #0d0806,
    0 0 0 3px rgba(120,80,20,0.4),
    0 0 60px rgba(200,148,58,0.15),
    0 30px 80px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(200,148,58,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.5);
  padding: 0;
  animation: panelRise 1.2s cubic-bezier(0.16,1,0.3,1) both;
  animation-delay: 0.3s;
}

@keyframes panelRise {
  from { opacity: 0; transform: translateY(40px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Parchment texture ─────────────────────────────────────────────────────── */
#parchment {
  isolation: isolate;
}

/* Fiber layer — subtle cross-grain lines */
#parchment .panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.06;
  background-image:
    repeating-linear-gradient(
      17deg,
      transparent 0px,
      transparent 2px,
      rgba(200,148,58,0.8) 2px,
      rgba(200,148,58,0.8) 3px
    ),
    repeating-linear-gradient(
      97deg,
      transparent 0px,
      transparent 4px,
      rgba(160,110,40,0.5) 4px,
      rgba(160,110,40,0.5) 5px
    );
}

/* Age spots — warm brown blotches */
#parchment .panel::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  background:
    radial-gradient(ellipse 60px 40px at 12% 18%,  rgba(180,120,40,0.9) 0%, transparent 100%),
    radial-gradient(ellipse 40px 60px at 88% 75%,  rgba(160,100,30,0.8) 0%, transparent 100%),
    radial-gradient(ellipse 80px 30px at 55% 92%,  rgba(140, 90,20,0.7) 0%, transparent 100%),
    radial-gradient(ellipse 30px 50px at  8% 60%,  rgba(180,130,50,0.6) 0%, transparent 100%),
    radial-gradient(ellipse 50px 35px at 75% 12%,  rgba(160,110,35,0.5) 0%, transparent 100%);
}

/* Make panel content sit above texture layers */
#parchment .panel > * {
  position: relative;
  z-index: 1;
}

/* Corner ornaments */
#parchment::before,
#parchment::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border-color: var(--gold-dark);
  border-style: solid;
  opacity: 0.6;
}
#parchment::before {
  top: 8px; left: 8px;
  border-width: 1px 0 0 1px;
}
#parchment::after {
  bottom: 8px; right: 8px;
  border-width: 0 1px 1px 0;
}

/* ── Panels ────────────────────────────────────────────────────────────────── */
.panel {
  display: none;
  padding: 44px 48px 40px;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.panel.active { display: flex; }

/* ── Logo / title ──────────────────────────────────────────────────────────── */
#logo-wrap {
  text-align: center;
  margin-bottom: 6px;
  position: relative;
}

.logo-eyebrow {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--gold-dark);
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: 6px;
}

h1.game-title {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 700;
  font-size: clamp(28px, 6vw, 48px);
  color: var(--gold);
  letter-spacing: 6px;
  text-transform: uppercase;
  line-height: 1;
  text-shadow:
    0 0 30px rgba(200,148,58,0.6),
    0 0 60px rgba(200,148,58,0.3),
    0 2px 4px rgba(0,0,0,0.8);
  animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 30px rgba(200,148,58,0.6), 0 0 60px rgba(200,148,58,0.3), 0 2px 4px #000; }
  50%       { text-shadow: 0 0 40px rgba(200,148,58,0.9), 0 0 80px rgba(200,148,58,0.5), 0 2px 4px #000; }
}

.logo-sub {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--gold-dark);
  letter-spacing: 3px;
  margin-top: 6px;
  opacity: 0.9;
}

/* ── Divider ───────────────────────────────────────────────────────────────── */
.divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  opacity: 0.6;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}
.divider-glyph {
  font-family: 'Cinzel', serif;
  color: var(--gold-dark);
  font-size: 14px;
  letter-spacing: 4px;
}

/* ── Description ───────────────────────────────────────────────────────────── */
.desc {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 1.25rem;
  color: var(--parchment2);
  text-align: center;
  line-height: 1.8;
  opacity: 0.85;
  margin-bottom: 24px;
  max-width: 360px;
}

/* ── Name input ────────────────────────────────────────────────────────────── */
.input-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold-dark);
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: 0.8;
}

#nameinput {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--gold-dark);
  border-bottom-color: var(--gold);
  color: var(--parchment);
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 18px;
  text-align: center;
  padding: 12px 20px;
  outline: none;
  letter-spacing: 2px;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

#nameinput::placeholder {
  color: rgba(180,140,80,0.35);
  font-style: italic;
}

#nameinput:focus {
  border-color: var(--gold);
  background: rgba(0,0,0,0.65);
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.4),
    0 0 20px rgba(200,148,58,0.15);
}

/* ── Play button ───────────────────────────────────────────────────────────── */
#play-btn {
  margin-top: 20px;
  width: 100%;
  position: relative;
  background: linear-gradient(180deg, #3a2008 0%, #1e1004 100%);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 5px;
  text-transform: uppercase;
  padding: 16px 32px;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  opacity: 0.5;
  pointer-events: none;
}

#play-btn.ready {
  opacity: 1;
  pointer-events: all;
}

#play-btn.ready:hover {
  background: linear-gradient(180deg, #5a3010 0%, #3a1e08 100%);
  border-color: var(--gold);
  color: var(--gold-light);
  box-shadow: 0 0 30px rgba(200,148,58,0.25);
}

#play-btn.ready:active {
  transform: translateY(1px);
}

#play-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(200,148,58,0.12), transparent);
  transition: left 0.5s;
}
#play-btn.ready:hover::after { left: 160%; }

/* ── Layla quote ───────────────────────────────────────────────────────────── */
.layla-quote {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 1rem;
  color: rgba(180,140,80,0.45);
  text-align: center;
  margin-top: 16px;
  line-height: 1.7;
  letter-spacing: 0.5px;
}

/* ── Load character panel ──────────────────────────────────────────────────── */
#play-btn-load {
  margin-top: 4px;
  width: 100%;
  position: relative;
  background: linear-gradient(180deg, #3a2008 0%, #1e1004 100%);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 5px;
  text-transform: uppercase;
  padding: 16px 32px;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

#play-btn-load:hover {
  background: linear-gradient(180deg, #5a3010 0%, #3a1e08 100%);
  border-color: var(--gold);
  color: var(--gold-light);
  box-shadow: 0 0 30px rgba(200,148,58,0.25);
}

#play-btn-load:active {
  transform: translateY(1px);
}

#play-btn-load::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(200,148,58,0.12), transparent);
  transition: left 0.5s;
}
#play-btn-load:hover::after { left: 160%; }

#panel-load .char-name-display {
  font-family: 'Cinzel Decorative', serif;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 4px;
  text-shadow: 0 0 20px rgba(200,148,58,0.5);
}

#panel-load .char-title-display {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--gold-dark);
  text-align: center;
  margin-bottom: 20px;
  opacity: 0.8;
}

.char-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.stat-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(120,80,20,0.3);
  padding: 8px 12px;
  text-align: center;
}

.stat-label {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--gold-dark);
  text-transform: uppercase;
  margin-bottom: 3px;
  opacity: 0.7;
}

.stat-value {
  font-family: 'IM Fell English', serif;
  font-size: 16px;
  color: var(--parchment);
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(120,80,20,0.4);
  border-color: transparent;
  border-radius: 50%;
  color: rgba(180,140,80,0.6);
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 10px 20px;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--gold-dark);
  color: var(--gold-dark);
}

/* ── Candleflame ───────────────────────────────────────────────────────────── */
.candle-wrap {
  position: absolute;
  bottom: -10px;
  right: 24px;
  pointer-events: none;
  z-index: 20;
}

.candle-body {
  width: 18px; height: 32px;
  background: linear-gradient(180deg, #f0e0b8 0%, #d4b87a 40%, #b89050 100%);
  margin: 0 auto;
  position: relative;
  border-radius: 2px 2px 1px 1px;
  box-shadow: inset -3px 0 6px rgba(0,0,0,0.25), inset 2px 0 4px rgba(255,255,220,0.15);
}

.candle-flame {
  width: 8px; height: 10px;
  background: radial-gradient(ellipse at 50% 80%, #fff 0%, #f4d040 30%, #e87a10 70%, transparent 100%);
  border-radius: 50% 50% 30% 30%;
  margin: 0 auto -2px;
  animation: flicker 0.15s ease-in-out infinite alternate;
  transform-origin: bottom center;
  filter: blur(0.6px);
}

@keyframes flicker {
  0%   { transform: scaleX(1)    scaleY(1)    rotate(-1deg);  opacity: 0.95; }
  33%  { transform: scaleX(0.85) scaleY(1.08) rotate(1.5deg); opacity: 1;    }
  66%  { transform: scaleX(1.1)  scaleY(0.95) rotate(-2deg);  opacity: 0.9;  }
  100% { transform: scaleX(0.9)  scaleY(1.05) rotate(0.5deg); opacity: 1;    }
}

/* ── Arabic script decoration ──────────────────────────────────────────────── */
.arabic-deco {
  font-size: 18px;
  color: rgba(200,148,58,0.2);
  letter-spacing: 6px;
  text-align: center;
  margin-bottom: 2px;
  font-family: serif;
  direction: rtl;
}

/* ── layla-smoke.css ─────────────────────────────────────── (extracted) ─── */


/* ── birds.css ───────────────────────────────────────────── (extracted) ─── */

/* ── Transition overlay ────────────────────────────────────────────────────── */
#fade-overlay {
  position: fixed;
  inset: 0;
  background: var(--earth-deep);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
#fade-overlay.fading { opacity: 1; pointer-events: all; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-height: 600px) {
  .panel   { padding: 28px 36px 24px; gap: 0; }
  .desc    { margin-bottom: 16px; font-size: 12px; }
  .divider { margin: 14px 0; }
}
