:root {
    color-scheme: dark;
    --ink: #080806;
    --panel: #11100d;
    --panel-raised: #191712;
    --bone: #e7dfcf;
    --muted: #8e887b;
    --brass: #b79a58;
    --brass-bright: #dbc478;
    --rust: #9d3d2e;
    --blood: #cf4b3d;
    --signal: #d9b85d;
    --border: rgba(218, 196, 120, 0.25);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--ink);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    color: var(--bone);
    background: #060705 url("assets/background.jpg") center / cover fixed no-repeat;
}

body::before {
    content: "";
    position: fixed;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 12%, rgba(224, 210, 151, 0.14), transparent 26%),
        radial-gradient(ellipse at center, transparent 22%, rgba(0, 0, 0, 0.58) 72%, rgba(0, 0, 0, 0.92) 100%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(2, 3, 2, 0.78));
}

body::after {
    content: "";
    position: fixed;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    opacity: 0.14;
    background-image:
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.018) 3px 4px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.01) 0 1px, transparent 1px 5px);
    mix-blend-mode: screen;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

.atmosphere {
    position: fixed;
    z-index: 0;
    top: -8vh;
    left: 50%;
    width: min(70vw, 780px);
    height: 36vh;
    transform: translateX(-50%);
    pointer-events: none;
    background: linear-gradient(180deg, rgba(224, 213, 164, 0.16), transparent 82%);
    clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
    filter: blur(22px);
    animation: overhead-flicker 9s infinite;
}

.experience-shell {
    position: relative;
    z-index: 1;
    width: min(100% - 2rem, 960px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 2.5rem 0 1.25rem;
}

.brand-header {
    margin-bottom: 1.2rem;
    text-align: center;
    text-shadow: 0 3px 18px #000;
}

.eyebrow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin: 0 0 0.25rem;
    color: var(--brass);
    font-family: "Courier New", monospace;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.22em;
}

.eyebrow span {
    width: 2.5rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brass));
}

.eyebrow span:last-child {
    transform: rotate(180deg);
}

.brand-header h1 {
    margin: 0;
    color: #eee6d7;
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 900;
    letter-spacing: 0.055em;
    line-height: 0.98;
    text-transform: uppercase;
}

.tagline {
    margin: 0.45rem 0 0;
    color: #aaa396;
    font-family: Georgia, serif;
    font-size: clamp(0.84rem, 2vw, 1rem);
    font-style: italic;
}

.character-stage {
    position: relative;
    width: min(100%, 860px);
    margin: 0 auto;
}

.frame-outer {
    position: relative;
    padding: clamp(0.5rem, 1.2vw, 0.8rem);
    border: 1px solid #55472d;
    border-radius: 0.9rem;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 18% 74%, rgba(255, 255, 255, 0.04)),
        repeating-linear-gradient(90deg, #282116 0 4px, #1d180f 4px 9px, #322719 9px 13px);
    box-shadow:
        0 0 0 3px #090806,
        0 0 0 4px #3f3423,
        0 1.8rem 4rem rgba(0, 0, 0, 0.78),
        inset 0 0 1rem #000;
}

.frame-screw {
    position: absolute;
    z-index: 4;
    width: 0.62rem;
    height: 0.62rem;
    border: 1px solid #0d0c09;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #8a7a5b, #30291d 52%, #111 54%);
    box-shadow: 0 1px 2px #000;
}

.frame-screw::after {
    content: "";
    position: absolute;
    top: 48%;
    left: 14%;
    width: 72%;
    height: 1px;
    transform: rotate(-25deg);
    background: #17140f;
}

.screw-top-left { top: 0.28rem; left: 0.3rem; }
.screw-top-right { top: 0.28rem; right: 0.3rem; }
.screw-bottom-left { bottom: 0.28rem; left: 0.3rem; }
.screw-bottom-right { right: 0.3rem; bottom: 0.28rem; }

.video-container {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border: 1px solid rgba(220, 200, 148, 0.16);
    border-radius: 0.45rem;
    background: #050504;
    box-shadow: inset 0 0 2.5rem rgba(0, 0, 0, 0.72);
}

.video-box {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.78) contrast(1.1) brightness(0.82) sepia(0.08);
}

body[data-character-state="speaking"] .video-box {
    filter: saturate(0.98) contrast(1.12) brightness(0.92) sepia(0.04);
}

.screen-grain {
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
    opacity: 0.34;
    background:
        linear-gradient(90deg, rgba(110, 30, 21, 0.08), transparent 18% 82%, rgba(110, 30, 21, 0.08)),
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.1) 0 1px, transparent 1px 4px);
    box-shadow: inset 0 0 4rem #000;
}

