/* =========================================================
   WORD BOMB — قنبلة الكلمات
   Palette: Dark charred obsidian background with rich hot ember
   accents and high-contrast typography.
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@400;700;800;900&display=swap');
:root {
  --bg:            #0c0907;
  --bg-2:          #140f0c;
  --panel:         #1a130e;
  --panel-border:  #38291d;
  --ember-amber:   #ffb72b;
  --ember-orange:  #ff6d1f;
  --ember-red:     #ff3535;
  --safe-green:    #48d97a;
  --text:          #fbf5ed;
  --text-dim:      #c7b6a3;
  --text-faint:    #857463;

  --font-display:  'Alexandria', system-ui, -apple-system, sans-serif;
  --font-body:     'Tajawal', 'Cairo', sans-serif;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  color-scheme: dark;
}

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

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(120% 90% at 50% -10%, #21150c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100dvh;
  display: flex;
  overflow: hidden;
  user-select: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
.diff-card:focus-visible {
  outline: 2px solid var(--ember-amber);
  outline-offset: 3px;
}

/* ============ Ambient background ============ */
.bg-fog {
  position: fixed; inset: 0;
  background:
    radial-gradient(60% 40% at 20% 100%, rgba(255,109,31,0.08), transparent 70%),
    radial-gradient(50% 35% at 90% 10%, rgba(255,53,53,0.06), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.bg-sparks {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-sparks span {
  position: absolute;
  bottom: -10px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ember-amber);
  box-shadow: 0 0 6px 1px rgba(255,183,43,0.8);
  opacity: 0;
  animation: spark-rise linear infinite;
}
@keyframes spark-rise {
  0%   { opacity: 0; transform: translateY(0) translateX(0); }
  10%  { opacity: 1; }
  90%  { opacity: 0.4; }
  100% { opacity: 0; transform: translateY(-100vh) translateX(var(--drift, 20px)); }
}

/* ============ App shell / screens ============ */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  animation: screen-in 380ms cubic-bezier(.25,.9,.35,1);
}
.screen.is-active { display: flex; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ================= SETUP SCREEN ================= */
.screen--setup {
  justify-content: space-between;
  gap: 24px;
}

.brand {
  text-align: center;
  padding-top: clamp(8px, 4vh, 28px);
}

.brand__fuse {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ember-amber) 0%, var(--ember-orange) 55%, transparent 75%);
  display: flex; align-items: center; justify-content: center;
  animation: fuse-flicker 1.1s ease-in-out infinite;
}
.fuse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff3d6;
  box-shadow: 0 0 14px 4px rgba(255,183,43,.9);
}
@keyframes fuse-flicker {
  0%, 100% { transform: scale(1);   filter: brightness(1); }
  50%      { transform: scale(1.12); filter: brightness(1.25); }
}

.brand__title { margin: 0; line-height: 1.3; }
.brand__title-ar {
  display: block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.1rem, 9vw, 2.8rem);
  background: linear-gradient(180deg, #ffffff 0%, var(--ember-amber) 60%, var(--ember-orange) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.5px;
  
  /* ADD THIS LINE: */
  padding: 10px 0; 
}
.brand__title-en {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 6px;
  color: var(--text-faint);
}
.brand__tagline {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.setup-card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px 18px 24px;
}

.setup-card__label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.setup-card__label:not(:first-child) { margin-top: 22px; }
.label-index {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 800;
  color: #0c0907;
  background: var(--ember-amber);
  border-radius: 999px;
  padding: 3px 8px;
  letter-spacing: 1px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.diff-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  background: var(--bg);
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius-md);
  transition: border-color 160ms ease, transform 120ms ease, background 160ms ease;
}
.diff-card:active { transform: scale(0.96); }
.diff-card__icon { font-size: 1.3rem; }
.diff-card__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
}
.diff-card__range {
  font-size: 0.72rem;
  color: var(--text-faint);
}
.diff-card.is-selected {
  border-color: var(--ember-orange);
  background: linear-gradient(180deg, rgba(255,109,31,0.18), rgba(255,109,31,0.04));
  box-shadow: 0 0 0 1px rgba(255,109,31,0.3), 0 6px 18px -8px rgba(255,109,31,0.5);
}
.diff-card.is-selected .diff-card__name { color: #ffe2c2; }

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  background: var(--bg);
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius-md);
  font-weight: 500;
  color: var(--text-dim);
}
.sound-toggle[aria-pressed="true"] { color: var(--text); }
.sound-toggle[aria-pressed="false"] .sound-toggle__icon { opacity: 0.4; }
.sound-toggle__icon { font-size: 1.1rem; }

.btn-primary {
  position: relative;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: #120b06;
  padding: 19px 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffcf6b 0%, var(--ember-orange) 55%, #ff4b0d 100%);
  box-shadow: 0 10px 26px -8px rgba(255,109,31,0.65), inset 0 1px 0 rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 4px 14px -6px rgba(255,109,31,0.6), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-start__spark { font-size: 1rem; }

.setup-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0 6px;
}

/* ================= PLAY SCREEN ================= */
.screen--play {
  justify-content: space-between;
}

