:root {
    --bg-900: #111111;
    --bg-800: #1a1a1a;
    --bg-700: rgba(42, 42, 42, 0.88);
    --panel: rgba(36, 36, 36, 0.88);
    --panel-strong: rgba(53, 53, 53, 0.96);
    --line: rgba(255, 199, 0, 0.18);
    --text-strong: #ffffff;
    --text: #efefef;
    --text-muted: #bdbdbd;
    --accent: #ffc700;
    --accent-strong: #ffd84d;
    --accent-soft: rgba(255, 199, 0, 0.18);
    --emerald: #4CAF50;
    --emerald-soft: rgba(76, 175, 80, 0.18);
    --danger: #F44336;
    --danger-soft: rgba(244, 67, 54, 0.16);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --title-font: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    --body-font: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg-900);
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--body-font);
    color: var(--text-strong);
    background:
        radial-gradient(circle at top right, rgba(255, 199, 0, 0.12), transparent 28%),
        radial-gradient(circle at left center, rgba(76, 175, 80, 0.1), transparent 26%),
        linear-gradient(rgba(17, 17, 17, 0.96), rgba(17, 17, 17, 0.96)),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23262626' fill-opacity='0.34'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    -webkit-tap-highlight-color: transparent;
}

button,
a {
    font: inherit;
}

.app-bg {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(145deg, rgba(255, 199, 0, 0.08), transparent 40%),
        linear-gradient(325deg, rgba(76, 175, 80, 0.08), transparent 30%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='rgba(255,199,0,0.05)' stroke-width='1'%3E%3Cpath d='M0 45h180M0 90h180M0 135h180M45 0v180M90 0v180M135 0v180'/%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: env(safe-area-inset-top, 0) 18px calc(env(safe-area-inset-bottom, 0) + 98px);
}

.screen.hidden,
.stage-screen:not(.active),
.hidden {
    display: none !important;
}

.landing-screen,
.game-shell {
    min-height: 100vh;
}

.landing-screen {
    display: grid;
    gap: 24px;
    align-content: center;
    padding: 42px 0;
}

.landing-hero,
.panel,
.resource-card {
    backdrop-filter: blur(22px);
}

.landing-hero {
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(160deg, rgba(36, 36, 36, 0.96), rgba(20, 20, 20, 0.94)),
        linear-gradient(135deg, rgba(255, 199, 0, 0.18), transparent 42%);
    box-shadow: var(--shadow);
}

.eyebrow,
.panel-label,
.resource-label {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.game-mark,
.section-title,
.panel h2,
.modal-card h2 {
    margin: 0;
    font-family: var(--title-font);
    letter-spacing: 0.04em;
}

.game-mark {
    font-size: clamp(3rem, 8vw, 5.4rem);
    line-height: 0.92;
    color: #ffffff;
}

.landing-copy,
.panel-copy,
.modal-body,
.stack-copy,
.journal-copy {
    color: var(--text);
    line-height: 1.6;
}

.landing-actions,
.modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.landing-grid,
.journal-grid {
    display: grid;
    gap: 18px;
}

.landing-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.feature-panel,
.panel {
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.spotlight-panel {
    background:
        linear-gradient(180deg, rgba(44, 44, 44, 0.97), rgba(24, 24, 24, 0.96)),
        linear-gradient(140deg, rgba(76, 175, 80, 0.15), transparent 40%);
}

.feature-list,
.studio-panel ul {
    padding-left: 18px;
    color: var(--text);
    line-height: 1.65;
}

.guide-list {
    margin: 16px 0 0;
    padding-left: 20px;
    color: var(--text);
    line-height: 1.7;
}

.guide-list li + li {
    margin-top: 8px;
}

.guide-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 6px;
}

.guide-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 0.82rem;
}

.guide-chip-strong {
    background: rgba(255, 199, 0, 0.12);
    border-color: rgba(255, 199, 0, 0.22);
    color: #fff2ad;
}

.guide-card .stack-copy {
    margin-bottom: 0;
}

.button {
    appearance: none;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 13px 18px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px rgba(0, 0, 0, 0.18);
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease, filter 180ms ease;
}

.button::before,
.button::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.button::before {
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 46%);
    z-index: -1;
}

.button::after {
    top: -120%;
    left: -36%;
    width: 42%;
    height: 260%;
    transform: rotate(18deg);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
    opacity: 0;
    transition: transform 240ms ease, opacity 240ms ease;
}

.button:hover,
.button:focus-visible,
.nav-button:hover,
.nav-button:focus-visible {
    transform: translateY(-2px);
}

.button:hover:not([disabled])::after,
.button:focus-visible:not([disabled])::after {
    opacity: 1;
    transform: translateX(240%) rotate(18deg);
}

.button:focus-visible,
.nav-button:focus-visible {
    outline: 2px solid rgba(255, 199, 0, 0.8);
    outline-offset: 3px;
}

.button:active:not([disabled]),
.nav-button:active:not([disabled]) {
    transform: translateY(1px) scale(0.98);
    filter: brightness(0.98);
}

