/* ==========================================================================
   rcd800.dev, shared stylesheet (v3)
   Dimmed light page, dark when the system asks for it. #760024 stays as the homage colour.
   Two families: Space Grotesk for text, JetBrains Mono for real values only.
   The wordmark is an outlined SVG (Ethnocentric), not a font.
   ========================================================================== */

@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/vendor/fonts/space-grotesk-latin-wght-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('/vendor/fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
}

/* Only for the MOTD preview: OFL pixel font drawn after the game font */
@font-face {
    font-family: 'Monocraft';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/vendor/fonts/monocraft.ttf') format('truetype');
}

:root {
    color-scheme: light dark;

    /* Accent hue: crimson. #760024 is hsl(342, 100%, 23%) */
    --primary-hue: 342;
    --homage: hsl(var(--primary-hue), 100%, 23%);

    /* Light: a mid-light cool grey, never white, so the page does not glare at night */
    --color-bg: #D8D6DB;
    --color-field: #E2E0E5;
    --color-line: #B3AFB8;
    --color-line-strong: #8C8792;
    --text-main: #17151A;
    --text-muted: #55515B;

    --accent-text: var(--homage);
    --accent-fill: var(--homage);
    --accent-fill-hover: hsl(var(--primary-hue), 100%, 17%);
    --on-accent: #FFFFFF;
    --on-accent-muted: hsla(0, 0%, 100%, 0.72);
    --on-accent-line: hsla(0, 0%, 100%, 0.4);

    --color-ok: #0B6E4F;
    --color-warn: #8A5300;
    --color-danger: var(--homage);
    --overlay: hsla(270, 6%, 10%, 0.55);

    --font-text: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

    /* Radius by role, not one value for everything */
    --radius-control: 4px;
    --radius-dialog: 8px;

    --page-width: 64rem;
    --gutter: clamp(1rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1C1A1F;
        --color-field: #26232A;
        --color-line: #3A363F;
        --color-line-strong: #57525D;
        --text-main: #E6E3E8;
        --text-muted: #A29DA8;

        /* #760024 fails as text on dark (under 2:1), so dark text accents use a lighter tone of the same hue */
        --accent-text: hsl(var(--primary-hue), 69%, 61%);
        --accent-fill-hover: hsl(var(--primary-hue), 100%, 29%);

        --color-ok: hsl(155, 55%, 58%);
        --color-warn: hsl(35, 80%, 62%);
        --color-danger: hsl(var(--primary-hue), 69%, 61%);
        --overlay: hsla(270, 8%, 4%, 0.7);
    }
}

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

body {
    background: var(--color-bg);
    color: var(--text-main);
    font-family: var(--font-text);
    font-size: 1rem;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-text);
    text-underline-offset: 3px;
}

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

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

[hidden] {
    display: none !important;
}

