/* Astra Luma — "night fox" theme: deep plum night sky, watercolor fox oranges, cream paper, silver stars. */
:root {
  --night: #2a162c;
  --night-2: #341c3a;
  --night-3: #4a2a4f;
  --plum-line: rgba(236, 212, 190, .14);
  --paper: #fbf1e4;
  --paper-2: #f4e3cf;
  --ink: #3a1f3c;
  --muted: #7d6272;
  --on-night: #f6e8d8;
  --on-night-muted: #c9b4bf;
  --fox: #c8693f;
  --fox-dark: #9c4a28;
  --fox-light: #e8a374;
  --cream: #ecd4be;
  --star: #d9d4e4;
  --moon: #f2cf8d;
  --sage: #7fa48f;
  --sage-dark: #587a67;
  --berry: #b5536b;
  --berry-dark: #8a3a50;
  --danger: #c2413d;
  --ok: #4f8a6d;
  --line: #ead6c2;
  --shadow: 0 6px 0 rgba(20, 8, 22, .25), 0 18px 40px rgba(10, 3, 12, .35);
  --soft: 0 5px 0 rgba(58, 31, 60, .10), 0 12px 28px rgba(58, 31, 60, .12);
  --radius: 28px;
  --paper-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .2 0 0 0 0 .25 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  --sky-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1400' height='1000' preserveAspectRatio='none'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0025 .004' numOctaves='5' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .3 0 0 0 0 .6 0 0 0 .28 0'/%3E%3C/filter%3E%3Crect width='1400' height='1000' filter='url(%23n)'/%3E%3C/svg%3E");
  font-family: 'Baloo Bhaijaan 2', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--night); }
body { min-height: 100vh; color: var(--on-night); font-size: 18px; line-height: 1.65; background: var(--night); position: relative; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    var(--sky-tex),
    radial-gradient(ellipse 60% 45% at 85% 8%, rgba(200, 105, 63, .16), transparent 70%),
    radial-gradient(ellipse 55% 50% at 8% 40%, rgba(120, 70, 140, .35), transparent 70%),
    radial-gradient(ellipse 70% 50% at 60% 100%, rgba(181, 83, 107, .18), transparent 70%),
    linear-gradient(180deg, var(--night-2) 0%, var(--night) 100%);
  background-size: cover, auto, auto, auto, auto;
  background-repeat: no-repeat;
}
header.top { position: relative; z-index: 2; }
a { color: var(--fox-light); }
img { max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; position: relative; z-index: 1; }

/* Twinkling four-point stars (added by app.js) */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sky i { position: absolute; width: var(--s); height: var(--s); background: var(--star); opacity: .7;
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  animation: twinkle var(--d) ease-in-out infinite; animation-delay: var(--w); filter: drop-shadow(0 0 4px rgba(217, 212, 228, .7)); }
.sky i.dot { clip-path: circle(50%); opacity: .45; }
@keyframes twinkle { 50% { opacity: .15; transform: scale(.6) rotate(20deg); } }
@media (prefers-reduced-motion: reduce) { .sky i, .moon-logo { animation: none !important; } }

