/*
 * Ma di? uživo (/ma-di/uzivo/{room}): the live room over the whole screen, in the game's look (ma-di.css: square
 * blocks, ink borders, the gold of the games, the red as the accent, never a solid black button). A phone: the bar, the
 * postcard, the time, the map, one big button; the table and the chat in a sheet from the bar's button. A computer: the
 * table and the chat in a column on the right. Every column is minmax(0, 1fr).
 */

body.madi-live-page {
    overflow: hidden;
}

.md.ml {
    position: fixed;
    inset: 0;
    z-index: 1085;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: auto;
    height: 100dvh;
    margin: 0;
    padding: 0;
    background: var(--md-paper);
    overscroll-behavior: contain;
}

/* ---------- the bar ---------- */

.ml-bar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 0.45rem;
    padding: calc(0.35rem + env(safe-area-inset-top, 0px)) 0.5rem 0.35rem;
    background: var(--md-paper);
    border-bottom: 1px solid var(--md-rule-strong);
}

.ml-title {
    display: grid;
    min-width: 0;
    line-height: 1.1;
}

.ml-title h1 {
    overflow: hidden;
    margin: 0;
    font-family: var(--news-font-head);
    font-size: 1.02rem;
    font-weight: 900;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ml-title span {
    overflow: hidden;
    color: var(--md-muted);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ml-title b {
    color: var(--md-ink);
}

.ml-score {
    display: grid;
    justify-items: center;
    min-width: 3.2rem;
    padding: 0.15rem 0.5rem;
    background: var(--md-gold);
    border: 2px solid var(--md-ink);
    line-height: 1;
}

.ml-score b {
    font-family: var(--news-font-head);
    font-size: 1.05rem;
    font-weight: 900;
}

.ml-score small {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
}

.ml-side-toggle {
    position: relative;
}

.ml-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 1.15rem;
    padding: 0 0.25rem;
    color: #fff;
    background: var(--md-accent);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1.15rem;
    text-align: center;
}

.ml-unread[hidden] {
    display: none;
}

/* ---------- the stage: the postcard, the time, the map, the button ---------- */

.ml-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
}

/* The stage holds the button's frame: on a computer the button floats centred over the map, never over the side column. */
.ml-stage {
    position: relative;
    display: grid;
    grid-template-rows: auto 6px minmax(0, 1fr) auto;
    min-height: 0;
}

.ml-card.md-card {
    grid-row: 1;
    margin: 0.45rem 0.5rem 0.4rem;
}

.ml-timer {
    grid-row: 2;
    margin: 0 0.5rem;
    overflow: hidden;
    background: var(--md-rule);
}

.ml-timer span {
    display: block;
    height: 100%;
    background: var(--md-gold-deep);
    transform: scaleX(0);
    transform-origin: left center;
}

.ml-timer span.is-late {
    background: var(--md-accent);
}

.ml-map-wrap {
    grid-row: 3;
    position: relative;
    min-height: 0;
    margin-top: 0.35rem;
}

/* The world map on a tall phone is shorter than the screen: what is above and below it looks like the sea. */
.ml .md-map {
    background: #cfd9df;
}

/* Bubi's bonus postcard (a picture between the map's): paper around the picture, never the sea. */
.ml .md-map.is-board {
    background: #ece5d6;
}

.ml-actionbar.md-actionbar {
    grid-row: 4;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
}