.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #111111;
    box-shadow: 0 14px 34px rgba(255, 199, 0, 0.22);
}

.button-secondary {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    color: var(--text-strong);
    border-color: var(--line);
}

.button-ghost {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.12);
}

.button[data-action="manual-hustle"] {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3), rgba(76, 175, 80, 0.14));
    border-color: rgba(76, 175, 80, 0.34);
    color: #f7fff7;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 24px rgba(76, 175, 80, 0.16);
}

.button[data-action="buy-hustle"].button-primary,
.button[data-action="claim-reward"],
.button[data-action="install-app"] {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 14px 28px rgba(255, 199, 0, 0.18);
}

.button[data-action="manual-hustle"]:not([disabled]):hover,
.button[data-action="manual-hustle"]:not([disabled]):focus-visible {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 14px 28px rgba(76, 175, 80, 0.22);
}

.compact-button {
    padding: 10px 14px;
}

.text-link {
    color: var(--accent-strong);
    text-decoration: none;
}

.install-hint {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.top-bar,
.resource-bar,
.main-stage,
.bottom-nav {
    width: 100%;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 28px 0 18px;
}

.status-row,
.district-meta,
.panel-head,
.section-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.status-pill,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.status-pill.muted {
    color: var(--text-muted);
}

.tag-warm {
    background: var(--accent-soft);
    color: #fff2ad;
    border-color: rgba(255, 199, 0, 0.25);
}

.tag-emerald {
    background: var(--emerald-soft);
    color: #d4ffd7;
    border-color: rgba(76, 175, 80, 0.2);
}

.tag-danger {
    background: var(--danger-soft);
    color: #ffc8c1;
    border-color: rgba(244, 67, 54, 0.2);
}

.resource-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.resource-card {
    position: relative;
    overflow: hidden;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(44, 44, 44, 0.92), rgba(24, 24, 24, 0.9));
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.resource-card::before {
    content: attr(data-icon);
    position: absolute;
    right: 14px;
    top: 10px;
    font-size: 1.55rem;
    opacity: 0.12;
}

.resource-card::after {
    content: attr(data-delta);
    position: absolute;
    right: 14px;
    bottom: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(4px);
}

.resource-card[data-resource="cash"] {
    border-color: rgba(255, 199, 0, 0.26);
}

.resource-card[data-resource="cash"] .resource-value {
    color: var(--accent-strong);
}

.resource-card[data-resource="income"] .resource-value {
    color: #d7ffd8;
}

.resource-card-updated-up {
    animation: resource-pop-up 680ms ease;
    box-shadow: 0 18px 30px rgba(76, 175, 80, 0.14);
}

.resource-card-updated-down {
    animation: resource-pop-down 680ms ease;
    box-shadow: 0 18px 30px rgba(244, 67, 54, 0.12);
}

.resource-card-updated-up::after,
.resource-card-updated-down::after {
    opacity: 1;
    animation: resource-delta-float 900ms ease forwards;
}

.resource-card-updated-up::after {
    color: #d4ffd7;
}

.resource-card-updated-down::after {
    color: #ffc8c1;
}

.resource-value {
    display: block;
    margin-top: 8px;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: #ffffff;
}

.main-stage {
    margin-top: 18px;
}

.hero-stack,
.content-section,
.stage-screen {
    display: grid;
    gap: 18px;
}

.hero-stack {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.progress-shell {
    width: 100%;
    height: 12px;
    margin-top: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    transition: width 220ms ease;
}

.progress-copy {
    margin: 10px 0 0;
    color: var(--text-muted);
}

.effect-ribbon {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.effect-chip {
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(76, 175, 80, 0.14);
    border: 1px solid rgba(76, 175, 80, 0.18);
    color: #d9ffd9;
    font-size: 0.86rem;
}

.reward-tray,
.hustle-list,
.district-list,
.stack-list {
    display: grid;
    gap: 14px;
}

.reward-card,
.hustle-card,
.district-tile,
.stack-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.reward-card {
    background: linear-gradient(180deg, rgba(58, 58, 58, 0.96), rgba(28, 28, 28, 0.98));
}

.reward-card .panel-head,
.hustle-card .panel-head,
.district-tile .panel-head {
    align-items: flex-start;
}

.hustle-card {
    display: grid;
    gap: 16px;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.hustle-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 199, 0, 0.28);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.18);
}

.hustle-card:active {
    transform: translateY(0) scale(0.996);
}

.hustle-header {
    display: grid;
    gap: 12px;
    grid-template-columns: auto 1fr auto;
    align-items: start;
}

.hustle-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 1.7rem;
}

.hustle-meta {
    display: grid;
    gap: 6px;
}

.hustle-name {
    margin: 0;
    font-size: 1.15rem;
}

.hustle-story {
    margin: 0;
    color: var(--text);
}

