/* The editor page: style.css's look, a dark code editor, and the emulator beside it. */

:root {
    --code-background: #1e1e1e;
    --code-sidebar: #181818;
    --code-tabs: #252526;
    --code-border: #2b2b2b;
    --code-text: #cccccc;
    --code-muted: #8b8b8b;
    --code-hover: #2a2d2e;
    --code-selected: #37373d;
    --code-accent: #3d5cde;

    /* The left knob's blue: Verify, Upload and the editor's status bar. */
    --brand-blue: #3d5cde;
    --brand-blue-hover: #2f4cc4;

    /* The knobs' blue and red, for the AI touches. */
    --spark-gradient: linear-gradient(120deg, #3d5cde, #8a5cf0 50%, #e83b3b);
}

body.editor-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    min-height: 0;
}

/* Slimmer than the emulator page's bar: the code gets the room. */
body.editor-page .bar {
    padding: 8px 16px;
}

.icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.badge {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

/* The game's name: click to rename it (editor.js). */
.project-name {
    padding: 4px 8px;
    margin-left: 2px;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0 8px 8px 0;
    background: transparent;
    color: var(--text);
    font: 600 15px var(--font);
    cursor: pointer;
}

.project-name:hover {
    background: var(--surface-raised);
}

.project-name::after {
    content: "✎";
    margin-left: 6px;
    color: var(--muted);
    font-weight: 400;
    opacity: 0;
    transition: opacity 120ms;
}

.project-name:hover::after,
.project-name:focus-visible::after {
    opacity: 1;
}

.upload-button {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}

.upload-button:hover {
    background: rgb(61 92 222 / 0.1);
}

.button[aria-busy="true"] {
    opacity: 0.7;
    cursor: progress;
}

.agent-button .icon {
    stroke: none;
    fill: #8a5cf0;
}

/* All of it is code; the emulator comes forward over it when a game runs. */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    padding: 12px;
}

/* The code, the agent's conversation, the prompt and the status bar are one
 * dark panel, rounded at its top (the code) and its foot (the status bar). */
.code-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

/* --------------------------------------------------------------------------
 * "What do you want to make?"
 * -------------------------------------------------------------------------- */

.prompt {
    position: relative;
    flex: none;
    padding: 10px 12px;
    border-top: 1px solid var(--code-border);
    background: var(--code-background);
    color-scheme: dark;
}

.prompt-box {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 5px 5px 5px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background:
        linear-gradient(var(--code-tabs), var(--code-tabs)) padding-box,
        var(--spark-gradient) border-box;
}

.prompt-spark {
    flex: none;
    width: 20px;
    height: 20px;
    margin-bottom: 6px;
    fill: #8a5cf0;
}

.prompt-box textarea {
    flex: 1;
    min-height: 32px;
    max-height: 160px;
    padding: 6px 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--code-text);
    font: 14px/1.35 var(--font);
}

.prompt-box textarea::placeholder {
    color: var(--code-muted);
}

/* Blue, as Verify is: the two things to press. */
.prompt-send {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: var(--brand-blue);
    color: #ffffff;
    cursor: pointer;
}

.prompt-send:hover {
    background: var(--brand-blue-hover);
}

.prompt-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.prompt-send.stop {
    background: #c74e39;
}

.prompt-send.stop:hover {
    background: #b0432f;
}

.prompt-send.stop svg {
    fill: currentColor;
    stroke: none;
}

/* The output and the conversation are resized from their top edge (editor.js),
 * as VS Code's panels are: a thin line that lights up under the pointer. */
.resize-handle {
    position: absolute;
    inset: -3px 0 auto;
    z-index: 4;
    height: 7px;
    cursor: ns-resize;
    touch-action: none;
}

.resize-handle::after {
    content: "";
    position: absolute;
    inset: 3px 0 auto;
    height: 1px;
    transition: background 120ms 80ms;
}

.resize-handle:hover::after,
.resize-handle:focus-visible::after,
.resize-handle.dragging::after {
    height: 2px;
    background: var(--code-accent);
}

.resize-handle:focus-visible {
    outline: none;
}

/* While dragging, the pointer stays a resize arrow, and text isn't selected. */
body.resizing {
    cursor: ns-resize;
    user-select: none;
}

/* The conversation with the agent: a pane of the editor, like the output. */
.chat {
    position: relative;
    display: flex;
    flex: none;
    flex-direction: column;
    max-height: 38vh;
    border-top: 1px solid var(--code-border);
    background: var(--code-background);
    color: var(--code-text);
    color-scheme: dark;
    font-size: 13.5px;
}

.chat[hidden] {
    display: none;
}

/* As the Files and Output headings. */
.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 8px 4px 14px;
}

.chat-title {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 3px 6px;
    margin-left: -6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--code-text);
    font: 600 12.5px var(--font);
    cursor: pointer;
}

.chat-title:hover {
    background: var(--code-hover);
}

.chat-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-title svg {
    flex: none;
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--code-muted);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-link {
    padding: 3px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--code-muted);
    font: 500 12px var(--font);
    cursor: pointer;
}

.chat-link:hover {
    background: var(--code-hover);
    color: var(--code-text);
}

.chat-log {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    margin: 0;
    padding: 4px 14px 10px;
    overflow-y: auto;
    list-style: none;
    scrollbar-width: thin;
}

