:root {
    color-scheme: dark;
    --ink: #edf7ff;
    --muted: #91a4be;
    --panel: rgba(10, 20, 38, 0.88);
    --panel-deep: #08101f;
    --line: rgba(135, 164, 202, 0.22);
    --cyan: #52f0e5;
    --cyan-bright: #a3fff8;
    --yellow: #ffdc5e;
    --violet: #9b8cff;
    --red: #ff7085;
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    min-height: 100%;
    background: #050a13;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% 10%, rgba(39, 220, 205, 0.12), transparent 28rem),
        radial-gradient(circle at 85% 75%, rgba(124, 101, 255, 0.14), transparent 31rem),
        linear-gradient(135deg, #050a13 0%, #0a1427 52%, #070c18 100%);
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    opacity: 0.32;
    background-image:
        linear-gradient(rgba(119, 174, 214, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(119, 174, 214, 0.08) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, black, transparent 88%);
}

.noise {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    opacity: 0.13;
    background-image:
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.045) 3px 4px),
        repeating-linear-gradient(90deg, transparent 0 11px, rgba(82, 240, 229, 0.025) 11px 12px);
}

.pixel-field span {
    position: fixed;
    z-index: -1;
    width: 5px;
    height: 5px;
    background: var(--cyan);
    box-shadow: 0 0 14px var(--cyan);
    animation: drift 9s ease-in-out infinite;
}

.pixel-field span:nth-child(1) { top: 13%; left: 6%; }
.pixel-field span:nth-child(2) { top: 82%; left: 12%; animation-delay: -3s; }
.pixel-field span:nth-child(3) { top: 20%; right: 7%; animation-delay: -6s; }
.pixel-field span:nth-child(4) { top: 72%; right: 4%; animation-delay: -1s; }
.pixel-field span:nth-child(5) { top: 7%; left: 53%; animation-delay: -4s; background: var(--violet); }
.pixel-field span:nth-child(6) { bottom: 4%; left: 61%; animation-delay: -7s; background: var(--yellow); }

.game-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.72fr);
    gap: clamp(2rem, 5vw, 6rem);
    width: min(1180px, calc(100% - 48px));
    min-height: calc(100vh - 86px);
    min-height: calc(100svh - 86px);
    min-height: calc(100dvh - 86px);
    margin: 0 auto;
    align-items: center;
    padding: 48px 0 34px;
}

.story-panel {
    min-width: 0;
}

.eyebrow,
.panel-kicker,
footer,
.label-row span {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--yellow);
    font-size: 0.72rem;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-size: clamp(2.75rem, 6.1vw, 5.6rem);
    line-height: 1.03;
    letter-spacing: -0.065em;
    text-shadow: 0 8px 34px rgba(0, 0, 0, 0.4);
}

.loading-dots {
    display: inline-block;
    width: 0.75em;
    overflow: hidden;
    vertical-align: bottom;
    animation: reveal-dots 1.7s steps(4, end) infinite;
}

.english-title {
    margin: 10px 0 22px;
    color: transparent;
    font-size: clamp(1.35rem, 2.6vw, 2.2rem);
    font-weight: 800;
    letter-spacing: 0.015em;
    -webkit-text-stroke: 1px rgba(163, 255, 248, 0.68);
}

.program-name {
    max-width: 720px;
    margin: 0;
    color: #c6d4e7;
    font-size: clamp(1rem, 1.7vw, 1.18rem);
    font-weight: 650;
    line-height: 1.7;
}

.login-panel {
    position: relative;
    padding: clamp(1.8rem, 4vw, 3rem);
    border: 1px solid rgba(134, 164, 204, 0.28);
    border-radius: 13px;
    background:
        linear-gradient(145deg, rgba(17, 32, 56, 0.93), rgba(6, 13, 27, 0.96)),
        var(--panel-deep);
    box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.035);
    backdrop-filter: blur(18px);
}

.login-panel::before {
    position: absolute;
    inset: 10px;
    z-index: -1;
    content: "";
    border: 1px solid rgba(255, 255, 255, 0.025);
    border-radius: 7px;
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 15px;
    height: 15px;
    border-color: var(--cyan);
    opacity: 0.8;
}

