* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f4f4f4;
    color: #111;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.4;
}

.top {
    background: #ba0c2f;
    color: #fff;
    padding: 14px 20px;
}

.top h1 {
    margin: 0;
    font-size: 24px;
}

.sub {
    margin: 2px 0 0;
    opacity: 0.85;
    font-size: 14px;
}

.app {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

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

h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin: 0 0 8px;
}

/* Game list */
.game-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.game-list button {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}

.game-list button:hover {
    border-color: #ba0c2f;
}

.game-list button:disabled {
    cursor: default;
    opacity: 0.6;
}

.game-list button:disabled:hover {
    border-color: #ddd;
}

.game-list button.active {
    border-color: #ba0c2f;
    box-shadow: inset 4px 0 0 #ba0c2f;
}

.game-list .opp {
    font-weight: 600;
}

.game-list .date {
    grid-column: 1;
    font-size: 13px;
    color: #666;
}

.game-list .result {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.result.W {
    color: #1a7f37;
}

.result.L {
    color: #b42318;
}

.result.live {
    color: #ba0c2f;
}

/* Detail */
.placeholder {
    color: #666;
}

.error {
    background: #fde8e8;
    color: #b42318;
    padding: 10px 12px;
    border-radius: 6px;
}

.scoreboard {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.scoreboard .teams {
    display: flex;
    gap: 24px;
    align-items: baseline;
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.scoreboard .status {
    color: #666;
    font-size: 14px;
    margin-top: 4px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 12px;
    font-size: 14px;
}

.drive {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 10px;
}

.drive summary {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
}

.drive summary::-webkit-details-marker {
    display: none;
}

.drive .team {
    font-weight: 700;
    min-width: 48px;
}

.drive.osu .team {
    color: #ba0c2f;
}

.drive .desc {
    color: #666;
    font-size: 14px;
    flex: 1;
}

.drive .outcome {
    font-weight: 600;
    font-size: 14px;
}

.drive.score .outcome {
    color: #1a7f37;
}

.plays {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid #eee;
}

.play {
    display: grid;
    grid-template-columns: 70px 110px 1fr;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.play:last-child {
    border-bottom: none;
}

.play .when {
    color: #666;
    font-variant-numeric: tabular-nums;
}

.play .dd {
    font-weight: 600;
}

.play.scoring {
    background: #eaf6ec;
}

.play.turnover {
    background: #fdecec;
}

.play.penalty .text {
    color: #8a5a00;
}

@media (max-width: 600px) {
    .play {
        grid-template-columns: 60px 1fr;
    }

    .play .text {
        grid-column: 1 / span 2;
    }
}

/* ---------- Header tabs ---------- */
.tabs {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.tabs a {
    color: #fff;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0.85;
}

.tabs a:hover {
    opacity: 1;
}

.tabs a.current {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    font-weight: 600;
}

/* ---------- Analysis page ---------- */
.analysis {
    min-width: 0; /* let wide tables scroll inside the grid column */
}

.analysis section {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.analysis h3 {
    font-size: 16px;
    margin: 20px 0 4px;
}

.analysis h4 {
    font-size: 14px;
    margin: 16px 0 4px;
    color: #444;
}

.analysis .filters {
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.analysis select {
    font: inherit;
    padding: 2px 4px;
}

.note {
    color: #666;
    font-size: 13px;
    margin: 0 0 10px;
}

.stat-line {
    margin: 0 0 10px;
}

/* Run = blue, pass = orange (validated pair; values are always printed alongside) */
.legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: #444;
}

.swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.swatch.run,
.seg.run {
    background: #257de0;
}

.swatch.pass,
.seg.pass {
    background: #f47230;
}

.split {
    display: flex;
    gap: 2px;
    width: 140px;
    height: 12px;
}

.seg {
    display: block;
    height: 100%;
}

.seg:first-child {
    border-radius: 4px 0 0 4px;
}

.seg:last-child {
    border-radius: 0 4px 4px 0;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.tile {
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 10px 12px;
}

.tile-label {
    font-size: 13px;
    color: #666;
}

.tile-value {
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tile-sub {
    font-size: 12px;
    color: #666;
}

.table-wrap {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

table.data th {
    text-align: left;
    font-size: 12px;
    color: #666;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
    padding: 6px 8px;
    white-space: nowrap;
}

table.data td {
    border-bottom: 1px solid #f0f0f0;
    padding: 6px 8px;
    vertical-align: top;
}

table.data tr.total td {
    font-weight: 700;
}

table.data tr.group td {
    background: #f7f7f7;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
}

table.data tr.scored td:first-child {
    box-shadow: inset 3px 0 0 #1a7f37;
}

table.data a {
    color: #ba0c2f;
    white-space: nowrap;
}

.pen-list {
    margin: 0;
    padding-left: 16px;
}

.pen-list li.late-down {
    font-weight: 600;
}

/* ---------- Call the Play game ---------- */
.caller {
    min-width: 0;
}

/* Elements below set their own display, which would otherwise override [hidden] */
.caller [hidden] {
    display: none !important;
}

.card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 18px;
    text-transform: none;
    letter-spacing: 0;
    color: #111;
}

kbd {
    border: 1px solid #ccc;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 5px;
    font-size: 13px;
    background: #f7f7f7;
}

.setup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.setup-row select {
    font: inherit;
    padding: 4px;
}

.btn {
    font: inherit;
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.btn:hover {
    border-color: #ba0c2f;
}

.btn.primary {
    background: #ba0c2f;
    border-color: #ba0c2f;
    color: #fff;
    font-weight: 600;
}

.label {
    display: block;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.big {
    display: block;
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.scorebox {
    display: grid;
    grid-template-columns: repeat(3, auto) 1fr;
    gap: 24px;
    align-items: end;
}

.scorebox .rank {
    text-align: right;
    font-weight: 600;
}

.drive-banner {
    background: #fff5d6;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 12px;
    font-weight: 600;
}

.situation {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.last-play {
    margin: 14px 0;
    color: #444;
    font-size: 14px;
}

.last-play .label {
    display: inline;
    margin-right: 6px;
}

.call-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn.call {
    font-size: 24px;
    font-weight: 800;
    padding: 22px;
    color: #fff;
    border: none;
}

.btn.call.run {
    background: #257de0;
}

.btn.call.pass {
    background: #f47230;
}

.btn.call:hover {
    filter: brightness(1.08);
}

.reveal {
    border-radius: 6px;
    padding: 12px 14px;
}

.reveal.right {
    background: #eaf6ec;
}

.reveal.wrong {
    background: #fdecec;
}

.verdict {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px;
}

.actual {
    margin: 0 0 6px;
}

@media (max-width: 600px) {
    .situation,
    .scorebox {
        grid-template-columns: 1fr 1fr;
    }

    .scorebox .rank {
        text-align: left;
    }
}

/* Game animations (CSS only) */
.btn.call {
    transition: transform 0.08s ease;
}

.btn.call:active {
    transform: scale(0.96);
}

.reveal.right {
    animation: pop-in 0.35s ease-out;
}

.reveal.wrong {
    animation: shake 0.4s ease-in-out;
}

.reveal.right .verdict {
    animation: bounce 0.6s ease-out 0.1s;
}

.drive-banner:not([hidden]) {
    animation: slide-down 0.3s ease-out;
}

.scorebox .big {
    transition: color 0.3s;
}

@keyframes pop-in {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

@keyframes slide-down {
    from { transform: translateY(-6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .reveal.right,
    .reveal.wrong,
    .reveal.right .verdict,
    .drive-banner:not([hidden]) {
        animation: none;
    }
}
