/*
 *= 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;
}

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;
    gap: 0.75rem;
    align-items: center;
}

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

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-link {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--accent);
}

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

/* 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;
}

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

.game-area {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: 1rem;
}

.game-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.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;
}

.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. */
.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.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;
}

/* 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 .log-idx   {
    font-size: 0.35rem;
}

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

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

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

/* ============================
 * 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);
    }
}
