/* ========== TIC TAC TOE ========== */

.ttt-page {
    display: grid;
    gap: 1rem;
    max-width: 480px;
    margin: 0 auto;
    padding: 0.5rem;
}

.ttt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.ttt-header-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.ttt-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.ttt-match-id {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: monospace;
    opacity: 0.7;
}

.ttt-header-right {
    display: flex;
    align-items: center;
}

.ttt-conn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background 200ms ease;
}

.ttt-conn-ok {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.ttt-conn-warn {
    background: #f59e0b;
    animation: ttt-pulse 1.2s infinite;
}

.ttt-conn-off {
    background: #ef4444;
}

/* Players bar */
.ttt-players-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.9));
    border-radius: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.ttt-player-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    transition: all 200ms ease;
}

.ttt-player-card.ttt-player-active {
    background: rgb(from var(--mud-palette-primary) r g b / 0.12);
    box-shadow: 0 0 0 2px rgb(from var(--mud-palette-primary) r g b / 0.25);
}

.ttt-player-symbol {
    font-size: 1.1rem;
    font-weight: 800;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.ttt-symbol-x {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
}

.ttt-symbol-o {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.ttt-player-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ttt-you-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgb(from var(--mud-palette-primary) r g b / 0.15);
    color: var(--accent-strong);
}

.ttt-vs {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    opacity: 0.6;
}

/* Turn banner */
.ttt-turn-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: 0.85rem;
    transition: all 250ms ease;
}

.ttt-turn-waiting {
    background: rgba(0, 0, 0, 0.04);
}

.ttt-turn-yours {
    background: linear-gradient(135deg, rgb(from var(--mud-palette-primary) r g b / 0.15), rgba(16, 185, 129, 0.1));
    border: 1px solid rgb(from var(--mud-palette-primary) r g b / 0.2);
    animation: ttt-glow 2s ease-in-out infinite;
}

.ttt-turn-finished {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(168, 85, 247, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.15);
}

@keyframes ttt-glow {
    0%, 100% { box-shadow: 0 0 12px rgb(from var(--mud-palette-primary) r g b / 0.15); }
    50% { box-shadow: 0 0 20px rgb(from var(--mud-palette-primary) r g b / 0.25); }
}

.ttt-turn-icon {
    font-size: 1.2rem;
    animation: ttt-bounce 0.6s ease-in-out infinite;
}

@keyframes ttt-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.ttt-turn-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
}

/* Timer */
.ttt-timer {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ttt-timer-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ttt-timer-bg {
    fill: none;
    stroke: rgba(0, 0, 0, 0.08);
    stroke-width: 3;
}

.ttt-timer-progress {
    fill: none;
    stroke: var(--accent-strong);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 500ms linear, stroke 300ms ease;
}

.ttt-timer-warning .ttt-timer-progress {
    stroke: #f59e0b;
}

.ttt-timer-urgent .ttt-timer-progress {
    stroke: #ef4444;
    animation: ttt-pulse-stroke 0.5s ease-in-out infinite;
}

@keyframes ttt-pulse-stroke {
    0%, 100% { stroke-width: 3; }
    50% { stroke-width: 4; }
}

.ttt-timer-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
}

.ttt-timer-urgent .ttt-timer-value {
    color: #ef4444;
}

/* Spectator banner */
.ttt-spectator-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed rgba(99, 102, 241, 0.25);
}

.ttt-spectator-content {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.ttt-spectator-icon {
    font-size: 1.3rem;
}

.ttt-spectator-content strong {
    font-size: 0.85rem;
    color: var(--ink);
}

.ttt-spectator-content p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--muted);
}

.ttt-play-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--accent-strong);
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.ttt-play-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgb(from var(--mud-palette-primary) r g b / 0.3);
}

/* Board */
.ttt-board-wrapper {
    padding: 1.25rem;
    border-radius: 1.25rem;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
}

/* Narrow-screen contract: three 1fr tracks, square by ratio, no px floor. min-height:80px used
   to transfer THROUGH aspect-ratio into an 80px min-WIDTH, so each cell refused to shrink and
   the page overflowed at 320px -- and below ~400px the cells rendered 70x80, i.e. not square.
   Cells are ~65px at 320px, well past the 24px floor, and .ttt-page's 480px max-width still
   pins them at 134px on desktop, so nothing moves there. */
.ttt-cell {
    aspect-ratio: 1;
    border-radius: 0.9rem;
    border: 2px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 150ms ease;
}

.ttt-cell-empty:not(:disabled):hover {
    background: rgb(from var(--mud-palette-primary) r g b / 0.06);
    border-color: rgb(from var(--mud-palette-primary) r g b / 0.2);
    transform: scale(1.02);
}

.ttt-cell-x {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.2);
}

.ttt-cell-o {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
}

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

.ttt-mark {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    animation: ttt-pop 200ms ease-out;
}

@keyframes ttt-pop {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.ttt-mark-x {
    color: #3b82f6;
    text-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.ttt-mark-o {
    color: #ef4444;
    text-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

@keyframes ttt-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
