:root {
    --sg-safe-top: env(safe-area-inset-top, 0px);
    --sg-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    margin: 0;
    /* Dark until MudBlazor injects the theme variables, then follows light/dark mode. */
    background: var(--mud-palette-background, #1b1f2a);
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.boot {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #f2c14e;
}

.loading-progress {
    position: relative;
    display: block;
    width: 5rem;
    height: 5rem;
}

.loading-progress circle {
    fill: none;
    stroke: #2c3242;
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #f2c14e;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    font-weight: 600;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "");
}

#blazor-error-ui {
    background: #ffe08a;
    color: #222;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.8rem 1.25rem calc(0.8rem + var(--sg-safe-bottom));
    position: fixed;
    width: 100%;
    z-index: 2000;
    box-sizing: border-box;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.6rem;
}

/* ---- layout
   Phones first: tight paddings and one column. From 960 px (MudBlazor "md", see the MudHidden in Room.razor)
   the page spreads out: wider container, side columns, inline settings and actions. */
.sg-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 8px 10px calc(16px + var(--sg-safe-bottom));
}

.sg-narrow {
    max-width: 560px;
    margin: 0 auto;
}

.sg-panel {
    padding: 12px 14px;
}

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

.sg-hero {
    text-align: center;
    padding: 4px 0;
}

/* An input with its button on one line (join by code): same height, no MudBlazor field margins, so the edges line up. */
.sg-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.sg-input-row > .mud-input-control {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.sg-input-row > .mud-button-root {
    flex-shrink: 0;
    min-height: 56px;
}

/* rules: one readable column (560–760 px on desktop) laid out as a timeline */
.sg-rules {
    width: 100%;
    max-width: 760px;
    box-sizing: border-box;
}

@media (min-width: 960px) {
    .sg-rules {
        width: clamp(560px, 60vw, 760px);
    }
}

.sg-timeline {
    list-style: none;
    margin: 20px 0 0;
    padding: 0;
}

/* Icon centred against its text block; the line runs through every dot (first starts at its dot, last ends at it). */
.sg-tl-item {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    column-gap: 18px;
    padding: 8px 0;
}

.sg-tl-item::before {
    content: "";
    position: absolute;
    left: 19px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--mud-palette-lines-default);
}

.sg-tl-item:first-child::before {
    top: 50%;
}

.sg-tl-item:last-child::before {
    bottom: 50%;
}

.sg-tl-dot {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    box-sizing: border-box;
    border: 2px solid var(--mud-palette-primary);
    border-radius: 50%;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-primary);
}

/* Each step is a speech bubble pointing at its icon on the line. */
.sg-tl-body {
    position: relative;
    padding: 12px 16px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-background-gray);
}

.sg-tl-body::before,
.sg-tl-body::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    border-style: solid;
    transform: translateY(-50%);
}

/* Arrow = border-coloured triangle with a background-coloured one 1px inside it. */
.sg-tl-body::before {
    left: -9px;
    border-width: 8px 9px 8px 0;
    border-color: transparent var(--mud-palette-lines-default) transparent transparent;
}

.sg-tl-body::after {
    left: -7px;
    border-width: 7px 8px 7px 0;
    border-color: transparent var(--mud-palette-background-gray) transparent transparent;
}

/* home */
.sg-home {
    max-width: 560px;
}

.sg-home-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
}

/* room */
.sg-room-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.sg-room {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
}

.sg-room-main,
.sg-room-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* Card actions (desktop host): bottom-right corner, hint to the left of the buttons. */
.sg-panel-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.sg-panel-foot .sg-host-actions {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px 16px;
}

.sg-play {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
}

.sg-play-info {
    display: flex;
    flex-direction: column;
}

.sg-play-actions {
    margin-top: auto;
    padding-top: 16px;
}

.sg-host-hint {
    margin-top: 4px;
    text-align: center;
}

.sg-panel-foot .sg-host-hint {
    margin-top: 0;
}

/* room settings */
.sg-settings {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
}

