:root {
    color-scheme: dark;
    --bg: #05070b;
    --panel: rgba(10, 16, 25, 0.72);
    --panel-strong: rgba(14, 23, 36, 0.9);
    --line: rgba(143, 211, 255, 0.22);
    --text: #eef7ff;
    --muted: #9bb4c8;
    --cyan: #64e8ff;
    --amber: #ffd36a;
    --rose: #ff6689;
    --green: #74f2ad;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.home-screen,
.result-screen,
.admin-screen {
    background:
        radial-gradient(circle at 25% 15%, rgba(100, 232, 255, 0.18), transparent 28rem),
        radial-gradient(circle at 80% 70%, rgba(255, 211, 106, 0.12), transparent 24rem),
        linear-gradient(135deg, #05070b 0%, #0b111a 52%, #070b10 100%);
}

.home-shell,
.result-shell,
.admin-login {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.hero,
.result-card,
.admin-form {
    width: min(760px, 100%);
    padding: clamp(24px, 6vw, 56px);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(10, 16, 25, 0.78), rgba(8, 12, 18, 0.62));
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(18px);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--cyan);
    font-size: 0.85rem;
    letter-spacing: 0;
}

h1 {
    margin: 0;
    font-size: clamp(2.6rem, 12vw, 6.8rem);
    line-height: 0.9;
    letter-spacing: 0;
}

.lead {
    margin: 22px 0 0;
    color: #d8e8f5;
    font-size: clamp(1rem, 3vw, 1.25rem);
    line-height: 1.9;
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-top: 32px;
}

.primary-link,
.secondary-button,
.icon-button {
    border: 1px solid rgba(100, 232, 255, 0.45);
    background: rgba(100, 232, 255, 0.12);
    color: var(--text);
    min-height: 46px;
    padding: 0 20px;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, rgba(100, 232, 255, 0.28), rgba(116, 242, 173, 0.18));
}

.secondary-button {
    background: rgba(255, 255, 255, 0.06);
}

.primary-link:hover,
.secondary-button:hover,
.icon-button:hover {
    transform: translateY(-1px);
    border-color: var(--cyan);
}

.soft-warning {
    color: var(--muted);
    line-height: 1.8;
}

.play-screen {
    min-height: 100svh;
    overflow: hidden;
}

.game-shell {
    position: relative;
    min-height: 100svh;
    isolation: isolate;
}

#world-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: #04070b;
}

.game-shell::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.62)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 4px);
}

.game-topbar {
    position: fixed;
    top: 0;
    inset-inline: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 14px clamp(14px, 4vw, 34px);
    background: linear-gradient(180deg, rgba(5, 7, 11, 0.9), transparent);
    z-index: 5;
}

.brand-mark {
    color: var(--cyan);
    font-weight: 700;
}

.progress-wrap {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.84rem;
}

.progress-line {
    height: 3px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.progress-line i {
    display: block;
    width: 6%;
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    transition: width 400ms ease;
}

.icon-button {
    width: 44px;
    padding: 0;
}

.transmission {
    width: min(820px, calc(100% - 28px));
    min-height: 48svh;
    margin: 0 auto;
    padding-top: clamp(96px, 16svh, 150px);
}

.stage-badge {
    width: max-content;
    max-width: 100%;
    color: var(--amber);
    border: 1px solid rgba(255, 211, 106, 0.28);
    background: rgba(255, 211, 106, 0.08);
    padding: 8px 12px;
    margin-bottom: 18px;
}

.message-stream {
    display: grid;
    gap: 12px;
}

.message {
    max-width: min(680px, 100%);
    padding: 16px 18px;
    border: 1px solid var(--line);
    background: var(--panel);
    line-height: 2;
    white-space: pre-wrap;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

.message.system {
    color: #cfe4f6;
}

.message.warning {
    border-color: rgba(255, 102, 137, 0.42);
    color: #ffd6df;
}

.typing-indicator {
    display: flex;
    gap: 7px;
    margin: 18px 4px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    animation: blink 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 120ms;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 240ms;
}

@keyframes blink {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-4px); }
}

.choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
    margin-top: 22px;
}

.choice-button {
    min-height: 54px;
    text-align: right;
    border: 1px solid rgba(100, 232, 255, 0.35);
    background: rgba(7, 13, 21, 0.72);
    color: var(--text);
    padding: 12px 14px;
    cursor: pointer;
}

.choice-button:hover,
.choice-button:focus-visible {
    outline: none;
    border-color: var(--cyan);
    background: rgba(100, 232, 255, 0.14);
}

.stability-panel {
    position: fixed;
    inset-inline: 18px;
    bottom: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    z-index: 3;
}

.stability-panel div {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(5, 8, 13, 0.7);
    padding: 10px 12px;
}

.stability-panel span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.stability-panel strong {
    display: block;
    margin-top: 3px;
    color: var(--green);
}

.warning-overlay {
    position: fixed;
    inset: auto 16px 92px 16px;
    z-index: 6;
    border: 1px solid rgba(255, 102, 137, 0.5);
    background: rgba(35, 8, 18, 0.9);
    color: #ffe4ea;
    padding: 16px;
}

.analysis-grid,
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 26px 0;
}

.analysis-grid div,
.admin-stats div,
.admin-list article {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    padding: 14px;
}

dt,
.admin-stats span,
.admin-list span {
    color: var(--muted);
    font-size: 0.82rem;
}

dd {
    margin: 6px 0 0;
    font-size: 1.4rem;
    color: var(--cyan);
}

.loss-reason {
    color: #ffd6df;
    line-height: 1.8;
}

.admin-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 26px 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
}

.admin-header h1 {
    font-size: clamp(2rem, 8vw, 4rem);
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.6fr);
    gap: 14px;
}

.admin-list {
    display: grid;
    gap: 8px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: right;
}

th {
    color: var(--cyan);
    font-weight: 400;
}

.admin-form {
    display: grid;
    gap: 16px;
}

.admin-form h1 {
    font-size: clamp(2rem, 8vw, 4rem);
}

.admin-form label {
    display: grid;
    gap: 7px;
}

.admin-form input {
    min-height: 46px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text);
    padding: 0 12px;
}

.form-error {
    color: #ffd6df;
}

@media (max-width: 720px) {
    .game-topbar {
        grid-template-columns: auto 1fr auto;
    }

    .transmission {
        padding-top: 92px;
        padding-bottom: 132px;
    }

    .message {
        font-size: 0.96rem;
    }

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

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