/* قاب طلایی — تم تیرهٔ کهربایی */
@font-face {
    font-family: 'Vazirmatn';
    src: url('./fonts/vazirmatn-arabic-wght-normal.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('./fonts/vazirmatn-latin-wght-normal.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+2600-27BF;
}

:root {
    --bg: #0b0d12;
    --panel: #151922;
    --panel2: #1d2330;
    --line: #2a3242;
    --text: #f3f1ea;
    --muted: #9aa3b5;
    --gold: #fbbf24;
    --gold2: #f59e0b;
    --ok: #4ade80;
    --bad: #f87171;
    --r: 16px;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
    background:
        radial-gradient(120% 60% at 50% -10%, rgba(251, 191, 36, .10), transparent 60%),
        radial-gradient(80% 50% at 100% 100%, rgba(120, 60, 200, .08), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}
body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
a { color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.app { min-height: 100%; max-width: 560px; margin: 0 auto; }
.loading { text-align: center; padding: 40vh 16px 0; color: var(--muted); }

.screen { padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.bar { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; min-height: 48px; }
.bar h1 { font-size: 18px; margin: 0; text-align: center; font-weight: 700; }
.bar-stars { color: var(--gold); font-weight: 700; font-size: 14px; white-space: nowrap; }
h2 { font-size: 18px; margin: 0 0 8px; }
h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
h3 { font-size: 15px; margin: 4px 0 0; color: var(--muted); font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; }
.center { text-align: center; padding: 32px 0; }

.card {
    background: linear-gradient(180deg, rgba(29, 35, 48, .85), rgba(21, 25, 34, .92)); border: 1px solid var(--line);
    border-radius: var(--r); padding: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); backdrop-filter: blur(6px);
}
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 50px; padding: 10px 18px; border-radius: 14px; border: 1px solid var(--line);
    background: var(--panel2); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
    transition: transform .12s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary {
    background: linear-gradient(180deg, #fcd34d, var(--gold) 40%, var(--gold2)); color: #1a1205; border-color: transparent; font-weight: 800;
    box-shadow: 0 8px 24px rgba(245, 158, 11, .28), 0 1px 0 rgba(255, 255, 255, .5) inset;
}
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.icon-btn {
    width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; line-height: 1;
}
.icon-btn.back { font-size: 0; }
.icon-btn.back::before { content: '→'; font-size: 22px; }
.icon-btn.on { border-color: var(--gold); color: var(--gold); }
.row, .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link { text-align: center; padding: 8px; font-size: 14px; }

/* منو */
.hero {
    position: relative; overflow: hidden; text-align: center; padding: 120px 20px 22px; margin: -12px -16px 0;
    border-radius: 0 0 28px 28px; isolation: isolate; min-height: 290px;
    background: linear-gradient(160deg, #3a1d0a, #120a05);
}
.hero::after {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(180deg, rgba(11, 13, 18, .05) 0%, rgba(11, 13, 18, .35) 45%, rgba(11, 13, 18, .96) 100%);
}
.hero .thumb-cv { z-index: -2; }
.hero h1 {
    font-size: 40px; margin: 10px 0 2px; font-weight: 900; letter-spacing: -0.5px;
    background: linear-gradient(180deg, #fff3c4, #fbbf24 55%, #d97706); -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 12px rgba(0, 0, 0, .6));
}
.hero p { color: #e7e2d6; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
.thumb-cv { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .6s ease, transform 6s ease-out; transform: scale(1.06); }
.thumb-cv.in { opacity: 1; transform: scale(1); }
.thumb-cv.dim { filter: grayscale(.85) brightness(.45); }
.logo { width: 84px; height: 64px; margin: 0 auto; border: 3px solid var(--gold); border-radius: 10px; position: relative; }
.logo::before, .logo::after { content: ''; position: absolute; background: rgba(251, 191, 36, .45); }
.logo::before { left: 33.3%; right: 33.3%; top: 0; bottom: 0; border-inline: 1px solid rgba(251, 191, 36, .6); background: none; }
.logo::after { top: 33.3%; bottom: 33.3%; left: 0; right: 0; border-block: 1px solid rgba(251, 191, 36, .6); background: none; }
.logo span { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); right: 33.3%; top: 33.3%; transform: translate(50%, -50%); box-shadow: 0 0 14px var(--gold); }
.menu-btns { display: flex; flex-direction: column; gap: 10px; }
.status .big { font-size: 22px; font-weight: 800; color: var(--gold); }
.status b { font-size: 13px; color: var(--muted); font-weight: 600; }
.status.practice { border-color: rgba(251, 191, 36, .4); }
.status.practice b { color: var(--gold); font-size: 15px; }
.meter { height: 8px; background: var(--panel2); border-radius: 8px; overflow: hidden; margin: 10px 0; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.credit { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* مرحله‌ها */
.chapter .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.lvl {
    position: relative; min-height: 96px; padding: 12px; border-radius: 16px; border: 1px solid var(--line);
    background: linear-gradient(160deg, var(--panel2), var(--panel)); text-align: start; cursor: pointer;
    display: flex; flex-direction: column; justify-content: space-between; gap: 4px; overflow: hidden; isolation: isolate;
    transition: transform .15s ease, border-color .2s;
}
.lvl:active { transform: scale(.97); }
.lvl.has-thumb { min-height: 150px; border-color: rgba(251, 191, 36, .25); }
.lvl.has-thumb::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(5, 6, 9, .92)); }
.lvl .thumb-cv { z-index: -2; }
.lvl-foot { display: flex; flex-direction: column; gap: 2px; }
.lvl.has-thumb .t { text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
.lvl .n { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #1a1205; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.lvl .t { font-weight: 700; }
.lvl.locked:not(.has-thumb) { opacity: .5; }
.lvl.locked .t { color: #a8a29e; }
.lvl .lock { position: absolute; left: 12px; top: 12px; }
.stars { letter-spacing: 2px; font-size: 18px; }
.stars .on { color: var(--gold); }
.stars .off { color: #3b4252; }

/* پیش از مرحله */
.intro-art { position: relative; overflow: hidden; isolation: isolate; height: 200px; border-radius: var(--r); display: flex; align-items: flex-end; padding: 14px 16px; border: 1px solid rgba(251, 191, 36, .25); }
.intro-art::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, transparent 40%, rgba(5, 6, 9, .9)); }
.intro-art .thumb-cv { z-index: -2; }
.intro-art h2 { margin: 0; font-size: 24px; font-weight: 900; text-shadow: 0 2px 10px rgba(0, 0, 0, .9); }
.goals { margin: 0 0 10px; padding-inline-start: 20px; }
.goals li { margin-bottom: 4px; }
.tip { background: rgba(251, 191, 36, .08); border: 1px dashed rgba(251, 191, 36, .4); padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.lenses { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lens { text-align: start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; display: flex; flex-direction: column; }
.lens small { color: var(--muted); font-size: 12px; }
.lens.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.lens.locked { opacity: .45; }

/* آموزش */
.tut { text-align: center; }
.tut-icon { width: 120px; height: 90px; margin: 8px auto 16px; border: 2px solid var(--gold); border-radius: 10px; position: relative; overflow: hidden; }
.tut-icon span { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, .85); top: 34px; left: 49px; }
.tut-icon.drag span { animation: drag 1.8s ease-in-out infinite; }
.tut-icon.zoom span { animation: pinch 1.8s ease-in-out infinite; }
.tut-icon.shutter span { background: var(--gold); top: 25px; left: 75px; width: 14px; height: 14px; box-shadow: 0 0 0 6px rgba(251, 191, 36, .25); }
@keyframes drag { 0%, 100% { transform: translateX(-30px); } 50% { transform: translateX(30px); } }
@keyframes pinch { 0%, 100% { transform: scale(.7); } 50% { transform: scale(1.6); } }
.dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--gold); }

/* بازی */
.screen.play { padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); gap: 6px; height: 100dvh; min-height: 100vh; }
@supports (height: 100dvh) { .screen.play { min-height: 0; } }
.screen.play .bar { padding: 0 12px; }
.vf { flex: 1; position: relative; min-height: 220px; }
.vf-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: grab; }
.vf-canvas:active { cursor: grabbing; }
.timebar { height: 4px; margin: 0 12px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.timebar span { display: block; height: 100%; width: 100%; background: var(--gold); transition: width .2s linear; }
.timebar.low span { background: var(--bad); }
.controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 6px 12px 0; }
.zoom { display: flex; align-items: center; gap: 6px; }
.zoom-lbl { min-width: 40px; text-align: center; font-size: 13px; color: var(--muted); }
.rot-wrap { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); text-align: center; }
.rot { width: 100%; accent-color: var(--gold); height: 32px; }
.shoot { display: flex; align-items: center; gap: 8px; }
.clock { min-width: 26px; text-align: center; font-weight: 700; color: var(--muted); font-size: 14px; }
.shutter {
    width: 68px; height: 68px; border-radius: 50%; border: 4px solid #e5e7eb; background: transparent; padding: 4px; cursor: pointer;
}
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #6b7280; transition: background .3s, transform .1s; }
.shutter.ready span { background: #f9fafb; }
.shutter:active span { transform: scale(.9); }
.shutter:disabled { cursor: not-allowed; opacity: .7; }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

/* نتیجه */
.photo-wrap {
    align-self: center; max-width: 100%; padding: 10px 10px 38px; background: #f6f2e8; border-radius: 4px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 2px 0 rgba(255, 255, 255, .5) inset; transform: rotate(-1.2deg);
    animation: print .7s cubic-bezier(.2, .9, .3, 1.1) both; position: relative;
}
.photo-wrap::after { content: 'دیدگاه · قاب طلایی'; position: absolute; bottom: 9px; left: 0; right: 0; text-align: center; color: #6b5d45; font-size: 13px; font-weight: 600; }
.photo-wrap.gold { box-shadow: 0 0 0 3px var(--gold), 0 0 40px rgba(251, 191, 36, .45), 0 18px 50px rgba(0, 0, 0, .6); }
.photo-wrap .photo { animation: develop 1.6s ease-out both; }
@keyframes print { from { transform: translateY(40px) rotate(4deg) scale(.9); opacity: 0; } }
@keyframes develop { from { filter: brightness(2.2) sepia(.6) contrast(.6); } to { filter: none; } }
.photo { display: block; width: 100%; height: auto; max-height: 55vh; object-fit: contain; }
.photo.small { max-width: 260px; margin: 10px auto 0; border-radius: 8px; }
.score { text-align: center; }
.score .stars { font-size: 34px; }
.reveal .on { display: inline-block; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.reveal .on:nth-child(2) { animation-delay: .15s; }
.reveal .on:nth-child(3) { animation-delay: .3s; }
@keyframes pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.total { font-size: 44px; font-weight: 900; line-height: 1.2; }
.total small { font-size: 16px; color: var(--muted); font-weight: 400; }
.breakdown { list-style: none; padding: 0; margin: 12px 0; text-align: start; }
.breakdown li { display: grid; grid-template-columns: 96px 1fr 52px; gap: 8px; align-items: center; font-size: 14px; padding: 3px 0; }
.breakdown .meterbar { height: 8px; background: var(--panel2); border-radius: 8px; overflow: hidden; display: block; }
.breakdown .meterbar i { display: block; height: 100%; background: var(--gold); }
.breakdown b { text-align: end; }
.breakdown .pen { color: var(--bad); }
.server { font-size: 14px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line); }
.server.ok { color: var(--ok); }
.warn { color: var(--bad); }
.ideal summary { cursor: pointer; font-weight: 600; }
.actions { margin-top: 2px; }
.showcase { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); border-color: rgba(251, 191, 36, .3); }
.showcase small { color: var(--gold); }
.showcase .go { color: var(--gold); font-size: 14px; margin-top: 4px; }

/* روزانه و آلبوم */
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.board .rank { color: var(--gold); font-weight: 800; }
.board li.me { background: rgba(251,191,36,.12); border-radius: 10px; border-bottom-color: transparent; }
.board li.me b { color: var(--gold); }
.my-rank { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--gold); color: var(--gold); font-weight: 700; }
.rank-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.rank-card b { color: var(--gold); font-size: 20px; margin-inline-end: auto; }
.album-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.album-grid figure { margin: 0; background: var(--panel); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.album-grid img { display: block; width: 100%; height: auto; }
.album-grid figcaption { padding: 6px 10px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.album-grid .stars { font-size: 13px; }

/* تنظیمات */
.toggle { display: flex; justify-content: space-between; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--gold); }

.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    background: #f3f1ea; color: #111; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5); z-index: 10; animation: toast .25s ease-out;
}
@keyframes toast { from { transform: translate(-50%, 20px); opacity: 0; } }

@media (min-width: 900px) {
    .app { max-width: 960px; }
    .screen:not(.play) { max-width: 560px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* فرصت دوباره */
.status .row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.status .row > div { min-width: 0; }
.retry-dots { display: flex; gap: 6px; align-items: center; min-height: 30px; }
.retry-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); }
.retry-dots span.on { background: var(--gold); box-shadow: 0 0 10px rgba(251, 191, 36, .55); }
.retry-dots span.off { opacity: .45; }
.retry-note { margin: 14px 0 8px; padding: 10px 12px; border-radius: 12px; background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .35); font-size: 14px; line-height: 1.8; }
.retry-note.out { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .4); }
.btn.wide + .btn.wide { margin-top: 8px; }
/* جایزهٔ چالش روزانه */
.prize-card { display: flex; gap: 12px; align-items: center; background: linear-gradient(100deg, rgba(251, 191, 36, .2), rgba(251, 191, 36, .05)); border-color: rgba(251, 191, 36, .55); }
.prize-card[hidden] { display: none; }
.prize-card .ic { font-size: 34px; line-height: 1; }
.prize-card b { color: var(--gold); }
.prize-card p { margin: 4px 0 0; font-size: 14px; line-height: 1.8; }