.play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 1rem;
  color: var(--text-dim);
}

.diff-chip {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 14px;
}

.danger-pulse {
  position: relative;
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
}
.danger-pulse__ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ember-orange);
  opacity: 0.7;
  animation: pulse-ring 1.4s ease-out infinite;
}
.danger-pulse__core { font-size: 1.6rem; position: relative; z-index: 1; }
@keyframes pulse-ring {
  0%   { transform: scale(0.7); opacity: 0.75; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* Eye-friendly non-irritating pulse (smooth inset vignette glow) */
.screen--play { --tick-speed: 1.4s; }
.danger-pulse__ring { animation-duration: var(--tick-speed); }
.screen--play.is-active {
  animation: screen-in 380ms cubic-bezier(.25,.9,.35,1), bg-vignette-pulse var(--tick-speed) ease-in-out infinite;
}

@keyframes bg-vignette-pulse {
  0%, 100% { box-shadow: inset 0 0 0px transparent; }
  50%      { box-shadow: inset 0 0 70px rgba(255, 75, 13, 0.12); }
}

.prompt-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.prompt-card {
  width: 100%;
  text-align: center;
  padding: 32px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1.5px solid var(--panel-border);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,0.8);
}

.prompt-eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-faint);
  text-transform: uppercase;
}

.prompt-category {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 7.5vw, 2.1rem);
  line-height: 1.3;
  color: #ffffff;
}

.prompt-divider {
  display: flex; justify-content: center;
  margin: 20px 0;
}
.prompt-divider span {
  width: 48px; height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--ember-orange), transparent);
}

/* Constraint Highlight Pill Box */
.prompt-constraint-box {
  margin-top: 8px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,183,43,0.12) 0%, rgba(255,109,31,0.06) 100%);
  border: 1.5px solid rgba(255,183,43,0.35);
  border-radius: var(--radius-md);
}

.prompt-constraint-eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--ember-amber);
  text-transform: uppercase;
}

.prompt-constraint {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.3rem, 6.5vw, 1.75rem);
  color: #ffffff;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.btn-pass {
  position: relative;
  width: 100%;
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--ember-red) 0%, #ba1010 100%);
  box-shadow: 0 16px 34px -12px rgba(255,53,53,0.65), inset 0 1px 0 rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  transition: transform 90ms ease, box-shadow 90ms ease;
}
.btn-pass:active {
  transform: scale(0.96);
  box-shadow: 0 6px 16px -10px rgba(255,53,53,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-pass__label {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.6rem, 8vw, 2.1rem);
  color: #ffffff;
  letter-spacing: 0.5px;
}
.btn-pass__bomb {
  font-size: clamp(1.6rem, 8vw, 2.1rem);
  animation: bomb-jiggle 1.2s ease-in-out infinite;
}
@keyframes bomb-jiggle {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-8deg); }
  75%      { transform: rotate(8deg); }
}

/* ================= EXPLOSION SCREEN ================= */
.screen--boom {
  align-items: center;
  justify-content: center;
  position: relative;
  background: #0a0605;
  overflow: hidden;
}

.boom-flash {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 45%, #fff3d6 0%, var(--ember-amber) 18%, var(--ember-red) 42%, #1a0603 75%);
  animation: boom-flash-anim 900ms cubic-bezier(.15,.8,.3,1) both;
}
@keyframes boom-flash-anim {
  0%   { opacity: 0; transform: scale(0.2); }
  35%  { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0.55; transform: scale(1); }
}

.boom-shrapnel {
  position: absolute; inset: 0;
  background:
    repeating-conic-gradient(from 0deg, rgba(255,183,43,0.25) 0deg 3deg, transparent 3deg 18deg);
  mix-blend-mode: screen;
  animation: shrapnel-spin 6s linear infinite, shrapnel-fade 1.2s ease-out both;
  opacity: 0.5;
}
@keyframes shrapnel-spin { to { transform: rotate(360deg); } }
@keyframes shrapnel-fade { from { opacity: 0.9; } to { opacity: 0.35; } }

.boom-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.boom-word {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 20vw, 5rem);
  letter-spacing: 2px;
  color: #ffffff;
  text-shadow: 0 0 30px rgba(255,109,31,0.9), 0 0 70px rgba(255,53,53,0.6);
  animation: boom-word-pop 560ms cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes boom-word-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.boom-emoji {
  margin: 0;
  font-size: clamp(3rem, 16vw, 4.5rem);
  animation: boom-word-pop 560ms 80ms cubic-bezier(.2,1.4,.4,1) both;
}

.boom-sub {
  margin: 10px 0 30px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffe1b8;
}

.btn-again {
  width: 100%;
  max-width: 320px;
}

.btn-ghost {
  margin-top: 14px;
  padding: 10px;
  color: var(--text-faint);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ================= Reduced motion ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================= Small screens ================= */
@media (max-height: 640px) {
  .brand { padding-top: 4px; }
  .brand__fuse { margin-bottom: 8px; }
  .setup-card { padding: 16px 16px 18px; }
  .prompt-card { padding: 24px 16px; }
}