:root {
    color-scheme: dark;
    --bg: #050816;
    --bg-2: #081122;
    --panel: rgba(8, 14, 29, 0.82);
    --panel-strong: rgba(8, 15, 31, 0.96);
    --line: rgba(145, 178, 255, 0.14);
    --line-strong: rgba(145, 178, 255, 0.24);
    --text: #edf4ff;
    --muted: #8ea0c3;
    --cyan: #3dd6ff;
    --blue: #5b8cff;
    --green: #7dffb2;
    --amber: #ffb949;
    --red: #ff6b7d;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
    --radius: 22px;
    --radius-sm: 14px;
    --max-width: 480px;
    --footer-height: 82px;
}

* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    min-height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
    background:
        linear-gradient(180deg, rgba(5, 8, 22, 0.92), rgba(5, 8, 22, 0.98)),
        linear-gradient(135deg, rgba(91, 140, 255, 0.1), rgba(61, 214, 255, 0.04));
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    direction: rtl;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    background:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 85%);
    opacity: 0.7;
}

body::after {
    background:
        linear-gradient(90deg, transparent 0, rgba(61, 214, 255, 0.02) 50%, transparent 100%);
    background-size: 100% 4px;
    mix-blend-mode: screen;
    opacity: 0.38;
    animation: scanline 10s linear infinite;
}

@keyframes scanline {
    from { transform: translateY(-20px); }
    to { transform: translateY(20px); }
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.desktop-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(5, 8, 22, 0.98), rgba(5, 8, 22, 0.98));
}

.gate-panel {
    width: min(92vw, 420px);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel-strong);
    box-shadow: var(--shadow);
    text-align: center;
}

.gate-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    margin-bottom: 18px;
    border-radius: 999px;
    background: rgba(61, 214, 255, 0.12);
    color: var(--cyan);
    border: 1px solid rgba(61, 214, 255, 0.18);
    font-weight: 700;
    letter-spacing: 0;
}

.gate-panel h1 {
    margin: 0 0 10px;
    font-size: 22px;
    line-height: 1.35;
}

.gate-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.8;
}

.boot-screen {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top, rgba(91, 140, 255, 0.18), transparent 34%),
        linear-gradient(180deg, #040714 0%, #050816 100%);
}

.boot-shell {
    width: min(100%, 420px);
    padding: 24px 22px 22px;
    border-radius: 28px;
    border: 1px solid rgba(145, 178, 255, 0.16);
    background: rgba(8, 14, 29, 0.9);
    box-shadow: var(--shadow);
    text-align: center;
}

.boot-mark {
    width: 92px;
    height: 92px;
    margin: 4px auto 18px;
    position: relative;
    border-radius: 24px;
    border: 1px solid rgba(61, 214, 255, 0.28);
    background:
        linear-gradient(145deg, rgba(61, 214, 255, 0.16), rgba(91, 140, 255, 0.02)),
        rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.boot-mark::before,
.boot-mark::after,
.boot-mark span::before,
.boot-mark span::after {
    content: "";
    position: absolute;
    inset: 18px;
    border-radius: 16px;
    border: 1px solid rgba(125, 255, 178, 0.24);
    transform: rotate(12deg);
}

.boot-mark::after {
    inset: 28px;
    border-color: rgba(61, 214, 255, 0.22);
    transform: rotate(-10deg);
}

.boot-mark span::before {
    inset: 34px 22px;
    border-color: rgba(255, 185, 73, 0.18);
    transform: rotate(34deg);
}

.boot-mark span::after {
    inset: 24px 34px;
    border-color: rgba(255, 255, 255, 0.22);
    transform: rotate(-34deg);
}

.boot-kicker {
    margin: 0 0 10px;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.boot-screen h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.35;
}

.boot-copy {
    margin: 10px 0 18px;
    color: var(--muted);
    line-height: 1.8;
}

.boot-timer {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 18px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(61, 214, 255, 0.08);
    border: 1px solid rgba(61, 214, 255, 0.14);
}

.boot-timer span {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
}

.boot-timer small {
    color: var(--muted);
    font-weight: 700;
}

.boot-progress {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.boot-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cyan), var(--blue), var(--green));
    box-shadow: 0 0 18px rgba(61, 214, 255, 0.4);
    transition: width 0.3s linear;
}

.app-shell {
    width: min(100vw, var(--max-width));
    min-height: 100svh;
    margin: 0 auto;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px) + 112px);
    scrollbar-width: none;
}