.metric-row,
.reward-meta,
.stack-meta,
.district-criteria {
    display: flex;
    gap: 10px 18px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.hustle-actions,
.reward-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.mini-progress {
    height: 10px;
}

.district-list {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.district-tile.locked {
    opacity: 0.72;
}

.district-tile.active {
    border-color: rgba(76, 175, 80, 0.4);
    box-shadow: 0 18px 44px rgba(76, 175, 80, 0.14);
}

.stack-card {
    display: grid;
    gap: 12px;
}

.stack-title {
    margin: 0;
    font-size: 1rem;
}

.stack-copy,
.journal-copy {
    margin: 0;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
    transform: translateX(-50%);
    width: min(960px, calc(100% - 24px));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(22, 14, 10, 0.92);
    backdrop-filter: blur(22px);
    box-shadow: var(--shadow);
}

.nav-button {
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    padding: 12px 10px;
    cursor: pointer;
    transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.nav-button.active {
    background: linear-gradient(135deg, rgba(255, 199, 0, 0.2), rgba(255, 199, 0, 0.1));
    color: var(--text-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 18px rgba(255, 199, 0, 0.12);
}

.studio-panel {
    display: grid;
    gap: 14px;
    color: var(--text);
    line-height: 1.65;
}

.studio-quote {
    margin: 0;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.toast-region {
    position: fixed;
    right: 16px;
    top: calc(env(safe-area-inset-top, 0) + 16px);
    display: grid;
    gap: 10px;
    z-index: 30;
    width: min(360px, calc(100% - 32px));
}

.toast {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: rgba(27, 17, 11, 0.95);
    color: var(--text-strong);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.34);
    animation: toast-in 180ms ease;
}

.toast.success {
    border-color: rgba(76, 175, 80, 0.32);
}

.toast.warning {
    border-color: rgba(255, 199, 0, 0.3);
}

.toast.danger {
    border-color: rgba(244, 67, 54, 0.3);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(10, 6, 4, 0.72);
    z-index: 40;
}

.modal-card {
    width: min(560px, 100%);
    padding: 24px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(46, 28, 18, 0.98), rgba(24, 15, 10, 0.98));
    box-shadow: var(--shadow);
}

.modal-body {
    margin-top: 14px;
}

.modal-actions {
    margin-top: 20px;
}

.empty-state {
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
}

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

@keyframes resource-pop-up {
    0% {
        transform: translateY(0);
        border-color: rgba(76, 175, 80, 0.18);
    }
    35% {
        transform: translateY(-3px);
        border-color: rgba(76, 175, 80, 0.44);
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes resource-pop-down {
    0% {
        transform: translateY(0);
        border-color: rgba(244, 67, 54, 0.18);
    }
    35% {
        transform: translateY(-2px);
        border-color: rgba(244, 67, 54, 0.38);
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes resource-delta-float {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@media (max-width: 900px) {
    .resource-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding-left: 14px;
        padding-right: 14px;
        padding-bottom: calc(env(safe-area-inset-bottom, 0) + 104px);
    }

    .landing-hero,
    .feature-panel,
    .panel,
    .resource-card,
    .reward-card,
    .hustle-card,
    .district-tile,
    .stack-card {
        padding: 18px;
    }

    .top-bar {
        padding-top: 18px;
    }

    .resource-bar {
        position: sticky;
        top: calc(env(safe-area-inset-top, 0) + 6px);
        z-index: 22;
        display: grid;
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(150px, 1fr);
        gap: 10px;
        overflow-x: auto;
        margin: 0 -4px;
        padding: 6px 4px 12px;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
    }

    .resource-bar::-webkit-scrollbar {
        display: none;
    }

    .resource-card {
        min-height: 92px;
        padding: 14px 16px;
        scroll-snap-align: start;
        background: linear-gradient(180deg, rgba(46, 46, 46, 0.94), rgba(24, 24, 24, 0.92));
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
    }

    .resource-label {
        font-size: 0.62rem;
    }

    .bottom-nav {
        width: calc(100% - 16px);
        bottom: calc(env(safe-area-inset-bottom, 0) + 8px);
        gap: 6px;
        padding: 8px;
    }

    .nav-button {
        padding: 10px 6px;
        font-size: 0.84rem;
    }
}

@media (max-width: 560px) {
    .landing-actions,
    .hustle-actions,
    .reward-actions,
    .modal-actions {
        flex-direction: column;
    }

    .hustle-header {
        grid-template-columns: auto 1fr;
    }

    .district-list,
    .journal-grid,
    .hero-stack {
        grid-template-columns: 1fr;
    }

    .main-stage {
        margin-top: 12px;
    }

    .resource-bar {
        top: calc(env(safe-area-inset-top, 0) + 4px);
        grid-auto-columns: minmax(138px, 1fr);
    }

    .resource-card {
        min-height: 88px;
        border-radius: 18px;
    }

    .resource-value {
        font-size: 1.06rem;
        margin-top: 12px;
        padding-right: 24px;
    }

    .status-row {
        width: 100%;
    }

    .bottom-nav {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        border-radius: 24px;
    }
}
