/* ==========================================================================
   Leno — Design Tokens (مستوحى من أجواء Scratch Adventure)
   ========================================================================== */
:root {
  --bg-deep: #1A1145;
  --bg-deep-2: #241457;
  --bg-panel: #2D1B69;
  --bg-panel-2: #382277;

  --accent-yellow: #FFC845;
  --accent-yellow-shadow: #C98F0F;
  --accent-teal: #2EE6D6;
  --accent-teal-shadow: #0FA398;
  --accent-pink: #FF6B9D;
  --accent-pink-shadow: #C93C6C;
  --accent-purple: #9B6BFF;
  --accent-purple-shadow: #6438C4;

  --text-light: #F5F0FF;
  --text-muted: #B8A9E0;
  --shadow-dark: #0D0824;

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

  --font-display: 'Baloo 2', 'Tahoma', sans-serif;
  --font-body: 'Nunito', 'Tahoma', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 20% 0%, var(--bg-deep-2), var(--bg-deep) 60%);
  color: var(--text-light);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  direction: rtl;
}

body {
  background-image:
    radial-gradient(circle at 85% 15%, rgba(255, 200, 69, 0.10), transparent 40%),
    radial-gradient(circle at 10% 80%, rgba(46, 230, 214, 0.10), transparent 40%);
  padding-bottom: 40px;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-pink); color: var(--shadow-dark); }

/* ==========================================================================
   Layout shells
   ========================================================================== */
.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 18px 10px;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .logo-badge {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent-pink), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 var(--accent-pink-shadow), 0 8px 14px rgba(0,0,0,0.35);
}

.brand .logo-badge svg { width: 26px; height: 26px; }

.brand h1 {
  font-size: 26px;
  color: var(--text-light);
  letter-spacing: 0.5px;
}

.brand .sub {
  font-size: 11px;
  color: var(--accent-teal);
  font-weight: 800;
  letter-spacing: 1.5px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bg-panel);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--shadow-dark), inset 0 0 0 2px rgba(255,255,255,0.05);
  cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow-dark); }

/* ==========================================================================
   Hero / stage
   ========================================================================== */
.stage {
  background: linear-gradient(165deg, var(--bg-panel), var(--bg-panel-2));
  border-radius: var(--radius-lg);
  padding: 26px 20px 30px;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 0 var(--shadow-dark), 0 18px 30px rgba(0,0,0,0.35);
  overflow: hidden;
}

.stage::before, .stage::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: 0.5;
}
.stage::before {
  width: 140px; height: 140px;
  background: radial-gradient(circle, var(--accent-teal), transparent 70%);
  top: -60px; right: -40px;
  opacity: 0.25;
}
.stage::after {
  width: 160px; height: 160px;
  background: radial-gradient(circle, var(--accent-pink), transparent 70%);
  bottom: -70px; left: -50px;
  opacity: 0.2;
}

.stage .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  color: var(--accent-yellow);
  font-weight: 800;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.stage .eyebrow svg { width: 14px; height: 14px; }

.stage h2 {
  font-size: 22px;
  color: var(--text-light);
  margin-bottom: 6px;
  position: relative;
}

.stage p.hint {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 22px;
  position: relative;
}

/* ==========================================================================
   Dice button — العنصر المميز (signature element)
   ========================================================================== */
.dice-wrap {
  position: relative;
  display: inline-block;
}

.dice-btn {
  width: 128px;
  height: 128px;
  border: none;
  border-radius: 32px;
  background: linear-gradient(155deg, var(--accent-yellow), #FFB020);
  box-shadow:
    0 10px 0 var(--accent-yellow-shadow),
    0 18px 26px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s ease;
  position: relative;
}

.dice-btn svg { width: 62px; height: 62px; }

.dice-btn:active {
  transform: translateY(8px);
  box-shadow: 0 2px 0 var(--accent-yellow-shadow), 0 6px 10px rgba(0,0,0,0.3);
}

.dice-btn.rolling svg {
  animation: dice-spin 0.6s ease-in-out;
}

@keyframes dice-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

.dice-caption {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--accent-teal);
  position: relative;
}

/* ==========================================================================
   Scratch card
   ========================================================================== */
.scratch-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 8, 36, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}
.scratch-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.scratch-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 12px 0 var(--shadow-dark), 0 24px 40px rgba(0,0,0,0.5);
  transform: translateY(30px) scale(0.95);
  transition: transform 0.3s cubic-bezier(.2,.9,.3,1.3);
}
.scratch-overlay.open .scratch-card { transform: translateY(0) scale(1); }

