:root {
  /* Wareed competition palette: solid deep plum + warm gold accent */
  --plum-0: #2a0d3e;   /* darkest corner */
  --plum-1: #3d1452;   /* mid */
  --plum-2: #4f1a68;   /* highlight */
  --plum-3: #1f0a30;   /* outer fade */

  --bg-0: var(--plum-0);
  --bg-1: var(--plum-1);
  --ink: #f7eed9;          /* warm cream like the headline */
  --ink-dim: #cdb6dc;
  --ink-mute: #8e76b3;
  --line: rgba(255,255,255,0.10);
  --line-strong: rgba(228, 198, 132, 0.30);
  --glass: rgba(45, 14, 66, 0.62);
  --glass-2: rgba(255,255,255,0.04);

  --accent: #d4b975;       /* warm gold (primary CTA) */
  --accent-2: #ecd189;     /* lighter gold */
  --accent-3: #b86bff;     /* purple support */
  --gold-1: #f4d57a;
  --gold-2: #c89a4a;
  --good: #34d399;
  --bad: #f87171;
  --shadow: 0 30px 80px rgba(0,0,0,0.55);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: 'Cairo', 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1400px 900px at 50% 0%, var(--plum-2) 0%, transparent 60%),
    radial-gradient(1000px 700px at 50% 100%, var(--plum-3) 0%, transparent 65%),
    linear-gradient(180deg, var(--plum-1) 0%, var(--plum-0) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  animation: float 14s ease-in-out infinite;
}
.orb1 { width: 520px; height: 520px; background: #6b2a8f; top: -180px; right: -180px; opacity: 0.35; }
.orb2 { width: 460px; height: 460px; background: #4a1a68; bottom: -200px; left: -140px; opacity: 0.40; animation-delay: -5s; }
.orb3 { width: 360px; height: 360px; background: #d4b975; top: 20%; left: 50%; opacity: 0.06; animation-delay: -9s; }
@keyframes float {
  0%,100% { transform: translateY(0) translateX(0); }
  50%     { transform: translateY(-30px) translateX(20px); }
}

/* =============== TOPBAR =============== */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(26, 5, 48, 0.55);
}
.brand { display: flex; flex-direction: column; line-height: 1.2; align-items: flex-end; }
.brand-ar { font-weight: 700; font-size: 14px; color: var(--ink); letter-spacing: 0.3px; }
.brand-en { font-family: 'Inter', sans-serif; font-size: 10px; color: var(--ink-mute); letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }

.topbar-actions { display: flex; gap: 10px; }
.topbar-left { /* mirrored side in RTL */ }

/* =============== LOGIN =============== */
.login-stage {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
  text-align: center;
  animation: fadeUp .45s ease;
}
.login-logo-wrap {
  display: flex; justify-content: center; margin-bottom: 18px;
}
.login-logo {
  max-height: 90px; width: auto; object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.4));
}
.login-form {
  display: flex; flex-direction: column; gap: 14px;
  margin-top: 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; text-align: start; }
.field-label {
  font-size: 12px; color: var(--ink-dim);
  letter-spacing: 0.4px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: 'Inter', 'Cairo', sans-serif;
  font-size: 15px;
  transition: border-color .2s ease, background .2s ease;
}
.field input::placeholder { color: var(--ink-mute); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0,0,0,0.35);
}
.login-error {
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(248,113,113,0.10);
  border: 1px solid rgba(248,113,113,0.30);
  color: #fecaca;
  font-size: 13px;
}
.login-btn { width: 100%; justify-content: center; margin-top: 4px; }

/* =============== HERO (logo band) =============== */
.hero {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 38px 24px 24px;
  flex-wrap: wrap;
}
.hero-logo {
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.4));
  transition: transform .4s ease;
}
.hero-anniv { max-height: 100px; }
.hero-logo:hover { transform: translateY(-2px); }

.hero-company { max-height: 180px; }
.hero-divider {
  width: 1px; height: 110px;
  background: linear-gradient(180deg, transparent, rgba(228,198,132,0.45), transparent);
}
@media (max-width: 600px) {
  .hero { gap: 18px; padding: 24px 16px 8px; }
  .hero-anniv,
  .hero-company { max-height: 180px; }
  .hero-divider { display: none; }
}