.wrap {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* The home page reads like a short document; the working pages need room for tables */
.home {
    --page-width: 52rem;
}

/* --------------------------------------------------------------------------
   Type. Scale: major third (0.8, 1, 1.25, 1.563, 1.953, 2.441rem)
   -------------------------------------------------------------------------- */

h1,
h2,
h3 {
    font-family: var(--font-text);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

h1 { font-size: 1.953rem; }
h2 { font-size: 1.563rem; }
h3 { font-size: 1.25rem; }

/* Small secondary text: field labels, table heads, captions. Sentence case, no tracking. */
.label,
.eyebrow {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

code,
.mono {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

.muted {
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Wordmark: RCD800 as an outlined logo (mask, so it takes the text colour) + ".dev"
   -------------------------------------------------------------------------- */

.wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3em;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    font-size: 1rem;
}

.wordmark-logo {
    display: inline-block;
    /* Logo aspect ratio is 5604 x 691 */
    height: 1.1em;
    width: calc(1.1em * 8.11);
    background-color: currentColor;
    -webkit-mask: url('/assets/wordmark.svg') no-repeat left bottom / contain;
    mask: url('/assets/wordmark.svg') no-repeat left bottom / contain;
}

.wordmark-tld {
    font-weight: 500;
    font-size: 0.95em;
    line-height: 1;
    opacity: 0.7;
}

/* --------------------------------------------------------------------------
   Band: the one crimson block at the top of every full page
   -------------------------------------------------------------------------- */

.band {
    background: var(--homage);
    color: var(--on-accent);
}

.band a {
    color: inherit;
}

.band .label,
.band .eyebrow {
    color: var(--on-accent-muted);
}

.band-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
    min-height: 3.25rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.band-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Same width in both languages, so nothing shifts on a language switch */
.band-actions .btn {
    min-width: 5.5rem;
}

.band-title {
    padding-top: 0.5rem;
    padding-bottom: 1.25rem;
}

.band-title h1 {
    font-size: clamp(1.563rem, 3.5vw, 1.953rem);
}

/* --------------------------------------------------------------------------
   Edge: a quiet footer detail naming the Cloudflare location that served the page.
   It opens to the other connection facts.
   -------------------------------------------------------------------------- */

.edge-details summary {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
}

.edge-details summary::-webkit-details-marker {
    display: none;
}

.edge-code {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-main);
}

.edge-details summary::after {
    content: '';
    align-self: center;
    width: 0.35em;
    height: 0.35em;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-0.1em) rotate(45deg);
}

.edge-details[open] summary::after {
    transform: translateY(0.1em) rotate(-135deg);
}

.edge-details summary:hover {
    color: var(--text-main);
}

.band :focus-visible {
    outline-color: var(--on-accent);
}

/* Key/value facts */
.facts {
    display: grid;
    grid-template-columns: max-content max-content;
    gap: 0.3rem 1rem;
    margin-top: 0.6rem;
    font-size: 0.8rem;
    text-align: left;
}

.facts dt {
    color: var(--text-muted);
}

.facts dd {
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.facts button {
    display: inline-grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    font: inherit;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: none;
    border: 0;
    border-radius: var(--radius-control);
    cursor: pointer;
}

.facts button:hover {
    color: var(--text-main);
}

/* --------------------------------------------------------------------------
   Controls
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-text);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.7rem 1.1rem;
    min-height: 2.5rem;
    border-radius: var(--radius-control);
    border: 1px solid var(--color-line-strong);
    background: transparent;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--text-main);
}

.btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.btn-primary {
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: var(--on-accent);
}

.btn-primary:hover {
    background: var(--accent-fill-hover);
    border-color: var(--accent-fill-hover);
}

.band .btn {
    color: var(--on-accent);
    border-color: var(--on-accent-line);
}

.band .btn:hover {
    border-color: var(--on-accent);
}

.btn-small {
    padding: 0.45rem 0.75rem;
    min-height: 2rem;
    font-size: 0.8rem;
}

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--text-main);
    border-color: var(--color-line-strong);
}

.btn-icon.danger:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
}

/* Segmented switch (redirect type, source kind) */
.segmented {
    display: inline-flex;
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-control);
    overflow: hidden;
}

.segmented button,
.segmented label {
    font-family: var(--font-text);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    background: none;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.segmented button + button,
.segmented label + label {
    border-left: 1px solid var(--color-line-strong);
}

.segmented button[aria-pressed="true"],
.segmented label:has(input:checked) {
    background: var(--text-main);
    color: var(--color-bg);
}

.segmented label:has(input:focus-visible) {
    outline: 2px solid var(--accent-text);
    outline-offset: -2px;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Language switch: each button sits on its flag's colours (the only gradients on the site).
   The colour stops overlap by about a pixel so the diagonal edges are blended. The dark veil
   keeps the label readable and lifts on the selected language. */
[data-lang-switch].segmented {
    border-color: var(--on-accent-line);
}

[data-lang-switch].segmented button {
    --veil: 0.62;
    min-width: 2.9rem;
    justify-content: center;
    font-weight: 700;
    color: hsla(0, 0%, 100%, 0.78);
    text-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.9);
    background-image:
        linear-gradient(hsla(0, 0%, 0%, var(--veil)), hsla(0, 0%, 0%, var(--veil))),
        var(--flag);
}

[data-lang-switch].segmented button + button {
    border-left-color: var(--on-accent-line);
}

[data-lang-switch].segmented button:hover {
    --veil: 0.4;
}

[data-lang-switch].segmented button[aria-pressed="true"] {
    --veil: 0.25;
    color: #FFFFFF;
    box-shadow: inset 0 0 0 1px hsla(0, 0%, 100%, 0.85);
}

[data-lang-switch] button[data-lang="en-US"] {
    --flag: linear-gradient(115deg, #3c3b6e calc(38% - 0.6px), #ffffff calc(38% + 0.6px), #ffffff calc(46% - 0.6px), #b22234 calc(46% + 0.6px));
}

[data-lang-switch] button[data-lang="pt-BR"] {
    --flag: linear-gradient(115deg, #009c3b calc(40% - 0.6px), #ffdf00 calc(40% + 0.6px), #ffdf00 calc(60% - 0.6px), #002776 calc(60% + 0.6px));
}

/* Off the band (404, notices) the switch sits on the page colour */
.notice [data-lang-switch].segmented {
    border-color: var(--color-line-strong);
}

/* Inputs */
.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.input {
    width: 100%;
    font-family: var(--font-text);
    font-size: 1rem;
    color: var(--text-main);
    background: var(--color-field);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-control);
    padding: 0.6rem 0.8rem;
    min-height: 2.5rem;
}

.input.mono {
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.input:focus {
    outline: none;
    border-color: var(--accent-text);
    box-shadow: 0 0 0 1px var(--accent-text);
}

.input-prefixed {
    display: flex;
    align-items: stretch;
}

.input-prefixed > span {
    display: inline-flex;
    align-items: center;
    padding: 0 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    border: 1px solid var(--color-line);
    border-right: 0;
    border-radius: var(--radius-control) 0 0 var(--radius-control);
    white-space: nowrap;
}

.input-prefixed .input {
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
}

/* Checkbox (on/off column of a table) */
.check {
    display: block;
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--accent-fill);
    cursor: pointer;
}

/* Inline messages */
.message {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border-left: 3px solid var(--color-danger);
    background: var(--color-field);
    font-size: 0.9rem;
    color: var(--text-main);
}

.message.warning { border-left-color: var(--color-warn); }
.message.success { border-left-color: var(--color-ok); }

/* --------------------------------------------------------------------------
   Sections: separated by rules, not boxes
   -------------------------------------------------------------------------- */

main.wrap {
    padding-bottom: 1rem;
}

.section {
    padding-top: clamp(2rem, 5vw, 3rem);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--color-line-strong);
}

.section-head h2 {
    font-size: 1.25rem;
}

.section-head .label b {
    color: var(--text-main);
    font-family: var(--font-mono);
    font-weight: 600;
}

.section-lead {
    margin-top: 0.75rem;
    max-width: 68ch;
    color: var(--text-muted);
}

/* Project index */
.projects {
    list-style: none;
}

.project {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.15rem 1.25rem;
    align-items: baseline;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--color-line);
    color: inherit;
    text-decoration: none;
}

.project-name {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

.project:hover .project-name {
    color: var(--accent-text);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.project-lead {
    grid-column: 1;
    max-width: 68ch;
    color: var(--text-muted);
}

.project-meta {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.tag.open { color: var(--color-ok); }
.tag.direct { color: var(--accent-text); }
.tag.warn { color: var(--color-warn); }

/* Panel: a working area (forms). No box; the section rule above already frames it. */
.panel {
    margin-top: 1rem;
}

.panel > h3 {
    font-size: 1.25rem;
}

.panel > h3 + p {
    color: var(--text-muted);
    margin-top: 0.3rem;
    max-width: 68ch;
}

.form-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-row .field,
.form-row > .input {
    flex: 1 1 14rem;
}

/* Key/value output rows (UUID converter) */
.outputs {
    margin-top: 1rem;
    border-top: 1px solid var(--color-line);
}

.output {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--color-line);
}

.output code {
    overflow-wrap: anywhere;
}

.player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.player canvas {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    border-radius: 2px;
    background: #000;
}

.player.loading canvas {
    opacity: 0.4;
}

.player-name {
    font-weight: 600;
}

/* Table */
.table-scroll {
    overflow-x: auto;
    margin-top: 0.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-line-strong);
    white-space: nowrap;
}

td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-line);
    vertical-align: middle;
}

td.num,
th.num {
    text-align: right;
    font-family: var(--font-mono);
}

td.truncate {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

td.actions {
    text-align: right;
    white-space: nowrap;
}

td.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 0;
}

td a {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Figures row (shortener and log source counts) */
.figures {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* Language composition bar */
.langbar {
    display: flex;
    height: 6px;
    overflow: hidden;
    gap: 2px;
}

.langbar span {
    display: block;
    height: 100%;
}

.langlegend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    list-style: none;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.langlegend i {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
}

.langlegend b {
    color: var(--text-main);
    font-weight: 500;
    margin-right: 0.3rem;
}

/* Footer */
.footer {
    margin-top: clamp(3rem, 8vw, 4.5rem);
    padding-top: 1.25rem;
    padding-bottom: 2.5rem;
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem 2rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--color-line-strong);
}

.footer-langs {
    flex: 1 1 16rem;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.footer [data-site-version] {
    font-family: var(--font-mono);
}

.footer-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    text-align: right;
}

@media (max-width: 640px) {
    .footer-meta {
        align-items: flex-start;
        text-align: left;
    }
}

/* --------------------------------------------------------------------------
   Centered single-purpose pages (404, short-link notices)
   -------------------------------------------------------------------------- */

.page-center {
    display: grid;
    place-items: center;
    padding: var(--gutter);
    border-top: 6px solid var(--homage);
}

.notice {
    width: 100%;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.notice > .wordmark {
    color: var(--text-main);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.notice .eyebrow {
    font-family: var(--font-mono);
}

.notice h1 {
    font-size: 1.953rem;
}

.notice p {
    color: var(--text-muted);
}

.notice .btn-primary {
    align-self: stretch;
}

.notice-foot {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-line);
    font-size: 0.9rem;
}

.notice-foot [data-site-version] {
    font-family: var(--font-mono);
}

.countdown {
    font-family: var(--font-mono);
    font-size: 3.815rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-main) !important;
}

.countdown small {
    font-family: var(--font-text);
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-muted);
}

.countdown-track {
    width: 100%;
    height: 3px;
    background: var(--color-line);
}

.countdown-fill {
    width: 0;
    height: 100%;
    background: var(--accent-fill);
    transition: width 5s linear;
}

.destination {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-main) !important;
    padding: 0.6rem 0.8rem;
    background: var(--color-field);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-control);
    overflow-wrap: anywhere;
}