.chat-log li {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-log .you {
    align-self: flex-end;
    max-width: 80%;
    padding: 6px 12px;
    border-radius: 10px;
    background: var(--code-selected);
}

/* What the agent did, as the output's lines. */
.chat-log .action,
.chat-log .note {
    color: var(--code-muted);
    font: 12.5px/1.5 ui-monospace, Consolas, "Cascadia Mono", monospace;
}

.chat-log .action::before {
    content: "✎ ";
    color: #4ec9b0;
}

.chat-log .bad {
    color: #f48771;
}

.chat-log .action.bad::before {
    content: "";
}

.chat-working {
    margin: 0;
    padding: 0 14px 10px;
    color: var(--code-muted);
    font: 12.5px/1.5 ui-monospace, Consolas, "Cascadia Mono", monospace;
}





/* --------------------------------------------------------------------------
 * The code editor
 * -------------------------------------------------------------------------- */

.code-panel {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    flex: 1;
    /* As small as the agent's conversation may squeeze it (editor.js). */
    min-height: 240px;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--code-background);
    color: var(--code-text);
    color-scheme: dark;
    font-size: 13px;
}

.files {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--code-border);
    background: var(--code-sidebar);
}

.files-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 10px 6px 14px;
    color: var(--code-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--code-muted);
    cursor: pointer;
}

.icon-button:hover {
    background: var(--code-hover);
    color: var(--code-text);
}

.icon-button svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.files-buttons {
    display: flex;
    gap: 2px;
}

.file-tree {
    flex: 1;
    margin: 0;
    padding: 0 0 12px;
    overflow-y: auto;
    list-style: none;
}

.file-tree .folder {
    padding: 8px 14px 3px;
    color: var(--code-muted);
    font-size: 12px;
}

/* sdk/: DualSlide's headers, folded away until wanted. */
.file-tree .folder:has(.folder-toggle) {
    margin-top: 10px;
    padding: 0;
    border-top: 1px solid var(--code-border);
}

.file-tree .folder-toggle {
    padding: 8px 14px 4px;
    color: var(--code-muted);
    font-size: 12px;
}

.file-tree .folder-toggle::before {
    content: "▸";
    width: 10px;
}

.file-tree .folder-toggle[aria-expanded="true"]::before {
    content: "▾";
}

.folder-note {
    margin-left: auto;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.file-tree button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 14px 4px 22px;
    border: 0;
    background: transparent;
    color: var(--code-text);
    font: 13px var(--font);
    text-align: left;
    cursor: pointer;
}

.file-tree button:hover {
    background: var(--code-hover);
}

.file-tree button.active {
    background: var(--code-selected);
}

.file-kind {
    flex: none;
    width: 18px;
    font: 600 10px/1 ui-monospace, Consolas, monospace;
    text-align: center;
}

.file-kind.c { color: #6ea8fe; }
.file-kind.h { color: #b392f0; }
.file-kind.md { color: #79c0ff; }
.file-kind.other { color: var(--code-muted); }
.file-kind.info { color: #e5c07b; }

.file-tree li {
    position: relative;
}

/* Files every game needs carry a lock; the rest can be removed. */
.file-lock {
    display: inline-flex;
    margin-left: 2px;
    color: var(--code-muted);
}

.file-lock svg {
    width: 11px;
    height: 11px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

/* As specific as .file-tree button, which styles the file names. */
/* Rename and remove, at the row's end while it's pointed at. */
.file-tree .file-tools {
    position: absolute;
    top: 50%;
    right: 6px;
    display: none;
    gap: 2px;
    transform: translateY(-50%);
}

.file-tree li:hover .file-tools,
.file-tree .file-tools:focus-within {
    display: flex;
}

/* As specific as .file-tree button, which styles the file names. */
.file-tree .file-tools .icon-button {
    display: grid;
    width: 22px;
    height: 22px;
    padding: 0;
    place-items: center;
}

.file-tree .file-tools .icon-button:hover {
    background: var(--code-selected);
}

.file-tree li:hover .modified::after {
    visibility: hidden;
}

.modified::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--code-text);
}

.code-main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
}

.tab-bar {
    display: flex;
    min-width: 0;
    background: var(--code-tabs);
}

.tabs {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 36px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
}

/* Verify is the one thing to press after every change, so it is the largest and boldest. */
.run-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border: 1px solid var(--brand-blue);
    border-radius: 10px;
    background: var(--brand-blue);
    color: #ffffff;
    font: 700 14px var(--font);
    white-space: nowrap;
    cursor: pointer;
    transition: background 120ms;
}

.run-button:hover {
    background: var(--brand-blue-hover);
}

.run-button.secondary {
    padding: 8px 14px;
    border-color: #4a4a4a;
    background: transparent;
    color: var(--code-text);
    font-weight: 600;
}

.run-button.secondary:hover {
    background: var(--code-hover);
}

.run-button .icon {
    width: 14px;
    height: 14px;
    margin: 0;
    fill: currentColor;
    stroke: none;
}

.run-button[aria-busy="true"] {
    opacity: 0.7;
    cursor: progress;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px 0 14px;
    border-right: 1px solid var(--code-border);
    border-top: 2px solid transparent;
    color: var(--code-muted);
    white-space: nowrap;
    cursor: pointer;
}

.tab.active {
    border-top-color: var(--code-accent);
    background: var(--code-background);
    color: var(--code-text);
}

.tab .icon-button {
    width: 20px;
    height: 20px;
}

.tab.modified .tab-close svg {
    display: none;
}

.tab.modified .tab-close::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.tab.modified::after {
    display: none;
}

.code-host {
    position: relative;
    min-height: 0;
}

/* Without the full editor (offline, say), a plain text box stands in. */
.code-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 12px 16px;
    border: 0;
    outline: none;
    resize: none;
    background: var(--code-background);
    color: var(--code-text);
    font: 14px/1.5 ui-monospace, Consolas, "Cascadia Mono", monospace;
    tab-size: 4;
    white-space: pre;
}

.code-empty {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    margin: 0;
    background: var(--code-background);
    place-items: center;
    color: var(--code-muted);
}

.status {
    display: flex;
    flex: none;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 12px;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--code-accent);
    color: #ffffff;
    font-size: 12px;
}

/* --------------------------------------------------------------------------
 * The emulator, in front of the code while a game runs
 * -------------------------------------------------------------------------- */

.emulator-layer {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgb(15 18 24 / 0.55);
    backdrop-filter: blur(6px);
}

