/*
 *= require_tree .
 *= require_self
 */

:root {
    --bg: #fafafa;
    --fg: #1a1a1a;
    --muted: #6b6b6b;
    --accent: #1f6feb;
    --accent-edge: #fff8c4;
    --accent-edge-shadow: #6b6b6b;
    --accent-fg: #fff;
    --line: #e2e2e2;
    --warn-bg: #fff4d6;
    --warn-fg: #6a4b00;
    --ok-bg: #e1f6e0;
    --ok-fg: #14532d;
    --x-color: #c63333;
    --o-color: #1f6feb;
    --highlight: #fff8c4;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: white;
}

.site-header .brand a {
    text-decoration: none;
    color: var(--fg);
    font-weight: 700;
}

.site-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
}

.site-header .user-tag {
    color: var(--muted);
}

.locale-switcher {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
}

.locale-switcher__option {
    min-width: 2.25rem;
    padding: 0.2rem 0.45rem;
    border: 0;
    border-radius: 0;
    font-size: 0.75rem;
    line-height: 1.2;
}

.locale-switcher__option + .locale-switcher__option {
    border-left: 1px solid var(--line);
}

.locale-switcher__option[aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-fg);
    cursor: default;
    opacity: 1;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

.site-footer {
    text-align: center;
    padding: 1rem;
    color: var(--muted);
}

.flash {
    margin: 0.75rem auto;
    max-width: 1100px;
    padding: 0.75rem 1rem;
    border-radius: 4px;
}

.flash-notice {
    background: var(--ok-bg);
    color: var(--ok-fg);
}

.flash-alert {
    background: var(--warn-bg);
    color: var(--warn-fg);
}

/* Buttons */
.btn, button, input[type="submit"] {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: white;
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover, button:hover {
    background: #f0f0f0;
}

.btn-primary, .btn.btn-primary, input[type="submit"].btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #1857c2;
}

.btn-danger, .btn.btn-danger, input[type="submit"].btn-danger {
    background: #b42318;
    color: white;
    border-color: #b42318;
}

.btn-danger:hover {
    background: #8f1c13;
}

.btn-link {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--accent);
}

.btn-inline {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.admin-delete-form {
    margin: 0;
}

.admin-danger-zone {
    margin: 1.5rem 0;
    padding: 1rem;
    border: 1px solid #f0a39b;
    border-radius: 6px;
    background: #fff1f0;
}

.admin-danger-zone h2 {
    margin-top: 0;
    color: #8f1c13;
}

/* Framework-level entity inspection. The trigger/template contract and one
   top-layer panel are owned by entity_info_controller.js on #game-area. */
.entity-info-panel {
    position: fixed;
    z-index: 10000;
    margin: 0;
    padding: 0;
    width: min(240px, calc(100vw - 16px));
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 6px;
    background: #fafafa;
    color: #263241;
    font-size: 0.82rem;
    line-height: 1.35;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/* `data-entity-info-open` also makes the component work in browsers where
   the Popover API is unavailable or only partially implemented. */
.entity-info-panel[data-entity-info-open="false"] {
    display: none;
}

.entity-info-panel[data-entity-info-open="true"] {
    display: block;
}

.entity-info__text {
    margin: 0;
    padding: 9px 10px;
}

/* Forms */
.field {
    margin-bottom: 0.75rem;
}

.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

input[type="text"], select {
    width: 100%;
    max-width: 320px;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--line);
    font-size: 1rem;
}

/* Match listing */
.match-list {
    list-style: none;
    padding: 0;
}

.match-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.match-list__item {
    justify-content: space-between;
}

.match-list__main {
    display: grid;
    gap: 0.25rem;
}

.match-list__header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}

.match-list__status,
.match-list__details {
    color: var(--muted);
    font-size: 0.9rem;
}

.match-list__details,
.match-list__scores {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}

.match-list__score {
    font-size: 0.9rem;
    white-space: nowrap;
}

.home-match-section {
    margin-top: 1.5rem;
}

.match-list__pagination {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
}

.match-list__page {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ============================
 * GAME AREA — generic shell
 * ============================ */

.game-area {
    display: grid;
    gap: 1rem;
}

.phase-indicator {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.game-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 700px) {
    .game-grid {
        grid-template-columns: 1fr;
    }
}

.players-area h2 {
    font-size: 1rem;
    margin-top: 0;
}

.player-list {
    list-style: none;
    padding: 0;
}

.player-list .player {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: white;
}

.player-list .player.is-current {
    border-color: var(--accent);
    background: #f0f6ff;
}

.player-list .player.is-viewer {
    font-weight: 600;
}

.player-list .seat {
    font-family: ui-monospace, monospace;
    background: var(--player-color);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: white;
}

.presence-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #c9c9c9;
    border: 1px solid rgba(0, 0, 0, 0.18);
    display: inline-block;
    flex: 0 0 auto;
}