.app-shell::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.top-hero {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 14px 14px 16px;
    background: linear-gradient(180deg, rgba(5, 8, 22, 0.98), rgba(5, 8, 22, 0.78));
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(145, 178, 255, 0.08);
}

.hero-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(61, 214, 255, 0.08), transparent 42%),
        linear-gradient(315deg, rgba(125, 255, 178, 0.06), transparent 38%);
}

.hero-shell {
    position: relative;
    z-index: 1;
}

.hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: #06101c;
    background: linear-gradient(145deg, #7ef1ff, #5b8cff);
    box-shadow: 0 18px 40px rgba(61, 214, 255, 0.22);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.identity-copy {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 800;
}

.identity-copy h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.meta-line {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-pill {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    color: var(--cyan);
    border: 1px solid rgba(61, 214, 255, 0.18);
    background: rgba(61, 214, 255, 0.08);
}

.command-board {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.stat-chip,
.meter,
.panel,
.resource-card,
.arena,
.battle-btn,
.action-card {
    border: 1px solid rgba(145, 178, 255, 0.12);
    background: rgba(8, 14, 29, 0.78);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

.stat-chip {
    padding: 11px 12px;
    border-radius: 18px;
    min-height: 70px;
}

.stat-chip span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.stat-chip strong {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
}

.meter-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.meter {
    padding: 12px;
    border-radius: 18px;
}

.meter-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.meter-row span {
    color: var(--muted);
    font-size: 12px;
}

.meter-row strong {
    color: var(--text);
    font-size: 14px;
}

.meter-track {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
}

.meter-track i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cyan), var(--blue), var(--green));
    transition: width 0.45s ease;
}

.viewport {
    padding: 14px 14px 0;
    padding-bottom: 16px;
}

.screen {
    display: none;
    animation: screenIn 0.34s ease;
    padding-bottom: 8px;
}

.screen.active {
    display: block;
}

@keyframes screenIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    margin-bottom: 14px;
}

.section-title h2 {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.4;
}

.section-title p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.action-card {
    min-height: 104px;
    border-radius: 20px;
    color: var(--text);
    padding: 14px;
    display: grid;
    align-content: space-between;
    justify-items: start;
    text-align: right;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.action-card i {
    font-size: 22px;
    color: var(--cyan);
}

.action-card span {
    font-size: 14px;
    font-weight: 700;
}

.action-card:active,
.battle-btn:active,
.wide-btn:active,
.ghost-btn:active,
.nav-btn:active {
    transform: scale(0.98);
}

.action-primary {
    background:
        linear-gradient(180deg, rgba(61, 214, 255, 0.11), rgba(8, 14, 29, 0.88));
    border-color: rgba(61, 214, 255, 0.18);
}

.panel {
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    background: var(--panel);
    backdrop-filter: blur(16px);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-head.compact {
    margin-bottom: 12px;
}

.panel-head p {
    margin: 0 0 4px;
    color: var(--cyan);
    font-size: 11px;
    font-weight: 800;
}

.panel-head h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

.countdown,
.tag {
    flex: 0 0 auto;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid rgba(145, 178, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.mission-bars {
    display: grid;
    gap: 10px;
}

.mission-bar {
    display: grid;
    gap: 8px;
}

.mission-bar span {
    font-size: 12px;
    color: var(--muted);
}

.mission-bar i {
    display: block;
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.mission-bar b {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--cyan));
    transition: width 0.6s ease;
}

.feed-list {
    display: grid;
    gap: 10px;
}

.feed-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(145, 178, 255, 0.08);
}

.feed-item i {
    color: var(--cyan);
}

.feed-item span {
    font-size: 13px;
    line-height: 1.6;
}

.feed-item time {
    color: var(--muted);
    font-size: 11px;
}

.arena {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(116px, 0.7fr);
    gap: 10px;
    padding: 12px;
    border-radius: 24px;
    margin-bottom: 12px;
    background:
        linear-gradient(180deg, rgba(8, 14, 29, 0.92), rgba(8, 14, 29, 0.78));
}

.arena-core {
    position: relative;
    min-height: 220px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(61, 214, 255, 0.06), rgba(91, 140, 255, 0.03)),
        rgba(255, 255, 255, 0.02);
}

.arena-core::before {
    content: "";
    position: absolute;
    inset: 16px;
    border-radius: 22px;
    border: 1px solid rgba(145, 178, 255, 0.12);
}

.arena-core::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 0 30%, rgba(61, 214, 255, 0.08) 45%, transparent 60%);
    animation: pulseLine 4s linear infinite;
}