/* Toast & dialog */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    max-width: calc(100vw - 2rem);
    padding: 0.7rem 1rem;
    background: var(--text-main);
    color: var(--color-bg);
    border-radius: var(--radius-control);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 30;
}

.toast.error {
    background: var(--accent-fill);
    color: var(--on-accent);
}

dialog {
    margin: auto;
    width: min(28rem, calc(100vw - 2rem));
    background: var(--color-bg);
    color: var(--text-main);
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-dialog);
    padding: 1.5rem;
}

dialog::backdrop {
    background: var(--overlay);
}

dialog h3 {
    font-size: 1.25rem;
}

/* Page-level backdrop for a dialog opened with show() instead of showModal() */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow-y: auto;
    background: var(--overlay);
}

.overlay dialog {
    position: static;
    margin: 0;
}

/* The one piece of motion besides the details toggle: the dialog appearing after a click */
dialog[open] {
    animation: dialog-in 0.15s ease-out;
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(4px); }
}

.dialog-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.dialog-lead {
    margin-top: 0.3rem;
    color: var(--text-muted);
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.25rem;
}

.dialog-form .dialog-actions {
    margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Minecraft MOTD editor (home page)
   The preview imitates the game's server list, so it keeps the game's own
   black backdrop and palette in both colour schemes: those colours are content.
   -------------------------------------------------------------------------- */

.motd-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin-top: 0.75rem;
}