/* =============== BUTTONS =============== */
.primary-btn, .ghost-btn, .link-btn, .icon-btn {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}
.primary-btn {
  padding: 12px 22px;
  border-radius: 999px;
  background: transparent;
  color: var(--accent-2);
  border: 1.5px solid var(--accent);
  box-shadow: 0 6px 24px rgba(212,185,117,0.12);
  font-size: 15px;
  letter-spacing: 0.3px;
}
.primary-btn:hover {
  transform: translateY(-1px);
  background: var(--accent);
  color: #2a0d3e;
  box-shadow: 0 12px 30px rgba(212,185,117,0.35);
}
.primary-btn:active { transform: translateY(0); }
.primary-btn.big { padding: 16px 28px; font-size: 17px; border-radius: 16px; }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ghost-btn {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--glass-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  font-size: 13px;
}
.ghost-btn:hover { background: rgba(255,255,255,0.08); }
.ghost-btn.danger { color: #ffb3b3; border-color: rgba(248,113,113,0.35); }
.ghost-btn.danger:hover { background: rgba(248,113,113,0.12); }
.pill {
  background: var(--accent);
  color: #2a0d3e;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 800;
}

.link-btn {
  background: transparent; color: var(--accent);
  padding: 0; font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent-2); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--glass-2); border: 1px solid var(--line);
  color: var(--ink); justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }

/* =============== STAGES =============== */
#app {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px 80px;
}
.stage { animation: fadeUp .45s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.glass {
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

/* =============== UPLOAD =============== */
.upload-card { padding: 36px; }
.title { font-size: 28px; font-weight: 900; margin: 0 0 8px; letter-spacing: -0.2px; }
.subtitle { color: var(--ink-dim); margin: 0 0 24px; line-height: 1.7; font-size: 15px; }
.subtitle b { color: var(--ink); font-weight: 700; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 16px;
  padding: 38px 20px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
  outline: none;
}
.dropzone:hover, .dropzone:focus, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(212,185,117,0.08);
}
.dz-icon { color: var(--accent); }
.dz-text { text-align: center; }
.dz-text strong { display: block; font-size: 16px; margin-bottom: 6px; }
.dz-text span { color: var(--ink-dim); font-size: 13px; }
.dz-text code {
  background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 6px;
  font-family: 'Inter', monospace; font-size: 12px; margin: 0 2px;
}

.hint-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 14px; color: var(--ink-mute); font-size: 13px;
}
.hint-row .dot { color: var(--ink-mute); }