.corner-tl { top: -2px; left: -2px; border-top: 2px solid; border-left: 2px solid; }
.corner-tr { top: -2px; right: -2px; border-top: 2px solid; border-right: 2px solid; }
.corner-bl { bottom: -2px; left: -2px; border-bottom: 2px solid; border-left: 2px solid; }
.corner-br { right: -2px; bottom: -2px; border-right: 2px solid; border-bottom: 2px solid; }

.panel-kicker {
    margin: 0 0 8px;
    color: var(--cyan);
    font-size: 0.69rem;
    font-weight: 800;
}

.login-heading h2,
.success-state h2 {
    margin: 0;
    font-size: clamp(1.45rem, 2.7vw, 2rem);
    letter-spacing: -0.035em;
}

.login-heading > p:last-child,
.success-copy {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.91rem;
    line-height: 1.6;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 22px 0 -2px;
    padding: 12px 13px;
    border: 1px solid rgba(255, 112, 133, 0.35);
    border-radius: 7px;
    color: #ffc5cd;
    background: rgba(255, 112, 133, 0.08);
}

.error-message > span {
    display: grid;
    flex: 0 0 23px;
    height: 23px;
    place-items: center;
    border: 1px solid var(--red);
    border-radius: 50%;
    color: var(--red);
    font-family: monospace;
    font-weight: 800;
}

.error-message p {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
}

.error-message strong {
    display: block;
    color: #ffe9ec;
}

.login-form {
    margin-top: 27px;
}

.login-form label,
.label-row {
    color: #c5d2e4;
    font-size: 0.75rem;
    font-weight: 700;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
}

.label-row span {
    color: #60718a;
    font-size: 0.54rem;
}

.input-shell {
    display: flex;
    align-items: center;
    height: 52px;
    margin-top: 8px;
    border: 1px solid rgba(141, 169, 205, 0.24);
    border-radius: 7px;
    background: rgba(2, 8, 18, 0.58);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-shell:focus-within {
    border-color: rgba(82, 240, 229, 0.75);
    background: rgba(3, 12, 24, 0.85);
    box-shadow: 0 0 0 3px rgba(82, 240, 229, 0.08), inset 0 0 16px rgba(82, 240, 229, 0.035);
}

.input-icon {
    display: grid;
    width: 46px;
    align-self: stretch;
    place-items: center;
    color: var(--cyan);
    font-family: monospace;
    font-weight: 800;
}

.input-shell input {
    width: 100%;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font: inherit;
    font-size: 0.91rem;
}

.input-shell input::placeholder {
    color: #52637a;
}

.reveal-button {
    align-self: stretch;
    padding: 0 15px;
    border: 0;
    color: #7e91ab;
    background: transparent;
    font-size: 0.7rem;
    cursor: pointer;
}

.reveal-button:hover {
    color: var(--cyan-bright);
}

.start-button,
.secondary-button {
    width: 100%;
    min-height: 52px;
    border-radius: 7px;
    font: inherit;
    font-weight: 850;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.start-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 23px;
    border: 1px solid var(--cyan-bright);
    color: #041515;
    background: linear-gradient(100deg, var(--cyan) 0%, #91fff7 52%, #55e4da 100%);
    box-shadow: 0 10px 30px rgba(45, 217, 206, 0.19), inset 0 1px rgba(255, 255, 255, 0.55);
}

.start-button:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
    box-shadow: 0 14px 40px rgba(45, 217, 206, 0.29), inset 0 1px rgba(255, 255, 255, 0.6);
}

.start-button:active,
.secondary-button:active {
    transform: translateY(1px);
}

.start-button:disabled {
    cursor: wait;
    filter: saturate(0.5);
}

.button-arrow {
    font-size: 0.7rem;
}

.security-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
    color: #6d8098;
}

.security-note .shield {
    color: var(--cyan);
}

.security-note p {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.55;
}

.security-note strong {
    display: block;
    color: #9dafc5;
}

.security-note.insecure-note,
.security-note.insecure-note .shield,
.security-note.insecure-note strong {
    color: var(--yellow);
}