.sg-settings-rules {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sg-panel-accent {
    border: 1px solid var(--mud-palette-primary);
}

/* ---- player list */
.sg-players {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sg-player {
    display: grid;
    align-items: center;
    column-gap: 10px;
    min-height: 44px;
}

.sg-player-main {
    min-width: 0;
}

.sg-player-wide {
    grid-column: 2 / -1;
}

.sg-player-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.sg-player-nick {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
}

.sg-player-you {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.sg-player-sub {
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
}

.sg-player-muted {
    color: var(--mud-palette-text-secondary);
}

/* Icons sit centred in their slot; MudTooltip would otherwise align them on the text baseline. */
.sg-player .mud-tooltip-root {
    display: inline-flex;
    flex-shrink: 0;
}

.sg-player-slot {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- list editor */
.sg-step-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sg-locs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sg-loc {
    padding: 10px 10px 10px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
}

.sg-loc-error {
    border-color: var(--mud-palette-error);
}

.sg-loc-head {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.sg-loc-head > .mud-input-control {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 4px;
}

.sg-loc-head > .mud-icon-button {
    margin-top: 6px;
}

.sg-loc-roles {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

/* Role = neutral pill with a remove button (it is content, not an on/off toggle). */
.sg-role {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    max-width: 100%;
    min-height: 28px;
    padding: 0 4px 0 10px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--mud-palette-action-default-hover);
    font-size: 0.8125rem;
    line-height: 20px;
}

.sg-role-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sg-role-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
}

.sg-role-remove:hover {
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-text-primary);
}

.sg-role-remove .mud-icon-root {
    font-size: 1rem;
}

.sg-role-input {
    flex: 1 1 180px;
    min-width: 0;
    min-height: 28px;
    padding: 0 4px;
    border: 0;
    border-bottom: 1px dashed var(--mud-palette-lines-inputs);
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.8125rem;
    outline: none;
}

.sg-role-input:focus {
    border-bottom-color: var(--mud-palette-primary);
}

.sg-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
}

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

.sg-check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
}

.sg-check-ok {
    color: var(--mud-palette-text-primary);
}

.sg-check-ok .mud-icon-root {
    color: var(--mud-palette-primary);
}

/* ---- segmented button group: one choice out of a few. Joined segments, selected = primary (yellow). */
.sg-seg {
    display: flex;
    width: 100%;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 10px;
    overflow: hidden;
}

/* Each segment grows from its label width, labels never wrap, so all segments keep one height. */
.sg-seg-item {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 38px;
    padding: 6px 12px;
    border: 0;
    border-left: 1px solid var(--mud-palette-lines-inputs);
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sg-seg-item:first-child {
    border-left: 0;
}

/* Narrow phones: tighter segments so labels like "S odkazem" still fit. */
@media (max-width: 420px) {
    .sg-seg-item {
        gap: 4px;
        padding: 6px 6px;
    }
}

/* Numbers: equal cells. */
.sg-seg-equal .sg-seg-item {
    flex: 1 1 0;
    padding: 6px 4px;
}

.sg-seg-item:hover:not(:disabled):not(.sg-seg-on) {
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-text-primary);
}

.sg-seg-item:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

.sg-seg-item:disabled {
    opacity: 0.45;
    cursor: default;
}

.sg-seg-on {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.sg-seg-icon {
    flex-shrink: 0;
    font-size: 1.1rem !important;
}

.sg-seg-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- count badge next to a title ("Players 3") */
.sg-title-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sg-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-text-primary);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* ---- toggles: the single on/off control of the app. On = primary (yellow), off = grey outline. */
.sg-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sg-toggles-tight {
    gap: 6px;
}

.sg-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--mud-palette-lines-inputs);
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 20px;
    max-width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sg-toggle:hover:not(:disabled) {
    border-color: var(--mud-palette-primary);
    color: var(--mud-palette-text-primary);
}

.sg-toggle:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.sg-toggle:disabled {
    opacity: 0.5;
    cursor: default;
}

.sg-toggle-on,
.sg-toggle-on:hover:not(:disabled) {
    background: var(--mud-palette-primary);
    border-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.sg-toggle-icon {
    flex-shrink: 0;
    font-size: 1.1rem !important;
}

/* Long names (custom lists, locations) shorten instead of breaking the pill. */
.sg-toggle-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sg-toggle-meta {
    flex-shrink: 0;
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.75;
}

.sg-toggle-sm {
    min-height: 28px;
    padding: 3px 10px;
    font-size: 0.8125rem;
}

.sg-toggle-struck .sg-toggle-text {
    text-decoration: line-through;
    opacity: 0.6;
}

/* "Add" action that sits among toggles (e.g. own location list). */
.sg-toggle-add {
    border-style: dashed;
    color: var(--mud-palette-primary);
}

.sg-settings-full {
    grid-column: 1 / -1;
}

.sg-invite {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 12px 0 8px;
}

.sg-invite .sg-qr svg {
    max-width: 200px;
}

@media (min-width: 960px) {
    .sg-page {
        padding: 24px 32px calc(32px + var(--sg-safe-bottom));
    }

    .sg-panel {
        padding: 20px 24px;
    }

    .sg-stack {
        gap: 16px;
    }

    .sg-hero {
        padding: 24px 0 8px;
    }

    .sg-home {
        max-width: 960px;
    }

    .sg-home-actions {
        gap: 16px;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }

    .sg-room-head {
        margin-bottom: 16px;
    }

    .sg-room {
        gap: 20px;
        grid-template-columns: minmax(0, 1fr) 340px;
        align-items: start;
    }

    .sg-room-main,
    .sg-room-side {
        gap: 16px;
    }

    .sg-play {
        gap: 16px;
        grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
    }

    .sg-play .sg-card {
        min-height: 340px;
        padding: 32px;
    }

    .sg-settings-wide {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: 40px;
    }


    .sg-timer {
        font-size: 2.6rem;
    }
}

@media (min-width: 1280px) {
    .sg-room {
        grid-template-columns: minmax(0, 1fr) 380px;
    }
}

.sg-code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: 0.2em;
    font-weight: 700;
}

.sg-card {
    position: relative;
    min-height: 200px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.15s ease;
}

.sg-card:active {
    transform: scale(0.98);
}

.sg-card-hidden {
    background: repeating-linear-gradient(45deg, var(--mud-palette-surface), var(--mud-palette-surface) 14px, var(--mud-palette-background-gray) 14px, var(--mud-palette-background-gray) 28px);
    border: 2px dashed var(--mud-palette-lines-default);
}

.sg-card-location {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.sg-card-spy {
    background: var(--mud-palette-error);
    color: var(--mud-palette-error-text);
}

.sg-card-leader {
    background: var(--mud-palette-surface);
    border: 2px solid var(--mud-palette-primary);
}

.sg-card-title {
    font-size: clamp(1.6rem, 7vw, 2.4rem);
    font-weight: 800;
    line-height: 1.15;
    word-break: break-word;
}

.sg-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.75rem;
}

.sg-struck {
    text-decoration: line-through;
    opacity: 0.45;
}

.sg-sticky-actions {
    position: sticky;
    bottom: 0;
    padding: 10px 0 calc(10px + var(--sg-safe-bottom));
    background: linear-gradient(transparent, var(--mud-palette-background) 30%);
    z-index: 5;
}

.sg-qr {
    width: 100%;
    text-align: center;
}

.sg-qr svg {
    width: 100%;
    max-width: 260px;
    height: auto;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
}