/* Header */
.top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--on-night); font-weight: 800; font-size: 26px; letter-spacing: .3px; }
.brand img { width: 54px; height: 54px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(236, 212, 190, .25), 0 0 24px rgba(242, 207, 141, .25); }
.top nav { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Buttons */
.btn { appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: 999px; background: var(--fox); color: #fff8ef; box-shadow: 0 5px 0 var(--fox-dark); transition: transform .08s, box-shadow .08s, filter .15s; min-height: 48px; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--fox-dark); }
.btn.sun { background: var(--moon); color: #4a2a1c; box-shadow: 0 5px 0 #c99a4a; }
.btn.sun:active { box-shadow: 0 1px 0 #c99a4a; }
.btn.pink { background: var(--night-3); color: var(--on-night); box-shadow: 0 5px 0 #1d0e20, inset 0 0 0 2px rgba(236, 212, 190, .18); }
.btn.mint { background: var(--sage); box-shadow: 0 5px 0 var(--sage-dark); }
.btn.mint:active { box-shadow: 0 1px 0 var(--sage-dark); }
.btn.ghost { background: var(--paper); color: var(--ink); box-shadow: 0 5px 0 var(--paper-2); }
.btn.ghost:active { box-shadow: 0 1px 0 var(--paper-2); }
.top .btn.ghost { background: rgba(251, 241, 228, .08); color: var(--on-night); box-shadow: inset 0 0 0 2px rgba(236, 212, 190, .22); }
.btn.danger { background: var(--danger); box-shadow: 0 5px 0 #8e2a27; }
.btn.small { min-height: 40px; padding: 6px 16px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Paper cards */
.card { background: var(--paper) var(--paper-tex); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
.card a:not(.btn) { color: var(--fox-dark); }
.card .muted, .card .sub { color: var(--muted); }
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.pcard { position: relative; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--paper) var(--paper-tex); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .2s; }
.pcard:hover { transform: translateY(-5px) rotate(-.5deg); }
.pcard .art { height: 160px; display: grid; place-items: center; font-size: 72px; background-size: cover; background-position: center; position: relative; }
.pcard .art::after { content: ''; position: absolute; inset: auto 0 -1px 0; height: 26px; background: var(--paper);
  -webkit-mask: radial-gradient(18px 14px at 50% 0, transparent 98%, #000) 0 0 / 36px 26px repeat-x; mask: radial-gradient(18px 14px at 50% 0, transparent 98%, #000) 0 0 / 36px 26px repeat-x; }
.pcard .body { padding: 10px 18px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard h3 { margin: 0; font-size: 22px; line-height: 1.3; }
.pcard p { margin: 0; color: var(--muted); font-size: 15px; }
.pcard .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: #f6dfd0; color: var(--fox-dark); }
.chip.sun { background: #f8e6c2; color: #8a5a17; }
.chip.mint { background: #dde9e1; color: #3f6450; }
.chip.lock { background: #eadfe3; color: #6d5563; }
.badge-owned { position: absolute; inset-inline-end: 12px; top: 12px; z-index: 1; background: var(--sage); color: #fff; border-radius: 999px; padding: 2px 12px; font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 var(--sage-dark); }

/* Hero */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: center; padding: 20px 0 46px; }
.hero h1 { font-size: clamp(36px, 6vw, 60px); line-height: 1.15; margin: 0 0 14px; }
.hero h1 .hl { color: var(--fox-light); background: linear-gradient(90deg, var(--moon), var(--fox-light)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { font-size: 20px; color: var(--on-night-muted); margin: 0 0 24px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; }
.moon-logo { width: 100%; max-width: 420px; margin: 0 auto; aspect-ratio: 1; border-radius: 50%; overflow: hidden; position: relative;
  box-shadow: 0 0 0 10px rgba(236, 212, 190, .06), 0 0 0 22px rgba(236, 212, 190, .035), 0 0 90px rgba(242, 207, 141, .22); animation: float 7s ease-in-out infinite; }
.moon-logo img { width: 100%; height: 100%; display: block; }
@keyframes float { 50% { transform: translateY(-10px); } }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 10px 0 46px; }
.step { text-align: center; }
.step h3 { margin: 6px 0 2px; }
.step p { margin: 0; }
.step .n { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 6px; font-size: 28px; font-weight: 800; color: #fff8ef; box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.section-title { font-size: 32px; margin: 30px 0 18px; display: flex; align-items: center; gap: 10px; color: var(--on-night); }
.section-title::after { content: ''; flex: 1; height: 2px; background: linear-gradient(90deg, rgba(236, 212, 190, .35), transparent); margin-inline-start: 8px; }
[dir=rtl] .section-title::after { background: linear-gradient(270deg, rgba(236, 212, 190, .35), transparent); }

/* Forms */
.auth { max-width: 480px; margin: 26px auto 60px; }
.auth h1 { margin: 0 0 4px; text-align: center; font-size: 32px; }
.auth .sub { text-align: center; margin: 0 0 20px; }
.auth-art { width: 96px; height: 96px; border-radius: 50%; display: block; margin: -70px auto 8px; box-shadow: 0 0 0 6px var(--paper), 0 10px 24px rgba(0,0,0,.3); }
.auth .emoji { text-align: center; font-size: 52px; line-height: 1.2; }
label { display: block; font-weight: 700; margin: 14px 0 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); padding: 12px 16px; border-radius: 18px; border: 3px solid var(--line); background: #fffaf3; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--fox-light); box-shadow: 0 0 0 4px rgba(232, 163, 116, .25); }
input.code { direction: ltr; text-align: center; font-family: ui-monospace, Consolas, monospace; letter-spacing: 2px; font-size: 22px; text-transform: uppercase; background: #fbf0dc; border-color: #ecc98a; }
.form-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { margin-top: 14px; padding: 12px 16px; border-radius: 16px; font-weight: 700; display: none; }
.msg.show { display: block; }
.msg.err { background: #f8dcd8; color: #8e2a27; }
.msg.ok { background: #dde9e1; color: #34573f; }
.center { text-align: center; }
.muted { color: var(--on-night-muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 12px; }
.li { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: #fffaf3; border-radius: 22px; box-shadow: var(--soft); text-decoration: none; color: var(--ink); border: 2px solid var(--line); transition: transform .15s; }
a.li:hover { transform: translateX(4px); }
[dir=rtl] a.li:hover { transform: translateX(-4px); }
.li .ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; flex: none; }
.li .t { font-weight: 800; font-size: 20px; }
.li .s { color: var(--muted); font-size: 15px; }
.li .go { margin-inline-start: auto; font-size: 26px; }
.li .btn.go { font-size: 15px; flex: none; }
.li > div { min-width: 0; }

/* Viewer (slides & games) */
.stage-page { min-height: 100vh; color: var(--on-night); }
.stage-bar { display: flex; gap: 10px; align-items: center; padding: 10px 16px; flex-wrap: wrap; position: relative; z-index: 1; }
.stage-bar .title { font-weight: 800; font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stageWrap { position: relative; z-index: 1; }
.stage { position: relative; margin: 0 auto; width: fit-content; }
.stage canvas { max-width: calc(100vw - 32px); max-height: calc(100vh - 150px); width: auto; height: auto; display: block; border-radius: 18px; background: #fff; box-shadow: 0 0 0 6px rgba(236, 212, 190, .12), 0 20px 50px rgba(0,0,0,.5); }
.stage .nav { position: absolute; top: 0; bottom: 0; width: 22%; cursor: pointer; }
.stage .nav.prev { inset-inline-start: 0; }
.stage .nav.next { inset-inline-end: 0; }
.dots { display: flex; justify-content: center; gap: 12px; align-items: center; padding: 14px; font-weight: 800; }
.stage-page .btn.ghost { background: rgba(251, 241, 228, .08); color: var(--on-night); box-shadow: inset 0 0 0 2px rgba(236, 212, 190, .22); }
#stageWrap:fullscreen { background: var(--night); display: flex; flex-direction: column; justify-content: center; }
#stageWrap:fullscreen .stage canvas { max-height: calc(100vh - 90px); }
#frameWrap { position: relative; z-index: 1; }
.gameframe { width: 100%; height: calc(100vh - 70px); border: 0; display: block; background: #fff; }
.protect, .protect * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }
@media print { body * { display: none !important; } body::after { content: 'Printing is disabled · الطباعة غير متاحة'; display: block !important; } }

/* Tables (admin) */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; }
.mono { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 20px; }
.tabs .btn { background: var(--night-3); box-shadow: 0 5px 0 #1d0e20; color: var(--on-night); }
.tabs .btn.on { background: var(--fox); color: #fff8ef; box-shadow: 0 5px 0 var(--fox-dark); }
.hidden { display: none !important; }
.overlay { position: fixed; inset: 0; background: rgba(20, 8, 22, .7); display: grid; place-items: center; padding: 16px; z-index: 50; }
.overlay .card { width: min(640px, 100%); max-height: 90vh; overflow: auto; }
.progress { height: 14px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--fox), var(--moon)); transition: width .2s; }
footer { text-align: center; color: var(--on-night-muted); padding: 34px 16px 40px; font-size: 15px; position: relative; z-index: 1; }
footer img { width: 34px; height: 34px; border-radius: 50%; vertical-align: middle; margin-inline-end: 6px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero .cta { justify-content: center; }
  .moon-logo { max-width: 260px; grid-row: 1; }
  .steps { grid-template-columns: 1fr; }
  body { font-size: 17px; }
  .brand { font-size: 22px; }
  .brand img { width: 46px; height: 46px; }
  .card { padding: 20px; }
}