@keyframes pulseLine {
    from { transform: translateY(-18%); }
    to { transform: translateY(18%); }
}

.arena-ring {
    width: 150px;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid rgba(61, 214, 255, 0.22);
    background:
        radial-gradient(circle, rgba(61, 214, 255, 0.14), transparent 58%),
        radial-gradient(circle, rgba(125, 255, 178, 0.06), transparent 66%);
    box-shadow:
        0 0 0 18px rgba(61, 214, 255, 0.03),
        0 0 48px rgba(61, 214, 255, 0.08);
    animation: spin 18s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.arena-stat {
    position: absolute;
    inset-inline: 20px;
    bottom: 20px;
    z-index: 1;
    display: grid;
    gap: 6px;
    text-align: center;
}

.arena-stat span,
.mini-stat span,
.resource-card span,
.profile-row span {
    color: var(--muted);
    font-size: 12px;
}

.arena-stat strong {
    font-size: 26px;
    line-height: 1;
}

.arena-side {
    display: grid;
    gap: 10px;
    align-content: start;
}

.mini-stat {
    padding: 12px;
    min-height: 66px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(145, 178, 255, 0.08);
}

.mini-stat strong {
    display: block;
    margin-top: 8px;
    font-size: 18px;
}

.battle-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.battle-btn,
.wide-btn,
.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 18px;
    border: 1px solid rgba(145, 178, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.battle-btn {
    min-height: 84px;
    padding: 12px;
    flex-direction: column;
    text-align: center;
}

.battle-btn i {
    color: var(--cyan);
    font-size: 20px;
}

.battle-btn span {
    font-size: 13px;
    font-weight: 700;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.resource-card {
    min-height: 90px;
    padding: 12px;
    border-radius: 18px;
    display: grid;
    align-content: space-between;
}

.resource-card strong {
    font-size: 22px;
    line-height: 1.2;
}

.market-copy p {
    margin: 0 0 12px;
    color: var(--muted);
    line-height: 1.85;
    font-size: 13px;
}

.wide-btn {
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    font-weight: 800;
    border-color: rgba(61, 214, 255, 0.18);
    background: linear-gradient(180deg, rgba(61, 214, 255, 0.12), rgba(61, 214, 255, 0.04));
}

.wide-btn i {
    color: var(--cyan);
}

.profile-panel {
    display: grid;
    gap: 10px;
}

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(145, 178, 255, 0.08);
}

.profile-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.profile-row strong {
    font-size: 13px;
    text-align: left;
    max-width: 58%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    transform: translateX(-50%);
    width: min(100vw, var(--max-width));
    height: var(--footer-height);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    z-index: 30;
    background: rgba(6, 10, 21, 0.86);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(145, 178, 255, 0.1);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.nav-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    display: grid;
    gap: 5px;
    place-items: center;
    border-radius: 18px;
    cursor: pointer;
    padding: 8px 4px;
    transition: transform 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.nav-btn i {
    font-size: 18px;
}

.nav-btn span {
    font-size: 11px;
    font-weight: 700;
}

.nav-btn.active {
    color: var(--text);
    background: rgba(61, 214, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(61, 214, 255, 0.14);
}

.toast-host {
    position: fixed;
    left: 50%;
    bottom: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px) + 18px);
    transform: translateX(-50%);
    width: min(100vw - 24px, var(--max-width));
    display: grid;
    gap: 8px;
    z-index: 40;
    pointer-events: none;
}

.toast {
    pointer-events: none;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(145, 178, 255, 0.14);
    background: rgba(8, 14, 29, 0.94);
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 0.28s ease;
}

.toast strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

.toast span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.toast.success {
    border-color: rgba(125, 255, 178, 0.2);
}

.toast.error {
    border-color: rgba(255, 107, 125, 0.2);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 821px) {
    .app-shell,
    .boot-screen {
        display: none !important;
    }
    .desktop-gate {
        display: grid !important;
    }
}

@media (max-width: 420px) {
    .top-hero {
        padding-inline: 12px;
    }

    .viewport {
        padding-inline: 12px;
    }

    .hero-head {
        align-items: center;
    }

    .identity-copy h1 {
        font-size: 18px;
    }

    .arena {
        grid-template-columns: 1fr;
    }

    .arena-core {
        min-height: 200px;
    }

    .battle-actions {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