.status-plaque {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    width: min(82%, 560px);
    min-height: 2.55rem;
    margin: -0.3rem auto 0;
    padding: 0.55rem 0.85rem;
    border: 1px solid #6d5934;
    border-radius: 0.22rem;
    color: #1a160e;
    background:
        linear-gradient(rgba(255, 255, 255, 0.18), transparent 36%),
        repeating-linear-gradient(90deg, #a88948 0 2px, #b89852 2px 5px, #9a7b3f 5px 7px);
    box-shadow: 0 0.45rem 1rem rgba(0, 0, 0, 0.62), inset 0 0 0 1px rgba(255, 245, 193, 0.3);
    font-family: "Courier New", monospace;
    font-size: clamp(0.64rem, 2vw, 0.76rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.status-light {
    width: 0.54rem;
    height: 0.54rem;
    margin-right: 0.6rem;
    border: 1px solid rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    background: #354326;
    box-shadow: 0 0 0.45rem #7e9b4d;
}

.status-plaque[data-state="thinking"] .status-light {
    background: #9f7021;
    box-shadow: 0 0 0.65rem #f0b943;
    animation: status-pulse 0.75s infinite alternate;
}

.status-plaque[data-state="speaking"] .status-light {
    background: #9e2c24;
    box-shadow: 0 0 0.65rem #ef493b;
    animation: status-pulse 0.35s infinite alternate;
}

.status-plaque[data-state="error"] .status-light {
    background: #711d19;
    box-shadow: 0 0 0.5rem #ef493b;
}

.waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 1rem;
    margin-left: auto;
}

.waveform i {
    width: 2px;
    height: 20%;
    background: #282014;
}

.status-plaque[data-state="thinking"] .waveform i,
.status-plaque[data-state="speaking"] .waveform i {
    animation: wave 0.72s ease-in-out infinite alternate;
}

.waveform i:nth-child(2n) { animation-delay: -0.3s !important; }
.waveform i:nth-child(3n) { animation-delay: -0.5s !important; }
.waveform i:nth-child(4n) { animation-delay: -0.15s !important; }

.chat-container {
    position: relative;
    width: min(100%, 900px);
    margin: 1.1rem auto 0;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.028), transparent 30%),
        rgba(11, 10, 8, 0.94);
    box-shadow: 0 1.2rem 3rem rgba(0, 0, 0, 0.65), inset 0 0 2.5rem rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
}

.chat-container::before {
    content: "";
    position: absolute;
    inset: 0.28rem;
    pointer-events: none;
    border: 1px solid rgba(183, 154, 88, 0.08);
    border-radius: 0.35rem;
}

.chat-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.25rem 0.65rem;
    border-bottom: 1px solid rgba(183, 154, 88, 0.13);
}

.chat-header > div {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.chat-kicker {
    color: var(--brass-bright);
    font-family: "Courier New", monospace;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.18em;
}

.memory-label {
    color: #6f6a61;
    font-size: 0.68rem;
}

.clear-chat {
    border: 0;
    color: #8c877d;
    cursor: pointer;
    background: transparent;
    font-size: 0.72rem;
    text-decoration: underline;
    text-decoration-color: rgba(183, 154, 88, 0.32);
    text-underline-offset: 0.2rem;
}

.clear-chat:hover:not(:disabled) {
    color: var(--bone);
}

.clear-chat:disabled {
    cursor: default;
    opacity: 0.3;
}

.prompt-suggestions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.7rem 0.2rem 0.1rem;
}