.emulator-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: min(100%, calc((100vh - 140px) * var(--art-ratio)));
    outline: none;
}

.emulator-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 8px 8px 8px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}

.emulator-title {
    font-weight: 600;
}

.emulator-panel .device {
    align-self: stretch;
}

.emulator-panel .device-art {
    width: 100%;
}

/* The output, docked under the code while verifying. */
.console {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 220px;
    border-top: 1px solid var(--code-border);
    background: var(--code-background);
}

.console[hidden] {
    display: none;
}

.console-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 4px 14px;
    color: var(--code-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.console-lines {
    flex: 1;
    margin: 0;
    padding: 10px 14px;
    overflow-y: auto;
    list-style: none;
    font: 12.5px/1.6 ui-monospace, Consolas, "Cascadia Mono", monospace;
}

.console-lines .muted { color: var(--code-muted); }
.console-lines .good { color: #4ec9b0; }
.console-lines .bad { color: #f48771; }
.console-lines .warn { color: #cca700; }

/* The compiler's messages point at columns with carets, so keep their spacing. */
.console-lines li { white-space: pre-wrap; }

/* --------------------------------------------------------------------------
 * Dialogs and messages
 * -------------------------------------------------------------------------- */

.sheet {
    width: min(460px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 60px rgb(0 0 0 / 0.18);
}

.sheet::backdrop {
    background: rgb(0 0 0 / 0.3);
}

.sheet h2 {
    margin-bottom: 8px;
    font-size: 20px;
}

.agent-list, .checks {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    padding: 0;
    list-style: none;
}

.agent-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* The code OpenRouter shows, pasted back on a network address (agent.js). */
.agent-list .code-step {
    flex-direction: column;
    align-items: stretch;
}

.agent-list .code-step[hidden] {
    display: none;
}

.code-step .key-row {
    margin-top: 0;
}

.agent-list .button:disabled {
    opacity: 0.5;
    cursor: default;
}

.checks li::before {
    display: inline-block;
    width: 22px;
    font-weight: 700;
}

.checks .pass::before { content: "✓"; color: #2e7d32; }
.checks .fail::before { content: "!"; color: var(--danger); }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
}

.key-paste {
    margin-top: 12px;
    font-size: 14px;
}

.key-paste[hidden] {
    display: none;
}

.key-paste summary {
    color: var(--muted);
    cursor: pointer;
}

.key-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.key-row input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font: 400 15px/1.4 var(--font);
}

.field select,
.field input, .field textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font: 400 15px/1.4 var(--font);
    resize: vertical;
}

.sheet-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* The site's bar, on every page: the brand (home), Library and Projects, the page's own things,
   and the account. Signed out, Projects goes; without accounts set up, all of it does. */
body.booting > :not(.toast) {
    visibility: hidden;
}

a.brand {
    color: var(--text);
    text-decoration: none;
}

a.button {
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 6px;
}

.site-nav a {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.site-nav a:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.site-nav a[aria-current] {
    background: var(--text);
    color: var(--background);
}

body:not(.signed-in) .signed-in-only,
body.signed-in .signed-out-only,
body.no-accounts .site-nav {
    display: none;
}

.page-name {
    color: var(--muted);
    font-weight: 500;
}

/* The editor's project name, after the site's tabs. */
.site-nav + .project-name {
    margin-left: 6px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.nav-account:not(.signed-in) .account-initial,
.nav-account.signed-in .nav-account-label {
    display: none;
}

.back-link,
.small-ai,
.site-tabs {
    display: none;
}

/* The DualSlide launcher's colours, for its CRT housings wherever they are (the editor's too). */
:root {
    --launcher-beige: #cbbf9e;
    --launcher-light: #e8ddbf;
    --launcher-dark: #8d916c;
    --launcher-ink: #2c2b1f;
}

/* The bar's account button: "Sign in", or, signed in, the person's initial in a circle. */
.account-button:not(.signed-in) .account-initial,
.account-button.signed-in .account-icon,
.account-button.signed-in #account-button-label {
    display: none;
}

.account-button.signed-in {
    display: grid;
    place-items: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--brand-blue);
    color: #ffffff;
    font: 600 16px var(--font);
    cursor: pointer;
}

.account-button.signed-in:hover {
    background: var(--brand-blue-hover);
}

.account-initial.large {
    display: grid;
    flex: none;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-blue);
    color: #ffffff;
    font: 600 24px var(--font);
}

/* The project as a .zip: two quiet halves of one small box. */
.zip-box {
    display: inline-flex;
    align-self: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.zip-box button {
    padding: 6px 12px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: 500 13px var(--font);
    cursor: pointer;
}

.zip-box button + button {
    border-left: 1px solid var(--border);
}

.zip-box button:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.zip-box button:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: -2px;
}

/* The account page. */
.account-layer {
    position: fixed;
    inset: 0;
    z-index: 15;
    overflow-y: auto;
    background: var(--background);
    color: var(--text);
}

.account-layer[hidden] {
    display: none;
}

.account-main {
    max-width: 640px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 40px) 16px;
}

.account-card {
    margin-bottom: 16px;
    padding: 20px 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.account-card h3 {
    margin-bottom: 4px;
    font-size: 16px;
}

.account-identity {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.account-identity h2 {
    font-size: 20px;
    overflow-wrap: anywhere;
}

.account-card.danger-zone {
    border-color: #f0c9c9;
}

.sheet-actions.start {
    justify-content: flex-start;
}

/* --------------------------------------------------------------------------
 * The public library (library.js): the projects page's look, with each game's
 * author and likes beneath its CRT; a game's own page; moderation.
 * -------------------------------------------------------------------------- */

.library-caption {
    color: var(--launcher-ink);
    font-size: 13px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-empty {
    padding: 0 36px 36px;
    color: var(--launcher-ink);
    text-align: center;
}

.library-empty[hidden] {
    display: none;
}

.library-more {
    display: flex;
    justify-content: center;
    padding: 0 0 32px;
}

.library-more .button[hidden] {
    display: none;
}

.zip-box button[aria-pressed="true"] {
    background: var(--text);
    color: var(--background);
}

.button.account-button.library-account:not(.signed-in) {
    border-radius: 999px;
}

/* A game's page: its CRT large, then what it is and what to do with it. */
.game-sheet {
    --launcher-beige: #cbbf9e;
    --launcher-light: #e8ddbf;
    --launcher-dark: #8d916c;
    --launcher-ink: #2c2b1f;

    width: min(640px, calc(100vw - 32px));
}

.game-crt {
    margin-bottom: 16px;
}

.game-crt .project-screen {
    cursor: default;
}

.game-sheet h2 {
    margin-bottom: 2px;
    overflow-wrap: anywhere;
}

.game-description {
    margin-top: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.game-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.game-actions .button[hidden] {
    display: none;
}

.game-actions .button[aria-pressed="true"] {
    border-color: #e83b3b;
    background: #fff1f1;
    color: #c62828;
}

/* The publish sheet's rules. */
.rules {
    margin-top: 12px;
    font-size: 14px;
}

.rules summary {
    color: var(--muted);
    cursor: pointer;
}

.rules ul {
    margin: 8px 0 0;
    padding-left: 20px;
    color: var(--muted);
}

#publish-fields[hidden] {
    display: none;
}

/* The person's own published games, on the account page. */
.my-games {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.my-games li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.my-games li.muted {
    border: 0;
    padding: 0;
}

.my-games li > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.game-status {
    color: var(--muted);
    font-size: 13px;
}

.game-status.approved { color: #2e7d32; }
.game-status.rejected,
.game-status.hidden { color: var(--danger); }

/* Moderation: each submission's CRT beside what a moderator needs. */
.moderation-layer {
    --launcher-beige: #cbbf9e;
    --launcher-light: #e8ddbf;
    --launcher-dark: #8d916c;
    --launcher-ink: #2c2b1f;
}

.moderation-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 40px) 16px;
}

.moderation-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.moderation-card {
    display: grid;
    grid-template-columns: minmax(240px, 380px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

@media (max-width: 760px) {
    .moderation-card {
        grid-template-columns: 1fr;
    }
}

.moderation-card .project-screen {
    cursor: default;
}

.moderation-card h3 {
    font-size: 18px;
    overflow-wrap: anywhere;
}

.moderation-card p {
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.report-reason {
    color: var(--danger);
    font-size: 14px;
}

.moderation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

/* The AI's review of a submission, on the moderation page. */
.ai-report {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
}

.ai-report[hidden],
.moderation-actions[hidden] {
    display: none;
}

.ai-status {
    color: var(--muted);
}

.ai-verdict {
    font-weight: 700;
}

.ai-verdict.approve { color: #2e7d32; }
.ai-verdict.reject { color: var(--danger); }
.ai-verdict.needs_human { color: #b26a00; }

.ai-findings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.ai-findings li {
    padding-left: 10px;
    border-left: 3px solid var(--border);
    overflow-wrap: anywhere;
}

.ai-findings .severity-high { border-left-color: var(--danger); }
.ai-findings .severity-medium { border-left-color: #e0a100; }

.ai-findings strong {
    text-transform: capitalize;
}

.ai-screenshots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ai-screenshots img {
    width: 120px;
    height: auto;
    border-radius: 4px;
    image-rendering: auto;
}

/* A game's code, read-only (library.js): its files beside the one shown, as the editor shows code. */
.code-sheet {
    width: min(1100px, calc(100vw - 32px));
}

.code-view {
    display: grid;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    height: min(62vh, 640px);
    margin-top: 14px;
    overflow: hidden;
    border: 1px solid var(--code-border);
    border-radius: 10px;
    background: var(--code-background);
}

.code-files {
    margin: 0;
    padding: 8px 0;
    overflow-y: auto;
    background: var(--code-sidebar);
    list-style: none;
}

.code-files button {
    display: block;
    width: 100%;
    padding: 5px 14px;
    border: 0;
    background: none;
    color: var(--code-text);
    font: 400 13px var(--font);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.code-files button:hover {
    background: var(--code-hover);
}

.code-files button[aria-current="true"] {
    background: var(--code-selected);
    color: #ffffff;
}

.code-text {
    margin: 0;
    padding: 14px 18px;
    overflow: auto;
    color: var(--code-text);
    font: 400 13px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace;
    tab-size: 4;
    white-space: pre;
}

@media (max-width: 700px) {
    .code-view {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .code-files {
        max-height: 120px;
    }
}

.game-actions .button#game-code[hidden] {
    display: none;
}

/* Messages, on top of everything (a popover): placed as before, not centred as popovers are. */
.toast[popover] {
    inset: auto auto 24px 50%;
    margin: 0;
    border: 0;
    overflow: visible;
}

/* The AI sheet's model suggestions, and the cheaper way. */
.model-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.cost-note {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-raised);
    font-size: 14px;
}

/* The account sheet (editor.js, account.js). */

.text-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--brand-blue);
    font: 500 14px var(--font);
    cursor: pointer;
}

.text-link:hover {
    text-decoration: underline;
}

.text-link:disabled {
    opacity: 0.5;
    cursor: default;
}

.text-link.danger {
    color: var(--danger);
}

.text-link[hidden] {
    display: none;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 14px;
}

.check[hidden] {
    display: none;
}

.account-links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 14px;
}

.account-error {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-raised);
    font-size: 14px;
}

.account-error[hidden] {
    display: none;
}

/* --------------------------------------------------------------------------
 * The projects page: a white page with the account's controls in its bar, and
 * a beige panel like the DualSlide launcher's, where each project is a CRT
 * housing in the launcher's style around its preview (projects.js).
 * -------------------------------------------------------------------------- */

.projects-layer {
    --launcher-beige: #cbbf9e;
    --launcher-light: #e8ddbf;
    --launcher-dark: #8d916c;
    --launcher-panel: #b4a985;
    --launcher-ink: #2c2b1f;

    position: fixed;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--background);
    color: var(--text);
}

.projects-layer[hidden] {
    display: none;
}

.projects-bar {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--background);
}

.projects-account {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    margin: 0 4px 0 8px;
    line-height: 1.25;
    text-align: right;
}

.projects-who {
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.projects-status {
    color: var(--muted);
    font-size: 12px;
}

.button.danger-button {
    color: var(--danger);
}

.projects-main {
    flex: 1;
    padding: clamp(16px, 3vw, 32px);
}

/* The beige the housings stand on, edged as the launcher's is. */
.projects-panel {
    min-height: 100%;
    border: 6px solid;
    border-color: var(--launcher-light) var(--launcher-dark) var(--launcher-dark) var(--launcher-light);
    border-radius: 10px;
    background: var(--launcher-panel);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.12);
}

.projects-grid {
    --columns: 3;

    display: grid;
    grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
    gap: 32px;
    margin: 0;
    padding: clamp(16px, 3vw, 36px);
    list-style: none;
}

.project-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* A CRT housing: raised edges (light above and to the left, dark below and to
   the right), a screw in each corner, and a plate under the screen. */
.crt {
    padding: 16px 16px 8px;
    border: 5px solid;
    border-color: var(--launcher-light) var(--launcher-dark) var(--launcher-dark) var(--launcher-light);
    border-radius: 4px;
    background:
        radial-gradient(circle at 8px 8px, var(--launcher-dark) 0 2.5px, transparent 3px),
        radial-gradient(circle at calc(100% - 8px) 8px, var(--launcher-dark) 0 2.5px, transparent 3px),
        radial-gradient(circle at 8px calc(100% - 8px), var(--launcher-dark) 0 2.5px, transparent 3px),
        radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--launcher-dark) 0 2.5px, transparent 3px),
        var(--launcher-beige);
    box-shadow: 0 8px 0 -2px rgb(60 56 36 / 0.35), 0 14px 24px rgb(40 36 20 / 0.25);
}

.project-screen {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.project-tile.blank .project-screen {
    cursor: default;
}

.project-screen canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 704 / 384;
}

.project-screen:focus-visible {
    outline: 3px solid var(--launcher-ink);
    outline-offset: 4px;
}

.project-screen:not(:disabled):hover canvas {
    filter: brightness(1.08);
}

/* Over a screen with no preview yet. */
.project-note {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 0 12%;
    color: #9aa3b5;
    font: 500 14px var(--font);
    text-align: center;
    pointer-events: none;
}

/* The plate: status light, name, speaker grille. */
.crt-plate {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding-top: 8px;
    color: var(--launcher-ink);
}

.crt-light {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #5f5c46;
    box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5);
}

.crt-light.on {
    background: #37c95a;
    box-shadow: 0 0 6px #37c95a, inset 0 -1px 1px rgb(0 0 0 / 0.25);
}

.project-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crt-grille {
    flex: none;
    width: 42px;
    height: 12px;
    background: repeating-linear-gradient(90deg, var(--launcher-dark) 0 3px, transparent 3px 6px);
    border-radius: 2px;
    opacity: 0.8;
}

.project-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    min-height: 20px;
    opacity: 0;
    transition: opacity 120ms;
}

