:root {
    --bg: #090710;
    --surface: #15111e;
    --surface-2: #20182b;
    --border: rgba(255, 255, 255, 0.12);
    --text: #f7f3fb;
    --muted: #bdb4c8;
    --purple: #6f2c91;
    --purple-light: #9b62b8;
    --blue: #168de2;
    --green: #00d4a1;
    --orange: #f1a33c;
    --red: #c94a5b;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 78px;
    padding: 12px clamp(20px, 5vw, 72px);
    background: rgba(255, 255, 255, 0.96);
    color: #17111f;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.site-header--dark {
    position: sticky;
    top: 0;
    background: rgba(9, 7, 16, 0.94);
    color: var(--text);
    border-color: var(--border);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    font-weight: 800;
    text-decoration: none;
}

.brand img {
    width: 120px;
    height: 44px;
    object-fit: contain;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 38px);
}

.site-nav a,
.nav-button {
    padding: 8px 0;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.site-nav a:hover,
.nav-button:hover {
    color: var(--purple-light);
}

.landing-hero {
    min-height: min(800px, calc(100vh - 78px));
    display: grid;
    align-items: center;
    padding: clamp(50px, 9vw, 120px) clamp(24px, 8vw, 130px);
    background:
        linear-gradient(90deg, rgba(8, 5, 13, 0.95) 0%, rgba(8, 5, 13, 0.62) 48%, rgba(8, 5, 13, 0.15) 100%),
        url("DMS-Mining-splash.png") center / cover no-repeat;
}

.landing-hero__content {
    max-width: 680px;
}

.landing-hero h1,
.sim-hero h1 {
    margin: 10px 0 20px;
    font-size: clamp(2.4rem, 6vw, 5.4rem);
    line-height: 0.98;
    letter-spacing: -0.045em;
}

.landing-hero p:not(.eyebrow) {
    max-width: 620px;
    color: #e2d9e8;
    font-size: clamp(1rem, 2vw, 1.25rem);
}

.eyebrow {
    margin: 0;
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.hero-actions,
.utility-actions,
.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 20px;
    border: 1px solid var(--purple-light);
    border-radius: 8px;
    background: var(--purple);
    color: white;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-2px);
    background: #8438a8;
}

.button--primary {
    border-color: var(--green);
    background: var(--green);
    color: #07130f;
}

.button--primary:hover:not(:disabled) {
    background: #36e2b9;
}

.button--ghost {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.42);
}

.button--danger {
    background: transparent;
    border-color: var(--red);
    color: #ffadb9;
}

.button--small {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.9rem;
}

.button:disabled,
.upgrade-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.content-section {
    max-width: 1180px;
    margin: 0 auto;
    padding: 90px 24px;
}

.content-section h2 {
    margin: 8px 0 16px;
    font-size: clamp(2rem, 4vw, 3.5rem);
}

.section-intro {
    max-width: 760px;
    color: var(--muted);
    font-size: 1.1rem;
}

.feature-grid,
.dashboard-grid,
.graph-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.feature-grid {
    margin-top: 44px;
}

.feature-card,
.panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(32, 24, 43, 0.96), rgba(17, 13, 24, 0.96));
    box-shadow: var(--shadow);
}

.feature-card {
    min-height: 220px;
    padding: 28px;
}

.feature-card__number {
    color: var(--green);
    font-weight: 900;
}

.feature-card h3 {
    margin: 32px 0 8px;
    font-size: 1.5rem;
}

.feature-card p {
    margin: 0;
    color: var(--muted);
}

.games-section {
    max-width: none;
    padding-inline: clamp(24px, 8vw, 130px);
    background:
        radial-gradient(circle at 85% 20%, rgba(111, 44, 145, 0.2), transparent 32%),
        #0d0913;
    border-top: 1px solid var(--border);
}

.game-showcase {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 552px);
    align-items: center;
    gap: clamp(36px, 7vw, 90px);
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(30px, 5vw, 56px);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(32, 24, 43, 0.96), rgba(17, 13, 24, 0.96));
    box-shadow: var(--shadow);
}

.game-showcase + .game-showcase {
    margin-top: 30px;
}

.game-showcase h2 {
    margin-bottom: 14px;
}

.game-showcase__copy > p:not(.eyebrow) {
    max-width: 620px;
    color: var(--muted);
    font-size: 1.05rem;
}

