/* ============ 磷光终端 ============ */
:root {
    --bg: #030605;
    --ph: #33ff88;
    --ph-dim: rgba(51, 255, 136, 0.55);
    --ph-faint: rgba(51, 255, 136, 0.14);
    --glow: 0 0 6px rgba(51, 255, 136, 0.55), 0 0 18px rgba(51, 255, 136, 0.25);
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "PingFang SC", "Microsoft YaHei", monospace;
    --gutter: clamp(16px, 4vw, 56px);
}

body.amber {
    --ph: #ffb347;
    --ph-dim: rgba(255, 179, 71, 0.55);
    --ph-faint: rgba(255, 179, 71, 0.14);
    --glow: 0 0 6px rgba(255, 179, 71, 0.55), 0 0 18px rgba(255, 179, 71, 0.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--ph);
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.6;
    text-shadow: var(--glow);
    overflow-x: hidden;
}

body.booting { overflow: hidden; }

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

a:hover { background: var(--ph); color: var(--bg); text-shadow: none; }

canvas { display: block; }

::selection { background: var(--ph); color: var(--bg); text-shadow: none; }

/* ============ CRT ============ */
.crt {
    position: fixed;
    inset: 0;
    z-index: 150;
    pointer-events: none;
    background:
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.28) 3px),
        radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.75) 100%);
    animation: flicker 0.12s infinite alternate;
}

.crt::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.9);
    border-radius: 18px;
}

.crt-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 18vh;
    background: linear-gradient(to bottom, transparent, var(--ph-faint) 50%, transparent);
    opacity: 0.35;
    animation: refresh 7s linear infinite;
}

@keyframes flicker {
    from { opacity: 0.94; }
    to { opacity: 1; }
}

@keyframes refresh {
    from { transform: translateY(-20vh); }
    to { transform: translateY(120vh); }
}

/* 开机 */
.boot {
    position: fixed;
    inset: 0;
    z-index: 140;
    background: var(--bg);
    padding: var(--gutter);
    overflow: hidden;
    font-size: 13px;
}

.boot pre { white-space: pre-wrap; font-family: inherit; }

.boot.off { display: none; }

#screen, .bar, .footer { transform-origin: center; }

.booting #screen, .booting .bar, .booting .footer { visibility: hidden; }

.power-on #screen { animation: powerOn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both; }

@keyframes powerOn {
    0% { transform: scale(1, 0.004); filter: brightness(6); }
    40% { transform: scale(1, 0.004); filter: brightness(6); }
    70% { transform: scale(1, 1.04); filter: brightness(1.6); }
    100% { transform: none; filter: none; }
}

.matrix {
    position: fixed;
    inset: 0;
    z-index: 130;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s;
}

.matrix.on { opacity: 1; }

/* ============ 顶栏 ============ */
.bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 6px var(--gutter);
    background: var(--bg);
    border-bottom: 1px solid var(--ph-faint);
    font-size: 12px;
    white-space: nowrap;
}

.bar-id { background: var(--ph); color: var(--bg); text-shadow: none; padding: 0 6px; }

.bar-nav { display: flex; gap: 18px; }

.bar-right { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ============ 通用 ============ */
.prompt { white-space: pre-wrap; word-break: break-all; }

.ps1 { color: var(--ph); font-weight: 700; }

.comment { color: var(--ph-dim); }

.caret {
    display: inline-block;
    width: 0.62em;
    height: 1.15em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--ph);
    box-shadow: var(--glow);
    animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.ascii-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ============ Hero ============ */
.hero {
    position: relative;
    height: 100vh;
    height: 100svh;
    min-height: 560px;
    overflow: hidden;
    touch-action: pan-y;
}

.hero-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 80px var(--gutter) 0;
    pointer-events: none;
}

.ascii-title {
    font-family: var(--mono);
    font-size: var(--fs, 8px);
    line-height: 1;
    letter-spacing: 0;
    white-space: pre;
    color: var(--ph);
    text-shadow: 0 0 4px var(--ph), 0 0 16px var(--ph-dim);
    align-self: flex-start;
}

.hero-sub { color: var(--ph-dim); }

.status-line {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    gap: 20px;
    padding: 4px var(--gutter);
    background: var(--ph);
    color: var(--bg);
    text-shadow: none;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
}

.status-line .mode { font-weight: 700; }

.status-line .grow { flex: 1; }

/* ============ 宣言 ============ */
.manifesto {
    min-height: 100vh;
    display: flex;
    align-items: center;
    border-top: 1px dashed var(--ph-faint);
}

.wrap { padding: 120px var(--gutter); width: 100%; }

.type-block {
    margin-top: 28px;
    font-size: clamp(22px, 3.6vw, 48px);
    line-height: 1.5;
    min-height: 10em;
}

.type-block p { min-height: 1.5em; }

.type-block .eof { color: var(--ph-dim); font-size: 0.5em; }

/* ============ 场景 ============ */
.scene {
    position: relative;
    height: 100vh;
    height: 100svh;
    min-height: 560px;
    overflow: hidden;
    border-top: 1px dashed var(--ph-faint);
    touch-action: pan-y;
}

.scene-head {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 80px var(--gutter) 0;
    pointer-events: none;
}

.scene-title {
    font-size: clamp(56px, 12vw, 180px);
    line-height: 0.9;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.hint { color: var(--ph-dim); }

.scene-stats {
    position: absolute;
    right: var(--gutter);
    bottom: 24px;
    z-index: 2;
    display: flex;
    gap: 22px;
    padding: 4px 10px;
    background: rgba(3, 6, 5, 0.75);
    font-variant-numeric: tabular-nums;
}

.scene-stats b { font-weight: 400; }

/* ============ 终端 ============ */
.shell-sec {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    padding: 100px var(--gutter);
    border-top: 1px dashed var(--ph-faint);
}

.term {
    width: 100%;
    max-width: 1000px;
    border: 1px solid var(--ph-dim);
    box-shadow: 0 0 30px var(--ph-faint), inset 0 0 40px var(--ph-faint);
}

.term-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--ph-dim);
    font-size: 12px;
}

.term-bar i { width: 10px; height: 10px; border: 1px solid var(--ph); border-radius: 50%; }

.term-bar span { margin-left: 10px; color: var(--ph-dim); }

.term-body {
    height: min(60vh, 520px);
    overflow-y: auto;
    padding: 14px 16px;
    cursor: text;
    scrollbar-width: thin;
    scrollbar-color: var(--ph-dim) transparent;
}

#termOut > div { white-space: pre-wrap; word-break: break-word; }

#termOut .err { color: #ff5f5f; text-shadow: 0 0 6px rgba(255, 95, 95, 0.5); }

#termOut .dim { color: var(--ph-dim); }

.term-line { position: relative; display: flex; gap: 10px; }

.term-input-wrap { white-space: pre; }

.term-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    font-size: 16px;
    border: 0;
    background: transparent;
}

/* ============ 页脚 ============ */
.footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding: 18px var(--gutter);
    border-top: 1px solid var(--ph-faint);
    font-size: 12px;
    color: var(--ph-dim);
}

.tip-touch { display: none; }

@media (max-width: 760px) {
    .bar-nav { display: none; }
    .status-line span:nth-child(2) { display: none; }
}

@media (pointer: coarse) {
    .tip-desktop { display: none; }
    .tip-touch { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .crt, .crt-bar, .caret { animation: none; }
    .power-on #screen { animation: none; }
}