.scratch-card .card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  color: var(--accent-pink);
  font-weight: 800;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.scratch-card .card-tag svg { width: 12px; height: 12px; }

.scratch-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.06);
}

.scratch-canvas-wrap img.result-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scratch-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.scratch-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.85);
  font-family: var(--font-display);
  font-size: 14px;
  pointer-events: none;
  z-index: 5;
}
.scratch-hint svg { width: 34px; height: 34px; opacity: 0.9; }

.result-desc {
  margin-top: 14px;
  color: var(--text-light);
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
  min-height: 24px;
}

.result-title {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--accent-yellow);
  text-align: center;
  margin-top: 10px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* ==========================================================================
   3D Buttons (reusable)
   ========================================================================== */
.btn3d {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease;
}
.btn3d svg { width: 17px; height: 17px; }

.btn3d.teal {
  background: linear-gradient(155deg, var(--accent-teal), #17B9AC);
  color: var(--shadow-dark);
  box-shadow: 0 6px 0 var(--accent-teal-shadow);
}
.btn3d.pink {
  background: linear-gradient(155deg, var(--accent-pink), #E14A80);
  color: #fff;
  box-shadow: 0 6px 0 var(--accent-pink-shadow);
}
.btn3d.purple {
  background: linear-gradient(155deg, var(--accent-purple), #7B4FE0);
  color: #fff;
  box-shadow: 0 6px 0 var(--accent-purple-shadow);
}
.btn3d:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

.close-scratch {
  position: absolute;
  top: -14px;
  left: -14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-pink);
  box-shadow: 0 4px 0 var(--accent-pink-shadow);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.close-scratch svg { width: 15px; height: 15px; }

/* ==========================================================================
   Gallery grid (category chips + list preview)
   ========================================================================== */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 4px 12px;
  font-size: 16px;
  color: var(--text-light);
}
.section-title svg { width: 18px; height: 18px; color: var(--accent-yellow); }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  background: var(--bg-panel);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--shadow-dark);
  cursor: pointer;
}
.chip.active {
  background: var(--accent-teal);
  color: var(--shadow-dark);
  box-shadow: 0 3px 0 var(--accent-teal-shadow);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.stat-box {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  box-shadow: 0 5px 0 var(--shadow-dark);
}
.stat-box .num {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--accent-yellow);
}
.stat-box .lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 60px; height: 60px; margin-bottom: 14px; opacity: 0.6; }

/* ==========================================================================
   Admin panel
   ========================================================================== */
.admin-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.panel {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 8px 0 var(--shadow-dark);
  margin-bottom: 22px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 svg { width: 20px; height: 20px; color: var(--accent-teal); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-teal);
  margin-bottom: 6px;
}
.field input[type=text],
.field input[type=password],
.field textarea,
.field select {
  width: 100%;
  background: var(--bg-deep);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent-teal);
}
.field textarea { min-height: 90px; resize: vertical; }

.file-drop {
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
}
.file-drop svg { width: 30px; height: 30px; margin-bottom: 8px; color: var(--accent-yellow); }
.file-drop input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.admin-card {
  background: var(--bg-deep-2);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 5px 0 var(--shadow-dark);
}
.admin-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.admin-card .body { padding: 12px; }
.admin-card .title { font-family: var(--font-display); font-size: 14px; margin-bottom: 4px; }
.admin-card .desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; max-height: 54px; overflow: hidden; }
.admin-card .row-actions { display: flex; gap: 8px; margin-top: 10px; }
.admin-card .row-actions a {
  flex: 1;
  text-align: center;
  padding: 7px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}
.admin-card .row-actions a.edit { background: var(--accent-teal); color: var(--shadow-dark); }
.admin-card .row-actions a.del { background: var(--accent-pink); color: #fff; }

.login-box {
  max-width: 360px;
  margin: 60px auto;
  padding: 0 18px;
}

.alert {
  background: rgba(255,107,157,0.15);
  border: 1px solid var(--accent-pink);
  color: var(--accent-pink);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert.success {
  background: rgba(46,230,214,0.15);
  border-color: var(--accent-teal);
  color: var(--accent-teal);
}

@media (max-width: 380px) {
  .dice-btn { width: 108px; height: 108px; }
  .dice-btn svg { width: 52px; height: 52px; }
}