.game-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0;
}

.game-meta span {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0, 212, 161, 0.1);
    color: #bdf7e9;
    font-size: 0.78rem;
    font-weight: 800;
}

.itch-embed {
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: white;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.itch-embed iframe {
    display: block;
    width: 100%;
    max-width: 552px;
    border: 0;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 28px clamp(24px, 8vw, 130px);
    background: #050408;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(6, 4, 10, 0.9);
    backdrop-filter: blur(12px);
}

.intro-overlay[hidden] {
    display: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(6, 4, 10, 0.78);
    backdrop-filter: blur(8px);
}

.modal-card {
    width: min(480px, 100%);
    padding: clamp(24px, 5vw, 38px);
    border: 1px solid rgba(0, 212, 161, 0.45);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.modal-card h2 {
    margin: 8px 0 12px;
    color: var(--text);
    font-size: clamp(1.7rem, 4vw, 2.3rem);
}

.modal-card p:not(.eyebrow) {
    margin: 0 0 24px;
    color: var(--muted);
}

.modal-card--resource {
    width: min(560px, 100%);
}

.modal-logo {
    display: block;
    width: min(210px, 55%);
    max-height: 70px;
    margin-bottom: 24px;
    object-fit: contain;
    object-position: left center;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.modal-card--pfs {
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.pfs-note,
.pfs-disclaimer {
    color: var(--muted);
}

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

.pfs-grid > div {
    display: grid;
    gap: 4px;
    min-height: 82px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.035);
}

.pfs-grid span,
.pfs-confidence {
    color: var(--muted);
    font-size: 0.82rem;
}

.pfs-grid strong {
    font-size: 1.08rem;
}

.pfs-positive strong {
    color: var(--green);
}

.pfs-negative strong {
    color: #ff8b9b;
}

.pfs-confidence {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.pfs-assumptions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -6px 0 18px;
}

.pfs-assumptions span,
.pfs-confidence span {
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(155, 98, 184, 0.14);
}

.pfs-assumptions span {
    color: #eee6f4;
    font-size: 0.78rem;
}

.pfs-disclaimer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
}

.dialog-card {
    display: grid;
    grid-template-columns: minmax(150px, 260px) minmax(0, 620px);
    align-items: center;
    gap: clamp(24px, 6vw, 70px);
    width: min(980px, 100%);
    padding: clamp(28px, 5vw, 60px);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dialog-card img {
    width: 100%;
    max-height: 330px;
    object-fit: contain;
}

.dialog-card h1 {
    margin: 8px 0 16px;
    font-size: clamp(2rem, 5vw, 3.8rem);
    line-height: 1;
}

.dialog-card p:not(.eyebrow) {
    color: var(--muted);
    font-size: 1.1rem;
}

.dialogue-text {
    min-height: 64px;
}

.simulator-shell,
.workspace-section {
    width: min(1540px, calc(100% - 32px));
    margin: 0 auto;
}

.simulator-shell {
    padding: 28px 0 80px;
}

.sim-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 360px);
    align-items: center;
    min-height: 350px;
    margin-bottom: 24px;
    padding: clamp(28px, 5vw, 64px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background:
        linear-gradient(90deg, rgba(9, 7, 16, 0.96), rgba(9, 7, 16, 0.55)),
        url("popup-landing.png") center / cover no-repeat;
}

.sim-hero h1 {
    max-width: 850px;
    font-size: clamp(2.3rem, 5vw, 4.7rem);
}

.sim-hero p:not(.eyebrow) {
    max-width: 720px;
    color: #ddd3e4;
}

.sim-hero img {
    width: 100%;
    max-height: 310px;
    object-fit: contain;
    filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.45));
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    margin-bottom: 24px;
}

.panel {
    margin-bottom: 24px;
    padding: clamp(20px, 3vw, 34px);
}

.dashboard-grid .panel {
    margin-bottom: 0;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.panel-heading h2 {
    margin: 5px 0 0;
    font-size: clamp(1.5rem, 3vw, 2.15rem);
}

.objective-panel > p,
.canvas-help {
    color: var(--muted);
}

.objective-progress {
    flex: 0 0 auto;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(0, 212, 161, 0.12);
    color: var(--green);
    font-weight: 900;
}

.progress-track {
    height: 8px;
    margin: 22px 0;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
    transition: width 240ms ease;
}

.objective-list {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: mission;
}

.objective-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    counter-increment: mission;
}