.files-list {
  margin-top: 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(34,211,238,0.10);
  border: 1px solid rgba(34,211,238,0.3);
  color: #b5edf8; font-size: 12px; font-weight: 600;
}
.file-chip svg { color: #22d3ee; }

.parse-status {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.25);
  color: #a7f3d0;
  font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.parse-status.error {
  background: rgba(248,113,113,0.08);
  border-color: rgba(248,113,113,0.3);
  color: #fecaca;
}

.categories {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.cat-card {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
}
.cat-name { font-weight: 800; font-size: 15px; }
.cat-stats { display: flex; gap: 14px; margin-top: 10px; align-items: baseline; }
.cat-stats .num { font-size: 26px; font-weight: 900; font-family: 'Inter', monospace; letter-spacing: -1px; }
.cat-stats .lbl { color: var(--ink-dim); font-size: 12px; }
.cat-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.cat-row label { font-size: 13px; color: var(--ink-dim); }
.cat-row input {
  width: 70px; padding: 8px 10px; border-radius: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line-strong);
  color: var(--ink); font-family: 'Inter', monospace; font-weight: 700;
  text-align: center;
}
.cat-row input:focus { outline: none; border-color: var(--accent); }
.cat-warn { margin-top: 8px; font-size: 12px; color: #fca5a5; }

.upload-actions { margin-top: 24px; display: flex; justify-content: flex-start; }

/* =============== DRAW STAGE =============== */
.draw-shell { display: flex; flex-direction: column; gap: 24px; padding: 8px 0; }

.progress-bar {
  height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s cubic-bezier(.2,.7,.2,1);
}

.draw-meta { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 6px; }
.meta-label { font-size: 12px; color: var(--ink-mute); letter-spacing: 1px; text-transform: uppercase; }
.meta-cat { margin: 4px 0 0; font-size: 28px; font-weight: 900; letter-spacing: -0.3px; }
.meta-count { font-family: 'Inter', monospace; font-size: 22px; font-weight: 800; }
.meta-sep { color: var(--ink-mute); margin: 0 4px; }

.reel-wrap {
  position: relative;
  border-radius: 24px;
  background:
    radial-gradient(600px 200px at 50% 0%, rgba(124,92,255,0.18), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--line-strong);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.reel {
  position: relative;
  height: 320px;
  display: grid; place-items: center;
  perspective: 1000px;
  text-align: center;
  padding: 24px;
}
.reel-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 160px at 50% 50%, rgba(255,255,255,0.06), transparent 70%);
}
.reel-name {
  font-size: clamp(38px, 7vw, 72px);
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #fff 0%, #e9d5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 30px rgba(255,94,166,0.40));
  display: inline-block;
  transform-style: preserve-3d;
  transition: transform .14s ease, opacity .14s ease;
}
.reel-name.placeholder {
  background: linear-gradient(180deg, #a989c9, #6f4d96);
  -webkit-background-clip: text;
  background-clip: text;
  font-weight: 700;
  font-size: clamp(22px, 3.4vw, 30px);
}
.reel-name.spinning { animation: tick .14s linear infinite; }
@keyframes tick {
  0%   { transform: translateY(-2px) rotateX(-2deg); opacity: .85; }
  50%  { transform: translateY(2px) rotateX(2deg); opacity: 1; }
  100% { transform: translateY(-2px) rotateX(-2deg); opacity: .85; }
}
.reel-name.reveal {
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  animation: revealPop .6s cubic-bezier(.2,.9,.3,1.4) both;
}
@keyframes revealPop {
  0%   { transform: scale(.6); opacity: 0; filter: blur(6px); }
  60%  { transform: scale(1.08); opacity: 1; filter: blur(0); }
  100% { transform: scale(1); }
}

.draw-actions { display: flex; justify-content: center; }

.winners-strip {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center;
  min-height: 44px;
}
.winner-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,214,110,0.18), rgba(255,138,61,0.12));
  border: 1px solid rgba(255,214,110,0.4);
  color: #ffe9b8;
  font-weight: 700; font-size: 14px;
  animation: chipIn .35s cubic-bezier(.2,.7,.2,1.2) both;
}
.winner-chip .chip-cat { color: var(--ink-mute); font-size: 11px; font-weight: 600; }
@keyframes chipIn {
  from { transform: translateY(8px) scale(.9); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* =============== RESULTS =============== */
.results-card { padding: 36px; text-align: center; }
.results-header { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 28px; }
.trophy {
  width: 72px; height: 72px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #2a1700;
  margin-bottom: 6px;
  box-shadow: 0 16px 40px rgba(255,138,61,0.35);
}

.results-list { display: flex; flex-direction: column; gap: 10px; text-align: start; }
.result-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
.result-rank {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 800;
  font-family: 'Inter', monospace;
}
.result-name { font-size: 17px; font-weight: 800; }
.result-cat { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.result-badge {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,214,110,0.15); color: var(--gold-1);
  border: 1px solid rgba(255,214,110,0.3);
  font-weight: 700;
}

.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 28px; }

/* =============== MODAL =============== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(2,4,16,0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  display: flex; flex-direction: column;
  animation: modalIn .25s cubic-bezier(.2,.8,.2,1.05);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); justify-content: flex-end; }
.muted { color: var(--ink-dim); }
.small { font-size: 13px; }

.history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.history-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  font-size: 14px; align-items: center;
}
.history-row .h-name { font-weight: 700; }
.history-row .h-cat { color: var(--ink-dim); font-size: 12px; }
.history-row .h-date { color: var(--ink-mute); font-size: 11px; font-family: 'Inter', monospace; }
.history-empty { padding: 24px; text-align: center; color: var(--ink-mute); font-size: 14px; }

/* =============== TOAST =============== */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 26, 60, 0.95);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  z-index: 100;
  box-shadow: var(--shadow);
  animation: toastIn .25s ease, toastOut .3s ease 2.4s forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes toastOut { to   { opacity: 0; transform: translate(-50%, 8px); } }
.toast.error { border-color: rgba(248,113,113,0.4); }
.toast.success { border-color: rgba(52,211,153,0.4); }

/* =============== RESPONSIVE =============== */
@media (max-width: 600px) {
  .topbar { padding: 14px 16px; }
  .brand-text .brand-en { display: none; }
  .upload-card, .results-card { padding: 24px 18px; }
  .reel { height: 240px; }
  .meta-cat { font-size: 22px; }
  .draw-meta { padding: 0 2px; }
}