.prompt-suggestions button {
    padding: 0.48rem 0.72rem;
    border: 1px solid rgba(183, 154, 88, 0.28);
    border-radius: 99px;
    color: #bdb4a2;
    cursor: pointer;
    background: rgba(183, 154, 88, 0.055);
    font-size: 0.72rem;
    transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.prompt-suggestions button:hover {
    border-color: rgba(219, 196, 120, 0.6);
    color: #efe2c4;
    background: rgba(183, 154, 88, 0.12);
}

.chat-log {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.62rem;
    min-height: 3.3rem;
    max-height: 13rem;
    padding: 0.85rem 0.2rem;
    overflow-y: auto;
    scrollbar-color: #5e4d31 transparent;
}

.chat-log:empty::before {
    content: "The fish is awake. That was your first mistake.";
    align-self: center;
    padding: 0.2rem;
    color: #69655d;
    font-family: Georgia, serif;
    font-size: 0.78rem;
    font-style: italic;
}

.message {
    width: fit-content;
    max-width: min(86%, 680px);
    padding: 0.62rem 0.76rem;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 0.65rem;
    color: #d8d2c6;
    background: #191815;
    font-size: clamp(0.82rem, 1.8vw, 0.94rem);
    line-height: 1.42;
    animation: message-enter 180ms ease-out both;
}

.message strong {
    color: #f1eadc;
    font-family: "Arial Narrow", sans-serif;
    font-size: 0.72em;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.message-user {
    align-self: flex-end;
    border-color: rgba(183, 154, 88, 0.19);
    border-bottom-right-radius: 0.15rem;
    color: #c9c2b5;
    background: #242018;
}

.message-billy {
    align-self: flex-start;
    border-color: rgba(157, 61, 46, 0.3);
    border-bottom-left-radius: 0.15rem;
    color: #f0c0b6;
    background: linear-gradient(135deg, rgba(157, 61, 46, 0.19), rgba(28, 15, 13, 0.96));
}

.message-billy strong {
    color: #ef6d5c;
}

.message-error {
    align-self: flex-start;
    border-color: rgba(207, 75, 61, 0.38);
    color: #ffaaa4;
    background: rgba(92, 23, 18, 0.34);
}

.message-notice {
    align-self: center;
    border: 0;
    color: #8e887b;
    background: transparent;
    font-size: 0.72rem;
    font-style: italic;
}

.chat-form {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0.6rem;
    padding-top: 0.72rem;
    border-top: 1px solid rgba(183, 154, 88, 0.13);
}

.input-shell {
    position: relative;
    min-width: 0;
    flex: 1;
}

.input-prompt {
    position: absolute;
    top: 50%;
    left: 0.85rem;
    transform: translateY(-50%);
    color: var(--rust);
    font-family: "Courier New", monospace;
    font-weight: 900;
}

.chat-input {
    width: 100%;
    height: 3rem;
    padding: 0 0.9rem 0 1.75rem;
    border: 1px solid #383227;
    border-radius: 0.35rem;
    color: #f2eadc;
    caret-color: var(--blood);
    background: #0b0b09;
    box-shadow: inset 0 0 1.2rem rgba(0, 0, 0, 0.72);
}

.chat-input::placeholder {
    color: #68645c;
}

.chat-submit {
    position: relative;
    min-width: 8.3rem;
    height: 3rem;
    padding: 0 1.1rem;
    overflow: hidden;
    border: 1px solid #6e241c;
    border-radius: 0.35rem;
    color: #f5ded8;
    font-family: "Arial Narrow", sans-serif;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 42%),
        #7d2a20;
    box-shadow: inset 0 0 0 1px rgba(255, 165, 143, 0.08), 0 0.3rem 0.8rem rgba(0, 0, 0, 0.35);
}

.chat-submit:hover:not(:disabled) {
    color: #fff;
    background-color: #9f382c;
}

.chat-submit:active:not(:disabled) {
    transform: translateY(1px);
}

.chat-submit:disabled,
.chat-input:disabled {
    cursor: wait;
    opacity: 0.58;
}

.chat-input:focus-visible,
.chat-submit:focus-visible,
.prompt-suggestions button:focus-visible,
.clear-chat:focus-visible {
    outline: 2px solid var(--brass-bright);
    outline-offset: 2px;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    width: min(100%, 900px);
    margin: 0.7rem auto 0;
    color: #555149;
    font-family: "Courier New", monospace;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
}

.footer-mark {
    text-align: right;
}

.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 overhead-flicker {
    0%, 17%, 20%, 51%, 54%, 100% { opacity: 0.85; }
    18%, 52% { opacity: 0.42; }
    19%, 53% { opacity: 0.7; }
}

@keyframes status-pulse {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

@keyframes wave {
    from { height: 18%; }
    to { height: 92%; }
}

@keyframes message-enter {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
    body {
        background-attachment: scroll;
    }

    .experience-shell {
        width: min(100% - 1rem, 960px);
        padding-top: 1.15rem;
    }

    .brand-header {
        margin-bottom: 0.8rem;
    }

    .tagline {
        margin-top: 0.28rem;
    }

    .frame-outer {
        padding: 0.4rem;
        border-radius: 0.6rem;
    }

    .status-plaque {
        width: 92%;
        min-height: 2.25rem;
    }

    .chat-container {
        margin-top: 0.85rem;
        padding: 0.7rem;
    }

    .memory-label {
        display: none;
    }

    .chat-log {
        max-height: 32vh;
    }

    .message {
        max-width: 92%;
    }

    .chat-form {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-submit {
        width: 100%;
    }

    .site-footer {
        padding: 0 0.2rem;
    }
}

@media (max-height: 760px) and (min-width: 641px) {
    .experience-shell {
        padding-top: 1rem;
    }

    .brand-header h1 {
        font-size: 2.4rem;
    }

    .tagline {
        display: none;
    }

    .character-stage {
        width: min(76vh, 760px);
    }

    .chat-log {
        max-height: 8rem;
    }
}

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