/* ============================================
   اللعبة - رحلة بصرية سينمائية
   ============================================ */

* { box-sizing: border-box; }

body.game-active {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  font-family: 'Tajawal', sans-serif;
  color: #e8d5b9;
  height: 100vh;
}

.game-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

/* خلفية متحركة Ken Burns */
.scene-background {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scene-bg-image {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2s ease-in-out;
  animation: kenBurns 40s ease-in-out infinite alternate;
  filter: brightness(0.65) contrast(1.05);
}

.scene-bg-image.active { opacity: 1; }

@keyframes kenBurns {
  0% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.1) translate(-2%, -1%); }
  100% { transform: scale(1.18) translate(-4%, -3%); }
}

/* جزيئات سينمائية */
.scene-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: floatUp linear infinite;
}

.particle.dust { background: rgba(255, 220, 150, 0.4); box-shadow: 0 0 4px rgba(255, 220, 150, 0.6); }
.particle.snow { background: rgba(255,255,255,0.85); box-shadow: 0 0 4px rgba(255,255,255,0.5); animation-name: floatDown; }
.particle.magic { background: rgba(160,102,255,0.7); box-shadow: 0 0 8px rgba(160,102,255,0.9); }
.particle.fire { background: rgba(255,120,40,0.7); box-shadow: 0 0 10px rgba(255,80,20,0.8); }
.particle.water { background: rgba(100,170,255,0.6); box-shadow: 0 0 6px rgba(100,170,255,0.5); }
.particle.gold { background: rgba(212,175,55,0.6); box-shadow: 0 0 8px rgba(212,175,55,0.8); }

@keyframes floatUp {
  0% { transform: translateY(110vh) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) translateX(40px); opacity: 0; }
}

@keyframes floatDown {
  0% { transform: translateY(-10vh) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(110vh) translateX(-40px); opacity: 0; }
}

/* ضباب */
.scene-fog {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at top, transparent 30%, rgba(0,0,0,0.5) 100%),
              radial-gradient(ellipse at bottom, transparent 40%, rgba(0,0,0,0.8) 100%);
}

.scene-fog.glow {
  background: radial-gradient(ellipse at top, rgba(212,175,55,0.15) 0%, transparent 50%),
              radial-gradient(ellipse at bottom, transparent 40%, rgba(0,0,0,0.7) 100%);
}

.scene-fog.purple {
  background: radial-gradient(ellipse at top, rgba(160,102,255,0.18) 0%, transparent 60%),
              radial-gradient(ellipse at bottom, transparent 40%, rgba(0,0,0,0.75) 100%);
}

.scene-fog.dark {
  background: radial-gradient(ellipse at center, transparent 20%, rgba(0,0,0,0.85) 100%);
}

/* HUD */
.game-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 1.5rem 2rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 100%);
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.game-hud > * { pointer-events: auto; }

.hud-back {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #d4af37;
  text-decoration: none;
  font-family: 'Cinzel', serif;
  padding: 0.5rem 1.2rem;
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 25px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  transition: all 0.3s;
  font-size: 0.9rem;
}

.hud-back:hover {
  background: rgba(212,175,55,0.15);
  border-color: #d4af37;
}

.progress-container {
  flex: 1;
  max-width: 600px;
  margin: 0 2rem;
}

.progress-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #b8943b, #d4af37, #a066ff);
  width: 0%;
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 0 12px rgba(212,175,55,0.8);
}

.progress-info {
  margin-top: 0.6rem;
  text-align: center;
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.15em;
}

.hud-controls { display: flex; gap: 0.5rem; }

.hud-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(212,175,55,0.3);
  color: #d4af37;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: all 0.3s;
}

.hud-btn:hover {
  background: rgba(212,175,55,0.2);
  border-color: #d4af37;
  transform: scale(1.05);
}

.hud-btn.active { background: #d4af37; color: #050208; }

/* المحتوى */
.scene-content-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
  padding: 2rem 1rem 0;
  pointer-events: none;
}

.scene-content {
  max-width: 1100px;
  width: 100%;
  background: linear-gradient(0deg, rgba(5,2,8,0.96) 0%, rgba(5,2,8,0.85) 70%, transparent 100%);
  padding: 4rem 3rem 3rem;
  border-radius: 20px 20px 0 0;
  pointer-events: auto;
  max-height: 65vh;
  overflow-y: auto;
}

