:root {
    --bg: #020403;
    --panel: rgba(5, 18, 10, 0.86);
    --panel-strong: rgba(10, 30, 16, 0.94);
    --line: rgba(131, 255, 168, 0.18);
    --text: #8dff9e;
    --text-dim: #5abf73;
    --accent: #c8ff72;
    --danger: #ff7a7a;
    --shadow: 0 0 24px rgba(64, 255, 127, 0.12);
    --font-main: "Courier New", "Lucida Console", monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top, rgba(60, 120, 60, 0.18), transparent 32%),
        linear-gradient(180deg, #030504 0%, #010201 100%);
    color: var(--text);
    font-family: var(--font-main);
}

body {
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.03) 0,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 4px
    );
    pointer-events: none;
    opacity: 0.18;
}

.screen-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.08), transparent 16%, rgba(0, 0, 0, 0.12) 34%, transparent 60%),
        radial-gradient(circle at 50% 20%, rgba(113, 255, 171, 0.06), transparent 45%);
    mix-blend-mode: screen;
}

.terminal-shell,
.admin-shell,
.admin-login {
    position: relative;
    width: min(1040px, calc(100% - 24px));
    margin: 24px auto;
    padding: 20px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow), inset 0 0 32px rgba(108, 255, 157, 0.05);
}

.hero,
.admin-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.boot-line,
.subtitle,
.mode-label,
.meter-name,
.meter-value,
.ghost-link,
.prompt,
button,
input {
    letter-spacing: 0.08em;
}

.boot-line,
.subtitle,
.mode-label,
.meter-value,
.pet-box p {
    color: var(--text-dim);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    text-shadow: 0 0 14px rgba(123, 255, 150, 0.2);
}

h2 {
    margin-bottom: 14px;
    font-size: 1rem;
    color: var(--accent);
}

.status-panel,
.chat-panel,
.meter-panel,
.word-table-wrap,
.admin-status,
.admin-actions {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
}

.status-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
    gap: 16px;
}

.mode-box strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(1.5rem, 3vw, 2.3rem);
    color: var(--accent);
}

.pet-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    min-height: 120px;
}

.pet-face {
    font-size: clamp(2rem, 6vw, 3.5rem);
    color: var(--accent);
    animation: blink 1.3s steps(2, end) infinite;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 320px;
    max-height: 48vh;
    overflow-y: auto;
    padding-right: 6px;
}

.line {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 12px;
    align-items: start;
}

.speaker {
    color: var(--accent);
}

.line p {
    line-height: 1.6;
    word-break: break-word;
}

.line.user p {
    color: #d8ffe3;
}

.line.pet p {
    color: var(--text);
}

.line.system p {
    color: var(--text-dim);
}

.chat-form {
    margin-top: 16px;
}

.input-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}

input,
button,
.ghost-link {
    border: 1px solid var(--line);
    background: #051108;
    color: var(--text);
    font: inherit;
}

input {
    width: 100%;
    padding: 12px 14px;
    outline: none;
}

input:focus {
    border-color: rgba(200, 255, 114, 0.75);
    box-shadow: 0 0 0 1px rgba(200, 255, 114, 0.35);
}

button,
.ghost-link {
    padding: 12px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
}

button:hover,
.ghost-link:hover {
    background: #0b2310;
    color: var(--accent);
}

.meter-grid {
    display: grid;
    gap: 12px;
}

.meter-row {
    display: grid;
    grid-template-columns: 88px 1fr 42px;
    gap: 10px;
    align-items: center;
}

.meter-track {
    height: 12px;
    border: 1px solid var(--line);
    background: rgba(3, 9, 5, 0.85);
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #48ef77 0%, #cbff78 100%);
    box-shadow: 0 0 16px rgba(127, 255, 126, 0.2);
    transition: width 0.24s ease;
}

.admin-body {
    padding-bottom: 32px;
}

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

.admin-actions form,
.word-table form {
    margin: 0;
}

.word-table {
    width: 100%;
    border-collapse: collapse;
}

.word-table th,
.word-table td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.login-form {
    display: grid;
    gap: 10px;
    max-width: 360px;
}

.error-text {
    color: var(--danger);
    margin: 8px 0 12px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes blink {
    0%,
    45%,
    100% {
        opacity: 1;
    }
    50%,
    55% {
        opacity: 0.18;
    }
}

@media (max-width: 760px) {
    .terminal-shell,
    .admin-shell,
    .admin-login {
        width: min(100% - 14px, 100%);
        margin: 8px auto;
        padding: 14px;
    }

    .status-panel {
        grid-template-columns: 1fr;
    }

    .input-wrap,
    .meter-row,
    .line {
        grid-template-columns: 1fr;
    }

    .prompt {
        display: none;
    }

    .speaker {
        margin-bottom: -6px;
    }

    button,
    .ghost-link {
        text-align: center;
    }
}
