:root {
    color-scheme: light;
    --paper: #f5f4eb;
    --ink: #293e35;
    --muted: #7b8679;
    --line: #dedfd2;
    --character-colour: #e07a5f;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--paper);
    color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 3px solid #3b765a;
    outline-offset: 4px;
}
.page { width: min(1280px, calc(100% - 96px)); margin: 0 auto; }
.topbar {
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; font-size: 25px; font-weight: 650; letter-spacing: -1px; }
.brand-caption { display: block; margin-top: 4px; font-size: 11px; letter-spacing: .4px; color: var(--muted); font-weight: 400; }
.brand-mark { position: relative; width: 35px; height: 36px; border-radius: 50%; background: #e1e7d6; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: #52765a; width: 13px; height: 19px; border-radius: 12px 2px 12px 2px; top: 6px; left: 8px; transform: rotate(-24deg); }
.brand-mark::after { width: 10px; height: 15px; background: #84a274; left: 19px; top: 13px; transform: rotate(26deg); }
.world-status { display: flex; gap: 18px; align-items: center; font-size: 12px; color: #637363; }
.connection-status { display: inline-flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #b5bcae; }
[data-state="connected"] .status-dot { background: #6d9760; box-shadow: 0 0 0 4px #6d976014; }
[data-state="connecting"] .status-dot { background: #d1aa58; animation: breathe 1s infinite alternate; }
.population { border: 1px solid #d9dece; background: #ecf0e4; padding: 7px 12px; border-radius: 20px; white-space: nowrap; }
.leave-button { background: transparent; border: 0; padding: 6px 0; color: #687567; text-decoration: underline; text-underline-offset: 3px; }
.world-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 36px 0 25px; }
.eyebrow { display: block; color: var(--muted); font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; font-weight: 600; }
h1 { margin: 9px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(32px, 4vw, 47px); font-weight: 400; letter-spacing: -1.7px; }
.world-heading p { margin: 0 0 3px; color: var(--muted); font-size: 12px; line-height: 1.8; text-align: right; }
.world-shell { position: relative; overflow: hidden; border: 1px solid #c6d3b9; border-radius: 17px; background: #dfe8cf; box-shadow: 0 7px 25px #42583506; }
canvas { display: block; width: 100%; aspect-ratio: 8 / 5; min-height: 570px; outline: none; }
canvas:focus-visible { box-shadow: inset 0 0 0 3px #52765a70; border-radius: 16px; }
.join-overlay { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; padding: 24px; background: #e3e9d74d; backdrop-filter: blur(3px); }
.join-card { width: 366px; padding: 27px 29px 23px; background: #fffef8; border: 1px solid #f4f3e9; border-radius: 14px; box-shadow: 0 12px 60px #3f573c1f; text-align: center; }
.avatar-preview { margin: 0 auto 17px; width: 41px; height: 41px; border-radius: 50% 50% 45% 45%; background: var(--character-colour); border: 1.5px solid #00000020; box-shadow: 0 5px 0 #0000000a; display: flex; align-items: center; justify-content: center; gap: 8px; }
.avatar-preview span { display: block; width: 5px; height: 7px; background: #273a31; border-radius: 50%; transform: translateY(-1px); }
.join-card .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
h2 { margin: 10px -10px; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 26px; line-height: 1.2; letter-spacing: -.7px; }
.join-card > p:not(.join-error) { margin: 12px 0 23px; font-size: 12px; line-height: 1.75; color: var(--muted); }
.field-label { display: block; font-size: 11px; font-weight: 600; text-align: left; }
#player-name { width: 100%; margin-top: 8px; padding: 11px 12px; border: 1px solid #dfe2d7; background: #fbfcf7; border-radius: 6px; color: var(--ink); font-size: 13px; }
#player-name::placeholder { color: #a0a799; }
.field-hint { display: block; margin-top: 7px; font-size: 10px; color: #91998b; text-align: left; }
.colour-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.custom-colour { position: relative; color: #85917f; font-size: 10px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.custom-colour input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.custom-colour:focus-within { outline: 2px solid #3b765a; outline-offset: 3px; }
.colour-swatches { display: flex; justify-content: space-between; margin: 13px 0 17px; padding: 0 3px; }
.colour-swatches button { display: block; width: 25px; height: 25px; padding: 0; border: 2px solid #fffef8; border-radius: 50%; background: var(--swatch); outline-offset: 1px; transition: transform .15s; }
.colour-swatches button:hover { transform: translateY(-2px); }
.colour-swatches [aria-pressed="true"] { outline: 1.5px solid var(--swatch); }
.join-error { margin: 0; font-size: 11px; color: #a34e36; line-height: 1.5; text-align: left; }
.join-error:not(:empty) { margin: 0 0 12px; }
.join-button { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; border-radius: 7px; padding: 12px 14px; background: #345a41; color: #fffef7; font-size: 12px; font-weight: 500; transition: background .15s; }
.join-button:hover { background: #284b34; }
.join-button span { font-size: 18px; line-height: 14px; }
.keyboard-note { display: block; margin-top: 13px; font-size: 9px; color: #99a08f; }
.world-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 2px; font-size: 11px; color: var(--muted); }
.controls, .key-group { display: flex; gap: 5px; align-items: center; }
.controls { gap: 10px; }
kbd { display: inline-flex; align-items: center; justify-content: center; width: 21px; height: 22px; font-family: inherit; font-size: 10px; background: #fafaf4; border: 1px solid #d8dcce; border-bottom-width: 2px; border-radius: 4px; color: #64745e; }
.footer-note { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 13px; }
.page-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding: 20px 0 24px; margin-top: 13px; font-size: 10px; color: #9aA18f; }
@keyframes breathe { to { opacity: .3; } }
@media (max-width: 900px) {
    .page { width: calc(100% - 48px); }
    .topbar { min-height: 90px; }
    .world-heading { padding-top: 27px; }
    canvas { min-height: 570px; }
    .join-card { padding-top: 24px; padding-bottom: 21px; }
}
@media (max-width: 560px) {
    .page { width: calc(100% - 28px); }
    .topbar { gap: 12px; min-height: 83px; }
    .brand { gap: 9px; font-size: 21px; }
    .brand-caption { font-size: 9px; letter-spacing: 0; }
    .brand-mark { transform: scale(.85); }
    .world-status { gap: 9px; font-size: 10px; }
    .connection-status #status-text { display: none; }
    .population { padding: 6px 9px; }
    .world-heading { gap: 10px; padding-bottom: 20px; }
    .world-heading .eyebrow { max-width: 190px; line-height: 1.6; font-size: 8px; letter-spacing: 1px; }
    .world-heading p { font-size: 10px; }
    .join-overlay { padding: 15px; }
    .join-card { width: min(100%, 366px); padding-left: 23px; padding-right: 23px; }
    h2 { font-size: 24px; }
    .world-footer { align-items: flex-start; gap: 10px; }
    .controls { gap: 7px; font-size: 9px; }
    .footer-note { max-width: 100px; text-align: right; line-height: 1.5; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
