:root {
    --bg: #14201a;
    --panel: #1e2d24;
    --panel-2: #26382d;
    --line: #3a4d40;
    --text: #f2efe4;
    --muted: #c9c3b0;
    --accent: #f5c542;
    --accent-ink: #1a1608;
    --green: #6fd08c;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#game {
    position: fixed;
    inset: 0;
    touch-action: none;
}

#game canvas {
    display: block;
    touch-action: none;
}

svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

/* ---------- menu screens ---------- */

#menu {
    position: fixed;
    inset: 0;
    z-index: 10;
    overflow-y: auto;
    background:
        radial-gradient(120% 60% at 50% 0%, #24402e 0%, rgba(20, 32, 26, 0) 70%),
        var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
}

#menu[hidden], .screen[hidden] {
    display: none;
}

.screen,
#menu-form,
#pin-form {
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.screen {
    padding: max(24px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

/* start page */

#screen-start {
    justify-content: safe center;
    gap: 32px;
    min-height: 100%;
}

/* phone held sideways: title left, choices right */
@media (orientation: landscape) and (max-height: 560px) {
    #screen-start {
        max-width: 860px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: center;
        gap: 24px;
    }

    .hero h1 { font-size: 36px; }
}

.hero {
    text-align: center;
}


.hero h1 {
    margin: 0;
    font-size: 44px;
    line-height: 1.05;
    letter-spacing: 0.01em;
    color: var(--accent);
}

.tagline {
    margin: 8px 0 0;
    font-size: 17px;
    color: var(--muted);
}