.presence-dot.is-online {
    background: #1f9d55;
    border-color: #137a3c;
    box-shadow: 0 0 0 2px rgba(31, 157, 85, 0.16);
}

.badge {
    background: var(--accent);
    color: var(--accent-fg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge.badge-you {
    background: var(--ok-fg);
}

.action-area {
    border-top: 1px solid var(--line);
    padding-top: 1rem;
}

.my-turn-banner {
    background: var(--ok-bg);
    color: var(--ok-fg);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Action panel — the single, generic fallback button list (see
   matches/_action_menu.html.erb). Used to be Brass-Pitt-only CSS
   (mode-buttons/btn-mode lived in brass_pitt.css) plus a separate,
   category-grouped <details> layout here (action-menu/action-category/
   action-list/btn-action) that the panel no longer renders — dropped in
   favor of one flat style, since grouping by category was the one part of
   that old layout that was actually game-specific behavior (which
   categories make sense, and whether grouping them helps) living in
   shared code. */
#actions-control {
    position: sticky;
    top: 0.5rem;
    z-index: 30;
    max-height: calc(100dvh - 1rem);
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

#actions-control > :first-child {
    margin-top: 0;
}

#actions-control > :last-child {
    margin-bottom: 0;
}

.action-menu__primary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.action-menu__primary h3 {
    flex: 0 0 auto;
    margin: 0;
}

.action-menu__primary .mode-buttons {
    min-width: 0;
    margin: 0;
}

.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.mode-buttons form {
    display: flex;
}

/* Default board slot for rules-only games. The playable controls live in
   .workbench-actions above; this panel documents that the absence of a
   graphical board is an intentional framework stage, not a missing partial. */
.workbench-board {
    max-width: 48rem;
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: 6px;
    background: #fafafa;
    color: var(--muted);
}

.workbench-board h2 {
    margin-top: 0;
    color: var(--fg);
}

.workbench-board p {
    margin-bottom: 0;
}

.btn-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    min-width: 100px;
}

.btn-mode strong {
    font-size: 0.9rem;
}

.btn-mode small {
    font-size: 0.7rem;
    color: var(--bg);
}

.btn-mode.is-disabled {
    opacity: 0.4;
    cursor: default;
}

.debug-actions {
    margin: 0.75rem 0 1rem;
    border: 1px dashed #9a6700;
    border-radius: 6px;
    background: #fffbea;
    font-size: 0.85rem;
}

html:not(.debug-panel-enabled) [data-debug-actions] {
    display: none;
}

.debug-panel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 0.78rem;
    cursor: pointer;
    user-select: none;
}

.debug-panel-toggle input {
    margin: 0;
}

.debug-actions > summary {
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    color: #6a4b00;
    font-weight: 700;
}

.debug-actions__count {
    display: inline-block;
    min-width: 1.5rem;
    margin-left: 0.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #9a6700;
    color: white;
    font-size: 0.72rem;
    line-height: 1.5rem;
    text-align: center;
}

.debug-actions__context,
.debug-actions__empty {
    margin: 0;
    padding: 0 0.75rem 0.6rem;
    color: var(--muted);
}

.debug-actions__context .phase-indicator {
    margin: 0 0 0.15rem;
}

.debug-actions__group {
    margin: 0 0.75rem 0.75rem;
}

.debug-actions__group h4 {
    margin: 0 0 0.25rem;
}

.debug-actions__group ol {
    max-height: 14rem;
    margin: 0;
    padding: 0.5rem 0.5rem 0.5rem 2.25rem;
    overflow: auto;
    border: 1px solid rgba(154, 103, 0, 0.2);
    border-radius: 4px;
    background: white;
}

.debug-actions__group li {
    padding: 0.15rem 0;
}

.debug-actions__group li > span {
    margin-left: 0.5rem;
    color: var(--muted);
}

/* Color only — box sizing (padding/min-width/flex layout) comes from
   .btn-mode, which every undo button also carries (see
   matches/_action_menu.html.erb) so it matches the other action buttons'
   size exactly instead of having its own competing padding. */
.btn-undo {
    background: #c44;
    color: #fff;
    border-color: #c44;
    font-weight: bold;
}

.game-log {
    background: white;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 4px;
}

.game-log .log-list {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    list-style: disc;
    padding-left: 1.5rem;
}

.game-log .log-list li {
    padding: 0.15rem 0;
}

.game-log__more {
    display: block;
    margin-top: 0.5rem;
    border-top: 1px solid var(--line);
}