.project-tile:hover .project-actions,
.project-tile:focus-within .project-actions {
    opacity: 1;
}

/* No hovering on touch screens: always there. */
@media (hover: none) {
    .project-actions {
        opacity: 1;
    }
}

/* A blank screen's choices: a new project, empty or from an example. */
.blank-choices {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 120ms;
}

.project-tile.blank:hover .blank-choices,
.project-tile.blank:focus-within .blank-choices {
    opacity: 1;
}

@media (hover: none) {
    .blank-choices {
        opacity: 1;
    }
}

.blank-choices .button {
    min-width: 200px;
    border-color: var(--launcher-light);
    background: rgb(16 24 32 / 0.85);
    color: var(--launcher-light);
}

.blank-choices .button:hover {
    background: var(--launcher-light);
    color: var(--launcher-ink);
}

/* The example picker: each example's CRT, on the launcher's beige. */
.examples-sheet {
    --launcher-beige: #cbbf9e;
    --launcher-light: #e8ddbf;
    --launcher-dark: #8d916c;
    --launcher-ink: #2c2b1f;

    width: min(760px, calc(100vw - 32px));
}

.examples-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.example-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.example-card .project-screen {
    cursor: pointer;
}

.example-card:hover canvas {
    filter: brightness(1.08);
}

