/* style.css */

:root {
    color-scheme: dark;

    --background: #050811;
    --surface: rgba(10, 16, 30, 0.92);
    --surface-soft: rgba(255, 255, 255, 0.055);
    --surface-hover: rgba(255, 255, 255, 0.08);

    --border: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.24);

    --text: #f5f7ff;
    --text-soft: rgba(245, 247, 255, 0.68);
    --text-muted: rgba(245, 247, 255, 0.46);

    --online: #79f2a8;
    --offline: #ff8383;
    --warning: #ffd479;

    --radius-large: 22px;
    --radius-medium: 14px;
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.46);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;

    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: var(--text);

    background:
        radial-gradient(circle at 50% 0%,
            rgba(52, 81, 145, 0.3),
            transparent 42%),
        linear-gradient(180deg,
            #090f1e 0%,
            var(--background) 65%);
}

button,
input,
select,
textarea {
    font: inherit;
}

#app {
    width: min(1240px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 32px;

    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* =========================
   Header
   ========================= */

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.brand-label,
.section-label {
    margin: 0 0 8px;

    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.26em;

    color: var(--text-muted);
}

.brand h1 {
    margin: 0;

    font-size: clamp(2.2rem, 7vw, 5.6rem);
    line-height: 0.95;
    letter-spacing: -0.055em;
}

.brand-motto {
    margin: 14px 0 0;

    font-size: 1rem;
    color: var(--text-soft);
}

.connection-indicator {
    min-width: 176px;
    padding: 12px 16px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: var(--surface-soft);

    font-size: 0.86rem;
    font-weight: 700;
}

.connection-dot {
    width: 9px;
    height: 9px;

    border-radius: 50%;
    background: var(--offline);

    box-shadow:
        0 0 0 4px rgba(255, 131, 131, 0.12);
}

.connection-indicator[data-connected="true"] {
    color: var(--online);
}

.connection-indicator[data-connected="true"] .connection-dot {
    background: var(--online);

    box-shadow:
        0 0 0 4px rgba(121, 242, 168, 0.12),
        0 0 20px rgba(121, 242, 168, 0.52);
}

/* =========================
   Main layout
   ========================= */

.app-main {
    display: grid;
    grid-template-columns:
        minmax(340px, 0.85fr) minmax(420px, 1.4fr);
    gap: 22px;
}

.engine-panel,
.arena-panel {
    padding: 28px;

    border: 1px solid var(--border);
    border-radius: var(--radius-large);

    background: var(--surface);
    box-shadow: var(--shadow);

    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.panel-heading {
    margin-bottom: 22px;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.panel-heading h2 {
    margin: 0;
    font-size: 1.6rem;
}

.status-badge {
    padding: 8px 12px;

    border: 1px solid var(--border);
    border-radius: 999px;

    background: var(--surface-soft);

    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-badge[data-status="running"] {
    color: var(--online);
    border-color: rgba(121, 242, 168, 0.32);
}

.status-badge[data-status="stopped"] {
    color: var(--offline);
    border-color: rgba(255, 131, 131, 0.32);
}

.status-badge[data-status="idle"] {
    color: var(--warning);
    border-color: rgba(255, 212, 121, 0.32);
}

/* =========================
   State cards
   ========================= */

.state-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.state-card {
    min-height: 116px;
    padding: 18px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;

    border: 1px solid transparent;
    border-radius: var(--radius-medium);

    background: var(--surface-soft);

    transition:
        border-color 160ms ease,
        background 160ms ease;
}

.state-card:hover {
    border-color: var(--border);
    background: var(--surface-hover);
}

.state-label {
    display: block;

    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;

    color: var(--text-muted);
}

.state-card strong {
    font-size: 1.22rem;
}

.tick-card {
    grid-column: 1 / -1;
    min-height: 170px;
}

.tick-value {
    font-size: clamp(4rem, 13vw, 8rem);
    line-height: 0.82;
    letter-spacing: -0.06em;
    font-variant-numeric: tabular-nums;
}

.sync-panel {
    margin-top: 14px;
    padding: 18px;

    display: grid;
    gap: 7px;

    border-radius: var(--radius-medium);
    background: var(--surface-soft);
}

#sync-time {
    font-size: 0.94rem;
}

#sync-reason {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================
   Arena
   ========================= */

.arena-wrapper {
    position: relative;

    width: 100%;
    aspect-ratio: 1 / 1;

    overflow: hidden;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-medium);

    background:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px,
            transparent 1px),
        linear-gradient(90deg,
            rgba(255, 255, 255, 0.025) 1px,
            transparent 1px),
        #03060c;

    background-size: 32px 32px;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.arena-placeholder {
    position: absolute;
    inset: 0;

    padding: 30px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;

    text-align: center;
    pointer-events: none;
}

.arena-placeholder strong {
    font-size: clamp(2rem, 6vw, 4rem);
    letter-spacing: -0.04em;
}

.arena-placeholder span {
    max-width: 390px;
    color: var(--text-muted);
    line-height: 1.55;
}

.arena-placeholder[hidden] {
    display: none;
}

/* =========================
   Footer
   ========================= */

.app-footer {
    padding: 4px 2px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    font-size: 0.78rem;
    color: var(--text-muted);
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 900px) {
    #app {
        padding: 22px;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-main {
        grid-template-columns: 1fr;
    }

    .engine-panel,
    .arena-panel {
        padding: 22px;
    }
}

@media (max-width: 560px) {
    #app {
        padding: 14px;
        gap: 18px;
    }

    .brand h1 {
        font-size: 2.7rem;
    }

    .connection-indicator {
        width: 100%;
    }

    .state-grid {
        grid-template-columns: 1fr;
    }

    .tick-card {
        grid-column: auto;
    }

    .app-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* =========================
   Foundation View
   ========================= */

#ge-foundation-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;

    box-sizing: border-box;

    font-family:
        Arial,
        sans-serif;

    background:
        radial-gradient(circle at center,
            #18233b 0%,
            #070b13 70%);

    color: #ffffff;
}

.ge-foundation-card {
    width: min(680px, 100%);
    padding: 40px;

    box-sizing: border-box;

    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;

    background: rgba(8, 13, 24, 0.9);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);

    text-align: center;
}

.ge-eyebrow {
    margin: 0 0 10px;

    font-size: 0.8rem;
    letter-spacing: 0.28em;

    opacity: 0.7;
}

.ge-foundation-card h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 4rem);
}

.ge-motto {
    margin: 12px 0 32px;
    opacity: 0.72;
}

.ge-state-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.ge-state-item {
    padding: 18px;

    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
}

.ge-state-item span {
    display: block;
    margin-bottom: 8px;

    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;

    opacity: 0.62;
}

.ge-state-item strong {
    font-size: 1.25rem;
}

.ge-tick-item strong {
    font-size: 2.7rem;
    font-variant-numeric: tabular-nums;
}

#ge-connection[data-connected="true"] {
    color: #7dffb2;
}

#ge-connection[data-connected="false"] {
    color: #ff8c8c;
}

.ge-sync-info {
    margin: 24px 0 0;

    font-size: 0.84rem;
    opacity: 0.58;
}

@media (max-width: 560px) {
    .ge-foundation-card {
        padding: 26px 18px;
    }

    .ge-state-grid {
        grid-template-columns: 1fr;
    }
}