.scene-content::-webkit-scrollbar { width: 6px; }
.scene-content::-webkit-scrollbar-thumb { background: #b8943b; border-radius: 3px; }

.scene-inner {
  animation: contentRise 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.scene-chapter-tag {
  display: inline-block;
  padding: 0.4rem 1.2rem;
  background: rgba(212,175,55,0.15);
  border: 1px solid #b8943b;
  border-radius: 20px;
  color: #d4af37;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  margin-bottom: 1rem;
}

.scene-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  background: linear-gradient(135deg, #f5cd4a 0%, #d4af37 50%, #a066ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 0.8rem;
  line-height: 1.15;
}

.scene-subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 1.2rem;
  font-style: italic;
  margin-bottom: 1.5rem;
  font-family: 'Cinzel', serif;
}

.scene-narrative {
  color: rgba(255,255,255,0.95);
  line-height: 2;
  font-size: 1.1rem;
  margin-bottom: 1.8rem;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.scene-narrative p { margin: 0 0 1.2rem; }
.scene-narrative b, .scene-narrative strong { color: #f5cd4a; font-weight: 700; }
.scene-narrative em { color: #a066ff; font-style: normal; }

/* صندوق الأبعاد والمسافات */
.dimensions-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(160,102,255,0.1), rgba(212,175,55,0.05));
  border: 1px solid #b8943b;
  border-radius: 12px;
}

.dimension-item {
  text-align: center;
  padding: 0.5rem;
}

.dimension-icon {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
  filter: drop-shadow(0 0 10px rgba(212,175,55,0.5));
}

.dimension-value {
  font-family: 'Cinzel', serif;
  color: #f5cd4a;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.dimension-label {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
}

/* أزرار التنقل */
.scene-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(212,175,55,0.2);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 2rem;
  background: linear-gradient(135deg, #b8943b, #d4af37);
  color: #050208;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.3s;
  box-shadow: 0 6px 20px rgba(212,175,55,0.3);
}

.nav-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(212,175,55,0.5);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-btn.secondary {
  background: rgba(0,0,0,0.5);
  color: #d4af37;
  border: 1px solid #b8943b;
}

.nav-btn.secondary:hover:not(:disabled) {
  background: rgba(212,175,55,0.15);
  border-color: #d4af37;
}

.scene-counter {
  font-family: 'Cinzel', serif;
  color: rgba(255,255,255,0.6);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}

/* شاشة البداية */
.splash-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a0a35 0%, #050208 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 1.8s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background-image: url('../assets/book/album-02.jpg');
  background-size: cover;
  background-position: center;
  opacity: 0.25;
  filter: blur(2px);
  animation: kenBurns 40s ease-in-out infinite alternate;
}

.splash-content {
  position: relative;
  text-align: center;
  max-width: 700px;
  padding: 2rem;
  z-index: 10;
  animation: contentRise 2s ease;
}

.splash-runes {
  font-family: 'Uncial Antiqua', serif;
  color: #d4af37;
  letter-spacing: 0.5em;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  animation: runeGlow 3s ease-in-out infinite;
}

@keyframes runeGlow {
  0%, 100% { opacity: 0.5; text-shadow: 0 0 20px rgba(212,175,55,0.5); }
  50% { opacity: 1; text-shadow: 0 0 50px rgba(212,175,55,1), 0 0 80px rgba(160,102,255,0.6); }
}

.splash-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.8rem, 7vw, 5rem);
  background: linear-gradient(135deg, #f5cd4a, #d4af37, #a066ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 30px rgba(0,0,0,0.8));
}

.splash-subtitle {
  color: rgba(255,255,255,0.85);
  font-family: 'Cinzel', serif;
  font-style: italic;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.splash-description {
  color: rgba(255,255,255,0.75);
  font-size: 1rem;
  line-height: 1.9;
  margin-bottom: 2.5rem;
}

.splash-start-btn {
  padding: 1.4rem 3.5rem;
  background: linear-gradient(135deg, #b8943b, #d4af37);
  color: #050208;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: 0 10px 40px rgba(212,175,55,0.4);
  transition: all 0.3s;
}

.splash-start-btn:hover {
  transform: scale(1.05) translateY(-3px);
  box-shadow: 0 20px 60px rgba(212,175,55,0.6);
}

/* شاشة النهاية */
.ending-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a0a35 0%, #050208 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 2rem;
  overflow-y: auto;
}

.ending-content {
  max-width: 800px;
  text-align: center;
  padding: 3rem 2rem;
  animation: contentRise 1.5s ease;
}

.ending-emblem {
  font-size: 5rem;
  color: #d4af37;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 0 50px rgba(212,175,55,0.8));
  animation: emblemSpin 12s linear infinite;
}

@keyframes emblemSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ending-content h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.5rem, 6vw, 4rem);
  background: linear-gradient(135deg, #f5cd4a, #d4af37, #a066ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .game-hud { padding: 1rem; }
  .hud-back { padding: 0.5rem 0.8rem; }
  .hud-back span:not(:first-child) { display: none; }
  .progress-container { margin: 0 0.8rem; }
  .scene-content { padding: 2rem 1.5rem 1.5rem; max-height: 70vh; }
  .scene-title { font-size: 1.8rem; }
  .scene-narrative { font-size: 0.95rem; line-height: 1.8; }
  .scene-nav { flex-direction: column; gap: 0.8rem; }
  .nav-btn { width: 100%; justify-content: center; }
  .dimensions-box { grid-template-columns: 1fr 1fr; }
}