.objective-list li::before {
    content: counter(mission);
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 900;
}

.objective-list li.is-complete {
    color: var(--green);
}

.objective-list li.is-complete::before {
    content: "OK";
    border-color: var(--green);
    font-size: 0.62rem;
}

.metrics-panel {
    display: grid;
    gap: 16px;
}

.metric {
    display: grid;
    gap: 3px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.metric span {
    color: var(--muted);
    font-size: 0.85rem;
}

.metric strong {
    overflow-wrap: anywhere;
    font-size: 1.25rem;
}

.seed-control label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}

.seed-control > div {
    display: flex;
    gap: 8px;
}

.seed-control input {
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #0d0a13;
    color: var(--text);
}

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

.action-card {
    display: grid;
    gap: 8px;
    min-height: 134px;
    padding: 18px;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    cursor: pointer;
    transition: border 160ms ease, background 160ms ease, transform 160ms ease;
}

.action-card:hover,
.action-card.objective-focus {
    transform: translateY(-2px);
    border-color: var(--green);
    background: rgba(0, 212, 161, 0.08);
}

.action-card.selected {
    border-color: var(--green);
    background: rgba(0, 212, 161, 0.14);
}

.action-card__step {
    color: var(--purple-light);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.action-card strong {
    font-size: 1.05rem;
}

.action-card small {
    color: var(--muted);
}

.canvas-panel {
    position: relative;
}

.canvas-scroll {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #030204;
}

#block-canvas {
    display: block;
    width: 100%;
    min-width: 760px;
    height: auto;
    cursor: crosshair;
}

.stockpile-wrap {
    overflow: auto;
    border-radius: 10px;
    background: white;
}

#stockpile-canvas {
    display: block;
    width: 100%;
    min-width: 520px;
    height: auto;
}

#grade-info {
    position: absolute;
    z-index: 5;
    display: none;
    padding: 5px 8px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    pointer-events: none;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.8rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.report-content {
    margin-top: 18px;
    padding: 18px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.24);
    color: #e5ddea;
}

.report-content[hidden] {
    display: none;
}

.workspace-section {
    padding: 40px 0 80px;
}

.workspace-section[hidden] {
    display: none;
}

.workspace-card {
    max-width: 1240px;
    margin: 0 auto;
}

.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.upgrade-grid h3 {
    margin-top: 0;
}

.upgrade-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    margin: 9px 0;
    padding: 12px 14px;
    text-align: left;
    border: 1px solid rgba(155, 98, 184, 0.5);
    border-radius: 8px;
    background: rgba(111, 44, 145, 0.32);
    color: white;
    cursor: pointer;
}

.upgrade-button span {
    color: #d6c2df;
    font-size: 0.78rem;
}

.upgrade-button.is-purchased {
    border-color: var(--green);
    background: rgba(0, 212, 161, 0.14);
}

.graph-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.graph-container {
    min-height: 360px;
    overflow: hidden;
    border-radius: 10px;
    background: white;
}

@media (max-width: 980px) {
    .dashboard-grid,
    .feature-grid,
    .upgrade-grid,
    .graph-grid {
        grid-template-columns: 1fr;
    }

    .game-showcase {
        grid-template-columns: 1fr;
    }

    .itch-embed {
        max-width: 552px;
    }

    .action-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sim-hero {
        grid-template-columns: 1fr;
    }

    .sim-hero img {
        display: none;
    }
}

@media (max-width: 680px) {
    .site-header,
    .site-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-header--dark {
        position: relative;
    }

    .site-nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 12px;
        font-size: 0.88rem;
    }

    .game-showcase {
        padding: 24px;
    }

    .brand img {
        width: 96px;
        height: 36px;
    }

    .landing-hero {
        background-position: 58% center;
    }

    .dialog-card {
        grid-template-columns: 1fr;
        max-height: calc(100vh - 40px);
        overflow: auto;
        text-align: center;
    }

    .dialog-card img {
        max-height: 180px;
    }

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

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

    .panel-heading {
        flex-direction: column;
    }

    .seed-control > div {
        flex-direction: column;
    }

    .simulator-shell,
    .workspace-section {
        width: min(100% - 20px, 1540px);
    }
}