.online {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 1.4em;
    margin: 14px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.online.live::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(111, 208, 140, 0.25);
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 60px;
    padding: 12px 18px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 18px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.choice span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.choice small {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.choice:hover { background: var(--panel-2); }

.choice.primary {
    min-height: 76px;
    border: 0;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 24px;
    box-shadow: 0 8px 28px rgba(245, 197, 66, 0.25);
    justify-content: center;
}

.choice.primary svg { fill: currentColor; }

/* start page: what is going on */
.lobby {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lobby[hidden] { display: none; }

.lobby-card {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.lobby-card h2 {
    margin: 0 0 10px;
    font-size: 15px;
    letter-spacing: 0.02em;
    color: var(--accent);
}

.feed, .recent, .top {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed li, .top li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    line-height: 1.35;
}

.feed .icon-emoji { flex: 0 0 auto; width: 24px; text-align: center; font-size: 18px; }
.feed .what { flex: 1; min-width: 0; }
.feed time, .recent time { flex: 0 0 auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed .empty-note, .top .empty-note { color: var(--muted); }

.face {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #0d1511;
    object-fit: contain;
    image-rendering: pixelated;
}

/* who was there: little figures in a row */
.recent {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.recent li {
    flex: 0 0 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
}

.recent .face { position: relative; width: 48px; height: 48px; border-radius: 12px; }
.recent .who { position: relative; }
.recent .who.on::after {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid var(--panel);
}
.recent b { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.recent .where { font-size: 11px; color: var(--green); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.top-tabs { margin-bottom: 10px; }
.top-tabs span { min-height: 36px; font-size: 14px; }
.top .rank { flex: 0 0 auto; width: 26px; text-align: center; font-size: 18px; }
.top .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .value { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.top li.me .name { color: var(--accent); }

@media (orientation: landscape) and (max-height: 560px) {
    .lobby { grid-column: 1 / -1; }
}

/* settings + map editor: small and quiet, bottom right */
.corner {
    position: fixed;
    right: calc(10px + env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    display: flex;
    gap: 2px;
}

.corner-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    opacity: 0.45;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}

.corner-btn svg { width: 20px; height: 20px; }
.corner-btn:hover, .corner-btn:focus-visible { opacity: 1; background: var(--panel); }

.choice:focus-visible, .corner-btn:focus-visible, .back:focus-visible, #menu .submit:focus-visible, .char:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* sub screens */

.screen-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.screen-head h2 {
    margin: 0;
    font-size: 24px;
}

.back {
    width: 44px;
    height: 44px;
    margin-left: -10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.back:hover { background: var(--panel-2); }

#menu label,
.menu-label {
    margin: 8px 0 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
}

#menu input[type="text"],
#menu input.pin {
    font: inherit;
    font-size: 18px; /* >=16px prevents auto-zoom on iOS */
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid var(--line);
    background: #0d1511;
    color: var(--text);
    -webkit-user-select: text;
    user-select: text;
}

#menu input[type="text"]:focus,
#menu input.pin:focus {
    outline: none;
    border-color: var(--accent);
}

#char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 8px;
}

.char {
    aspect-ratio: 1;
    padding: 4px;
    border-radius: 10px;
    border: 2px solid var(--line);
    background: var(--panel);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none;
}

.char[aria-checked="true"] {
    border-color: var(--accent);
    background: #3b3a1e;
}

#menu-hint {
    min-height: 1.2em;
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--muted);
}

#menu input.pin {
    max-width: 160px;
    letter-spacing: 0.5em;
    font-size: 22px;
}

#menu .submit {
    position: sticky;
    bottom: 12px;
    font: inherit;
    font-size: 20px;
    font-weight: 700;
    padding: 14px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
}

#menu .submit:disabled {
    background: #2c3a31;
    color: #aaa696;
    cursor: default;
}

/* settings */

fieldset {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

legend {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.muted {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: #0d1511;
}

#menu .segmented label { margin: 0; }

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

.segmented span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 9px;
    font-size: 16px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

.segmented input:checked + span {
    background: var(--accent);
    color: var(--accent-ink);
}

.segmented input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* zoom slider: settings page and game menu */
.zoom-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    font-size: 14px;
    color: var(--muted);
}

.zoom-row input, .menu-zoom input {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.menu-zoom {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    color: #2b3137;
    font-size: 15px;
}

.menu-zoom svg {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.menu-zoom input { accent-color: #1f6fd1; }

#menu label.switch {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 44px;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
}

.switch span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.switch small {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.switch input {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 48px;
    height: 28px;
    margin: 0;
    border-radius: 14px;
    background: #0d1511;
    border: 1px solid var(--line);
    position: relative;
    cursor: pointer;
    transition: background 0.15s;
}

.switch input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s;
}

.switch input:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.switch input:checked::after {
    background: var(--accent-ink);
    transform: translateX(20px);
}

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

/* ---------- login / account ---------- */

.choice .avatar {
    width: 40px;
    height: 40px;
    margin: -6px 0;
    image-rendering: pixelated;
    object-fit: contain;
}

.account {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 16px;
    margin: -12px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.account[hidden] { display: none; }

.link {
    font: inherit;
    min-height: 44px;
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.hint {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.form-error {
    min-height: 1.2em;
    margin: 4px 0 0;
    font-size: 14px;
    color: #ff8a7a;
}

.alt {
    margin: 8px 0 0;
    text-align: center;
    font-size: 15px;
    color: var(--muted);
}

#screen-kicked {
    justify-content: safe center;
    gap: 24px;
    min-height: 100%;
}

#screen-kicked h2 {
    margin: 0;
    font-size: 30px;
    color: var(--accent);
}

/* ---------- in game panel (inventory, merchant) ---------- */

#panel {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: var(--text);
}

#panel[hidden] { display: none; }

.sheet {
    width: 100%;
    max-width: 560px;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    border-radius: 18px 18px 0 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
}

@media (orientation: landscape) and (max-height: 560px) {
    #panel { align-items: stretch; justify-content: flex-end; }
    .sheet { max-height: none; max-width: 420px; border-radius: 18px 0 0 18px; border: 1px solid var(--line); border-right: 0; }
}

.sheet-head, .tabs, .detail {
    flex-shrink: 0;
}

.sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 10px 8px 18px;
}

.sheet-head > div { flex: 1; min-width: 0; }

.sheet-head h2 {
    margin: 0;
    font-size: 20px;
}

.sheet-head .muted { margin-top: 2px; }

.gold {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: #0d1511;
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 12px 8px;
}

.tabs:empty { display: none; }

.views {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: #0d1511;
}

.view {
    min-height: 40px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.view[aria-pressed="true"] {
    background: var(--panel-2);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--line);
}

.chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.tab {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.tab[aria-selected="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.sheet-body {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 4px 12px 12px;
}

.empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--muted);
}

/* inventory grid */

.slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
}

.slot {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    border: 2px solid var(--line);
    background: #0d1511;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.slot[aria-pressed="true"] { border-color: var(--accent); }

.slot .count {
    position: absolute;
    right: 4px;
    bottom: 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-shadow: 0 1px 2px #000;
}

.icon {
    width: 34px;
    height: 34px;
    font-size: 28px;
    line-height: 34px;
    text-align: center;
    object-fit: contain;
}

/* merchant list */

.wares {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ware {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 10px;
    border-radius: 12px;
    background: #0d1511;
}

.ware .info { flex: 1; min-width: 0; }
.ware .name { font-weight: 600; }
.ware .desc { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ware .have { font-size: 12px; color: var(--muted); }

/* sold by other players: the merchant has only a few */
.ware.used { box-shadow: inset 3px 0 0 var(--accent); }
.ware .stock { font-size: 12px; font-weight: 600; color: var(--accent); }

/* tap the text of a ware: the full description */
.ware .info { cursor: pointer; }
.ware .more { display: none; margin-top: 4px; font-size: 13px; line-height: 1.45; color: var(--text); }
.ware.open .desc { white-space: normal; }
.ware.open .more { display: block; }
.ware.open { box-shadow: inset 3px 0 0 var(--green); }
.item-info { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* a book from the bag */
.book { max-width: 640px; margin: 0 auto; padding-bottom: 8px; }
.book h3 { margin: 16px 0 4px; font-size: 15px; color: var(--accent); }
.book h3:first-child { margin-top: 4px; }
.book p { margin: 0; font-size: 15px; line-height: 1.55; }
.book .book-back { width: 100%; margin-top: 20px; }

.buy {
    flex: 0 0 auto;
    min-width: 76px;
    min-height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.buy:disabled { background: #2c3a31; color: #aaa696; cursor: default; }

.detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

.detail[hidden] { display: none; }

.detail-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.act {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.act.main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.act.danger-soft { color: #ff8a7a; }
.act.danger { background: #c4473a; border-color: #c4473a; color: #fff; }

.slot .badge {
    position: absolute;
    left: 4px;
    top: 3px;
    padding: 0 4px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 10px;
    font-weight: 700;
}

.buy.sell { background: var(--green); color: #0d1511; }

/* stats view */

.hpbar {
    position: relative;
    height: 28px;
    border-radius: 14px;
    background: #0d1511;
    overflow: hidden;
    margin: 4px 0 8px;
}

.hpbar span {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, #c4473a, #e8695a);
}

.hpbar b {
    position: relative;
    display: block;
    line-height: 28px;
    text-align: center;
    font-size: 14px;
    text-shadow: 0 1px 2px #000;
}

.sub {
    margin: 14px 0 6px;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.attrs { margin: 0; display: flex; flex-direction: column; gap: 4px; }

.attrs > div {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #0d1511;
}

.attrs dt { flex: 1; font-weight: 600; display: flex; flex-direction: column; }
.attrs dt small { font-weight: 400; font-size: 12px; color: var(--muted); }
.attrs dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.attrs .up { font-size: 13px; color: var(--green); }
.attrs .down { font-size: 13px; color: #ff8a7a; }

.equip { display: flex; flex-direction: column; gap: 4px; }

.eq {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 4px 12px;
    border: 0;
    border-radius: 10px;
    background: #0d1511;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.eq:disabled { cursor: default; }
.eq .icon { width: 28px; height: 28px; font-size: 22px; line-height: 28px; }
.eq-slot { width: 64px; font-size: 13px; color: var(--muted); }
.eq-name { flex: 1; font-weight: 600; }
.eq-off { font-size: 13px; color: var(--accent); }

.hint-small { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.detail .info { flex: 1; min-width: 0; }
.detail .name { font-weight: 700; }
.detail .desc { font-size: 14px; color: var(--muted); }

.view:focus-visible, .act:focus-visible, .eq:focus-visible,
.slot:focus-visible, .tab:focus-visible, .buy:focus-visible, .link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- chat: WhatsApp style at the top of the screen ---------- */

#chat {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(8px + env(safe-area-inset-top)) 8px 0;
    background: linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 70%);
    color: #e9edef;
}

#chat[hidden] { display: none; }

.wa {
    width: 100%;
    max-width: 560px;
    max-height: 55dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background-color: #0b141a;
    /* the faint WhatsApp wallpaper dots */
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 14px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    animation: wa-in 0.18s ease-out;
}

@media (orientation: landscape) and (max-height: 560px) {
    .wa { max-height: 70dvh; }
}

@keyframes wa-in {
    from { transform: translateY(-24px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.wa-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px 8px 10px;
    background: #202c33;
}

.wa-avatar {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #3b4a54;
    color: #0b141a;
    font-size: 18px;
    font-weight: 800;
}

.wa-title { flex: 1; min-width: 0; }

.wa-title h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-title p {
    margin: 0;
    font-size: 12px;
    color: #8696a0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-all {
    flex: none;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 17px;
    border: 1px solid #3b4a54;
    background: transparent;
    color: #e9edef;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.wa-all[hidden] { display: none; }

.wa-close {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.wa-close svg, .wa-send svg {
    width: 22px;
    height: 22px;
}

.wa-close svg {
    stroke: #aebac1;
    stroke-width: 2.4;
    stroke-linecap: round;
    fill: none;
}

.wa-body {
    flex: 1;
    min-height: 90px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 10px 6px;
}

.wa-log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wa-log li {
    position: relative;
    max-width: 78%;
    padding: 6px 9px 6px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    -webkit-user-select: text;
    user-select: text;
}

.wa-log li.first { margin-top: 6px; }

/* the others: left, dark grey */
.wa-log li.other {
    align-self: flex-start;
    background: #202c33;
}

/* own: right, green */
.wa-log li.own {
    align-self: flex-end;
    background: #005c4b;
}

/* the little tail at the first bubble of a row */
.wa-log li.other.first { border-top-left-radius: 0; }
.wa-log li.own.first { border-top-right-radius: 0; }

.wa-log li.other.first::before, .wa-log li.own.first::before {
    content: "";
    position: absolute;
    top: 0;
    width: 8px;
    height: 10px;
}

.wa-log li.other.first::before {
    left: -7px;
    background: inherit;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.wa-log li.own.first::before {
    right: -7px;
    background: inherit;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.wa-log li.private { cursor: pointer; }
.wa-log li.other.private { background: #2a3942; outline: 1px dashed #53bdeb; outline-offset: -1px; }

.wa-log .who {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #53bdeb;
}

.wa-log .time {
    float: right;
    margin: 6px 0 -4px 10px;
    font-size: 11px;
    color: rgba(233, 237, 239, 0.6);
}

.wa-log li.system {
    align-self: center;
    margin: 8px 0 4px;
    padding: 4px 10px;
    border-radius: 8px;
    background: #182229;
    font-size: 12px;
    color: #8696a0;
    box-shadow: none;
}

.wa-form {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #202c33;
}

#chat-input {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 21px;
    background: #2a3942;
    color: #e9edef;
    font: inherit;
    font-size: 16px;
    -webkit-user-select: text;
    user-select: text;
}

#chat-input::placeholder { color: #8696a0; }
#chat-input:focus { outline: 2px solid #00a884; outline-offset: -2px; }

.wa-send {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: #00a884;
    cursor: pointer;
}

.wa-send svg { fill: #0b141a; }

.wa-close:focus-visible, .wa-send:focus-visible, .wa-all:focus-visible, #chat-banner:focus-visible {
    outline: 2px solid #00a884;
    outline-offset: 2px;
}

/* new message while the chat is closed */
#chat-banner {
    position: fixed;
    z-index: 19;
    top: calc(8px + env(safe-area-inset-top));
    left: 50%;
    width: calc(100% - 16px);
    max-width: 480px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 14px;
    border: 0;
    border-radius: 14px;
    background: #202c33;
    color: #e9edef;
    font: inherit;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

#chat-banner[hidden] { display: none; }
#chat-banner.in { animation: banner-in 0.2s ease-out; }

@keyframes banner-in {
    from { transform: translate(-50%, -30px); opacity: 0; }
    to { transform: translateX(-50%); opacity: 1; }
}

#chat-banner strong { font-size: 13px; }

#chat-banner span {
    max-width: 100%;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-reduced-motion: reduce) {
    .wa, #chat-banner.in { animation: none; }
}

/* in-game choice of the figure */

.fig-group {
    margin: 12px 2px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.figures {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
}

/* ---------- in game: the menu button and its menu (plain, light, like a desktop menu) ---------- */

#game-menu-btn {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 15;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid #c4cad0;
    background: #f7f8f9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

#game-menu-btn[hidden] { display: none; }

/* inventory button: like the menu button, bottom left */
#game-bag-btn {
    position: fixed;
    left: calc(16px + env(safe-area-inset-left));
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 15;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid #c4cad0;
    background: #f7f8f9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    touch-action: manipulation;
}

#game-bag-btn[hidden] { display: none; }

#game-bag-btn svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #2b3137;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#game-bag-btn:active { background: #e3e7ea; }

#game-bag-btn:focus-visible {
    outline: 2px solid #1f6fd1;
    outline-offset: 2px;
}

/* the nurse call, right of the bag (patients only) - red like the call button at the bed */
#game-nurse-btn {
    position: fixed;
    left: calc(16px + 52px + 10px + env(safe-area-inset-left));
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 15;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid #c4cad0;
    background: #f7f8f9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    touch-action: manipulation;
}
#game-nurse-btn[hidden] { display: none; }
#game-nurse-btn svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #c8102e;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#game-nurse-btn:active { background: #fbe4e7; }
#game-nurse-btn:focus-visible { outline: 2px solid #1f6fd1; outline-offset: 2px; }

#game-menu-btn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: #2b3137;
    stroke-width: 2.2;
    stroke-linecap: round;
}

#game-menu-btn[aria-expanded="true"] {
    background: #e3e7ea;
}

#game-menu-btn:focus-visible, .win-menu button:focus-visible {
    outline: 2px solid #1f6fd1;
    outline-offset: 2px;
}

#game-people .dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d93a2f;
    border: 2px solid #f7f8f9;
}

.win-menu {
    position: fixed;
    top: calc(66px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 16;
    width: 264px;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #c4cad0;
    background: #fbfbfc;
    color: #1d2226;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    font-size: 15px;
}

.win-menu[hidden] { display: none; }

.win-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid #dde1e5;
}

.win-menu-head img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    image-rendering: pixelated;
    border-radius: 6px;
    background: #e8ecef;
}

.win-menu-head strong { display: block; font-size: 15px; }
.win-menu-head small { display: block; color: #545c63; font-size: 13px; margin-top: 1px; }

.win-menu button {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.win-menu button:hover { background: #e8eef5; }
.win-menu button:active { background: #d6e2ef; }

.win-menu button svg {
    flex: none;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #3b444c;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.win-menu button span:first-of-type { flex: 1; }

.win-menu kbd {
    font: 12px system-ui, sans-serif;
    color: #545c63;
}

.win-menu .badge {
    flex: none !important;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #d93a2f;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.win-menu .check {
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid #7d868e;
}

.win-menu [aria-checked="true"] .check {
    background: #1f6fd1;
    border-color: #1f6fd1;
    box-shadow: inset 0 0 0 3px #fbfbfc;
}

.win-menu hr {
    margin: 4px 6px;
    border: 0;
    border-top: 1px solid #dde1e5;
}

/* touch screens: no keyboard hints */
@media (pointer: coarse) {
    .win-menu kbd { display: none; }
}

/* ---------- new player, step 1: everything on one screen, the start button always visible ---------- */

#screen-register {
    height: 100%;
    min-height: 0;
}

#screen-register #menu-form {
    flex: 1;
    min-height: 0;
    gap: 8px;
}

#screen-register #char-grid {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    align-content: start;
}

#screen-register .char {
    padding: 2px;
    border-radius: 8px;
}

#screen-register .submit {
    flex: none;
}

#screen-register .alt {
    margin: 0;
    text-align: center;
}

/* ---------- new player, step 2: the PIN ---------- */

.pin-who {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
}

.pin-who img {
    width: 48px;
    height: 50px;
    image-rendering: pixelated;
}

.pin-who strong { display: block; font-size: 18px; }
.pin-who small { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }

.pin-text {
    margin: 6px 0 0;
    font-size: 16px;
    line-height: 1.45;
}

#pin-hint {
    min-height: 1.2em;
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--muted);
}

/* ---------- loading screen while the map is built ---------- */

#loading {
    position: fixed;
    inset: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg);
    color: var(--text);
    text-align: center;
}

#loading[hidden] { display: none; }

#loading .spinner {
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border-radius: 50%;
    border: 4px solid var(--line);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    #loading .spinner { animation-duration: 3s; }
}

.loading-title { margin: 0; font-size: 20px; font-weight: 700; }
.loading-sub { margin: 0; font-size: 15px; color: var(--muted); }


/* talking to the hospital staff */

.talk {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 4px 0 14px;
}

.talk-who {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 4px;
    border-radius: 12px;
    background: #0d1511;
    border: 2px solid var(--line);
}

.talk-who img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.talk-text {
    position: relative;
    flex: 1;
    margin: 0;
    padding: 10px 14px;
    border-radius: 4px 14px 14px 14px;
    background: #fff6d5;
    color: #1a1608;
    line-height: 1.4;
    min-height: 44px;
}

.talk-text.busy { opacity: 0.6; }

.talk-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.talk-options button {
    min-height: 44px;
    padding: 8px 14px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: #0d1511;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.talk-options button:hover { border-color: var(--green); }
.talk-options button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.talk-options button.done { border-color: var(--green); color: var(--green); font-weight: 600; }
.talk-options button.bye { color: var(--muted); }

/* start page, right at the top: who was online lately */
.last-online {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.last-online[hidden] { display: none; }

.last-online h2 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.last-online ul {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 0 0 6px;
    list-style: none;
    overflow-x: auto;
    scrollbar-width: thin;
}

.last-online li {
    flex: 0 0 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    text-align: center;
}

.last-online li.on { border-color: var(--green); }
.last-online .who { position: relative; }
.last-online .face { width: 44px; height: 44px; border-radius: 10px; }
.last-online li.on .who::after {
    content: "";
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid var(--panel);
}
.last-online b { max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.last-online time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.last-online .where { font-size: 11px; color: var(--green); max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (orientation: landscape) and (max-height: 560px) {
    .last-online { grid-column: 1 / -1; max-width: none; }
}

/* same name, same PIN: which figure are you? */
.login-choose {
    margin-top: 6px;
    padding: 12px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: #2a2a17;
}

.login-choose[hidden] { display: none; }
.login-choose p { margin: 0 0 10px; font-size: 14px; }

.login-choose-figs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.login-choose-figs .char { width: 64px; }

/* new player: figures somebody with the same name already has */
.char.taken {
    opacity: 0.35;
    background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(217, 83, 74, 0.35) 6px 8px), var(--panel);
}

/* the daily round */
.daily-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #0d1511;
    border: 1px solid var(--line);
}

.daily-streak { font-size: 28px; line-height: 1; }
.daily-head b { display: block; font-size: 16px; color: var(--accent); }
.daily-head small { color: var(--muted); font-size: 13px; }

.daily-tasks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.daily-tasks li {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 4px 10px;
    padding: 10px 12px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}

.daily-tasks li.done { border-color: var(--green); }
.daily-tasks .t-icon { grid-row: span 2; font-size: 22px; text-align: center; }
.daily-tasks .t-text { font-weight: 600; line-height: 1.3; }
.daily-tasks li.done .t-text { color: var(--green); }
.daily-tasks .t-gold { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.daily-tasks .t-bar {
    grid-column: 2 / -1;
    height: 8px;
    border-radius: 4px;
    background: #0d1511;
    overflow: hidden;
}
.daily-tasks .t-bar span { display: block; height: 100%; border-radius: 4px; background: var(--green); }
.daily-tasks .t-n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.daily-bonus {
    margin: 14px 0 0;
    padding: 12px 14px;
    border: 1px dashed var(--accent);
    border-radius: 12px;
    color: var(--text);
    line-height: 1.4;
}

.daily-bonus.got { border-style: solid; border-color: var(--green); }

/* a patient in a bed */
.patient-give { margin-top: 4px; }
.patient-give h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.patient-give .wares { gap: 6px; }
.patient-tip { margin: 0 0 12px; font-size: 14px; color: var(--accent); line-height: 1.4; }
.talk-text.healed { background: #d9f7e1; }

/* lab report from the patient monitor: a sheet of paper */
.lab-paper {
    margin: 2px 0 8px;
    padding: 16px 16px 12px;
    border-radius: 4px;
    background: #fbf9f2;
    color: #1f1f1f;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    font-size: 13px;
    line-height: 1.35;
}

.lab-paper header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #1f1f1f;
}

.lab-paper header b { display: block; font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase; }
.lab-paper header small { color: #555; font-size: 11px; }
.lab-meta { text-align: right; font-size: 11px; color: #555; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lab-patient { margin: 8px 0 4px; font-size: 12px; color: #333; }

.lab-paper h3 {
    margin: 12px 0 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #c9c4b4;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #444;
}

.lab-table { width: 100%; border-collapse: collapse; }
.lab-table thead th { font-size: 10px; font-weight: 600; color: #777; text-align: right; padding: 0 4px 2px; }
.lab-table th[scope="row"] { text-align: left; font-weight: 400; padding: 2px 4px 2px 0; }
.lab-table td { padding: 2px 4px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lab-table td.v { text-align: right; font-weight: 600; }
.lab-table td.f { width: 18px; text-align: center; padding: 2px 0; }
.lab-table td.u { color: #555; font-size: 11px; }
.lab-table td.r { text-align: right; color: #666; font-size: 11px; }
.lab-table tr.out td.v { color: #b0201a; }
.lab-flag { font-weight: 800; }
.lab-flag.hi { color: #b0201a; }
.lab-flag.lo { color: #1d4fb0; }
.lab-flag.crit { color: #fff; background: #b0201a; border-radius: 3px; padding: 0 3px; font-size: 11px; }
.lab-table tr.out:has(.lo) td.v { color: #1d4fb0; }

.lab-comment {
    margin-top: 12px;
    padding: 8px 10px;
    border-left: 4px solid #b0201a;
    background: #f3eee0;
}
.lab-comment.ok { border-left-color: #2e8b57; }
.lab-comment h3 { margin: 0 0 4px; border: 0; }
.lab-comment p { margin: 0 0 4px; }
.lab-paper footer { margin-top: 10px; font-size: 10px; color: #777; text-align: center; }

@media (max-width: 380px) {
    .lab-table td.r, .lab-table thead th:last-child { display: none; }
}

/* chat: who you write to - everybody here, or one person online (any map) */
.wa-people {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
    background: #111b21;
    border-bottom: 1px solid #222d34;
    scrollbar-width: none;
}
.wa-people[hidden] { display: none; }

.wa-person {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 28px auto;
    grid-template-rows: auto auto;
    column-gap: 6px;
    align-items: center;
    min-height: 40px;
    padding: 3px 10px 3px 4px;
    border: 1.5px solid #2a3942;
    border-radius: 20px;
    background: #202c33;
    color: #e9edef;
    font: inherit;
    cursor: pointer;
}
.wa-person img, .wa-person .all {
    grid-row: span 2;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0b141a;
    object-fit: contain;
    image-rendering: pixelated;
    display: grid;
    place-items: center;
    font-size: 15px;
}
.wa-person .n { font-size: 13px; font-weight: 600; line-height: 1.1; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.wa-person .m { font-size: 10px; color: #8696a0; line-height: 1.1; text-align: left; }
.wa-person.on { border-color: #25d366; background: #103529; }
.wa-person:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* keyboard open: the chat fills exactly the visible part, the input sits right above the keys */
#chat.keyboard { padding-top: 8px; }
#chat.keyboard .wa { animation: none; }

/* start page: somebody online can be tapped (chat) */
.last-online li.on { cursor: pointer; }
.last-online li.on:hover, .last-online li.on:focus-visible { background: var(--panel-2); outline: none; }

/* =====================================================================
   Start page and menu screens: clinic wayfinding look
   (light like a hospital corridor, clinic blue, mint, signage lettering).
   Only inside #menu - the game itself keeps its dark look.
   ===================================================================== */

@font-face {
    font-family: "Barlow Semi Condensed";
    src: url("../fonts/barlow-semi-condensed-500.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "Barlow Semi Condensed";
    src: url("../fonts/barlow-semi-condensed-700.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("../fonts/atkinson-hyperlegible-400.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("../fonts/atkinson-hyperlegible-700.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

#menu {
    --bg: #eef3f6;
    --panel: #ffffff;
    --panel-2: #e4edf2;
    --line: #cdd9e1;
    --text: #0f2a3d;
    --muted: #4a6274;
    --accent: #0b5ca5;          /* clinic blue */
    --accent-ink: #ffffff;
    --green: #17806a;           /* mint, dark enough for text on white */
    --mint: #2fb495;
    --signal: #f2b632;          /* the yellow guide line */
    --field: #ffffff;
    /* signs have crisp edges: a hairline border and only a short drop */
    --shadow: 0 1px 1px rgba(15, 42, 61, 0.05), 0 2px 5px rgba(15, 42, 61, 0.06);
    --sign: "Barlow Semi Condensed", "Arial Narrow", sans-serif;

    font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
    color: var(--text);
    caret-color: var(--accent);
    scrollbar-color: #b6c7d2 transparent;
    /* the coloured guide lines on a clinic floor, right at the top */
    background:
        linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 5px no-repeat,
        linear-gradient(var(--mint), var(--mint)) 0 8px / 100% 3px no-repeat,
        linear-gradient(var(--signal), var(--signal)) 0 14px / 100% 2px no-repeat,
        linear-gradient(180deg, #f6f9fb 0%, #eaf1f5 55%, #e1eaf0 100%);
    background-attachment: local;
}

#menu ::selection { background: #cfe3f5; color: var(--text); }

#menu .screen { padding-top: max(32px, calc(env(safe-area-inset-top) + 20px)); }
/* the sign sits high up, right under the board */
#menu #screen-start { justify-content: flex-start; gap: 22px; }

/* ---------- "Zuletzt online": the arrivals board at the entrance ---------- */

#menu .last-online {
    padding: 10px 10px 8px;
    border-radius: 14px;
    background: #0f2a3d;
    box-shadow: 0 2px 4px rgba(15, 42, 61, 0.12), 0 12px 28px rgba(15, 42, 61, 0.18);
}

#menu .last-online h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 2px 8px;
    font-family: var(--sign);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #8fe6cc;
}

/* a live light, like on a monitor */
#menu .last-online h2::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 3px rgba(47, 180, 149, 0.25);
}

#menu .last-online ul { scrollbar-color: #2f5670 transparent; }

#menu .last-online li {
    border: 1px solid #234a63;
    background: #163a52;
    color: #ffffff;
}

#menu .last-online li.on { border-color: var(--mint); background: #12443f; }
#menu .last-online li.on:hover, #menu .last-online li.on:focus-visible { background: #17544c; outline: 2px solid var(--mint); outline-offset: 1px; }
#menu .last-online .face { background: #0b2030; }
#menu .last-online li.on .who::after { background: var(--mint); border-color: #12443f; }
#menu .last-online b { color: #ffffff; font-family: var(--sign); font-weight: 500; font-size: 14px; letter-spacing: 0.01em; }
#menu .last-online time { color: #a9c4d4; font-variant-numeric: tabular-nums; }
#menu .last-online .where { color: #8fe6cc; }

/* ---------- the sign at the entrance ---------- */

#menu .hero { text-align: center; }


.clinic-sign {
    display: flex;
    align-items: stretch;
    margin: 4px auto 0;
    max-width: 440px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
    text-align: left;
}

.clinic-cross {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 64px;
    background: var(--accent);
}

.clinic-cross svg {
    width: 34px;
    height: 34px;
    fill: #ffffff;
    stroke: none;
}

#menu .hero h1 {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 10px 14px 11px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    font-family: var(--sign);
    font-weight: 700;
    font-size: clamp(28px, 8.4vw, 40px);
    line-height: 1.02;
    letter-spacing: -0.005em;
    color: var(--text);
    text-wrap: balance;
}

#menu .h1-tag {
    display: inline-block;
    padding: 3px 10px 4px;
    border-radius: 6px;
    background: #e3f4ef;
    color: #0f604b;
    font-size: 0.62em;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.1;
    transform: translateY(-0.12em);
}

/* the heartbeat under the sign: drawn again and again, like on a monitor */
.ecg {
    display: block;
    width: min(100%, 440px);
    height: 40px;
    margin: 10px auto 2px;
}

.ecg path {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.ecg-base { stroke: #d3e0e8; stroke-width: 2; }

.ecg-beat {
    stroke: var(--mint);
    stroke-width: 2.5;
    stroke-dasharray: 0.22 1;
    stroke-dashoffset: 0.22;
    animation: ecg-run 2.6s cubic-bezier(0.25, 1, 0.5, 1) infinite;
    filter: drop-shadow(0 1px 2px rgba(47, 180, 149, 0.35));
}

@keyframes ecg-run {
    from { stroke-dashoffset: 0.22; }
    to { stroke-dashoffset: -1; }
}

@media (prefers-reduced-motion: reduce) {
    .ecg-beat { animation: none; stroke-dasharray: none; }
}

#menu .tagline {
    margin: 4px auto 0;
    max-width: 34ch;
    font-size: 16px;
    line-height: 1.45;
    color: var(--muted);
}

#menu .online {
    margin-top: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 14px;
}
#menu .online:empty { display: none; }
#menu .online.live::before { background: var(--mint); box-shadow: 0 0 0 3px rgba(47, 180, 149, 0.22); }

/* ---------- the ward sign: the game is always on ME 7 ---------- */

#menu .ward-sign {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin: 0 0 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--accent);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--shadow);
}
#menu .ward-sign h2 {
    margin: 0;
    font-family: var(--sign);
    font-size: 22px;
    font-weight: 500;
    letter-spacing: 0.005em;
    color: var(--text);
}
#menu .ward-sign h2 b { font-weight: 700; color: var(--accent); }

/* ---------- the big button ---------- */

#menu .choice.primary {
    min-height: 72px;
    border-radius: 14px;
    background: var(--accent);
    color: #ffffff;
    font-family: var(--sign);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 4px rgba(11, 92, 165, 0.2), 0 12px 26px rgba(11, 92, 165, 0.28);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

#menu .choice.primary:hover { background: #094d8b; }
#menu .choice.primary:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(11, 92, 165, 0.2), 0 6px 14px rgba(11, 92, 165, 0.24); }
#menu .choice.primary .avatar { background: rgba(255, 255, 255, 0.16); border-radius: 10px; padding: 2px; }
#menu .choice:focus-visible { outline: 3px solid rgba(11, 92, 165, 0.4); outline-offset: 3px; }

#menu .account { color: var(--muted); }
#menu .link { color: var(--accent); }

#menu .corner-btn { color: var(--muted); opacity: 0.7; }
#menu .corner-btn:hover, #menu .corner-btn:focus-visible { opacity: 1; background: #ffffff; box-shadow: var(--shadow); }

/* ---------- "Was los ist" + best list ---------- */

#menu .lobby-card {
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: var(--shadow);
}

#menu .lobby-card h2 {
    font-family: var(--sign);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.005em;
    color: var(--text);
}

#menu .face { background: #e4edf2; }
#menu .feed time { color: var(--muted); font-variant-numeric: tabular-nums; }
#menu .top .value { color: var(--accent); }
#menu .top li.me .name { color: var(--accent); }

#menu .segmented { background: #e4edf2; }
#menu .segmented span { color: var(--muted); }
#menu .segmented input:checked + span { background: #ffffff; color: var(--text); box-shadow: 0 1px 3px rgba(15, 42, 61, 0.14); }

/* ---------- the other menu screens: login, new player, PIN, settings ---------- */

#menu .screen-head h2 { font-family: var(--sign); font-weight: 700; font-size: 28px; }
#menu .back { color: var(--text); }
#menu .back:hover { background: #ffffff; }

#menu input[type="text"],
#menu input.pin {
    background: var(--field);
    border: 1.5px solid var(--line);
    color: var(--text);
}
#menu input[type="text"]::placeholder { color: #7790a2; }
#menu input[type="text"]:focus,
#menu input.pin:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 92, 165, 0.15); }

#menu .submit { background: var(--accent); color: #ffffff; font-family: var(--sign); letter-spacing: 0.01em; box-shadow: 0 8px 20px rgba(11, 92, 165, 0.22); }
#menu .submit:disabled { background: #cbd8e1; color: #557083; box-shadow: none; }

#menu .char { background: #ffffff; border-color: var(--line); }
#menu .char[aria-checked="true"] { background: #e3f0fa; border-color: var(--accent); }
#menu .char.taken { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(192, 57, 43, 0.22) 6px 8px), #ffffff; }

#menu .login-choose { background: #fff7e0; border-color: var(--signal); }

#menu .form-error,
#menu #menu-hint.form-error,
#menu #pin-hint.form-error { color: #b42318; }

#menu fieldset { background: #ffffff; border-color: var(--line); box-shadow: var(--shadow); }
#menu legend { color: var(--accent); }

#menu .switch input { background: #d5e1e8; border-color: #c3d2dc; }
#menu .switch input::after { background: #ffffff; box-shadow: 0 1px 2px rgba(15, 42, 61, 0.3); }
#menu .switch input:checked { background: var(--accent); border-color: var(--accent); }

#menu .pin-who { background: #ffffff; box-shadow: var(--shadow); }
#menu #screen-kicked h2 { font-family: var(--sign); color: var(--accent); }

/* phone held sideways: the board over the whole width, sign left, choices right */
@media (orientation: landscape) and (max-height: 560px) {
    #menu .hero h1 { font-size: 30px; }
    .ecg { height: 30px; margin-top: 6px; }
}

/* how many players are on the ward right now */
#menu .ward-sign .sign-online {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf2f5;
    color: var(--muted);
    font-family: var(--sign);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#menu .ward-sign .sign-online:empty { visibility: hidden; }
#menu .ward-sign .sign-online::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a9bccb;
}
#menu .ward-sign .sign-online.live { background: #e3f4ef; color: #0f604b; }
#menu .ward-sign .sign-online.live::before { background: var(--mint); box-shadow: 0 0 0 3px rgba(47, 180, 149, 0.25); }


/* ---------- the player card (tap on a name on the board) ---------- */

#menu .last-online li[data-key] { cursor: pointer; }
#menu .last-online li[data-key]:hover, #menu .last-online li[data-key]:focus-visible { background: #1d4966; outline: 2px solid #8fe6cc; outline-offset: 1px; }

.pcard {
    width: min(460px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    box-sizing: border-box;
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: #f6f9fb;
    color: var(--text);
    box-shadow: 0 4px 10px rgba(15, 42, 61, 0.18), 0 24px 48px rgba(15, 42, 61, 0.28);
    overflow: auto;
    overscroll-behavior: contain;
}

.pcard::backdrop { background: rgba(10, 29, 43, 0.55); backdrop-filter: blur(2px); }
.pcard[open] { animation: pc-in 0.28s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes pc-in {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .pcard[open] { animation: none; }
}

.pc-close {
    position: absolute;
    top: 14px;
    right: 10px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    cursor: pointer;
    z-index: 1;
}
.pc-close:hover { background: #ffffff; box-shadow: var(--shadow); }
.pc-close:focus-visible { outline: 3px solid rgba(11, 92, 165, 0.4); outline-offset: 2px; }

#pc-body { padding: 0 18px 16px; }
.pc-loading { margin: 0; padding: 48px 0; text-align: center; color: var(--muted); }

/* the head: like a hospital ID badge - the blue band with the figure */
.pc-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 -18px;
    padding: 18px 56px 12px 18px;
    background: linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 6px no-repeat, #ffffff;
    border-bottom: 1px solid var(--line);
}

.pc-face {
    flex: 0 0 auto;
    width: 60px;
    height: 60px;
    padding: 3px;
    box-sizing: border-box;
    border-radius: 14px;
    background: #e4edf2;
    image-rendering: pixelated;
    object-fit: contain;
}

.pc-head h2 {
    margin: 0;
    font-family: var(--sign);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.pc-rank { margin: 2px 0 0; font-size: 14px; font-weight: 700; color: var(--accent); }

.pc-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--muted);
}
.pc-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #a9bccb; }
.pc-status.on { color: #0f604b; font-weight: 700; }
.pc-status.on::before { background: var(--mint); box-shadow: 0 0 0 3px rgba(47, 180, 149, 0.25); }


.pc-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin: 14px 0 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--line);
    overflow: hidden;
}
.pc-stats > div { padding: 7px 6px; background: #ffffff; text-align: center; min-width: 0; }
.pc-stats dt { font-size: 11px; color: var(--muted); }
.pc-stats dd {
    margin: 1px 0 0;
    font-family: var(--sign);
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    white-space: nowrap;
}



.pc-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* under the numbers: the way to the next rank and the badges you have, in one line */
.pc-more { margin-top: 10px; }
.pc-bar { height: 6px; border-radius: 3px; background: #dbe6ec; overflow: hidden; }
.pc-bar span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.pc-more p { margin: 5px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.pc-badges-mini { font-size: 15px; letter-spacing: 0.08em; }

.pc-login label { display: block; margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--text); }
.pc-pinrow { display: flex; gap: 8px; }
.pc-pinrow input.pin {
    flex: 0 0 104px;
    width: 104px;
    box-sizing: border-box;
    font: inherit;
    font-size: 22px;
    letter-spacing: 0.4em;
    text-align: center;
    padding: 10px 6px;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    background: #ffffff;
    color: var(--text);
    -webkit-user-select: text;
    user-select: text;
}
.pc-pinrow input.pin:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 92, 165, 0.15); }

.pc-primary, .pc-secondary {
    flex: 1;
    min-height: 50px;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: var(--sign);
    font-size: 19px;
    font-weight: 700;
    cursor: pointer;
}
.pc-primary { border: 0; background: var(--accent); color: #ffffff; box-shadow: 0 2px 4px rgba(11, 92, 165, 0.2), 0 6px 14px rgba(11, 92, 165, 0.22); }
.pc-primary:hover { background: #094d8b; }
.pc-secondary { border: 1.5px solid var(--accent); background: #ffffff; color: var(--accent); }
.pc-secondary:hover { background: #f3f8fc; }
.pc-primary:focus-visible, .pc-secondary:focus-visible { outline: 3px solid rgba(11, 92, 165, 0.4); outline-offset: 2px; }
.pc-login .form-error { margin-top: 6px; color: #b42318; }



/* ---------- player card: what they wrote about themselves ---------- */
.pc-about { margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; background: #ffffff; border: 1px solid var(--line); }
.pc-about b { display: block; font-size: 14px; color: var(--accent); }
.pc-about p {
    margin: 2px 0 0;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- in game: yes/no question, "Über mich" form ---------- */
.confirm-text { margin: 4px 0 16px; font-size: 16px; line-height: 1.5; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.confirm-actions .act { flex: 1 1 160px; min-height: 48px; }

.about-form { display: flex; flex-direction: column; gap: 6px; }
.about-form label { margin-top: 6px; font-weight: 600; font-size: 14px; }
.about-form label small { font-weight: 400; color: var(--muted); }
.about-form input, .about-form textarea {
    font: inherit;
    font-size: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 2px solid var(--line);
    background: #0d1511;
    color: var(--text);
    -webkit-user-select: text;
    user-select: text;
    resize: vertical;
}
.about-form input:focus, .about-form textarea:focus { outline: none; border-color: var(--accent); }
.about-count { margin: 0; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- chat: "Über Anna" under the head ---------- */
.wa-about {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 7px 12px;
    border: 0;
    border-bottom: 1px solid #222d34;
    background: #182229;
    color: #e9edef;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.wa-about[hidden] { display: none; }
.wa-about:disabled { cursor: default; }
.wa-about-head { font-size: 13px; font-weight: 700; color: #25d366; }
.wa-about.empty .wa-about-head { font-weight: 400; color: #8696a0; }
.wa-about-text {
    font-size: 13px;
    line-height: 1.4;
    color: #d1d7db;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.wa-about[aria-expanded="true"] .wa-about-text { -webkit-line-clamp: unset; display: block; }

/* ---------- feedback (game menu) ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fb-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fb-form textarea {
    font: inherit;
    font-size: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 2px solid var(--line);
    background: #0d1511;
    color: var(--text);
    resize: vertical;
    -webkit-user-select: text;
    user-select: text;
}
.fb-form textarea:focus { outline: none; border-color: var(--accent); }
.fb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fb-row .act { min-height: 44px; padding: 0 18px; }
.fb-row .act:disabled { opacity: 0.5; }
.fb-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.fb-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; background: #0d1511; }
.fb-list li.empty { display: block; color: var(--muted); background: none; padding: 4px 0; }
.fb-list img { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px; background: var(--panel-2); image-rendering: pixelated; object-fit: contain; }
.fb-list li > div { flex: 1; min-width: 0; }
.fb-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.fb-meta time { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fb-list p { margin: 3px 0 0; font-size: 14px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }

/* ---------- role: staff or patient ---------- */
/* new player: two big choices side by side */
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#menu .role-pick label { position: relative; margin: 0; cursor: pointer; }
.role-pick input { position: absolute; opacity: 0; pointer-events: none; }
.role-pick span {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 9px 12px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}
.role-pick b { font-family: var(--sign, inherit); font-size: 18px; color: var(--text); }
.role-pick small { font-size: 13px; font-weight: 400; color: var(--muted); }
.role-pick input:checked + span { border-color: var(--accent); background: #e3f0fa; box-shadow: inset 0 0 0 1px var(--accent); }
.role-pick input:focus-visible + span { outline: 3px solid rgba(11, 92, 165, 0.35); outline-offset: 2px; }

/* player card: the role next to the rank */
.pc-role {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #e4edf2;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    vertical-align: 1px;
}

/* in game, "Über mich": staff / patient switch */
.segmented.two { grid-template-columns: 1fr 1fr; }
.about-kind { margin: 2px 0 14px; }
.about-kind p { margin: 0 0 6px; font-weight: 600; font-size: 14px; }
.about-kind small { display: block; margin-top: 6px; font-size: 12px; line-height: 1.4; color: var(--muted); }

/* ---------- in game: who is online (top right, left of the menu button) ---------- */
#game-people {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + 48px + 8px + env(safe-area-inset-right));
    z-index: 15;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px 0 8px;
    border-radius: 10px;
    border: 1px solid #c4cad0;
    background: #f7f8f9;
    color: #1d2a33;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    font: inherit;
    cursor: pointer;
}
#game-people[hidden] { display: none; }
#game-people:hover { background: #ffffff; }
#game-people:focus-visible { outline: 3px solid #1f6fd1; outline-offset: 2px; }

.gp-faces { display: flex; }
.gp-faces img {
    width: 30px;
    height: 30px;
    margin-left: -10px;
    border-radius: 50%;
    border: 2px solid #f7f8f9;
    background: #dfe5ea;
    object-fit: contain;
    image-rendering: pixelated;
}
.gp-faces img:first-child { margin-left: 0; }

.gp-count {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}
.gp-count::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2fb495;
    box-shadow: 0 0 0 3px rgba(47, 180, 149, 0.22);
}
/* only you: quieter */
#game-people.alone { opacity: 0.75; }
#game-people.alone .gp-count::before { background: #a9b6c0; box-shadow: none; }

/* ---------- "Wer ist da?" ---------- */
.pp-h { margin: 6px 0 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.pp-h + .pp-list { margin-bottom: 14px; }
.pp-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.pp { border-radius: 12px; background: #0d1511; }
.pp.open { box-shadow: inset 0 0 0 1px var(--line); }
.pp-main { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; }
.pp-face { position: relative; flex: 0 0 auto; }
.pp-face img { width: 40px; height: 40px; border-radius: 10px; background: var(--panel-2); object-fit: contain; image-rendering: pixelated; display: block; }
.pp-here { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid #0d1511; }
.pp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pp-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-text small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.pp-btn {
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.pp-btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line); }
.pp-btn.wide { width: 100%; margin-top: 10px; min-height: 42px; }
.pp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pp-more { padding: 0 12px 12px 60px; }
.pp-more p { margin: 0 0 6px; font-size: 14px; line-height: 1.45; }
.pp-rank { font-weight: 700; color: var(--accent); }
.pp-about { white-space: pre-line; overflow-wrap: anywhere; }
.pp-about b { color: var(--text); }
.pp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 0; }
.pp-stats > div { padding: 6px 8px; border-radius: 8px; background: var(--panel); }
.pp-stats dt { font-size: 11px; color: var(--muted); }
.pp-stats dd { margin: 1px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 380px) {
    .pp-more { padding-left: 12px; }
    .pp-btn { padding: 0 10px; }
}

/* ---------- the story at the very first start (public/js/Intro.js) ---------- */

/* nothing of the HUD meanwhile */
body.intro-on #game-menu-btn,
body.intro-on #game-menu,
body.intro-on #game-people,
body.intro-on #game-bag-btn,
body.intro-on #game-nurse-btn,
body.intro-on #chat-banner { display: none !important; }

.intro {
    --bar: 11vh;
    position: fixed;
    inset: 0;
    z-index: 30;
    font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
    color: #f2efe4;
    cursor: pointer;
    touch-action: none;
}

/* cinema bars - for patients they start closed and open like eyelids */
.intro-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    background: #050807;
    transition: height 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.intro-bar.top { top: 0; }
.intro-bar.bottom { bottom: 0; }
.intro.patient .intro-bar { height: 50.5vh; transition-duration: 2.6s; }
.intro.open .intro-bar { height: var(--bar); }
.intro.patient.open .intro-bar { animation: intro-blink 2.6s ease-in-out 0.4s; }
.intro.closing .intro-bar { height: 0; transition-duration: 0.5s; }
.intro.closing .intro-box, .intro.closing .intro-card { opacity: 0; transition: opacity 0.3s; }

@keyframes intro-blink {
    0% { height: 50.5vh; }
    35% { height: 30vh; }
    48% { height: 50.5vh; }
    100% { height: var(--bar); }
}

.intro-skip {
    position: absolute;
    top: max(12px, calc((var(--bar) - 32px) / 2));
    right: 16px;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(242, 239, 228, 0.25);
    border-radius: 999px;
    background: transparent;
    color: rgba(242, 239, 228, 0.75);
    font: 500 14px "Barlow Semi Condensed", system-ui, sans-serif;
    letter-spacing: 0.04em;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.6s 1.5s;
}
.intro.open .intro-skip { opacity: 1; }
.intro-skip:hover { color: #f2efe4; border-color: rgba(242, 239, 228, 0.5); }
.intro-skip:focus-visible { outline: 2px solid #f5c542; outline-offset: 2px; }
.intro-skip[hidden] { display: none; }

/* the text box sits on the lower bar */
.intro-box {
    position: absolute;
    left: 50%;
    bottom: max(16px, calc(var(--bar) - 44px));
    transform: translateX(-50%);
    box-sizing: border-box;
    width: min(640px, calc(100% - 32px));
    min-height: 112px;
    padding: 14px 18px 16px;
    border: 1px solid rgba(242, 239, 228, 0.14);
    border-radius: 14px;
    background: rgba(10, 16, 13, 0.94);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    animation: intro-box-in 0.35s ease-out;
}
.intro-box[hidden] { display: none; }
@keyframes intro-box-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
}

.intro-who {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 24px;
    margin-bottom: 6px;
}
.intro-who img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #26382d;
    object-fit: cover;
    image-rendering: pixelated;
}
.intro-who img[hidden] { display: none; }
.intro-name {
    font: 700 15px "Barlow Semi Condensed", system-ui, sans-serif;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #f5c542;
}
.intro-box.me .intro-name { color: #8fe0b0; }
.intro-name small {
    margin-left: 6px;
    font-weight: 500;
    font-size: 13px;
    color: rgba(242, 239, 228, 0.6);
}
.intro-box.narr .intro-who { display: none; }

.intro-text {
    margin: 0;
    padding-right: 18px;
    font-size: 18px;
    line-height: 1.5;
    text-wrap: pretty;
}
.intro-box.narr .intro-text { font-style: italic; color: #e3dccb; }
.intro-box.me .intro-text::before { content: "„"; }
.intro-box.me .intro-text::after { content: "“"; }

.intro-more {
    position: absolute;
    right: 14px;
    bottom: 10px;
    color: #f5c542;
    font-size: 16px;
    animation: intro-nudge 1.1s ease-in-out infinite;
}
.intro-more.wait { animation: none; font-size: 0; }
.intro-more.wait::before {
    content: "…";
    font-size: 18px;
    color: rgba(242, 239, 228, 0.6);
    animation: intro-dots 1.2s steps(2) infinite;
}
@keyframes intro-nudge {
    50% { transform: translateX(3px); }
}
@keyframes intro-dots {
    50% { opacity: 0.25; }
}

/* the last card: today's plan, like a sheet on a clipboard */
.intro-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    width: min(380px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow-y: auto;
    padding: 0 20px 20px;
    border-radius: 14px;
    background: #fbfaf6;
    color: #0f2a3d;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
    cursor: default;
    animation: intro-card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes intro-card-in {
    from { opacity: 0; transform: translate(-50%, -44%); }
}
/* patients: the wristband with the diagnosis, staff: the badge */
.intro-band {
    margin: 0 -20px 16px;
    padding: 10px 20px;
    border-radius: 14px 14px 0 0;
    background: #dcecfa;
    border-bottom: 2px dashed #9cc9ee;
    color: #1f4f78;
    font: 700 15px "Barlow Semi Condensed", system-ui, sans-serif;
    letter-spacing: 0.04em;
}
.intro-band.staff {
    background: #d8f1e7;
    border-bottom-color: #7fcfb2;
    color: #17604f;
}
.intro-card h2 {
    margin: 0 0 10px;
    font: 700 24px "Barlow Semi Condensed", system-ui, sans-serif;
}
.intro-card ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.intro-card li {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px solid #e3e8ec;
    font-size: 16px;
    line-height: 1.35;
}
.intro-card li span { flex: 0 0 22px; text-align: center; }
.intro-hint {
    margin: 12px 0 16px;
    color: #4a6274;
    font-size: 14px;
    line-height: 1.45;
}
.intro-go {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 10px;
    background: #0b5ca5;
    color: #ffffff;
    font: 700 18px "Barlow Semi Condensed", system-ui, sans-serif;
    letter-spacing: 0.04em;
    cursor: pointer;
}
.intro-go:hover { background: #094d8a; }
.intro-go:focus-visible { outline: 3px solid #f5c542; outline-offset: 2px; }

@media (max-width: 520px) {
    .intro-text { font-size: 16px; }
    .intro-box { min-height: 100px; }
}

@media (prefers-reduced-motion: reduce) {
    .intro-bar, .intro.patient .intro-bar { transition-duration: 0.01s; }
    .intro.patient.open .intro-bar { animation: none; }
    .intro-box, .intro-card, .intro-more { animation: none; }
}
