:root {
    --bg: #0a0e0a;
    --ink: #b8f0c0;
    --ink-dim: #5f8a66;
    --amber: #f0c674;
    --bad: #e06c75;
    --ok: #98c379;
    --panel: #0f1610;
    --line: #1c2a1e;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Consolas', 'SF Mono', 'Menlo', monospace;
    line-height: 1.6;
}

.terminal {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem 4rem;
    /* Without this the padding is added on top of the 100vh, which overflows the viewport by
       exactly 6rem and leaves a scrollbar on a screen that has nothing left to scroll to. */
    box-sizing: border-box;
}

.screen {
    width: 100%;
    max-width: 760px;
}

.title {
    font-size: 1.1rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.7em;
    /* The mark inherits this through currentColor; only the rotor's index tick breaks out of it. */
    color: var(--ink);
}

.logo-mark {
    width: 1.7em;
    height: 1.7em;
    flex: none;
}

.logo-text {
    letter-spacing: 0.35em;
    color: var(--amber);
    /* letter-spacing pads the last glyph too, which visually pulls the lockup off-centre. */
    margin-right: -0.35em;
}

/* Narrow phones: the wordmark plus a 0.35em gap after every letter no longer fits on one line. */
@media (max-width: 400px) {
    .title { font-size: 0.95rem; }
    .logo-text { letter-spacing: 0.2em; margin-right: -0.2em; }
}

.chapter {
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    margin: 0 0 0.5rem;
}

.narration {
    white-space: pre-wrap;
    margin-bottom: 1.5rem;
}

.puzzle, .choices, .ending {
    border-top: 1px solid var(--line);
    padding-top: 1.25rem;
    margin-top: 1.25rem;
}

.label {
    color: var(--ink-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.4rem;
}

.cipher {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 1rem;
    color: var(--amber);
    letter-spacing: 0.15em;
    white-space: pre-wrap;
    word-break: break-word;
}

.solve {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.answer {
    flex: 1 1 320px;
    background: #060906;
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 0.6rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
}

.answer:focus { outline: 1px solid var(--ink-dim); }

.btn {
    background: transparent;
    border: 1px solid var(--ink-dim);
    color: var(--ink);
    padding: 0.6rem 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.btn:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.ghost { border-color: var(--line); color: var(--ink-dim); }

.choices { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }

.tools { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

.feedback { margin-top: 0.75rem; }
.feedback.bad { color: var(--bad); }
.feedback.ok { color: var(--ok); }

.assistant {
    margin-top: 1rem;
    padding: 0.6rem 0.75rem;
    border-left: 2px solid var(--ink-dim);
    background: var(--panel);
}

.assistant .who {
    color: var(--ink-dim);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    margin-right: 0.5rem;
}

/* A faint cue that the assistant's help may not be trustworthy. */
.assistant.uneasy { border-left-color: var(--bad); animation: flicker 3s infinite; }
@keyframes flicker { 0%,97%,100% { opacity: 1; } 98% { opacity: 0.6; } }

.freq {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    margin-top: 1rem;
    height: 130px;
    border-bottom: 1px solid var(--line);
}

.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar .fill { width: 16px; background: var(--ink-dim); }
.bar .letter { font-size: 0.65rem; color: var(--ink-dim); margin-top: 2px; }

.ending .fin { color: var(--amber); letter-spacing: 0.2em; }

/* Web purchase: withdrawal consent and receipt restore on the unlock screen. */
.unlock .consent {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin: 1rem 0 0;
    color: var(--ink-dim);
    font-size: 0.9rem;
    cursor: pointer;
}
.unlock .consent input { margin-top: 0.2rem; accent-color: var(--amber); }
.unlock .restore { margin-top: 1.5rem; color: var(--ink-dim); }
.unlock .restore summary { cursor: pointer; }
/* Saved progress: the continue offer on the opening screen and the code under each scene. */
.resume { margin: 0 0 1.25rem; color: var(--ink-dim); }
.resume .restore { margin-top: 0.75rem; }
.resume .restore summary { cursor: pointer; }
.resume-code {
    border-top: 1px solid var(--line);
    margin-top: 1.5rem;
    padding-top: 0.75rem;
    color: var(--ink-dim);
    font-size: 0.8rem;
}
.resume-code code { color: var(--amber); letter-spacing: 0.15em; }
.loading { color: var(--ink-dim); }

.machine {
    margin-top: 1rem;
    border: 1px solid var(--line);
    padding: 0.9rem;
    background: var(--panel);
}

.dials { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.dial {
    background: #060906;
    border: 1px solid var(--ink-dim);
    color: var(--amber);
    font-family: inherit;
    font-size: 1.1rem;
    padding: 0.4rem 0.5rem;
}

.cipher.decoded { color: var(--ok); margin-top: 0.9rem; }

/* Blazor framework elements, themed dark. */
#blazor-error-ui {
    background: #2a1414;
    color: var(--bad);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .reload { color: var(--amber); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--line);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--amber);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--ink-dim);
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

/* Persistent AI disclosure + privacy link. Fixed, so it never adds to the page height; the
   terminal's 4rem bottom padding leaves room for it. */
.legal {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    border-top: 1px solid var(--line);
    color: var(--ink-dim);
    font-size: 0.7rem;
}

/* Not scoped to .legal — the language switch inside the notice uses it too. */
.linklike {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--amber);
    text-decoration: underline;
    cursor: pointer;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
    overflow-y: auto;
}

.overlay-panel {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    max-width: 680px;
    width: 100%;
    margin: auto;
    padding: 1.5rem;
}

.overlay-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* Keep the heading clear of the close button. */
.legal-doc h1 { padding-right: 6rem; }

/* The router's FocusOnNavigate puts focus on the first h1, which would otherwise draw a focus
   ring around the heading. Keyboard users still get rings on the controls that need them. */
h1:focus { outline: none; }

.lang-switch {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    color: var(--ink-dim);
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.lang-switch .current {
    color: var(--ink);
    text-decoration: none;
    cursor: default;
}

/* Legal copy: readable prose, still unmistakably the same terminal. */
.legal-doc h1 { font-size: 1rem; letter-spacing: 0.2em; color: var(--amber); }
.legal-doc h2 { font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-dim); margin-top: 1.75rem; }
.legal-doc p { margin: 0.6rem 0; }
.legal-doc a { color: var(--amber); }
.legal-doc code { color: var(--amber); }
.legal-doc .updated { color: var(--ink-dim); font-size: 0.75rem; }

.back { margin-top: 2rem; }
.back a { color: var(--amber); }

/* Native shell (MAUI BlazorWebView). The safe-area div only exists in the app's host page, so
   these rules are inert on the web. Keep the terminal clear of the notch and the home bar. */
.status-bar-safe-area {
    height: env(safe-area-inset-top, 0px);
    background: var(--bg);
}

.terminal {
    padding-top: max(2rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(4rem, env(safe-area-inset-bottom, 0px));
}

html {
    -webkit-text-size-adjust: 100%;   /* stop iOS reflowing the monospace layout */
}

body {
    -webkit-tap-highlight-color: transparent;
}

/* Touch devices have no hover; the inverted state would stick after a tap. */
@media (hover: none) {
    .btn:hover:not(:disabled) { background: transparent; color: var(--ink); }
    .btn:active:not(:disabled) { background: var(--ink); color: var(--bg); }
}