.ml-pinned {
    min-height: 1rem;
    color: var(--md-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}

/* ---------- the reveal: everyone's pins, a nameplate over each like a game's ---------- */

.leaflet-marker-icon.ml-player {
    overflow: visible;
    background: none;
    border: 0;
}

.ml-player-pin {
    position: absolute;
    left: -14px;
    top: -36px;
    filter: drop-shadow(0 3px 2px rgba(22, 23, 28, 0.45));
    animation: ml-pin-drop 0.38s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

.ml-plate {
    position: absolute;
    left: 0;
    bottom: 41px;
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    max-width: 150px;
    padding: 0.18rem 0.42rem 0.2rem 0.38rem;
    color: #fff;
    background: rgba(22, 23, 28, 0.9);
    border-left: 3px solid var(--tier, var(--md-gold));
    box-shadow: 0 2px 6px rgba(22, 23, 28, 0.3);
    font-family: var(--news-font-head);
    font-size: 0.74rem;
    font-weight: 900;
    line-height: 1.15;
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: none;
    animation: ml-plate-in 0.3s ease-out both;
}

.ml-plate::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: rgba(22, 23, 28, 0.9);
}

.ml-plate b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ml-plate i {
    flex: none;
    color: var(--md-gold);
    font-style: normal;
}

/* Mine: over my own big red pin, in the game's red. */
.ml-player.is-me .ml-plate {
    bottom: 50px;
    background: var(--md-accent);
}

.ml-player.is-me .ml-plate::after {
    border-top-color: var(--md-accent);
}

.ml-player.is-me .ml-plate i {
    color: #fff3c4;
}

/* Its place above taken: beside the pin's head, or under the pin (no pointer then). */
.ml-player.pos-right .ml-plate {
    left: 17px;
    bottom: 16px;
    transform: none;
}

.ml-player.pos-left .ml-plate {
    left: auto;
    right: 17px;
    bottom: 16px;
    transform: none;
}

.ml-player.pos-below .ml-plate {
    top: 6px;
    bottom: auto;
}

.ml-player.pos-right .ml-plate::after,
.ml-player.pos-left .ml-plate::after,
.ml-player.pos-below .ml-plate::after {
    display: none;
}

/* A plate with no room left opens on a tap or a hover of its pin. */
.ml-player.is-quiet .ml-plate {
    display: none;
}

.ml-player.is-quiet.is-open .ml-plate,
.ml-player.is-quiet:hover .ml-plate {
    display: inline-flex;
    animation: none;
}

@keyframes ml-pin-drop {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes ml-plate-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* After the time: my points, the place, the fact, the best three. */
.ml-result {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 600;
    display: grid;
    gap: 0.35rem;
    max-height: calc(100% - 1rem);
    overflow: auto;
    padding: 0.65rem 0.75rem;
    background: var(--md-paper);
    border: 2px solid var(--md-ink);
    border-top: 4px solid var(--md-gold);
    box-shadow: 0 10px 26px rgba(22, 23, 28, 0.2);
}

.ml-result.is-in {
    animation: md-rise 0.3s ease-out;
}

.ml-result-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.6rem;
}

.ml-result-host {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.ml-result-points {
    margin: 0;
    font-family: var(--news-font-head);
    font-size: 1.15rem;
    font-weight: 900;
    line-height: 1.15;
}

.ml-result[data-tier="perfect"] .ml-result-points { color: var(--md-perfect); }
.ml-result[data-tier="country"] .ml-result-points { color: #0e9384; }
.ml-result[data-tier="hot"] .ml-result-points { color: var(--md-hot); }
.ml-result[data-tier="warm"] .ml-result-points { color: #c4320a; }
.ml-result[data-tier="cold"] .ml-result-points,
.ml-result[data-tier="ice"] .ml-result-points { color: #175cd3; }

.ml-result-place {
    margin: 0.1rem 0 0;
    font-weight: 900;
}

.ml-result-place small {
    margin-left: 0.4rem;
    color: var(--md-muted);
    font-weight: 700;
}

.ml-result-fact {
    margin: 0;
    color: var(--md-soft);
    font-size: 0.88rem;
    line-height: 1.45;
}

.ml-result-best {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.8rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.82rem;
    font-weight: 800;
}

.ml-result-best li.is-me {
    color: var(--md-accent);
}

.ml-result-next {
    margin: 0;
    color: var(--md-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

/* ---------- the side: the table and the chat (a sheet on a phone) ---------- */

.ml-side {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1090;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: min(66dvh, 34rem);
    background: var(--md-paper);
    border-top: 4px solid var(--md-gold);
    box-shadow: 0 -12px 30px rgba(22, 23, 28, 0.22);
    transform: translateY(105%);
    transition: transform 0.25s ease;
}

.ml.is-side-open .ml-side {
    transform: none;
}

.ml-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    border-bottom: 1px solid var(--md-rule-strong);
}

.ml-tabs button {
    position: relative;
    min-height: 46px;
    padding: 0.4rem 0.6rem;
    color: var(--md-soft);
    background: var(--md-paper);
    border: 0;
    border-bottom: 3px solid transparent;
    font-weight: 900;
    cursor: pointer;
}

.ml-tabs button[aria-selected="true"] {
    color: var(--md-ink);
    border-bottom-color: var(--md-accent);
}

.ml-tabs .ml-unread {
    position: static;
    display: inline-block;
    margin-left: 0.3rem;
}

.ml-tabs-close {
    width: 46px;
}

.ml-panel {
    display: none;
    min-height: 0;
    padding: 0.55rem 0.7rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
}

.ml-panel.is-active {
    display: grid;
}

.ml-panel-title {
    display: none;
    margin: 0 0 0.4rem;
    font-family: var(--news-font-head);
    font-size: 1rem;
    font-weight: 900;
}

.ml-board-panel {
    align-content: start;
    gap: 0.4rem;
    overflow: auto;
}

.ml-board {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ml-board li {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.25rem;
    border-bottom: 1px solid var(--md-rule);
}

.ml-board li.is-me {
    background: var(--md-gold-soft);
}

.ml-board-place {
    color: var(--md-muted);
    font-family: var(--news-font-head);
    font-weight: 900;
}

.ml-board-name {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow: hidden;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ml-board-name img,
.ml-chat b img {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
}

.ml-board strong {
    font-family: var(--news-font-head);
    font-weight: 900;
}

.ml-board-empty,
.ml-me,
.ml-note {
    margin: 0;
    color: var(--md-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.ml-me {
    color: var(--md-ink);
    font-weight: 700;
}

.ml-note a {
    color: var(--md-accent);
    font-weight: 800;
}

.ml-rename {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.3rem;
}

.ml-rename label {
    font-size: 0.8rem;
    font-weight: 800;
}

.ml-rename span,
.ml-say {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.4rem;
}

.ml-rename input,
.ml-say input {
    min-width: 0;
    min-height: 42px;
    padding: 0.35rem 0.6rem;
    border: 2px solid var(--md-ink);
    border-radius: 0;
    font-size: 1rem;
}

.ml-rename button,
.ml-say button {
    min-height: 42px;
    padding: 0.35rem 0.85rem;
    color: #fff;
    background: var(--md-accent);
    border: 2px solid var(--md-accent);
    border-radius: 0;
    font-weight: 900;
    cursor: pointer;
}

/* A phone hides the panels' titles: the list and the form only (the title's row would take the form). */
.ml-chat-panel {
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.4rem;
}

.ml-chat {
    display: grid;
    align-content: start;
    gap: 0.25rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

.ml-chat li {
    padding: 0.25rem 0.35rem;
    font-size: 0.9rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.ml-chat b {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: 0.35rem;
}

.ml-chat li.is-bubi {
    background: var(--md-gold-soft);
    border-left: 3px solid var(--md-gold);
}

.ml-chat li.is-bubi b {
    color: var(--md-accent);
}

/* Bubi to a guest who keeps answering well (only they see it): open an account and the points stay (owner, 28 Nov 2026). */
.ml-chat li.is-join {
    padding: 0.4rem 0.5rem 0.5rem;
    background: var(--md-gold-soft);
    border-left: 3px solid var(--md-accent);
}

.ml-chat li.is-join b {
    color: var(--md-accent);
}

.ml-join-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.ml-join-link {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0 0.7rem;
    border: 1.5px solid var(--md-ink);
    color: var(--md-ink);
    background: #ffffff;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-decoration: none;
    text-transform: uppercase;
}

.ml-join-link.is-primary {
    border-color: var(--md-accent);
    color: #ffffff;
    background: var(--md-accent);
}

/* ---------- the overlay (connecting, closed) ---------- */

.ml-overlay {
    position: absolute;
    inset: 0;
    z-index: 1095;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.94);
    text-align: center;
}

.ml-overlay[hidden] {
    display: none;
}

.ml-overlay > div {
    display: grid;
    justify-items: center;
    gap: 0.7rem;
    max-width: 22rem;
}

.ml-overlay img {
    width: 120px;
    height: 120px;
}

.ml-overlay p {
    margin: 0;
    font-weight: 800;
}

.ml .md-toast {
    z-index: 1096;
}

/* ---------- small phones and phones held sideways ---------- */

@media (max-width: 380px) {
    .ml-title h1 {
        font-size: 0.92rem;
    }

    .ml-card .md-card-host {
        width: 44px;
        height: 44px;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    .ml-stage {
        grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
        grid-template-rows: auto 6px minmax(0, 1fr);
    }

    .ml-card.md-card {
        grid-column: 2;
        grid-row: 1 / 3;
        align-self: start;
    }

    .ml-timer {
        grid-column: 1;
        grid-row: 2;
    }

    .ml-map-wrap {
        grid-column: 1;
        grid-row: 1 / 4;
        margin: 0;
    }

    .ml-actionbar.md-actionbar {
        grid-column: 2;
        grid-row: 3;
        align-self: end;
        border-top: 0;
    }

    .ml-result {
        left: auto;
        width: min(22rem, 70%);
    }
}

/* ---------- a computer: the table and the chat on the right ---------- */

@media (min-width: 992px) {
    .ml-main {
        grid-template-columns: minmax(0, 1fr) 340px;
    }

    .ml-side-toggle {
        display: none;
    }

    .ml-side {
        position: static;
        z-index: auto;
        grid-template-rows: minmax(0, 0.9fr) minmax(0, 1.1fr);
        height: auto;
        min-height: 0;
        border-top: 0;
        border-left: 1px solid var(--md-rule-strong);
        box-shadow: none;
        transform: none;
        transition: none;
    }

    .ml-tabs {
        display: none;
    }

    .ml-panel,
    .ml-panel.is-active {
        display: grid;
    }

    .ml-panel-title {
        display: block;
    }

    .ml-chat-panel {
        grid-template-rows: auto minmax(0, 1fr) auto;
        border-top: 1px solid var(--md-rule-strong);
    }

    .ml-card.md-card {
        width: min(760px, calc(100% - 1rem));
        justify-self: center;
    }

    .ml-actionbar.md-actionbar {
        justify-items: center;
    }

    .ml-actionbar .md-go {
        width: min(420px, 100%);
    }

    .ml-result {
        left: auto;
        right: 0.75rem;
        top: 0.75rem;
        bottom: auto;
        width: 320px;
        max-height: calc(100% - 1.5rem);
    }
}

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

    .ml-result.is-in,
    .ml-player-pin,
    .ml-plate {
        animation: none;
    }
}