.motd-facts b {
    color: var(--text-main);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* The entry is laid out in the game's GUI pixels (--gp): 2 padding, 32 icon, 3 gap, 270 text, 2 padding.
   It scales with the frame's width, up to GUI scale 2. */
.motd-frame {
    container-type: inline-size;
    max-width: calc(309 * 2px + 2px);
    margin-top: 1rem;
}

.motd-entry {
    /* Fallback only: motd-editor.js sets --gp snapped to whole device pixels, like the game's GUI scale */
    --gp: calc((100cqw - 2px) / 309);
    width: fit-content;
    border: 1px solid var(--color-line-strong);
    display: grid;
    grid-template-columns: calc(var(--gp) * 32) calc(var(--gp) * 270);
    gap: 0 calc(var(--gp) * 3);
    padding: calc(var(--gp) * 2);
    background: #000000;
    color: #FFFFFF;
    font-family: 'Monocraft', var(--font-mono);
    /* Monocraft is 9 font pixels to the em, so this makes one font pixel one GUI pixel */
    font-size: calc(var(--gp) * 9);
    font-synthesis: none;
    line-height: calc(var(--gp) * 10);
}

.motd-icon {
    width: calc(var(--gp) * 32);
    height: calc(var(--gp) * 32);
    background: #2B2B2B;
}

.motd-icon img {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.motd-text {
    min-width: 0;
}

.motd-name-row {
    display: flex;
    justify-content: space-between;
    gap: calc(var(--gp) * 6);
    margin-bottom: calc(var(--gp) * 1);
    white-space: pre;
}

.motd-name {
    overflow: hidden;
}

.motd-players {
    color: #AAAAAA;
}

.motd-line {
    height: calc(var(--gp) * 10);
    white-space: pre;
    overflow: hidden;
}

/* One box per character, as wide as its advance in the game font */
.motd-entry .c {
    display: inline-block;
    position: relative;
    vertical-align: top;
    overflow: hidden;
}

/* Placed inside its box by motd-editor.js (inkOffset); the box clips what the game would not draw */
.motd-entry .g {
    display: inline-block;
    position: relative;
    width: calc(var(--gp) * 6);
    white-space: pre;
}

/* Extra pixels where Monocraft differs from the game (GLYPH_FIXUPS in motd-editor.js) */
.motd-entry .fix {
    position: absolute;
    top: 0;
}

/* Bold the way the game draws it: the glyph again, one pixel to the right */
.motd-line .b { text-shadow: var(--gp) 0 0 currentColor; }
.motd-line .i .c { transform: skewX(-14deg); }

/* The game draws these lines across the whole advance, so they join between characters */
.motd-line .u .c::after,
.motd-line .s .c::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: var(--gp);
    background: currentColor;
}

.motd-line .u .c::after { bottom: 0; }
.motd-line .s .c::before { top: calc(var(--gp) * 4.5); }

/* Two rows on purpose: colours, then every format together */
.motd-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    margin-top: 1.5rem;
}

