:root {
    color-scheme: dark;
    --bar-height: 64px;
    --panel-width: 360px;
    --bg: #0d0f10;
    --terminal-bg: #080a0b;
    --surface: #141719;
    --surface-2: #1a1e20;
    --surface-3: #22272a;
    --border: #30363a;
    --border-strong: #495157;
    --text: #eef1f2;
    --muted: #9ca6ac;
    --faint: #6f7a80;
    --teal: #68c9bd;
    --teal-dark: #245e58;
    --blue: #7eb6e8;
    --amber: #e8bd65;
    --red: #ef8383;
    --red-dark: #733c3c;
    --green: #72d397;
    --radius: 6px;
    --terminal-font-size: 15px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
textarea,
select {
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

button,
a,
input,
textarea,
summary {
    -webkit-tap-highlight-color: transparent;
}

button,
summary {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

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

.client-app {
    width: 100%;
    height: 100%;
}

.client-bar {
    display: flex;
    height: var(--bar-height);
    align-items: center;
    gap: 20px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: #111416;
}

.client-brand {
    display: inline-flex;
    min-width: 205px;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border: 1px solid #326a64;
    border-radius: var(--radius);
    background: #173f3b;
    color: #d9fff9;
    font-size: 0.75rem;
    font-weight: 800;
}

.client-brand strong,
.client-brand small {
    display: block;
}

.client-brand strong {
    font-size: 0.88rem;
}

.client-brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.68rem;
}

.connection-state {
    display: grid;
    min-width: 0;
    grid-template-columns: auto minmax(0, auto) auto;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.78rem;
}

.connection-state small {
    padding-left: 8px;
    border-left: 1px solid var(--border);
    color: var(--faint);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    border-radius: 50%;
    background: var(--faint);
}

.status-online {
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(114, 211, 151, 0.11);
}

.status-pending {
    background: var(--amber);
    box-shadow: 0 0 0 3px rgba(232, 189, 101, 0.11);
}

.status-offline,
.status-locked {
    background: var(--red);
    box-shadow: 0 0 0 3px rgba(239, 131, 131, 0.1);
}

.bar-actions {
    display: flex;
    margin-left: auto;
    align-items: center;
    gap: 8px;
}

.button,
.icon-button,
.text-button {
    border: 0;
    background: transparent;
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 7px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 650;
    white-space: nowrap;
}

.button.compact {
    min-height: 34px;
    padding: 5px 10px;
    font-size: 0.76rem;
}

.button-primary {
    border-color: #347a72;
    background: var(--teal-dark);
    color: #e5fffb;
}

.button-primary:hover:not(:disabled) {
    background: #2f716a;
}

.button-secondary {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.button-secondary:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.button-danger {
    border-color: #985050;
    background: var(--red-dark);
    color: #fff0f0;
}

.button-danger:hover:not(:disabled) {
    background: #854545;
}

.button:disabled,
.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.icon-button {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 1rem;
}

.icon-button:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.text-button,
.text-link {
    padding: 3px 0;
    color: var(--blue);
    font-size: 0.76rem;
    text-decoration: none;
}

.text-button:hover,
.text-link:hover {
    color: #b1d9fc;
}

.panel-toggle {
    display: none;
    align-content: center;
    gap: 3px;
}

.mobile-connection {
    display: none;
}

.panel-toggle span {
    display: block;
    width: 15px;
    height: 1px;
    background: currentColor;
}

.client-workspace {
    display: grid;
    width: 100%;
    height: calc(100dvh - var(--bar-height));
    grid-template-columns: minmax(0, 1fr) var(--panel-width);
}

.terminal-pane {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    background: var(--terminal-bg);
}

.terminal-banner {
    display: flex;
    min-height: 32px;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-bottom: 1px solid #202426;
    background: #0e1112;
    color: var(--faint);
    font-size: 0.7rem;
}

.terminal-banner strong {
    color: var(--muted);
}

.terminal-banner span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-terminal {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 14px 16px 24px;
    color: #d8dedb;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: var(--terminal-font-size);
    /* The world is drawn for a terminal, so the character cell has to keep a
       terminal's proportions. This font advances 0.55em, so 1.48 gave a cell
       2.7x taller than wide and stretched every piece of ASCII art vertically;
       1.15 puts the cell near the 0.5 ratio a real terminal has. */
    line-height: 1.15;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    scrollbar-color: #424a4e #111416;
}

.game-terminal.no-wrap {
    overflow-wrap: normal;
    white-space: pre;
}

.terminal-time {
    color: #566166;
    user-select: none;
}

.terminal-local {
    color: #82b9c9;
}

.terminal-system {
    color: var(--amber);
}

.terminal-error {
    color: var(--red);
}

.ansi-bold { font-weight: 700; }
.ansi-dim { opacity: 0.7; }
.ansi-underline { text-decoration: underline; }
.ansi-italic { font-style: italic; }
.ansi-fg-black { --ansi-fg: #7b858a; color: #7b858a; }
.ansi-fg-red { --ansi-fg: #ef7d7d; color: #ef7d7d; }
.ansi-fg-green { --ansi-fg: #79d89d; color: #79d89d; }
.ansi-fg-yellow { --ansi-fg: #e8c66d; color: #e8c66d; }
.ansi-fg-blue { --ansi-fg: #80adea; color: #80adea; }
.ansi-fg-magenta { --ansi-fg: #cd94dc; color: #cd94dc; }
.ansi-fg-cyan { --ansi-fg: #6fd0ce; color: #6fd0ce; }
.ansi-fg-white { --ansi-fg: #e7ebed; color: #e7ebed; }
.ansi-fg-bright-black { --ansi-fg: #9ca5a9; color: #9ca5a9; }
.ansi-fg-bright-red { --ansi-fg: #ff9b9b; color: #ff9b9b; }
.ansi-fg-bright-green { --ansi-fg: #9aebb6; color: #9aebb6; }
.ansi-fg-bright-yellow { --ansi-fg: #f4db8b; color: #f4db8b; }
.ansi-fg-bright-blue { --ansi-fg: #a6c8f4; color: #a6c8f4; }
.ansi-fg-bright-magenta { --ansi-fg: #e5b0f0; color: #e5b0f0; }
.ansi-fg-bright-cyan { --ansi-fg: #9be5e2; color: #9be5e2; }
.ansi-fg-bright-white { --ansi-fg: #ffffff; color: #ffffff; }
.ansi-bg-black { --ansi-bg: #141719; background: #141719; }
.ansi-bg-red { --ansi-bg: #6a3030; background: #6a3030; }
.ansi-bg-green { --ansi-bg: #28583b; background: #28583b; }
.ansi-bg-yellow { --ansi-bg: #665329; background: #665329; }
.ansi-bg-blue { --ansi-bg: #304b70; background: #304b70; }
.ansi-bg-magenta { --ansi-bg: #583663; background: #583663; }
.ansi-bg-cyan { --ansi-bg: #285a5a; background: #285a5a; }
.ansi-bg-white { --ansi-bg: #b8bec1; background: #b8bec1; }
.ansi-bg-bright-black { --ansi-bg: #9ca5a9; background: #9ca5a9; }
.ansi-bg-bright-red { --ansi-bg: #ff9b9b; background: #ff9b9b; }
.ansi-bg-bright-green { --ansi-bg: #9aebb6; background: #9aebb6; }
.ansi-bg-bright-yellow { --ansi-bg: #f4db8b; background: #f4db8b; }
.ansi-bg-bright-blue { --ansi-bg: #a6c8f4; background: #a6c8f4; }
.ansi-bg-bright-magenta { --ansi-bg: #e5b0f0; background: #e5b0f0; }
.ansi-bg-bright-cyan { --ansi-bg: #9be5e2; background: #9be5e2; }
.ansi-bg-bright-white { --ansi-bg: #ffffff; background: #ffffff; }
/* An exact 256-colour or true colour, from the span's inline property. */
.ansi-fg-rgb { color: var(--ansi-fg); }
.ansi-bg-rgb { background: var(--ansi-bg); }
/* Reverse video swaps the two colours; an invert filter gave each
   colour's complement instead. Unset, they are the terminal's own. */
.ansi-inverse { color: var(--ansi-bg, var(--terminal-bg)); background: var(--ansi-fg, #d8dedb); }

.macro-strip {
    display: none;
    min-height: 38px;
    gap: 6px;
    overflow-x: auto;
    padding: 5px 10px;
    border-top: 1px solid #202426;
    background: #101314;
    scrollbar-width: thin;
}

.macro-strip.has-items {
    display: flex;
}

.macro-strip button {
    min-width: max-content;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.72rem;
}

.command-form {
    display: grid;
    min-height: 58px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-top: 1px solid var(--border);
    background: #111416;
}

.command-prompt {
    color: var(--teal);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-weight: 800;
}

.command-form input {
    width: 100%;
    height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: 0;
    background: #090b0c;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.command-form input:focus {
    border-color: #4c958c;
    box-shadow: 0 0 0 2px rgba(104, 201, 189, 0.1);
}

.command-form input[type="password"] {
    letter-spacing: 2px;
}

.send-button {
    min-width: 70px;
}

.mobile-actions {
    display: none;
}

.utility-panel {
    min-width: 0;
    min-height: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
}

.utility-heading {
    display: flex;
    height: 52px;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.segmented-control {
    display: grid;
    width: 100%;
    /* Sized from however many tabs are present. It was pinned at two, so
       adding the Help tab pushed the third one out of the control. */
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #101314;
}

.segmented-control button {
    min-height: 32px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.segmented-control button.is-active {
    background: var(--surface-3);
    color: var(--text);
}

.close-panel {
    display: none;
}

.utility-content {
    display: none;
    height: calc(100% - 52px);
    overflow-y: auto;
    scrollbar-color: #424a4e var(--surface);
}

.utility-content.is-active {
    display: block;
}

.utility-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.section-title,
.admin-bar,
.dialog-heading,
.log-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-title {
    min-height: 25px;
    margin-bottom: 12px;
}

.section-title h2,
.admin-locked h2,
.dialog-heading h2 {
    margin: 0;
    font-size: 0.88rem;
}

.direction-pad {
    display: grid;
    width: 226px;
    height: 150px;
    margin: 0 auto;
    /* Four columns: the three compass ones, plus up and down beside
       them, so the corners have somewhere to go. */
    grid-template-columns: repeat(4, 52px);
    grid-template-rows: repeat(3, 46px);
    gap: 6px;
}

.direction-pad button,
.command-grid button {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.74rem;
}

.direction-pad button:hover,
.command-grid button:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
    color: var(--text);
}

.direction-pad .northwest { grid-column: 1; grid-row: 1; }
.direction-pad .north     { grid-column: 2; grid-row: 1; }
.direction-pad .northeast { grid-column: 3; grid-row: 1; }
.direction-pad .up        { grid-column: 4; grid-row: 1; }
.direction-pad .west      { grid-column: 1; grid-row: 2; }
.direction-pad .center    { grid-column: 2; grid-row: 2; }
.direction-pad .east      { grid-column: 3; grid-row: 2; }
.direction-pad .down      { grid-column: 4; grid-row: 2; }
.direction-pad .southwest { grid-column: 1; grid-row: 3; }
.direction-pad .south     { grid-column: 2; grid-row: 3; }
.direction-pad .southeast { grid-column: 3; grid-row: 3; }

.command-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.command-grid button {
    min-height: 38px;
    padding: 5px;
}

.alias-list {
    display: grid;
}

.alias-row {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 9px 0;
    border-top: 1px solid #292e31;
}

.alias-row:first-child {
    border-top: 0;
}

.alias-row strong,
.alias-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alias-row strong {
    color: var(--teal);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.76rem;
}

.alias-row small,
.muted {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.7rem;
}

.alias-buttons {
    display: flex;
    gap: 8px;
}

.alias-buttons button {
    padding: 3px 0;
    border: 0;
    background: transparent;
    color: var(--blue);
    font-size: 0.68rem;
}

.settings-section {
    display: grid;
    gap: 0;
}

.range-row,
.toggle-row {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #292e31;
    color: var(--muted);
    font-size: 0.75rem;
}

.settings-section .range-row:first-of-type,
.dialog .toggle-row {
    border-top: 0;
}

.range-row span,
.toggle-row span {
    flex: 1;
}

.range-row input {
    min-width: 90px;
    accent-color: var(--teal);
}

.range-row output {
    width: 36px;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    text-align: right;
}

.toggle-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--teal);
}

.session-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.admin-locked {
    display: grid;
    min-height: 320px;
    place-items: center;
    align-content: center;
    gap: 14px;
    padding: 30px;
    text-align: center;
}

.admin-bar {
    min-height: 50px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

.admin-bar > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-summary {
    padding-top: 14px;
}

.admin-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--border);
}

.admin-metrics div {
    min-width: 0;
    padding: 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.admin-metrics div:nth-child(2n) {
    border-right: 0;
}

.admin-metrics div:nth-last-child(-n + 2) {
    border-bottom: 0;
}

.admin-metrics span,
.admin-metrics strong {
    display: block;
}

.admin-metrics span {
    color: var(--faint);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-metrics strong {
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1rem;
    white-space: nowrap;
}

.admin-section {
    border-bottom: 1px solid var(--border);
}

.admin-section > summary {
    position: relative;
    min-height: 46px;
    padding: 14px 38px 12px 16px;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 750;
    list-style: none;
}

.admin-section > summary::-webkit-details-marker {
    display: none;
}

.admin-section > summary::after {
    position: absolute;
    top: 13px;
    right: 16px;
    color: var(--faint);
    content: "+";
    font-size: 1rem;
}

.admin-section[open] > summary::after {
    content: "-";
}

.inline-form,
.stack-form,
.operation-list,
.log-actions,
.player-summary,
.backup-list {
    margin: 0 14px 14px;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
}

input,
textarea,
select {
    width: 100%;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: 0;
    background: #0d1011;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #4c958c;
}

textarea {
    resize: vertical;
}

.stack-form {
    display: grid;
    gap: 10px;
}

.stack-form label,
.dialog label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.72rem;
}

.player-summary {
    min-height: 40px;
    padding: 10px;
    border: 1px solid var(--border);
    background: #101314;
}

.player-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.player-heading strong {
    overflow-wrap: anywhere;
}

.player-heading span {
    color: var(--amber);
    font-size: 0.72rem;
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin-top: 8px;
    background: var(--border);
}

.player-grid div {
    min-width: 0;
    padding: 7px;
    background: #101314;
}

.player-grid span,
.player-grid strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.equipment-list {
    display: grid;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.equipment-list div {
    display: grid;
    min-width: 0;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #292e31;
    font-size: 0.66rem;
}

.equipment-list span {
    color: var(--faint);
}

.equipment-list strong {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-grid span {
    color: var(--faint);
    font-size: 0.6rem;
    text-transform: uppercase;
}

.player-grid strong {
    margin-top: 3px;
    font-size: 0.72rem;
}

.log-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.log-actions span {
    margin-left: auto;
    color: var(--faint);
    font-size: 0.68rem;
}

.activity-toolbar {
    display: grid;
    gap: 8px;
    margin: 0 14px 10px;
}

.event-filter {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.event-filter button {
    min-width: 0;
}

.activity-actions {
    display: flex;
    min-height: 28px;
    align-items: center;
    gap: 12px;
}

.activity-actions span {
    margin-left: auto;
    color: var(--faint);
    font-size: 0.68rem;
}

.server-events {
    height: 280px;
    margin: 0 14px 14px;
    overflow: auto;
    border: 1px solid var(--border);
    background: #080a0b;
    scrollbar-color: #424a4e #080a0b;
}

.server-event {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 4px 9px;
    padding: 9px 10px;
    border-bottom: 1px solid #262b2e;
}

.server-event:last-child {
    border-bottom: 0;
}

.server-event time {
    grid-row: 1 / span 2;
    color: var(--faint);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.62rem;
    line-height: 1.6;
    white-space: nowrap;
}

.event-channel {
    justify-self: start;
    color: #73d4b0;
    font-size: 0.61rem;
    font-weight: 800;
    text-transform: uppercase;
}

.server-event.event-wizinfo .event-channel {
    color: #e9bd63;
}

.server-event p {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: #d1d8d5;
    font-size: 0.7rem;
    line-height: 1.45;
}

.event-empty {
    display: grid;
    height: 100%;
    place-items: center;
    padding: 20px;
    color: var(--faint);
    font-size: 0.72rem;
    text-align: center;
}

.admin-log {
    height: 260px;
    margin: 0 14px 14px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--border);
    background: #080a0b;
    color: #bbc3c6;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.67rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.operation-list {
    display: grid;
    gap: 7px;
}

.backup-list {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.68rem;
}

.backup-list div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-top: 5px;
    border-top: 1px solid #292e31;
}

.panel-scrim {
    display: none;
}

.dialog {
    width: min(440px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.dialog form {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.dialog-heading {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.dialog-heading .icon-button {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

.eyebrow {
    display: block;
    margin-bottom: 3px;
    color: var(--faint);
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dialog p {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

.form-error {
    min-height: 18px;
    color: var(--red) !important;
}

.toast-region {
    position: fixed;
    z-index: 100;
    right: 18px;
    bottom: 18px;
    display: grid;
    width: min(350px, calc(100vw - 36px));
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--teal);
    border-radius: var(--radius);
    background: #191d1f;
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 0.76rem;
}

.toast.error {
    border-left-color: var(--red);
}

.toast.success {
    border-left-color: var(--green);
}

@media (max-width: 980px) {
    .client-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .utility-panel {
        position: fixed;
        z-index: 60;
        top: var(--bar-height);
        right: 0;
        bottom: 0;
        width: min(var(--panel-width), calc(100vw - 34px));
        border-left: 1px solid var(--border-strong);
        box-shadow: -14px 0 40px rgba(0, 0, 0, 0.45);
        transform: translateX(105%);
        transition: transform 160ms ease;
    }

    body.panel-open .utility-panel {
        transform: translateX(0);
    }

    .panel-toggle,
    .close-panel {
        display: grid;
    }

    .panel-scrim {
        position: fixed;
        z-index: 50;
        inset: var(--bar-height) 0 0;
        background: rgba(0, 0, 0, 0.58);
    }

    body.panel-open .panel-scrim {
        display: block;
    }
}

@media (max-width: 640px) {
    :root {
        --bar-height: 58px;
    }

    .client-bar {
        gap: 8px;
        padding: 6px 9px;
    }

    .client-brand {
        min-width: 0;
    }

    .client-brand > span:last-child {
        display: none;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .connection-state {
        flex: 1;
        grid-template-columns: auto minmax(0, 1fr);
        font-size: 0.7rem;
    }

    .connection-state #game-status {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .connection-state small {
        display: none;
    }

    .bar-actions {
        gap: 5px;
    }

    .bar-actions .button {
        display: none;
    }

    .mobile-connection {
        display: grid;
    }

    .terminal-banner {
        min-height: 28px;
        padding-inline: 10px;
    }

    .game-terminal {
        padding: 10px 10px 18px;
        line-height: 1.42;
    }

    .command-form {
        min-height: 54px;
        gap: 7px;
        padding: 7px 8px;
    }

    .send-button {
        min-width: 58px;
        padding-inline: 9px;
    }

    .mobile-actions {
        display: grid;
        height: 86px;
        grid-template-columns: repeat(9, minmax(48px, 1fr));
        gap: 5px;
        overflow-x: auto;
        padding: 7px 8px;
        border-top: 1px solid var(--border);
        background: #111416;
        scrollbar-width: none;
    }

    .mobile-actions::-webkit-scrollbar {
        display: none;
    }

    .mobile-actions button {
        min-width: 48px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface-2);
        color: var(--text);
        font-size: 0.68rem;
    }

    .terminal-pane {
        grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    }

    .toast-region {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
    }
}

@media (max-height: 600px) and (max-width: 980px) {
    .mobile-actions {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .utility-panel {
        transition: none;
    }
}

/* Help browser -----------------------------------------------------------
   A list of topics beside the one being read. It stacks on a narrow panel,
   where side by side would leave both halves too cramped to use. */
.help-layout {
    display: grid;
    grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
    gap: 0.75rem;
    margin-top: 0.6rem;
    min-height: 0;
}

.help-topics {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 26rem;
    overflow-y: auto;
    padding-right: 2px;
}

.help-topic {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    padding: 0.3rem 0.45rem;
    text-align: left;
}

.help-topic:hover { background: var(--surface-3); }

.help-topic.is-active {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: inherit;
}

.help-article {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 26rem;
    overflow-y: auto;
    padding: 0.75rem;
}

.help-article h3 { margin: 0 0 0.5rem; }

/* Help text is laid out with spaces in the area files, so it needs a fixed
   pitch and its own line breaks kept. */
.help-body {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

#help-search {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: inherit;
    font: inherit;
    padding: 0.35rem 0.5rem;
    width: 100%;
}

@media (max-width: 640px) {
    .help-layout { grid-template-columns: minmax(0, 1fr); }
    .help-topics { max-height: 11rem; }
}

/* Routes panel: travel directions, checked against the world. */
.routes-intro {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.routes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    overflow-y: auto;
}

.route-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 10px 12px;
}

.route-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.route-head h3 {
    margin: 0;
    font-size: 13px;
    color: var(--text);
}

.route-badge {
    flex: none;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    color: var(--muted);
}

.route-verified,
.route-computed { color: var(--teal); border-color: var(--teal-dark); }

/* A handed-down route that had to be re-walked, and one that no longer
   arrives -- both still worth showing, with the difference visible. */
.route-repaired { color: var(--amber); border-color: var(--amber); }
.route-drifted { color: var(--red); border-color: var(--red-dark); }

/* What kind of route this is, beside how well it holds up. */
.route-tags { display: inline-flex; gap: 6px; flex: none; }

.route-kind {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px dashed var(--border-strong);
    color: var(--faint);
}

.route-dest {
    margin: 4px 0 8px;
    font-size: 12px;
    color: var(--muted);
}

/* The whole point of the panel: one click sends the lot. */
.route-commands {
    display: block;
    width: 100%;
    text-align: left;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
    background: var(--terminal-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    word-break: break-word;
}

.route-commands:hover { border-color: var(--teal-dark); }

.route-steps,
.route-note {
    margin: 8px 0 0;
    font-size: 11px;
    line-height: 1.6;
    color: var(--faint);
}

.route-note { color: var(--muted); }

/* Routes: the Mudlet separator toggle, and copying a set of directions.
   Mudlet reads a single semicolon as literal text, so directions pasted
   from here ran as one long nonsense command until the toggle existed. */
.routes-mudlet {
    /* The label's text is wrapped in one span on purpose. Left bare it
       is three flex items -- text, <code>, text -- so the gap opens up
       inside the sentence and each piece wraps on its own. */
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin: 0.5rem 0 0.25rem;
    font-size: 0.85rem;
    opacity: 0.85;
    cursor: pointer;
}

/* In the dashboard this label sits in a four-column filter grid, where
   a 159px cell folded it onto two lines. It wants the whole row. */
.filter-grid > .routes-mudlet {
    grid-column: 1 / -1;
    margin: 0;
}

.routes-mudlet > span {
    /* One flex item, so the sentence wraps as a sentence. */
    min-width: 0;
}

.routes-mudlet input[type="checkbox"] {
    /* The filter grid sizes form controls to 38px, which is right for a
       text box and three times too tall for a tick. */
    width: auto;
    height: auto;
    /* The global `input, select, textarea' rule sets min-height 38px and
       padding for text boxes; a tick inherits both and ends up three
       times too tall, which pushed the label onto two lines. */
    min-height: 0;
    padding: 0;
    flex: 0 0 auto;
    align-self: center;
    margin: 0;
    cursor: pointer;
}

.routes-mudlet code {
    padding: 0 0.25rem;
    border-radius: 3px;
    background: rgba(127, 127, 127, 0.22);
    font-size: 0.95em;
}

.route-command-row {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
}

.route-command-row > .route-commands {
    flex: 1 1 auto;
    min-width: 0;
}

.route-copy {
    flex: 0 0 auto;
    align-self: stretch;
    padding: 0 0.7rem;
    border: 1px solid rgba(127, 127, 127, 0.45);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.route-copy:hover {
    border-color: currentColor;
}

.route-copy.is-copied {
    border-color: #4caf50;
    color: #4caf50;
}

/* "How to connect" strip under the header: telnet address + Mudlet.
   Always visible so a new player knows how to reach the game and that
   Mudlet is the recommended way. Wraps to two rows on a phone. */
.play-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.play-info-telnet { color: var(--muted); }
.play-info-label { color: var(--text); font-weight: 650; margin-right: 8px; }
.play-info code {
    color: var(--teal);
    background: var(--terminal-bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}
.play-info-mudlet {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    color: var(--text);
    text-decoration: none;
    background: var(--teal-dark);
    border: 1px solid var(--teal);
    border-radius: var(--radius);
    font-weight: 600;
    transition: background 0.15s ease;
}
.play-info-mudlet:hover { background: var(--teal); }
.play-info-links { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.play-info-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 600;
    transition: border-color 0.15s ease;
}
.play-info-link:hover { border-color: var(--teal); }
.play-info-icon { width: 18px; height: 18px; color: var(--teal); flex: none; }
.play-info-mudlet:hover .play-info-icon { color: var(--text); }
@media (max-width: 640px) {
    .play-info { justify-content: center; text-align: center; }
    .play-info-links { width: 100%; }
    .play-info-mudlet, .play-info-link { width: 100%; justify-content: center; }
}