.random-tip {
    margin: 25px 0 0;
    padding-top: 16px;
    border-top: 1px dashed rgba(133, 160, 195, 0.17);
    color: #63768e;
    font-family: monospace;
    font-size: 0.65rem;
    line-height: 1.5;
}

.success-state {
    text-align: center;
}

.avatar-orbit {
    display: grid;
    width: 92px;
    height: 92px;
    margin: 0 auto 22px;
    place-items: center;
    border: 1px dashed rgba(82, 240, 229, 0.42);
    border-radius: 50%;
    animation: orbit 13s linear infinite;
}

.avatar {
    display: grid;
    width: 68px;
    height: 68px;
    place-items: center;
    border: 1px solid rgba(255, 220, 94, 0.34);
    border-radius: 50%;
    background: rgba(255, 220, 94, 0.08);
    box-shadow: 0 0 35px rgba(255, 220, 94, 0.14);
    font-size: 2rem;
    animation: orbit-reverse 13s linear infinite;
}

.character-card {
    margin: 27px 0 20px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: left;
    background: rgba(2, 8, 18, 0.43);
}

.character-card div {
    display: grid;
    grid-template-columns: 95px 1fr;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 0.74rem;
}

.character-card div:last-child {
    border-bottom: 0;
}

.character-card span {
    color: var(--muted);
}

.character-card strong {
    color: #dce9f8;
}

.secondary-button {
    border: 1px solid rgba(82, 240, 229, 0.32);
    color: var(--cyan-bright);
    background: rgba(82, 240, 229, 0.07);
}

.secondary-button:hover {
    transform: translateY(-2px);
    border-color: rgba(82, 240, 229, 0.68);
    background: rgba(82, 240, 229, 0.12);
}

footer {
    display: flex;
    justify-content: space-between;
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 0 0 22px;
    color: #45566d;
    font-size: 0.56rem;
}

@keyframes drift {
    0%, 100% { transform: translate(0, 0); opacity: 0.25; }
    50% { transform: translate(15px, -20px); opacity: 0.85; }
}

@keyframes reveal-dots {
    from { width: 0; }
    to { width: 0.75em; }
}

@keyframes orbit {
    to { transform: rotate(360deg); }
}

@keyframes orbit-reverse {
    to { transform: rotate(-360deg); }
}

@media (max-width: 900px) {
    .game-shell {
        grid-template-columns: 1fr;
        gap: 38px;
        width: min(680px, calc(100% - 34px));
        padding-top: 30px;
    }

    footer {
        width: min(680px, calc(100% - 34px));
        padding-top: 24px;
    }
}

@media (max-width: 640px) {
    body {
        min-height: 100svh;
        min-height: 100dvh;
    }

    .game-shell {
        display: flex;
        flex-direction: column;
        gap: 0;
        width: 100%;
        min-height: 100svh;
        min-height: 100dvh;
        padding: max(24px, env(safe-area-inset-top)) 0 0;
        align-items: stretch;
    }

    .story-panel {
        flex: 0 0 auto;
        padding: 8px max(22px, env(safe-area-inset-right)) 30px max(22px, env(safe-area-inset-left));
    }

    h1 {
        font-size: clamp(2.08rem, 10.5vw, 3.2rem);
        letter-spacing: -0.055em;
    }

    .english-title {
        margin-bottom: 15px;
        font-size: 1.25rem;
    }

    .program-name {
        font-size: 0.92rem;
        line-height: 1.58;
    }

    .login-panel {
        flex: 1 0 auto;
        width: 100%;
        padding: 30px max(22px, env(safe-area-inset-right)) calc(26px + env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 26px 26px 0 0;
        box-shadow: 0 -18px 55px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.035);
        backdrop-filter: none;
    }

    .login-panel::before {
        inset: 10px 10px 0;
        border-bottom: 0;
        border-radius: 18px 18px 0 0;
    }

    .corner-bl,
    .corner-br {
        display: none;
    }

    .input-shell,
    .start-button,
    .secondary-button {
        min-height: 56px;
    }

    .input-shell input {
        font-size: 1rem;
    }

    footer {
        display: none;
    }
}

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