.motd-colors,
.motd-formats {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.motd-formats {
    flex-wrap: wrap;
}

.motd-colors {
    width: 100%;
}

.motd-swatches {
    display: grid;
    grid-template-columns: repeat(16, 2rem);
    gap: 0.3rem;
}

/* Text colour is set per swatch (black or white) in motd-editor.js; the code is a real value, so mono */
.motd-swatch {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-control);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.motd-swatch:hover {
    border-color: var(--text-main);
}

.motd-hex {
    position: relative;
}

.motd-hex input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.motd-hex:has(input:focus-visible) {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.motd-source {
    display: block;
    margin-top: 0.5rem;
    min-height: 5.5rem;
    resize: vertical;
    line-height: 1.5;
}

.motd-hint {
    margin-top: 0.4rem;
    max-width: 68ch;
}

#motd-warning {
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.75rem;
}

.motd-export-head {
    margin-top: 2rem;
    align-items: center;
}

.motd-export-head h3 {
    font-size: 1rem;
}

/* The heading rule above already opens the list */
.motd-outputs {
    margin-top: 0;
    border-top: 0;
}

/* Runs of spaces centre a MOTD, so show them as they are */
.motd-outputs code {
    white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
    dialog {
        padding: 1rem;
    }

    .project {
        grid-template-columns: minmax(0, 1fr);
    }

    .project-meta {
        grid-column: 1;
        grid-row: auto;
        text-align: left;
        padding-top: 0.25rem;
    }

    .output {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .output .label {
        grid-column: 1 / -1;
    }

    /* The palette as two rows of eight: the game's dark half, then the light half */
    .motd-swatches {
        flex: 1;
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }

    /* Keep the band one row at 375px */
    .band-bar {
        flex-wrap: nowrap;
    }

    .band .wordmark {
        font-size: 0.85rem;
    }

    .band-actions {
        gap: 0.4rem;
    }

    .band-actions .btn {
        min-width: 0;
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    [data-lang-switch].segmented button {
        min-width: 2.4rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .countdown-fill {
        transition-duration: 5s !important;
    }
}
