/* Kilobots Online — public viewer styles */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --orange: #ffa500;
    --blue: #4a90d9;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #222222;
    --text-muted: #666666;
    --border: #dddddd;
    --accent: #333333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* --- Header --- */

header {
    background: var(--accent);
    color: #ffffff;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    white-space: nowrap;
}

#tabs {
    display: flex;
    gap: 0.25rem;
}

.tab {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.7);
    padding: 0.35rem 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.tab:hover { color: #ffffff; border-color: rgba(255,255,255,0.6); }
.tab.active { background: rgba(255,255,255,0.15); color: #ffffff; border-color: rgba(255,255,255,0.5); }

/* --- Main content --- */

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

.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Cards --- */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* --- Live section --- */

.fight-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.5rem;
    flex-wrap: wrap;
}

.fight-bot {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    min-width: 150px;
}

.fight-bot.red { background: #cc0000; color: #fff; }
.fight-bot.blue { background: var(--blue); color: #fff; }

.fight-vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
}

.fight-meta {
    text-align: center;
    width: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.fight-timer {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    width: 100%;
    font-variant-numeric: tabular-nums;
}

.fight-paused .fight-timer {
    color: var(--text-muted);
}

.fight-paused-label {
    text-align: center;
    width: 100%;
    font-size: 1.2rem;
    font-weight: 700;
    color: #cc0000;
    letter-spacing: 0.1em;
}

.no-fight {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* --- On-deck & recent results --- */

.match-list {
    list-style: none;
}

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

.match-list li:last-child { border-bottom: none; }

.match-label {
    font-weight: 700;
    min-width: 3rem;
}

.match-bracket {
    font-weight: 700;
}

.match-bots {
    flex: 1;
}

.match-result {
    font-weight: 700;
}

.match-winner {
    font-weight: 700;
}

.match-sep {
    color: var(--text-muted);
    margin: 0 0.4rem;
}

.match-time {
    font-weight: 700;
    white-space: nowrap;
}

/* --- Brackets section --- */

.bracket-container {
    margin-bottom: 1.5rem;
}

.bracket-container h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: var(--accent);
    color: #fff;
    border-radius: 4px 4px 0 0;
}

.bracket-pan-viewport {
    min-height: 300px;
    max-height: 70vh;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    background: #fff;
    overflow: hidden;
}

/* --- Schedule tables --- */

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.schedule-table th {
    background: var(--accent);
    color: #fff;
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
}

.schedule-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.schedule-table tr:nth-child(even) td {
    background: rgba(0,0,0,0.02);
}

.sched-red { color: #cc0000; font-weight: 700; }
.sched-blue { color: #2266cc; font-weight: 700; }
th.sched-red { background: #cc0000; color: #fff; }
th.sched-blue { background: #2266cc; color: #fff; }

/* --- Match detail modal --- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-bots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.modal-bot {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 600;
    text-align: center;
}

.modal-bot.red { background: #cc0000; color: #fff; }
.modal-bot.blue { background: var(--blue); color: #fff; }
.modal-bot.winner { outline: 3px solid #333; }

.modal-details {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

/* --- Rotate hint --- */

#rotate-hint {
    display: none;
    text-align: center;
    padding: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

@media (pointer: coarse) and (orientation: portrait) and (max-width: 520px) {
    #rotate-hint { display: block; }
}

/* --- Footer --- */

footer {
    text-align: center;
    padding: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Responsive --- */

/* --- Scroll gutters (touch devices) --- */

@media (pointer: coarse) {
    body {
        border-left: 1rem solid var(--accent);
        border-right: 1rem solid var(--accent);
    }
}

@media (max-width: 600px) {
    main { padding: 0.75rem 0.5rem; }
    header { flex-direction: column; align-items: flex-start; }
    .fight-card { flex-direction: column; gap: 0.5rem; }
    .fight-bot { min-width: 0; width: 100%; }
    .schedule-table { font-size: 0.8rem; }
    .schedule-table th, .schedule-table td { padding: 0.35rem; }
    .bracket-pan-viewport { max-height: 50vh; }
}

@media (max-width: 520px) {
    .schedule-table .col-bracket { display: none; }
}

@media (max-width: 440px) {
    body { font-size: 0.8rem; }
    header h1 { font-size: 1rem; }
    .tab { font-size: 0.75rem; padding: 0.25rem 0.6rem; }
    .card { padding: 0.5rem; }
    .card h2 { font-size: 0.9rem; }
    .schedule-table { font-size: 0.7rem; }
    .schedule-table th, .schedule-table td { padding: 0.25rem; }
    .fight-bot { font-size: 1rem; padding: 0.5rem 0.75rem; }
    .fight-timer { font-size: 1.5rem; }
    .fight-paused-label { font-size: 0.9rem; }
    .match-list li { font-size: 0.75rem; }
}