.example-card:focus-visible {
    outline: 3px solid var(--brand-blue);
    outline-offset: 4px;
}

.project-actions .text-link {
    color: var(--launcher-ink);
    font-size: 13px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 14px;
    transform: translateX(-50%);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
}

/* --------------------------------------------------------------------------
 * Screens smaller than a tablet (phones, either way up): the AI agent first, in
 * a dark app of its own. No code editor; a greeting, the prompt and ideas to
 * start from, then the conversation once there is one, messaging-style, with
 * the prompt at the bottom. A tablet's short side is at least 744px, a phone's
 * at most 430px.
 * -------------------------------------------------------------------------- */

.small-screen,
.small-actions,
.rotate-note {
    display: none;
}

/* The phone held upright message: a black card, white type, the knobs' colours along the top. */
.rotate-note {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    background: #0f1115;
    color: #ffffff;
    box-shadow: 0 14px 34px rgb(0 0 0 / 0.22);
}

.rotate-note::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: var(--spark-gradient);
}

@media (max-width: 699px) and (orientation: portrait) {
    body.editor-page {
        --phone-background: var(--background);
        --phone-surface: #f6f6f4;
        --phone-raised: #ececea;
        --phone-border: var(--border);
        --phone-text: var(--text);
        --phone-muted: rgb(0 0 0 / 0.56);

        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 100dvh;
        background: var(--phone-background);
        color: var(--phone-text);
    }

    /* One row: back and the project's name, then the agent and upload as icons, and Publish. */
    body.editor-page .bar {
        flex-wrap: nowrap;
        padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
        border-bottom-color: var(--phone-border);
        background: var(--phone-background);
    }

    .brand {
        color: var(--phone-text);
        white-space: nowrap;
    }

    .brand span {
        color: var(--phone-muted);
    }

    .badge {
        display: none;
    }

    .bar .actions {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .bar .button {
        justify-content: center;
        min-width: 42px;
        height: 42px;
        padding: 0 16px;
        border-color: var(--phone-border);
        border-radius: 12px;
        background: var(--phone-surface);
        color: var(--phone-text);
        font-size: 15px;
    }

    .bar .button.primary-action {
        border-color: var(--text);
        background: var(--text);
        color: var(--background);
    }

    .bar .account-button,
    .bar .library-button,
    .bar .projects-button,
    .bar .agent-button,
    .bar .upload-button {
        width: 42px;
        padding: 0;
    }

    /* No room in the editor's bar: phones have Download code and Add files under Build and play. */
    body > header.bar .zip-box {
        display: none;
    }

    .bar .button .icon {
        width: 19px;
        height: 19px;
        margin: 0;
    }

    .bar .upload-button {
        color: var(--brand-blue);
    }

    /* Their names stay for screen readers. */
    #account-button-label,
    #agent-button-label,
    .library-button .button-label,
    .projects-button .button-label,
    .upload-button .button-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .workspace {
        flex: 1;
        padding: 0 16px calc(16px + env(safe-area-inset-bottom));
    }

    .code-column {
        min-height: 100%;
    }

    .code-panel,
    .status,
    .resize-handle {
        display: none;
    }

    /* The greeting, just above the prompt it introduces, until a conversation starts. */
    .small-screen {
        display: flex;
        flex: 1;
        flex-direction: column;
        justify-content: flex-end;
        gap: 10px;
        padding: 32px 4px 20px;
    }


    .small-screen-spark {
        width: 34px;
        height: 34px;
        fill: #8a5cf0;
    }

    .small-screen h2 {
        margin: 0;
        text-wrap: balance;
        font-size: 30px;
        font-weight: 700;
        line-height: 1.15;
        letter-spacing: -0.01em;
    }

    .small-screen p {
        margin: 0;
        color: var(--phone-muted);
        font-size: 16px;
        line-height: 1.45;
    }

    /* The chat box: always there between the game and the prompt, filling the space, whatever
       size it was dragged to on a bigger screen. A light card, like a messaging app's. */
    .chat,
    .chat[hidden] {
        display: flex !important;           /* Over [hidden]: on a phone the chat box is always there */
        flex: 1;
        min-height: 140px;
        height: auto !important;
        max-height: none !important;
        border: 1px solid var(--code-border);
        border-bottom: 0;
        border-radius: 18px 18px 0 0;
        background: var(--code-background);
        color: var(--code-text);
        color-scheme: dark;
        font-size: 15px;
    }

    #chat-close,
    .chat:has(.chat-log:empty) #chat-new {
        display: none;
    }

    .chat-head {
        padding: 8px 10px 4px 16px;
    }

    .chat-title {
        font-size: 14px;
    }

    .chat-link {
        font-size: 13px;
    }

    .chat-log {
        gap: 8px;
        padding: 4px 14px 12px;
        line-height: 1.45;
    }

    /* Before anything's asked: what the agent is for. */
    .chat-log:empty::before {
        content: "Ask the AI agent to make a game, or to change this one. It writes the code, builds it, and plays it on the screen above.";
        margin: auto;
        padding: 12px 18px;
        color: var(--code-muted);
        font-size: 14px;
        text-align: center;
    }

    .chat-log .you {
        max-width: 82%;
        padding: 8px 13px;
        border-radius: 18px 18px 4px 18px;
        background: var(--brand-blue);
        color: #ffffff;
    }

    .chat-log .action,
    .chat-log .note {
        font-size: 12.5px;
    }

    /* The prompt, built into the bottom of the agent's dark box, as a terminal's input line. */
    .prompt {
        padding: 4px 10px 10px;
        border: 1px solid var(--code-border);
        border-top: 0;
        border-radius: 0 0 18px 18px;
        background: var(--code-background);
        color-scheme: dark;
    }

    .prompt-box {
        padding: 7px 7px 7px 14px;
        border-width: 1.5px;
        border-radius: 14px;
        background:
            linear-gradient(#2a2d33, #2a2d33) padding-box,
            var(--spark-gradient) border-box;
        box-shadow: none;
    }

    .prompt-spark {
        margin-bottom: 9px;
    }

    /* 16px, or Safari zooms the page when the box is tapped. */
    .prompt-box textarea {
        min-height: 38px;
        padding: 8px 0;
        color: var(--code-text);
        font-size: 16px;
        scrollbar-width: none;
    }

    .prompt-send {
        width: 38px;
        height: 38px;
        border-radius: 50%;
    }





    /* Build and play, and what happened last, under the prompt. */
    .small-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 14px;
    }

    .small-actions .button {
        justify-content: center;
        height: 46px;
        border-color: var(--phone-border);
        border-radius: 14px;
        background: var(--phone-surface);
        color: var(--phone-text);
        font-size: 15px;
        font-weight: 600;
    }

    .small-actions .icon {
        fill: currentColor;
        stroke: none;
    }

    /* Share with an AI app, and its answer back: side by side, under the prompt. */
    .small-ai {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .small-ai .button {
        justify-content: center;
        height: 42px;
        padding: 0 8px;
        border-color: var(--phone-border);
        background: var(--phone-surface);
        color: var(--phone-text);
        font-size: 14px;
        font-weight: 500;
        white-space: nowrap;
    }

    .small-ai .icon {
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* Download and Open, side by side and quieter than Build and play. */
    .small-files {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .small-files .button {
        height: 40px;
        background: transparent;
        color: var(--phone-muted);
        font-weight: 500;
    }

    .small-status {
        margin: 0;
        padding: 10px 12px;
        border-radius: 12px;
        background: var(--phone-surface);
        color: var(--phone-muted);
        font-size: 14px;
    }

    .small-status.good { color: #2e7d32; }
    .small-status.bad { color: var(--danger); }

    .small-note {
        margin: 2px 0 0;
        color: var(--phone-muted);
        font-size: 13px;
        text-align: center;
    }

    /* 16px here too, so Safari doesn't zoom. */
    .field input,
    .field textarea,
    .field select,
    .key-row input {
        font-size: 16px;
    }

    .emulator-layer {
        padding: 12px;
    }

    /* The emulator's bar stays light, with dark type, over the dark page. */
    .emulator-bar {
        color: var(--text);
    }
}

/* A phone on its side: the device as big as the height allows, under a slim bar. */
@media (max-height: 500px) {
    .emulator-layer {
        padding: 8px;
    }

    .emulator-panel {
        width: min(100%, calc((100vh - 72px) * var(--art-ratio)));
        gap: 8px;
    }

    .emulator-bar {
        padding: 4px 4px 4px 14px;
    }

    .emulator-bar .button {
        padding: 5px 12px;
        font-size: 13px;
    }
}

/* A phone held upright: the device only plays sideways. */
@media (max-width: 699px) and (orientation: portrait) {
    .emulator-panel .device {
        display: none;
    }

    .rotate-note {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 16px;
        padding: 44px 24px 40px;
        text-align: center;
        text-wrap: balance;
        font-size: 20px;
        font-weight: 700;
    }

    .rotate-note svg {
        box-sizing: border-box;
        width: 72px;
        height: 72px;
        padding: 14px;
        border-radius: 20px;
        background: var(--spark-gradient);
        fill: none;
        stroke: #ffffff;
        stroke-width: 1.6;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
}

/* --------------------------------------------------------------------------
 * Phones: the site as an app. Its pages are tabs along the bottom; each
 * page's bar keeps the brand and its own controls; the editor has a way back
 * and its project's name; dialogs are sheets from the bottom; the grids are
 * one CRT across.
 * -------------------------------------------------------------------------- */

@media (max-width: 699px) {
    /* The tabs, clear of the home indicator. */
    .site-tabs {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 16;
        display: flex;
        padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        border-top: 1px solid var(--border);
        background: rgb(255 255 255 / 0.92);
        backdrop-filter: blur(16px);
    }

    .site-tabs > * {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        min-width: 0;
        padding: 4px 0;
        border: 0;
        background: none;
        color: var(--muted);
        font: 500 11px var(--font);
        text-decoration: none;
        cursor: pointer;
    }

    .site-tabs svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .site-tabs [aria-current] {
        color: var(--text);
    }

    .site-tabs [aria-current] svg {
        stroke-width: 2.3;
    }

    body:not(.signed-in) .site-tabs .signed-in-only,
    body.signed-in .site-tabs .signed-out-only,
    body[data-page="edit"] .site-tabs,
    body.no-accounts .site-tabs,
    body.booting .site-tabs {
        display: none;
    }

    /* The tabs take over from the bars' own links and account buttons. */
    .site-nav,
    .bar .account-button.nav-account,
    .bar .signed-out-only,
    body > header.bar #account-button {
        display: none;
    }

    /* Each page's bar: the brand, then its own controls. */
    .projects-bar,
    .account-layer > .bar {
        flex-wrap: nowrap;
        padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    }

    .bar a.brand {
        font-size: 20px;
        letter-spacing: -0.01em;
    }

    .zip-box button {
        padding: 7px 12px;
    }

    /* The pages, clear of the tabs. */
    .projects-layer,
    .account-layer {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }

    /* The editor: back to the person's projects (or the library), and the project's name. */
    body[data-page="edit"] header.bar .brand {
        display: none;
    }

    body[data-page="edit"] .back-link {
        display: grid;
        flex: none;
        place-items: center;
        width: 38px;
        height: 42px;
        margin-left: -8px;
        color: var(--text);
    }

    body.no-accounts .back-link {
        display: none;
    }

    body.no-accounts header.bar .brand {
        display: inline;
    }

    .back-link svg {
        width: 26px;
        height: 26px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2.4;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    body > header.bar .title {
        flex: 1;
        gap: 2px;
    }

    body > header.bar .project-name {
        min-width: 0;
        max-width: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        font-size: 17px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* The grids: one CRT across, on a panel as tall as what's on it. */
    .projects-main {
        padding: 12px;
    }

    .projects-panel {
        min-height: 0;
        border-width: 4px;
        border-radius: 8px;
    }

    .projects-grid {
        gap: 22px;
        padding: 14px;
    }

    .crt {
        padding: 10px 10px 6px;
        border-width: 4px;
    }

    .crt-plate {
        min-height: 30px;
        padding-top: 6px;
    }

    .project-title {
        font-size: 15px;
    }

    .blank-choices {
        gap: 8px;
    }

    .blank-choices .button {
        min-width: 0;
        width: 72%;
        height: 36px;
        justify-content: center;
        font-size: 14px;
    }

    .library-caption {
        font-size: 14px;
    }

    /* Dialogs: sheets from the bottom, the whole width, scrolling when long. */
    dialog.sheet {
        width: 100%;
        max-width: none;
        max-height: 92dvh;
        margin: auto 0 0;
        padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
        overflow-y: auto;
        border: 0;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -10px 40px rgb(0 0 0 / 0.2);
    }

    .sheet h2 {
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .sheet-actions {
        flex-wrap: wrap;
    }

    .sheet-actions .button {
        flex: 1 1 140px;
        justify-content: center;
        height: 46px;
    }

    .account-footer .text-link {
        flex: none;
    }

    .account-links {
        gap: 10px 18px;
    }

    /* A game's page: Play across the top, the rest two by two (one left over takes the row). */
    .game-actions .button {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        height: 46px;
    }

    .game-actions .primary-action {
        flex-basis: 100%;
    }

    .code-view {
        height: 60dvh;
    }

    /* The account page, edge to edge. */
    .account-main {
        padding: 14px 12px;
    }

    .account-card {
        padding: 18px 16px;
    }

    .account-card .sheet-actions .button {
        flex: 0 1 auto;
    }

    .moderation-main {
        padding: 14px 12px;
    }

    .moderation-card {
        padding: 14px;
    }

    .moderation-actions .button {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* The game's CRT at the top: no greeting, the chat and the prompt say it. Tapping the CRT's
       screen plays the game, so no Build and play. */
    .small-screen-spark,
    .small-screen h2,
    .small-screen p {
        display: none;
    }

    .small-screen {
        flex: none;
        padding: 8px 0 12px;
    }

    .phone-game {
        width: 100%;
        max-width: min(100%, calc((100dvh - 460px) * 1.6));
        margin: 0 auto;
    }

    #small-verify-button,
    #small-show-button,
    .small-files {
        display: none;
    }

    /* The emulator's buttons, one even row under its title. */
    .emulator-bar .actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .emulator-bar .button {
        justify-content: center;
        min-height: 42px;
        padding: 0 4px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* Open AI's .zip: what it changes. */
.paste-ai-files {
    display: grid;
    gap: 4px;
    margin: 10px 0 0;
    padding: 0;
    font: 13px var(--mono, ui-monospace, monospace);
    list-style: none;
}

.paste-ai-files span {
    display: inline-block;
    min-width: 64px;
    color: #2e7d32;
    font-family: var(--font);
    font-weight: 600;
}

.paste-ai-files span.removed {
    color: var(--danger);
}

/* Share with an AI app: the apps, one row. */
.ai-apps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.ai-apps .button {
    justify-content: center;
    height: 48px;
    font-weight: 600;
    text-decoration: none;
}

/* Phones, before OpenRouter is connected: no chat box and no prompt, but a button to connect,
   at the bottom (the chat stays if something's been said, such as pasted changes and their undo). */
.phone-connect {
    display: none;
}

@media (max-width: 699px) and (orientation: portrait) {
    body:not(.ai-connected) .code-column:has(.chat-log:empty) .chat,
    body:not(.ai-connected) .prompt {
        display: none !important;
    }

    body:not(.ai-connected) .phone-connect {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        height: 56px;
        margin-top: auto;
        border: 1.5px solid transparent;
        border-radius: 18px;
        background:
            linear-gradient(var(--code-background), var(--code-background)) padding-box,
            var(--spark-gradient) border-box;
        color: #ffffff;
        font: 600 16px var(--font);
        cursor: pointer;
    }

    .phone-connect svg {
        width: 20px;
        height: 20px;
        fill: #b69cff;
    }

    /* After a paste: under the chat, as the prompt is. */
    body:not(.ai-connected) .chat:not([hidden]) + .phone-connect,
    body:not(.ai-connected) .code-column:not(:has(.chat-log:empty)) .phone-connect {
        margin-top: 10px;
    }
}

@media (max-width: 699px) and (orientation: portrait) {
    body:not(.ai-connected) .code-column:has(.chat-log:empty) .small-screen {
        flex: 1;
        justify-content: center;
    }
}

/* --------------------------------------------------------------------------
 * A phone on its side (or any short, wide screen): the whole editor, as on a
 * computer, made compact so it fits the height: one slim bar with icons, a
 * narrower file list, and tighter panels.
 * -------------------------------------------------------------------------- */

@media (max-height: 500px) and (orientation: landscape) {
    body.editor-page {
        height: 100dvh;
    }

    body.editor-page > .bar {
        flex-wrap: nowrap;
        gap: 10px;
        padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    }

    body.editor-page > .bar .title {
        min-width: 0;
        flex-wrap: nowrap;
    }

    body.editor-page > .bar .brand {
        font-size: 18px;
    }

    body.editor-page > .bar .project-name {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.editor-page > .bar .actions {
        flex-wrap: nowrap;
        gap: 6px;
    }

    body.editor-page > .bar .button {
        height: 34px;
        padding: 0 12px;
        font-size: 14px;
    }

    body.editor-page > .bar .agent-button,
    body.editor-page > .bar .upload-button,
    body.editor-page > .bar .account-button {
        width: 34px;
        padding: 0;
        justify-content: center;
    }

    body.editor-page > .bar .button .icon {
        margin: 0;
    }

    #agent-button-label,
    #account-button-label,
    body.editor-page > .bar .upload-button .button-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .zip-box button {
        padding: 5px 10px;
        font-size: 13px;
    }

    .workspace {
        padding: 0 max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    }

    .code-panel {
        grid-template-columns: 170px minmax(0, 1fr);
        min-height: 150px;
    }

    .files-head {
        padding-top: 6px;
        padding-bottom: 4px;
    }

    .file-tree {
        font-size: 13px;
    }

    .status {
        display: none;
    }

    .code-panel .tab-bar {
        min-height: 0;
    }

    .prompt {
        padding: 6px 8px;
    }

    .prompt-box textarea {
        min-height: 28px;
        max-height: 72px;
        padding: 4px 0;
    }
}

/* "Turn your phone sideways": its icon beside it, and not said once it is. */
.small-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.small-note svg {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (orientation: landscape) {
    .small-note {
        display: none;
    }
}
