/* ============================================================
   DEVIL DOOR — UI/UX Stylesheet
   Design Tokens مأخوذة من UI_UX_Design_Structure.md
   ============================================================ */

:root {
  /* Colors */
  --bg-primary: #0B0B12;
  --bg-surface: #16161F;
  --bg-surface-2: #1F1F2B;
  --devil-red: #FF3B3B;
  --player-yellow: #FFD84D;
  --exit-green: #4DFF9E;
  --trap-orange: #FF6B35;
  --text-primary: #F8F9FA;
  --text-secondary: #9CA3AF;
  --muted: #6B7280;

  /* Radius */
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-glow-red: 0 0 24px rgba(255, 59, 59, 0.5);
  --shadow-glow-green: 0 0 24px rgba(77, 255, 158, 0.5);

  /* Motion */
  --motion-fast: 0.15s;
  --motion-normal: 0.2s;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ---------- Game Wrap ---------- */
#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  background: var(--bg-primary);
  image-rendering: pixelated;
  max-width: 100%;
  max-height: 100%;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  pointer-events: none;
  z-index: 10;
}

#death-counter {
  font-size: 20px;
  font-weight: bold;
  color: var(--devil-red);
  background: rgba(0,0,0,0.5);
  padding: 6px 14px;
  border-radius: var(--radius-md);
}

#timer {
  font-size: 16px;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.5);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  margin-left: auto;
}

#btn-pause {
  pointer-events: all;
  width: 48px; height: 48px;
  background: var(--bg-surface-2);
  border: 1px solid #2A2A3A;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  transition: transform var(--motion-fast);
}
#btn-pause:active { transform: scale(0.95); }

/* ---------- Death Overlay ---------- */
#death-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn var(--motion-normal) ease-out;
}

.death-icon { font-size: 64px; animation: bounceIn 0.4s ease-out; }
.death-count {
  font-size: 56px;
  font-weight: 900;
  color: var(--devil-red);
  margin-top: 8px;
}

/* ---------- Results Overlay ---------- */
#results-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 30;
  animation: fadeIn var(--motion-normal) ease-out;
}

#results-overlay h2 {
  font-size: 32px;
  color: var(--exit-green);
  text-shadow: var(--shadow-glow-green);
}

#results-overlay p { color: var(--text-secondary); font-size: 18px; }

.stars { font-size: 48px; color: var(--player-yellow); letter-spacing: 8px; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform var(--motion-fast), box-shadow var(--motion-fast);
}
button:active { transform: scale(0.95); }

.btn-primary {
  padding: 16px 48px;
  font-size: 20px;
  font-weight: bold;
  background: var(--devil-red);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glow-red);
}
.btn-primary:hover { box-shadow: 0 0 32px rgba(255,59,59,0.7); }

.btn-secondary {
  padding: 12px 32px;
  font-size: 16px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid #2A2A3A;
  border-radius: var(--radius-md);
}

/* ---------- Offline Banner ---------- */
#offline-banner {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 15;
  animation: fadeIn var(--motion-normal);
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes bounceIn {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1.0); opacity: 1; }
}

/* ---------- RTL Support (Arabic) ---------- */
[dir="rtl"] #timer { margin-left: 0; margin-right: auto; }