.game-log__more-link {
    display: block;
    padding-top: 0.65rem;
    color: var(--accent);
    font-weight: 600;
}

.game-log__page > .log-list {
    margin-bottom: 0;
}

.game-log .log-idx   {
    font-size: 0.35rem;
}

.game-log .log-time   {
    font-size: 0.35rem;
}
.log-actor {
    color: var(--muted);
    margin-right: 0.5rem;
}

.action-history {
    margin-top: 1rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
}

.action-history__header,
.action-history__title,
.action-history__nav {
    display: flex;
    align-items: center;
}

.action-history__header {
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.action-history__eyebrow {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.action-history__nav {
    gap: 0.1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Replay replaces the local history navigator and is intentionally a fixed
   six-column grid. Links and disabled placeholders occupy the same cells, so
   repeated previous/next clicks never move under the pointer as the current
   position changes. */
.action-history__nav--replay {
    display: grid;
    flex: 0 0 11.75rem;
    grid-template-columns: repeat(2, 1.55rem) 3.5rem repeat(3, 1.55rem);
    width: 11.75rem;
}

.action-history__nav--replay .action-history__counter {
    width: 3.5rem;
    min-width: 3.5rem;
    font-variant-numeric: tabular-nums;
}

.action-history__button {
    display: inline-flex;
    flex: 0 0 1.55rem;
    align-items: center;
    justify-content: center;
    min-width: 1.55rem;
    padding: 0.25rem 0.35rem;
    line-height: 1;
    white-space: nowrap;
}

.action-history__button.is-disabled {
    cursor: default;
    opacity: 0.38;
}

.action-history__replay-button {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.action-history__replay-exit {
    margin-left: 0.15rem;
    color: var(--muted);
    font-size: 1.1rem;
}

.action-history__nav--replay .action-history__replay-exit {
    margin-left: 0;
}

.action-history__counter {
    min-width: 2.25rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

.action-history__title {
    margin-bottom: 0.45rem;
}

.action-history__title h3 {
    margin: 0;
    font-size: 1rem;
}

.action-history__title h3 > span {
    color: var(--muted);
    font-weight: 500;
}

.action-history__steps {
    margin: 0;
    padding-left: 1.4rem;
    font-size: 0.82rem;
}

.action-history__steps .log-row {
    padding: 0.18rem 0;
}

.log-related-player {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.35rem;
    padding: 0.08rem 0.38rem;
    border: 1px solid color-mix(in srgb, var(--related-player-color) 45%, var(--line));
    border-radius: 999px;
    background: color-mix(in srgb, var(--related-player-color) 9%, white);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.log-related-player__dot {
    flex: 0 0 0.55rem;
    width: 0.55rem;
    height: 0.55rem;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 50%;
    background: var(--related-player-color);
}

.action-history__steps .log-time {
    display: none;
}

.waiting {
    color: var(--muted);
    padding: 0.5rem 0;
}

.match-lobby {
    width: min(42rem, 100%);
    margin: 2rem auto;
    display: grid;
    gap: 1.25rem;
}

.match-lobby__header {
    text-align: center;
}

.match-lobby__header h1,
.match-lobby__header p {
    margin: 0.25rem 0;
}

.match-lobby__eyebrow {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.match-lobby__players {
    display: grid;
    gap: 0.65rem;
}

.match-lobby__player,
.match-lobby__empty {
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.match-lobby__player.is-viewer {
    border-color: var(--accent);
}

.match-lobby__player .presence-dot {
    margin-left: auto;
}

.match-lobby__empty {
    justify-content: center;
    color: var(--muted);
    border-style: dashed;
    background: transparent;
}

.match-lobby__swatch {
    width: 1.5rem;
    height: 1.5rem;
    flex: 0 0 1.5rem;
    border: 1px solid color-mix(in srgb, var(--player-color) 65%, #1f2937);
    border-radius: 50%;
    background: var(--player-color);
}

.match-lobby__color-name {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.match-lobby__join {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: center;
    gap: 0.65rem;
    padding: 1rem;
    border-radius: 8px;
    background: var(--highlight);
}

.match-lobby__join label {
    width: 100%;
    text-align: center;
    font-weight: 600;
}

.match-lobby__waiting {
    color: var(--muted);
    text-align: center;
}

.game-over {
    background: var(--highlight);
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
}

.match-unavailable {
    max-width: 42rem;
    margin: 3rem auto;
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.match-unavailable__eyebrow {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
}

.match-unavailable h1 {
    margin-top: 0.25rem;
}

.match-unavailable__summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.match-unavailable__summary div,
.match-unavailable__players li {
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 4px;
}

.match-unavailable__summary dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.match-unavailable__summary dd {
    margin: 0.15rem 0 0;
    font-weight: 600;
}

.match-unavailable__players {
    display: grid;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
}

.match-unavailable__players li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.viewer-list {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.viewer-list__title {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.viewer-list__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.viewer-list__item {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    font-size: 0.9rem;
}

.viewer-list__name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.viewer-list__meta,
.viewer-list__empty {
    color: var(--muted);
    font-size: 0.82rem;
}

.viewer-list__empty {
    margin: 0;
}

/* ============================
 * TIC-TAC-TOE specific
 * ============================ */

.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    background: var(--line);
    padding: 6px;
    width: min(360px, 90vw);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 8px;
}

.ttt-cell-form {
    margin: 0;
    padding: 0;
}

.ttt-cell {
    width: 100%;
    height: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 0;
    border-radius: 4px;
    font-size: 4rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 120ms ease;
    padding: 0;
}

.ttt-cell-empty:hover {
    background: #fff8c4;
}

.ttt-cell-filled {
    cursor: default;
}

.ttt-cell-x {
    color: var(--x-color);
}

.ttt-cell-o {
    color: var(--o-color);
}

@supports (view-transition-name: a) {
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation-duration: 220ms;
        animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
    }
}

/* Graphical game actions use fetch + Turbo Stream broadcasts rather than a
 * form submit. Keep their current legal highlight visible while preventing a
 * second click until the refreshed action region has applied the next legal
 * action set. */
.game-action--pending .is-legal {
    cursor: progress !important;
    pointer-events: none !important;
}

/* Match chat */
.match-chat {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 9000;
    width: clamp(240px, calc((min(100vw, 1100px) - 3.5rem) / 3), 348px);
}

.match-chat__desktop-trigger {
    display: flex;
    width: 100%;
    height: 2.75rem;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
    text-align: left;
}

.match-chat__trigger-title {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-chat__chevron {
    color: var(--muted);
    font-size: 1rem;
    transition: transform 150ms ease;
}

.match-chat__desktop-trigger[aria-expanded="true"] .match-chat__chevron {
    transform: rotate(180deg);
}

.match-chat__mobile-trigger {
    display: none;
}

.match-chat__badge {
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #c63333;
    color: white;
    font-size: 0.67rem;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}

.match-chat__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.5rem);
    display: none;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: 100%;
    height: min(460px, calc(100vh - 5.25rem));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
}

.match-chat__panel.is-open {
    display: grid;
}

.match-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--line);
}

.match-chat__header h2 {
    margin: 0;
    font-size: 1rem;
}

.match-chat__close {
    display: none;
    padding: 0.15rem 0.45rem;
    border: 0;
    font-size: 1.4rem;
    line-height: 1;
}

.match-chat__messages {
    min-height: 0;
    margin: 0;
    padding: 0.75rem;
    overflow-y: auto;
    list-style: none;
}

.match-chat__message {
    max-width: 88%;
    margin-bottom: 0.65rem;
    padding: 0.5rem 0.65rem;
    border-radius: 10px 10px 10px 2px;
    background: #f1f3f5;
}

.match-chat__message.is-own {
    margin-left: auto;
    border-radius: 10px 10px 2px 10px;
    background: #e6f0ff;
}

.match-chat__meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.7rem;
}

.match-chat__message p {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 0.88rem;
    line-height: 1.35;
    white-space: pre-wrap;
}

.match-chat__empty,
.match-chat__error {
    margin: 0;
    padding: 0 0.75rem 0.5rem;
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}

.match-chat__error {
    color: #b42318;
}

.match-chat__readonly {
    margin: 0;
    padding: 0.75rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}

.match-chat__form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.7rem;
    border-top: 1px solid var(--line);
}

.match-chat__form input[type="text"] {
    min-width: 0;
    width: 100%;
    max-width: none;
}

.match-chat__form button {
    padding-inline: 0.8rem;
}

@media (max-width: 700px) {
    .match-chat {
        top: auto;
        right: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom));
        width: auto;
    }

    .match-chat__desktop-trigger {
        display: none;
    }

    .match-chat__mobile-trigger {
        position: relative;
        display: grid;
        width: 2.6rem;
        height: 2.6rem;
        padding: 0;
        place-items: center;
        border-radius: 50%;
        background: white;
        font-size: 1.2rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
    }

    .match-chat__mobile-trigger .match-chat__badge {
        position: absolute;
        top: -0.35rem;
        right: -0.35rem;
        border: 2px solid white;
        line-height: 1rem;
    }

    .match-chat__panel {
        position: fixed;
        inset: 0;
        display: none;
        width: 100vw;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .match-chat__close {
        display: inline-block;
    }
}
