/* ---- Design tokens ---- */
:root {
    --bg: #f3f4ef;
    --surface: #ffffff;
    --surface-2: #e9ebe2;
    --text: #1c2117;
    --text-muted: #5d6556;
    --border: #d3d7c8;
    --accent: #4a6b25;
    --accent-hover: #3c5a1c;
    --accent-text: #ffffff;
    --danger: #b3261e;
    --danger-bg: #fbe9e7;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11140f;
        --surface: #1a1f17;
        --surface-2: #242a20;
        --text: #e6e9df;
        --text-muted: #9aa392;
        --border: #333b2d;
        --accent: #8bb455;
        --accent-hover: #9fc66a;
        --accent-text: #11140f;
        --danger: #f2a49b;
        --danger-bg: #3a1d1a;
        color-scheme: dark;
    }
}

/* ---- Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 0.75rem;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 0.35rem;
}

a {
    color: var(--accent);
}

.muted {
    color: var(--text-muted);
}

.loading {
    padding: 2rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

.notice {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---- Shell ---- */
.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text);
    text-decoration: none;
}

.brand span {
    color: var(--accent);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.callsign {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
    min-height: 36px;
    padding: 0.3rem 0.8rem;
}

.btn-ghost:hover {
    background: var(--surface-2);
}

.btn-block {
    width: 100%;
}

/* ---- Forms ---- */
.auth-card {
    max-width: 420px;
    margin: 1rem auto 0;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.field > span {
    font-weight: 600;
    font-size: 0.9rem;
}

.field input {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.invalid {
    border-color: var(--danger) !important;
}

.validation-message {
    color: var(--danger);
    font-size: 0.85rem;
}

.form-errors {
    margin: 0 0 1rem;
    padding: 0.6rem 0.8rem 0.6rem 1.8rem;
    border-radius: var(--radius);
    background: var(--danger-bg);
    color: var(--danger);
}

.auth-switch {
    margin: 1.25rem 0 0;
    text-align: center;
    color: var(--text-muted);
}

/* ---- Cards ---- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.card {
    padding: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card p {
    margin: 0 0 0.75rem;
    color: var(--text-muted);
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.card-link:hover {
    border-color: var(--accent);
}

.tag-accent {
    background: var(--accent);
    color: var(--accent-text);
}

/* ---- Navigation ---- */
.topnav {
    display: flex;
    gap: 0.25rem;
    margin-right: auto;
}

.topnav a {
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
}

.topnav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.topnav a.active {
    background: var(--surface-2);
    color: var(--text);
}

@media (max-width: 560px) {
    .topbar {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .topnav {
        order: 3;
        width: 100%;
        margin-right: 0;
    }
}

/* ---- Panels ---- */
.panel {
    margin-bottom: 1rem;
    padding: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-highlight {
    border-color: var(--accent);
    border-width: 2px;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.panel h2 {
    margin-bottom: 0.6rem;
}

.panel-head h2 {
    margin-bottom: 0;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.success {
    margin: 0;
    color: var(--accent);
    font-weight: 600;
}

/* ---- More buttons ---- */
.btn-sm {
    min-height: 34px;
    padding: 0.25rem 0.7rem;
    font-size: 0.875rem;
}

.btn-danger {
    background: var(--danger);
    color: var(--accent-text);
}

.btn-danger-outline {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger-bg);
}

.confirm {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.confirm-question {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ---- Inline forms ---- */
.single-field-form {
    margin-top: 0.75rem;
}

.single-field-form .field {
    margin-bottom: 0.5rem;
}

.inline-row {
    display: flex;
    gap: 0.5rem;
}

.inline-row input {
    flex: 1;
    min-width: 0;
}

.field input,
.role-select {
    font: inherit;
}

.role-select {
    min-height: 34px;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
}

/* ---- Unit type ---- */
.type-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--surface-2);
    color: var(--text-muted);
}

.type-company {
    background: var(--accent);
    color: var(--accent-text);
}

.type-platoon {
    background: color-mix(in srgb, var(--accent) 35%, var(--surface-2));
    color: var(--text);
}

.unit-header {
    margin-bottom: 1rem;
}

.unit-header h1 {
    margin: 0.35rem 0 0.15rem;
}

.unit-header p {
    margin: 0;
}

.type-picker {
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

.type-picker legend {
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.type-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.type-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--surface-2);
}

.type-option input {
    margin-top: 0.3rem;
    accent-color: var(--accent);
}

.type-option span {
    display: flex;
    flex-direction: column;
}

.type-option small {
    color: var(--text-muted);
}

/* ---- Roster ---- */
.roster {
    margin: 0;
    padding: 0;
    list-style: none;
}

.roster-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
}

.roster-row:first-child {
    border-top: 0;
}

.roster-who {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.roster-callsign {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.roster-role {
    color: var(--text-muted);
}

.roster-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

/* ---- Sub-units ---- */
.subunits {
    margin: 0;
    padding: 0;
    list-style: none;
}

.subunits .subunits {
    margin-top: 0.6rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--border);
}

.subunit {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}

.subunit:first-child {
    border-top: 0;
}

.subunit-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.subunit-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subunit-meta {
    margin: 0.2rem 0 0.3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.subunit details summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ---- Invitations ---- */
.invite-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.invite {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
}

.invite:first-child {
    border-top: 0;
}

.invite-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.invite-actions {
    display: flex;
    gap: 0.4rem;
}

/* ---- Page bits ---- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.page-head h1 {
    margin: 0;
}

.back-link {
    margin: 0 0 0.5rem;
}

.back-link a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
}

.empty {
    padding: 2rem 1rem;
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.empty p {
    margin: 0.25rem 0;
}

.optional {
    color: var(--text-muted);
    font-weight: 400;
}

.field textarea,
.field select,
.field input[type="datetime-local"],
.inline-row input {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field textarea {
    resize: vertical;
}

.field textarea:focus,
.inline-row input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field > label {
    font-weight: 600;
    font-size: 0.9rem;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 1rem;
}

/* ---- Tabs ---- */
.tabs {
    display: inline-flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding: 0.25rem;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.tab {
    min-height: 36px;
    padding: 0.3rem 1rem;
    border: 0;
    border-radius: calc(var(--radius) - 3px);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.tab.active {
    background: var(--surface);
    color: var(--text);
}

/* ---- Event list ---- */
.event-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.event-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
}

.event-card:hover {
    border-color: var(--accent);
}

.date-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 3.5rem;
    height: 3.75rem;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.date-month {
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.date-day {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.1;
}

.event-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.event-card-title {
    font-size: 1.05rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.rsvp-going {
    background: var(--accent);
    color: var(--accent-text);
}

.rsvp-maybe {
    background: color-mix(in srgb, #ca8a04 25%, var(--surface-2));
    color: var(--text);
}

.rsvp-notgoing {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---- Sides ---- */
.side-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
    vertical-align: middle;
}

.side-dot {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    flex: none;
}

.sides-list {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.sides-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
}

.sides-list li:first-child {
    border-top: 0;
}

.sides-list .muted {
    margin-right: auto;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.swatches legend {
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.swatch {
    position: relative;
    cursor: pointer;
}

.swatch input {
    position: absolute;
    opacity: 0;
}

.swatch-color {
    display: block;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
}

.swatch input:checked + .swatch-color {
    box-shadow: 0 0 0 2px var(--text);
}

.swatch input:focus-visible + .swatch-color {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- Event page ---- */
.event-header {
    margin-bottom: 1rem;
}

.event-header h1 {
    margin: 0.15rem 0 0.25rem;
}

.event-header p {
    margin: 0 0 0.6rem;
}

.event-when {
    color: var(--accent);
    font-weight: 700;
}

.event-place {
    margin: 0 0 0.6rem;
    font-weight: 600;
}

.event-description {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.map-links {
    margin-top: 0.6rem;
}

.rsvp-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.rsvp-option {
    min-height: 48px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.rsvp-option:hover:not(:disabled) {
    border-color: var(--accent);
}

.rsvp-option.selected {
    border-color: transparent;
}

.rsvp-option.rsvp-going.selected {
    background: var(--accent);
    color: var(--accent-text);
}

.rsvp-option.rsvp-maybe.selected {
    background: #ca8a04;
    color: #ffffff;
}

.rsvp-option.rsvp-notgoing.selected {
    background: var(--danger);
    color: var(--accent-text);
}

.attendance-totals {
    margin: 0 0 1rem;
    font-weight: 600;
}

.side-group {
    margin-bottom: 1rem;
    padding-left: 0.75rem;
    border-left: 4px solid var(--side-color);
}

.side-group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

.side-empty {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.attendance-units {
    margin: 0;
    padding: 0;
    list-style: none;
}

.attendance-unit {
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
}

.attendance-unit:first-child {
    border-top: 0;
}

.attendance-unit-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.attendance-unit details summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
}

.attendees {
    margin: 0.4rem 0 0;
    padding: 0;
    list-style: none;
}

.attendees li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    padding: 0.3rem 0;
}

.attendee-name {
    font-weight: 600;
}

.attendees .tag {
    margin-left: auto;
}

.invite-event-form .inline-row {
    flex-wrap: wrap;
}

.invite-event-form .inline-row input {
    flex: 1 1 180px;
}

/* ---- Maps ---- */
.map-frame {
    position: relative;
}

.map {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    z-index: 0;
}

.map-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
}

.map-pin svg path {
    fill: var(--danger);
    stroke: #ffffff;
    stroke-width: 1.5;
}

.map-pin svg circle {
    fill: #ffffff;
}

.location-picker {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.location-picker .hint {
    margin: 0;
}

.place-results {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.place-results button {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.place-results li:first-child button {
    border-top: 0;
}

.place-results button:hover,
.place-results button:focus-visible {
    background: var(--surface-2);
}

.place-results small {
    color: var(--text-muted);
}

/* ---- Game status ---- */
.status-pill {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-pill.status-live {
    background: #dc2626;
    color: #ffffff;
}

.tag-warn {
    background: #ca8a04;
    color: #ffffff;
}

.live-entry {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.live-entry h2 {
    margin-bottom: 0.2rem;
}

.live-entry p {
    margin: 0;
}

.live-entry-on {
    border-color: #dc2626;
    border-width: 2px;
}

/* ---- Live map (full screen) ---- */
.live {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #11140f;
}

.live-map {
    position: absolute;
    inset: 0;
}

.live-map.lm-placing {
    cursor: crosshair;
}

.live-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: calc(0.5rem + env(safe-area-inset-top)) 3.5rem 0.5rem calc(0.6rem + env(safe-area-inset-left));
    background: linear-gradient(rgba(17, 20, 15, 0.85), rgba(17, 20, 15, 0));
    color: #ffffff;
    pointer-events: none;
}

.live-top > * {
    pointer-events: auto;
}

.live-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(17, 20, 15, 0.75);
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 800;
    text-decoration: none;
}

.live-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.live-title strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.live-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

/* Leaflet's top-right controls sit below our top bar. */
.live .leaflet-top.leaflet-right {
    top: calc(3.75rem + env(safe-area-inset-top));
}

.live-message {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: #ffffff;
    text-align: center;
}

.live-toast {
    position: absolute;
    top: calc(4.5rem + env(safe-area-inset-top));
    left: 50%;
    z-index: 1100;
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius);
    background: rgba(17, 20, 15, 0.92);
    color: #ffffff;
    font-weight: 600;
    text-align: center;
}

.live-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 0.6rem calc(0.6rem + env(safe-area-inset-bottom));
    pointer-events: none;
}

.live-bottom > * {
    pointer-events: auto;
}

.live-fab {
    align-self: flex-end;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent);
    font-size: 1.4rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.live-sheet-area:empty {
    display: none;
}

.live-sheet,
.live-banner {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.live-sheet {
    max-height: 62vh;
    overflow-y: auto;
}

.live-sheet p {
    margin: 0.25rem 0 0.6rem;
}

.live-sheet .field {
    margin: 0.6rem 0;
}

.live-sheet .field input,
.live-sheet select {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.live-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.live-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.live-setting {
    max-width: 260px;
}

.field-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.map-swatches {
    margin: 0.4rem 0 0.75rem;
}

.map-swatches .swatch-color {
    width: 1.9rem;
    height: 1.9rem;
}

/* "Default": the default color with a diagonal stripe, so it reads as "automatic". */
.swatch-default {
    background:
        linear-gradient(135deg, transparent 45%, #ffffff 45%, #ffffff 55%, transparent 55%),
        var(--default);
}

.direction-picker {
    display: grid;
    grid-template-columns: repeat(3, 48px);
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.direction {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.direction.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-text);
}

.direction-arrow {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1;
}

.direction-name {
    font-size: 0.65rem;
    font-weight: 700;
}

.direction-none .direction-name {
    font-size: 0.75rem;
}

.marker-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0 1.5rem;
}

.marker-edit .field {
    margin: 0 0 0.5rem;
}

.marker-edit .map-swatches {
    max-width: 260px;
    margin-top: 0;
}

.kind-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.kind-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 48px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.kind-option:hover {
    border-color: var(--accent);
}

.kind-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.65rem;
    font-weight: 800;
}

.kind-swatch {
    flex: none;
    width: 34px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid currentColor;
}

.area-boundary { color: var(--text); border-style: dashed; }
.area-objective { color: #d4a017; background: rgba(212, 160, 23, 0.2); }
.area-danger { color: #f97316; background: rgba(249, 115, 22, 0.2); }
.area-friendly { color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, transparent); }
.area-enemy { color: #b91c1c; background: rgba(185, 28, 28, 0.2); }

/* A path is a line, so its swatch is a dashed stroke rather than a filled box. */
.area-path {
    height: 0;
    border-width: 0 0 4px;
    border-style: dashed;
    border-radius: 0;
    color: var(--accent);
}

.live-toolbar {
    display: flex;
    gap: 0.4rem;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 0.4rem;
    overflow-x: auto;
    border-radius: calc(var(--radius) + 4px);
    background: rgba(17, 20, 15, 0.88);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* Tools share the bar's width so up to six fit on a phone; the bar scrolls only as a last resort. */
.tool {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    min-width: 52px;
    min-height: 56px;
    padding: 0.3rem 0.25rem;
    line-height: 1.15;
    text-align: center;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: #e6e9df;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.tool:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tool-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.tool-on {
    background: #8bb455;
    color: #11140f;
}

.tool-on:hover {
    background: #9fc66a;
}

.tool-enemy .tool-icon {
    color: #f87171;
}

.tool {
    position: relative;
}

.tool-active {
    background: rgba(255, 255, 255, 0.14);
}

.tool-badge,
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1;
}

.tool-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 1.6rem);
}

.tab-badge {
    margin-left: 0.3rem;
}

/* ---- Callouts ---- */
.callout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.callout {
    min-height: 52px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.callout:hover:not(:disabled) {
    border-color: var(--accent);
}

.callout.urgent {
    border-color: #dc2626;
    background: #dc2626;
    color: #ffffff;
}

/* ---- Chat ---- */
.chat-sheet {
    display: flex;
    flex-direction: column;
    height: min(62vh, 520px);
    max-height: none;
    overflow: hidden;
}

.chat-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.2rem;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.chat-tabs .tab {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0.2rem 0.75rem;
}

.chat-audience {
    margin: 0.4rem 0 0.4rem !important;
    font-size: 0.8rem;
}

.chat-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 0;
    padding: 0.25rem 0.1rem;
    overflow-y: auto;
}

.chat-empty {
    margin: auto !important;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    max-width: 85%;
    padding: 0.4rem 0.65rem;
    border-radius: 12px 12px 12px 4px;
    background: var(--surface-2);
    overflow-wrap: anywhere;
}

.chat-msg.mine {
    align-self: flex-end;
    border-radius: 12px 12px 4px 12px;
    background: color-mix(in srgb, var(--accent) 22%, var(--surface));
}

.chat-msg.quick .chat-text {
    font-weight: 800;
}

.chat-msg.urgent {
    background: #dc2626;
    color: #ffffff;
}

.chat-msg.urgent .chat-meta,
.chat-msg.urgent .chat-locate {
    color: #ffffff;
}

.chat-meta {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.chat-text {
    white-space: pre-wrap;
}

.chat-locate {
    align-self: flex-start;
    margin-top: 0.15rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.chat-input input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

/* Banner for a message that arrives while the chat isn't showing it. */
.chat-banner {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 0.6rem 0.9rem;
    border: 0;
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.chat-banner.urgent {
    border-left-color: #7f1d1d;
    background: #dc2626;
    color: #ffffff;
}

.chat-banner-meta {
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.85;
}

.chat-banner-text {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Callout ping on the map (drawn by livemap.js). */
.lm-ping {
    position: relative;
    width: 36px;
    height: 36px;
}

.lm-ping-ring {
    position: absolute;
    inset: 9px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation: lm-pulse 1.4s ease-out infinite;
}

.lm-ping-urgent .lm-ping-ring {
    background: #dc2626;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    animation-name: lm-pulse-urgent;
}

@keyframes lm-pulse {
    to {
        box-shadow: 0 0 0 22px rgba(245, 158, 11, 0);
    }
}

@keyframes lm-pulse-urgent {
    to {
        box-shadow: 0 0 0 22px rgba(220, 38, 38, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .lm-ping-ring {
        animation: none;
    }
}

.live-note {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius);
    background: rgba(17, 20, 15, 0.88);
    color: #e6e9df;
    font-size: 0.85rem;
}

/* Map items (drawn by livemap.js) */
.lm-icon {
    background: none;
    border: 0;
}

.lm-marker-wrap {
    position: relative;
    width: 36px;
    height: 36px;
}

/* Direction pointer: a triangle on a ring around the badge, turned to the heading. */
.lm-heading {
    position: absolute;
    inset: -15px;
    pointer-events: none;
}

.lm-heading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 13px solid var(--c);
    filter: drop-shadow(0 0 1px #ffffff) drop-shadow(0 0 1px #ffffff) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.lm-arrowhead {
    width: 40px;
    height: 40px;
}

.lm-arrowhead svg {
    display: block;
    overflow: visible;
}

.lm-arrowhead path {
    fill: var(--c);
    stroke: #ffffff;
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.lm-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.lm-scope-game {
    border-radius: 6px;
}

.lm-kind-enemy {
    border-radius: 4px;
    transform: rotate(45deg) scale(0.85);
}

.lm-kind-enemy .lm-glyph {
    transform: rotate(-45deg);
}

.lm-glyph {
    color: var(--fg, #ffffff);
    font: 800 0.62rem/1 system-ui, sans-serif;
}

.lm-label {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-top: 3px;
    padding: 1px 6px;
    transform: translateX(-50%);
    border-radius: 4px;
    background: rgba(17, 20, 15, 0.8);
    color: #ffffff;
    font: 700 0.72rem/1.3 system-ui, sans-serif;
    white-space: nowrap;
}

.lm-player {
    position: relative;
    width: 30px;
    height: 30px;
}

/* A helmeted soldier on a disc in the side's color, outlined to stand out on satellite imagery. */
.lm-soldier {
    display: block;
    width: 30px;
    height: 30px;
    padding: 3px;
    box-sizing: border-box;
    border: 2px solid #ffffff;
    border-radius: 50%;
    overflow: hidden;
    background: var(--c);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.5);
}

.lm-soldier path {
    fill: #ffffff;
}

/* Leaders wear a gold star. */
.lm-rank {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 15px;
    height: 15px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.lm-rank path {
    fill: #facc15;
    stroke: #713f12;
    stroke-width: 0.6;
    stroke-linejoin: round;
}

/* You: cyan, with a halo. */
.lm-self .lm-soldier {
    background: #22d3ee;
    box-shadow: 0 0 0 5px rgba(34, 211, 238, 0.3), 0 1px 4px rgba(0, 0, 0, 0.5);
}

.lm-self .lm-soldier path {
    fill: #083344;
}

.lm-callsign {
    position: absolute;
    top: 50%;
    left: 34px;
    padding: 0 5px;
    transform: translateY(-50%);
    border-radius: 4px;
    background: rgba(17, 20, 15, 0.75);
    color: #ffffff;
    font: 700 0.7rem/1.4 system-ui, sans-serif;
    white-space: nowrap;
}

/* No update for a minute: still clearly visible, but grey and dashed (the label shows the age). */
.lm-stale .lm-soldier {
    background: #6b7280;
    border-style: dashed;
}

.lm-stale .lm-callsign {
    background: rgba(17, 20, 15, 0.6);
    color: #d1d5db;
}

/* A corner of the area being drawn: a big touch target around a small dot.
   (Leaflet's own CSS loads later and sets display on marker icons, so the dot is positioned absolutely.) */
.lm-vertex {
    background: none;
    border: 0;
    cursor: grab;
}

.lm-vertex::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #111827;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.5);
}

.lm-vertex.leaflet-drag-target,
.lm-vertex:active {
    cursor: grabbing;
}

.lm-vertex.leaflet-drag-target::after {
    width: 18px;
    height: 18px;
    background: #22d3ee;
}

.lm-area-label {
    padding: 1px 6px;
    border: 0;
    border-radius: 4px;
    background: rgba(17, 20, 15, 0.75);
    color: #ffffff;
    font-weight: 700;
    box-shadow: none;
}

.lm-area-label::before {
    display: none;
}

/* ---- Blazor error UI (shared by both layouts) ---- */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 2000;
    padding: 0.6rem 1.25rem 0.7rem;
    background: lightyellow;
    color: #1c2117;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    cursor: pointer;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ---- Objective boxes ---- */
.box-claim {
    display: grid;
    grid-template-columns: minmax(140px, 200px) minmax(160px, 1fr) auto;
    gap: 0 0.75rem;
    align-items: end;
}

.box-claim .field {
    margin-bottom: 0.4rem;
}

.box-claim .btn {
    margin-bottom: 0.4rem;
}

@media (max-width: 560px) {
    .box-claim {
        grid-template-columns: 1fr;
    }
}

.code-input {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace !important;
    font-size: 1.15rem !important;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.box-card .panel-head {
    gap: 0.75rem;
}

.box-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.9rem;
    margin: 0.35rem 0 0.6rem;
    font-size: 0.85rem;
}

.box-assignments {
    margin: 0 0 0.75rem;
    padding-left: 1.1rem;
}

.box-assignments li {
    margin-bottom: 0.2rem;
}

.box-sim-link {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.status-dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin: 0 0.2rem 0 0.35rem;
    border-radius: 50%;
    background: var(--text-muted);
    vertical-align: middle;
}

.status-dot.on {
    background: #16a34a;
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.check-row input {
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.15rem;
    accent-color: var(--accent);
}

/* Objectives on the event page */
.objective-list {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.objective-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

.objective-row:first-child {
    padding-top: 0;
}

.objective-row > .objective-form {
    flex: 1 1 100%;
}

.objective-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.6rem;
    min-width: 0;
}

.objective-summary .muted {
    font-size: 0.88rem;
}

.objective-form {
    margin-top: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 1rem;
}

.mode-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

.mode-picker legend {
    margin-bottom: 0.35rem;
    padding: 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.mode-option {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

.mode-option.selected {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.mode-option input {
    margin-top: 0.25rem;
    accent-color: var(--accent);
}

.mode-option span {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.mode-option small {
    color: var(--text-muted);
    line-height: 1.35;
}

/* ---- Box simulator: looks like the real box ---- */
.sim-box {
    max-width: 420px;
    margin: 0 auto 1.25rem;
    padding: 1rem;
    border-radius: 18px;
    background: #2b3326;
    box-shadow: inset 0 0 0 3px #3d4836, 0 4px 14px rgba(0, 0, 0, 0.3);
}

.sim-leds {
    height: 14px;
    margin: 0 0.5rem 0.9rem;
    border-radius: 999px;
    background: var(--led);
    transition: background 0.1s;
}

.sim-leds.on {
    box-shadow: 0 0 14px 2px var(--led);
}

.sim-screen {
    min-height: 7.2rem;
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    background: #050805;
    color: #9cf0a2;
    font: 600 1rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
    overflow-wrap: anywhere;
}

.sim-screen div:first-child {
    color: #ffffff;
}

.sim-progress {
    height: 6px;
    margin: 0.6rem 0 0.9rem;
    border-radius: 999px;
    background: #10140e;
    overflow: hidden;
}

.sim-progress span {
    display: block;
    height: 100%;
    background: var(--c);
}

.sim-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.75rem;
}

.sim-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 110px;
    border: 4px solid rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    aspect-ratio: 1;
    background: var(--c);
    color: #ffffff;
    font: 800 1rem/1.2 system-ui, sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.45);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.sim-button.held {
    transform: translateY(5px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45), 0 0 18px 4px var(--c);
}

.sim-button-number {
    font-size: 1.6rem;
}

.sim-status {
    margin: 0.9rem 0 0;
    color: #c7d0bd;
    font-size: 0.85rem;
    text-align: center;
}

.sim-status-error {
    color: #fca5a5;
}

.sim-buttons-setting {
    max-width: 180px;
}

/* ---- Objectives on the live map ---- */
.live-score {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.score-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.1rem 0.55rem 0.1rem 0.4rem;
    border-left: 4px solid var(--c);
    border-radius: 6px;
    background: rgba(17, 20, 15, 0.82);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
}

.score-chip strong {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.objective-state {
    margin: 0.2rem 0 0.4rem;
    font-weight: 700;
}

.hold-bar {
    height: 6px;
    margin-bottom: 0.6rem;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.hold-bar span {
    display: block;
    height: 100%;
    background: var(--c);
    transition: width 0.9s linear;
}

.objective-unplaced {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin: 0 0 0.6rem;
    font-size: 0.9rem;
}

.lm-objective {
    position: relative;
    width: 44px;
    height: 44px;
}

.lm-obj-badge {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 3px solid #ffffff;
    border-radius: 10px;
    background: var(--c);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.lm-obj-glyph {
    color: var(--fg, #ffffff);
    font: 900 0.68rem/1 system-ui, sans-serif;
    letter-spacing: 0.02em;
}

/* Someone holds a button: a ring fills in the color of their side and the badge pulses. */
.lm-obj-progress {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 64px;
    height: 64px;
    display: none;
    transform: rotate(-90deg);
    pointer-events: none;
}

.lm-obj-holding .lm-obj-progress {
    display: block;
}

.lm-obj-progress circle {
    fill: none;
    stroke-width: 6;
}

.lm-obj-track {
    stroke: rgba(17, 20, 15, 0.6);
}

.lm-obj-bar {
    stroke: var(--h);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    filter: drop-shadow(0 0 3px var(--h));
}

.lm-obj-holding .lm-obj-bar {
    animation-name: lm-obj-fill;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@keyframes lm-obj-fill {
    to { stroke-dashoffset: 0; }
}

.lm-objective.lm-obj-holding .lm-obj-badge {
    animation: lm-obj-hold 0.6s ease-in-out infinite alternate;
}

@keyframes lm-obj-hold {
    from { transform: scale(1); }
    to { transform: scale(1.12); box-shadow: 0 0 14px 4px var(--h); }
}

.lm-obj-holding .lm-obj-timer {
    background: var(--h);
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    font-family: system-ui, sans-serif;
    white-space: nowrap;
}

/* The state just changed: two rings burst out in the new color and the badge pops. */
.lm-obj-changed::before,
.lm-obj-changed::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 5px solid var(--b);
    border-radius: 12px;
    pointer-events: none;
    animation: lm-obj-burst 1.2s ease-out forwards;
}

.lm-obj-changed::after {
    animation-delay: 0.35s;
    opacity: 0;
}

@keyframes lm-obj-burst {
    from { transform: scale(0.9); opacity: 1; }
    to { transform: scale(3.2); opacity: 0; }
}

.lm-objective.lm-obj-changed .lm-obj-badge {
    animation: lm-obj-pop 0.7s ease-out;
}

@keyframes lm-obj-pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.lm-bomb-armed .lm-obj-badge {
    animation: lm-obj-armed 0.7s ease-in-out infinite alternate;
}

@keyframes lm-obj-armed {
    to { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0.35), 0 1px 6px rgba(0, 0, 0, 0.6); }
}

.lm-obj-timer:empty {
    display: none;
}

.lm-obj-timer {
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-bottom: 4px;
    padding: 1px 6px;
    transform: translateX(-50%);
    border-radius: 4px;
    background: #dc2626;
    color: #ffffff;
    font: 800 0.8rem/1.3 ui-monospace, Consolas, monospace;
}

/* The box stopped syncing, so what it shows may be out of date. */
.lm-obj-offline .lm-obj-badge {
    border-style: dashed;
    opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
    .lm-obj-holding .lm-obj-badge,
    .lm-obj-changed .lm-obj-badge,
    .lm-obj-changed::before,
    .lm-obj-changed::after,
    .lm-bomb-armed .lm-obj-badge {
        animation: none;
    }
}

.status-pill.status-online {
    background: #16a34a;
    color: #ffffff;
}

.objective-position .map-frame {
    margin-top: 0.2rem;
}

.objective-position-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 0.75rem;
}

/* Objective news on the live map: "Red captured Alpha". Tap to go to the objective. */
.objective-banner {
    position: absolute;
    top: calc(6rem + env(safe-area-inset-top));
    left: 50%;
    z-index: 1150;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: calc(100% - 2rem);
    padding: 0.55rem 1rem 0.55rem 0.55rem;
    border: 0;
    border-left: 6px solid var(--c);
    border-radius: var(--radius);
    background: rgba(17, 20, 15, 0.94);
    color: #ffffff;
    font: 700 1rem/1.3 var(--font);
    text-align: left;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--c);
    transform: translateX(-50%);
    cursor: pointer;
    animation: objective-banner-in 0.35s ease-out;
}

.objective-banner-glyph {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--c);
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

@keyframes objective-banner-in {
    from { opacity: 0; transform: translate(-50%, -12px) scale(0.96); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .objective-banner {
        animation: none;
    }
}

.box-on {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.box-on .status-dot {
    margin-left: 0;
}

.sim-off {
    max-width: 420px;
    margin: 0 auto 1.25rem;
    text-align: center;
}

.picker-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0.4rem 0;
}

#where:focus {
    outline: none;
}
