:root {
    color-scheme: light;
    --page-bg: #f5f8f2;
    --ink: #263b46;
    --muted: #7b8b91;
    --line: #e3ebe8;
    --blue: #24a9c7;
    --blue-soft: #e5f7fb;
    --green: #70bd55;
    --orange: #ffb83f;
    --orange-ink: #68420a;
    --panel: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    direction: rtl;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    background:
        radial-gradient(ellipse at 50% 44%, rgba(255,255,255,.95) 0%, rgba(255,255,255,.65) 34%, transparent 72%),
        #f4f7ef;
    color: var(--ink);
    font-family: "Vazirmatn", Tahoma, sans-serif;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible {
    outline: 3px solid rgba(36, 169, 199, .3);
    outline-offset: 3px;
}

.page {
    position: relative;
    display: grid;
    min-height: 100vh;
    min-height: 100svh;
    place-items: center;
    isolation: isolate;
    padding: clamp(12px, 3.5vw, 48px);
}

/* Keep the terrain artwork as-is; only the surrounding interface is restyled. */
.scene {
    position: relative;
    z-index: 1;
    width: min(100%, 650px);
    margin-inline: auto;
    overflow: visible;
    perspective: 1200px;
}
.scene__glow {
    position: absolute;
    z-index: -1;
    inset: 20% 12% 5%;
    border-radius: 50%;
    background: rgba(117, 151, 49, .12);
    filter: blur(68px);
    transform: translateY(7%);
    pointer-events: none;
}
#grassTerrain {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    filter: drop-shadow(0 22px 25px rgba(94, 119, 39, .08));
    transform-origin: 50% 58%;
}
.ambient {
    position: absolute;
    z-index: -1;
    width: clamp(180px, 26vw, 360px);
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(65px);
    opacity: .22;
    pointer-events: none;
}
.ambient--one { top: 8%; left: 4%; background: #d9f1c9; }
.ambient--two { right: 2%; bottom: 2%; background: #c9edf0; opacity: .2; }

/* User-provided trophy art with a code-rendered level number and live XP bar. */
.level-card {
    position: absolute;
    z-index: 5;
    top: max(18px, env(safe-area-inset-top));
    left: max(18px, env(safe-area-inset-left));
    /* 10% smaller than the previous 244.92px version. */
    width: min(220.43px, calc(100vw - 36px));
    aspect-ratio: 470 / 145;
    overflow: visible;
    direction: ltr;
    pointer-events: none;
}
.level-card__art {
    position: absolute;
    z-index: 3;
    top: 0;
    left: 0;
    display: block;
    width: auto;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}
.level-number {
    position: absolute;
    z-index: 4;
    left: 29%;
    top: 63%;
    display: grid;
    min-width: 1.55em;
    min-height: 1.2em;
    place-items: center;
    transform: translate(-50%, -50%);
    color: #78370f;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    font-size: clamp(16px, 1.65vw, 21px);
    font-weight: 900;
    line-height: 1;
    text-align: center;
    direction: ltr;
    font-variant-numeric: lining-nums;
    white-space: nowrap;
    user-select: none;
}
.xp-track {
    position: absolute;
    z-index: 1;
    /* Slimmer XP bar, tucked slightly beneath the shield. */
    top: 43.17%;
    left: 35.5%;
    display: block;
    width: 64.5%;
    height: 38.67%;
    overflow: hidden;
    border: 2px solid #f6dfc3;
    /* Flat left edge tucks under the shield; only the exposed right end is rounded. */
    border-radius: 0 999px 999px 0;
    background: linear-gradient(180deg, #fffaf2 0%, #ffefd9 100%);
    direction: ltr;
}
.xp-track__inner {
    position: absolute;
    inset: 3px;
    overflow: hidden;
    border-radius: 0 999px 999px 0;
    background: linear-gradient(180deg, #d8ccdf 0%, #eee6f0 100%);
}
.xp-track__fill {
    position: relative;
    display: block;
    width: 40%;
    height: 100%;
    border-radius: 0 999px 999px 0;
    background: linear-gradient(100deg, #c33cf2 0%, #a333f1 48%, #7427e7 100%);
    transition: width .45s cubic-bezier(.2,.75,.25,1);
}
.xp-track__fill::after {
    position: absolute;
    top: 2px;
    right: 5px;
    left: 5px;
    height: 2px;
    content: "";
    border-radius: 99px;
    background: rgba(255,255,255,.24);
}

/* Flat, colorful bottom navigation. */
.bottom-actions {
    position: absolute;
    z-index: 6;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    left: max(22px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    pointer-events: none;
}
/* Professional, flat bottom actions: Add on the right, Today's tasks on the left. */
.bottom-actions { direction: rtl; }
.bottom-actions button { pointer-events: auto; cursor: pointer; }
.today-button, .add-button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 12px;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
    font-size: 13px;
    font-weight: 700;
    box-shadow: none;
}
.today-button {
    padding: 0 15px;
    border-color: #dce7e5;
    color: #314b55;
    background: #ffffff;
}
.today-button:hover { background: #f7faf9; border-color: #cbdad7; }
.today-button:active, .add-button:active { transform: none; }
.today-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.today-button__count {
    display: inline-grid;
    min-width: 21px;
    height: 21px;
    padding-inline: 5px;
    place-items: center;
    border-radius: 6px;
    color: #167d99;
    background: #e5f7fb;
    font-size: 11px;
    font-weight: 800;
}
.add-button {
    min-width: 108px;
    padding: 0 15px;
    border-color: #24a9c7;
    color: #ffffff;
    background: #24a9c7;
}
.add-button:hover { background: #1d98b4; border-color: #1d98b4; }
.add-button__plus {
    display: grid;
    width: 23px;
    height: 23px;
    place-items: center;
    border-radius: 6px;
    color: #ffffff;
    background: rgba(255,255,255,.16);
    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

/* Flat, lightweight dialogs. */
.dialog-overlay {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    align-items: end;
    justify-items: center;
    padding: 20px;
    background: rgba(28, 50, 60, .32);
}
.dialog-overlay.is-open { animation: overlay-in .16s ease both; }
.dialog-sheet {
    width: min(100%, 460px);
    max-height: min(76vh, 680px);
    overflow: auto;
    padding: 22px;
    border: 1px solid #e2ebe9;
    border-radius: 21px;
    background: #fff;
    animation: sheet-in .2s ease both;
}
.dialog-sheet--add { width: min(100%, 420px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-eyebrow { color: #1b9bb5; font-size: 11px; font-weight: 700; }
.dialog-header h2 { margin: 5px 0 0; color: #263f4b; font-size: 20px; font-weight: 800; }
.icon-button {
    display: grid;
    width: 35px;
    height: 35px;
    flex: 0 0 auto;
    place-items: center;
    border: 0;
    border-radius: 10px;
    color: #5c7279;
    background: #eff5f4;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}
.icon-button:hover { color: #294c58; background: #e5eeee; }
.today-list-wrap { min-height: 88px; }
.empty-state { margin: 18px 0; color: #829398; text-align: center; font-size: 13px; }
.today-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.today-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid #e8efee;
    border-radius: 12px;
    background: #f8fbfa;
}
.today-item__check { width: 18px; height: 18px; flex: 0 0 auto; accent-color: #36ad80; cursor: pointer; }
.today-item__main { display: grid; min-width: 0; flex: 1; gap: 3px; }
.today-item__title { overflow-wrap: anywhere; color: #304b55; font-size: 13px; }
.today-item.is-done .today-item__title { color: #a1b0b2; text-decoration: line-through; }
.today-item__kind { color: #82999d; font-size: 10px; }
.today-item__delete {
    width: 29px;
    height: 29px;
    border: 0;
    border-radius: 8px;
    color: #a0abad;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
}
.today-item__delete:hover { color: #d65d62; background: #fff0ef; }
.sheet-add-button {
    width: 100%;
    min-height: 45px;
    margin-top: 17px;
    border: 1px solid #bce6ef;
    border-radius: 11px;
    color: #167d99;
    background: #e8f8fb;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}
.sheet-add-button:hover { background: #d9f2f8; }
.item-kind-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 11px; background: #eff5f4; }
.item-kind {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #7c9296;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}
.item-kind.is-active { border-color: #bce6ef; color: #147d98; background: #fff; }
#addItemForm { display: grid; margin-top: 19px; }
.field-label { margin-bottom: 8px; color: #49636b; font-size: 12px; font-weight: 700; }
.item-input {
    width: 100%;
    min-height: 48px;
    padding: 0 13px;
    border: 1px solid #dce8e6;
    border-radius: 10px;
    outline: 0;
    color: #29444e;
    background: #fff;
    font-size: 13px;
    direction: rtl;
}
.item-input::placeholder { color: #a6b5b7; }
.item-input:focus { border-color: #39aec5; }
.form-hint { min-height: 17px; margin: 8px 0 16px; color: #82979b; font-size: 10px; }
.submit-button {
    min-height: 47px;
    border: 0;
    border-radius: 11px;
    color: #fff;
    background: #24a9c7;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}
.submit-button:hover { background: #168faa; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 600px) {
    .page { padding: 8px; }
    .scene__glow { inset: 24% 9% 7%; filter: blur(42px); }
    .level-card { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); width: min(220.43px, calc(100vw - 24px)); }
    .level-number { font-size: 18px; }
    .bottom-actions { right: max(13px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); left: max(13px, env(safe-area-inset-left)); }
    .today-button, .add-button { min-height: 44px; border-radius: 11px; gap: 7px; }
    .today-button { padding-inline: 11px; font-size: 12px; }
    .add-button { min-width: 96px; padding-inline: 11px; font-size: 12px; }
    .dialog-overlay { align-items: end; padding: 10px; }
    .dialog-sheet { padding: 19px; border-radius: 18px; }
}

@media (max-width: 360px) {
    .level-card { width: min(220.43px, calc(100vw - 24px)); }
    .today-button { padding-inline: 9px; gap: 6px; font-size: 11px; }
    .add-button { min-width: 90px; padding-inline: 8px; }
    .today-button svg { width: 17px; height: 17px; }
}

@media (prefers-reduced-motion: no-preference) {
    #grassTerrain {
        animation: terrain-enter 1.05s cubic-bezier(.2, .75, .25, 1) both,
                   terrain-float 7s ease-in-out 1.05s infinite;
    }
    @keyframes terrain-enter {
        from { opacity: 0; transform: translateY(22px) scale(.965); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }
    @keyframes terrain-float {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-5px); }
    }
}


/* Target phone login and account controls */
.auth-page {
    position: relative;
    display: grid;
    min-height: 100vh;
    min-height: 100svh;
    place-items: center;
    overflow: hidden;
    isolation: isolate;
    padding: 24px;
}
.auth-orb { position: absolute; z-index: -1; width: min(46vw, 420px); aspect-ratio: 1; border-radius: 50%; filter: blur(70px); opacity: .4; pointer-events: none; }
.auth-orb--one { top: -15%; right: -8%; background: #d7f1de; }
.auth-orb--two { bottom: -20%; left: -8%; background: #cfeef3; }
.auth-card {
    width: min(100%, 410px);
    padding: clamp(27px, 6vw, 42px);
    border: 1px solid #e1ebe7;
    border-radius: 22px;
    background: rgba(255,255,255,.92);
    text-align: center;
}
.auth-brand-mark { display: grid; width: 58px; height: 58px; margin: 0 auto 11px; place-items: center; border-radius: 17px; color: #168da8; background: #e5f7fb; }
.auth-brand-mark svg { width: 36px; height: 36px; }
.auth-brand-name { color: #203d49; font-size: 24px; font-weight: 900; letter-spacing: -.5px; }
.auth-card h1 { margin: 24px 0 7px; color: #263b46; font-size: 19px; font-weight: 800; }
.auth-subtitle { margin: 0 0 27px; color: #7b8b91; font-size: 12px; line-height: 1.9; }
.auth-form { display: grid; gap: 10px; text-align: right; }
.auth-label { color: #405d68; font-size: 12px; font-weight: 800; }
.auth-phone-field { display: flex; min-height: 52px; align-items: center; gap: 12px; padding: 0 13px; border: 1px solid #dce8e6; border-radius: 11px; background: #fff; }
.auth-phone-field:focus-within { border-color: #24a9c7; }
.auth-phone-prefix { padding-inline-end: 12px; border-inline-end: 1px solid #e5edeb; color: #71858b; font-family: Arial,sans-serif; font-size: 13px; font-weight: 700; }
.auth-phone-field input { width: 100%; min-width: 0; border: 0; outline: 0; color: #263b46; background: transparent; font-family: Arial,sans-serif; font-size: 16px; letter-spacing: .7px; }
.auth-phone-field input::placeholder { color: #aab8b9; letter-spacing: .5px; }
.auth-submit { min-height: 49px; margin-top: 7px; border: 0; border-radius: 11px; color: #fff; background: #24a9c7; cursor: pointer; font-size: 13px; font-weight: 800; transition: background .15s ease, opacity .15s ease; }
.auth-submit:hover { background: #168faa; }
.auth-submit:disabled { cursor: wait; opacity: .65; }
.auth-edit-phone { justify-self: start; margin: -3px 0 5px; padding: 5px 0; border: 0; color: #188aa3; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.auth-otp-caption { margin: 0 0 10px; color: #72868b; font-size: 12px; line-height: 1.9; }
.auth-otp-caption strong { color: #314d57; font-family: Arial,sans-serif; letter-spacing: .3px; }
.auth-otp-input { width: 100%; min-height: 55px; border: 1px solid #dce8e6; border-radius: 11px; outline: 0; color: #263b46; background: #fff; font-family: Arial,sans-serif; font-size: 22px; font-weight: 800; letter-spacing: 9px; text-align: center; }
.auth-otp-input:focus { border-color: #24a9c7; }
.auth-resend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; color: #8b9a9d; font-size: 10px; }
.auth-resend-row button { padding: 5px 0; border: 0; color: #168aa5; background: transparent; cursor: pointer; font-family: inherit; font-size: 10px; font-weight: 800; }
.auth-resend-row button:disabled { color: #aab7b8; cursor: not-allowed; }
.auth-message { min-height: 19px; margin: 13px 0 0; color: #778c91; font-size: 11px; line-height: 1.8; }
.auth-message.is-error { color: #c34f58; }
.auth-message.is-success { color: #25845e; }
.auth-footnote { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid #edf1ef; color: #94a2a3; font-size: 10px; line-height: 1.8; }
.account-logout { position: absolute; z-index: 7; top: max(22px, env(safe-area-inset-top)); right: max(22px, env(safe-area-inset-right)); min-height: 34px; padding: 0 12px; border: 1px solid #dce8e6; border-radius: 9px; color: #62777d; background: #fff; cursor: pointer; font-family: inherit; font-size: 11px; font-weight: 700; }
.account-logout:hover { border-color: #c6dddc; color: #304c56; background: #f8fbfa; }
@media (max-width: 600px) {
    .auth-page { padding: 17px; }
    .auth-card { border-radius: 18px; }
    .account-logout { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
}
