:root {
    /* Warm cream palette (Anthropic-style) */
    --bg-primary:    #edeae4;
    --bg-secondary:  #e3ded7;
    --bg-card:       #f2efe9;
    --bg-card-alt:   #d9d4cc;
    --text-primary:  #1a1714;
    --text-secondary:#6b6560;
    --text-dim:      #a09890;
    --accent-four:   #0ea5e9;
    --accent-six:    #ec4899;
    --accent-wicket: #ef4444;
    --accent-live:   #10b981;
    --accent-extra:  #f59e0b;
    --accent-finished:#10b981;
    --accent-link:   #3b82f6;
    --border:        rgba(26, 20, 16, 0.10);

    /* Telegram safe area insets */
    --safe-top: var(--tg-content-safe-area-inset-top, 0px);
    --safe-bottom: var(--tg-safe-area-inset-bottom, 0px);
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(8px + var(--safe-top)) 0 calc(24px + var(--safe-bottom));
}

/* Tabs */
.tabs-bar {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    /* border-top: 1px solid var(--border); */
    margin-top: 10px;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tabs-list {
    display: flex;
    padding: 0 4px;
    gap: 0;
    white-space: nowrap;
}
.tab-btn {
    flex-shrink: 0;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.tab-btn.tab-active {
    color: var(--text-primary);
    border-bottom-color: #10b981;
    font-weight: 600;
}
.tab-pane { display: none; }
.tab-pane.tab-pane-active { display: block; }
.tab-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    padding: 48px 24px;
}

/* Loading */
#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 60vh;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-live);
    animation: pulse 1.2s ease-in-out infinite;
}

/* Error */
#error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60vh;
    color: var(--accent-wicket);
    font-size: 14px;
    padding: 0 24px;
    text-align: center;
}

/* Card */
.card {
    background: var(--bg-card);
    border-radius: 14px;
    margin: 8px 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
}

/* ========== HEADER ========== */
.mh-wrap {
    padding: 8px 12px 0;
}

.mh-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px 16px 0 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.mh-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.mh-league-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mh-league {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
}

.mh-dot {
    color: var(--text-dim);
    font-size: 12px;
}

.mh-round {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Team rows */
.mh-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mh-team-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

/* Score slot: win badge + box, right-aligned */
.mh-score-slot {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Status badge */
.mh-status {
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mh-green { color: #10b981; }
.mh-amber { color: #f59e0b; }
.mh-red   { color: #ef4444; }
.mh-dim   { color: var(--text-secondary); }

.mh-timer {
    color: var(--text-secondary);
    font-size: 12px;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

/* Logo */
.mh-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 2px;
    box-sizing: border-box;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.mh-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.mh-logo-fb {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card-alt);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
}

.mh-win-badge {
    width: 20px;
    height: 20px;
    background: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.mh-team-name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mh-standing {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.mh-form {
    display: inline-flex;
    gap: 2px;
}

.mh-form-w, .mh-form-l, .mh-form-d, .mh-form-n {
    font-size: 9px;
    font-weight: 700;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.mh-form-w { background: #10b981; }
.mh-form-l { background: #ef4444; }
.mh-form-d { background: #a09890; }
.mh-form-n { background: #a09890; }

/* Score boxes */
.mh-box {
    width: 70px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mh-box-dim {
    background: var(--bg-secondary);
}

.mh-box-active {
    background: rgba(16, 185, 129, 0.12);
    border: 1.5px solid rgba(16, 185, 129, 0.35);
}

.mh-box-finished {
    border: none;
}

.mh-box-score {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.mh-box-ov {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.mh-green-text { color: #10b981; font-weight: 700; }

.mh-team-loser .mh-team-name,
.mh-team-loser .mh-standing {
    color: #6b7280;
}

/* Bottom bar */
.mh-bottom {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.mh-b-green {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.mh-b-amber {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.mh-b-red {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* ========== SCORECARD WIDGET ========== */
.sc-wrap {
    background: var(--bg-card);
    border-radius: 16px;
    margin: 10px 12px 0;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Team switcher */
.sc-switcher {
    display: flex;
    gap: 6px;
    padding: 14px 16px 0;
}

.sc-btn {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.sc-btn-active {
    background: #1a1714;
    color: #fff;
    font-weight: 600;
}

/* Overs scroll strip */
.sc-overs-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.sc-overs-scroll::-webkit-scrollbar { display: none; }

.sc-over {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.sc-over-num {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
}
.sc-over-num-cur { color: #10b981; font-weight: 600; }

.sc-balls {
    display: flex;
    gap: 4px;
}

.sc-ball {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sc-b-grey   { background: #858b97; color: #fff; }
.sc-b-four   { background: #3b82f6; color: #fff; font-weight: 600; }
.sc-b-six    { background: #ec4899; color: #fff; font-weight: 600; }
.sc-b-wicket { background: #ef4444; color: #fff; font-weight: 700; }
.sc-b-pulse {
    background: transparent;
    position: relative;
}
.sc-b-pulse::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50%       { opacity: 0.3; transform: translate(-50%, -50%) scale(0.5); }
}

.sc-over-runs {
    color: var(--text-dim);
    font-size: 10px;
}
.sc-over-runs-cur { color: #10b981; font-weight: 500; }

.sc-sep {
    width: 1px;
    background: var(--border);
    margin: 6px 0;
    align-self: stretch;
    flex-shrink: 0;
}

/* Batting / Bowling sections */
.sc-section {
    padding: 12px 16px;
}
.sc-section-border {
    border-top: 1px solid var(--border);
}

.sc-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sc-label {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sc-col-heads {
    display: flex;
}
.sc-col {
    text-align: center;
    font-size: 10px;
    color: var(--text-dim);
}

.sc-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.sc-player-row:last-child { margin-bottom: 0; }

.sc-player-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.sc-marker {
    color: #10b981;
    font-size: 12px;
    line-height: 1;
}

.sc-name {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-name-on { color: var(--text-primary); font-weight: 500; }

.sc-stats {
    display: flex;
    font-size: 13px;
    font-family: ui-monospace, monospace;
    flex-shrink: 0;
}
.sc-stat { text-align: center; color: var(--text-secondary); }
.sc-bold  { color: var(--text-primary); font-weight: 600; }

/* Fixed column widths matching HTML prototype */
.sc-w28 { width: 28px; }
.sc-w24 { width: 24px; }
.sc-w36 { width: 36px; }

/* ========== RUNS WIDGET ========== */
.rg-wrap {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    margin: 10px 12px 0;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.rg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.rg-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.rg-legend {
    display: flex;
    gap: 16px;
}

.rg-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
}

.rg-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.rg-chart {
    position: relative;
    height: 180px;
}

/* ========== SCOREBOARD ========== */
.scoreboard {
    padding: 10px 16px 6px;
}

.innings-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 6px 0;
}

.innings-row.current {
    font-weight: 600;
}

.innings-row.past {
    color: var(--text-secondary);
}

.team-score {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.team-code {
    font-size: 15px;
    font-weight: 700;
    min-width: 36px;
}

.score-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.innings-row.past .score-value {
    font-size: 17px;
}

.overs {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

.run-rate {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Target line */
.target-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(0, 212, 255, 0.08);
    border-radius: 8px;
    font-size: 13px;
    color: var(--accent-four);
}

/* ========== CURRENT OVER ========== */
.over-section {
    padding-bottom: 4px;
}

.over-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.over-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ball-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    background: #2a3555;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.ball-badge.run {
    background: #2a3555;
    color: var(--text-primary);
}

.ball-badge.four {
    background: var(--accent-four);
    color: #0a0a1a;
}

.ball-badge.six {
    background: var(--accent-six);
    color: #fff;
}

.ball-badge.wicket {
    background: var(--accent-wicket);
    color: #fff;
}

.ball-badge.extra {
    background: rgba(255, 165, 0, 0.2);
    color: var(--accent-extra);
}

/* ========== LAST BALL ========== */
.last-ball {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    margin: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: background 0.4s;
}

.last-ball.flash-four {
    animation: flash-four 0.8s ease-out;
}

.last-ball.flash-six {
    animation: flash-six 0.8s ease-out;
}

.last-ball.flash-wicket {
    animation: flash-wicket 0.8s ease-out;
}

.last-ball-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.last-ball-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.last-ball-text strong {
    color: var(--text-primary);
}

.last-ball-desc {
    font-weight: 700;
}

.last-ball-desc.four { color: var(--accent-four); }
.last-ball-desc.six { color: var(--accent-six); }
.last-ball-desc.wicket { color: var(--accent-wicket); }

/* ========== PLAYERS ========== */
.players-section {
    padding-top: 2px;
}

.section-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
}

.player-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    min-width: 0;
    flex: 1;
}

.player-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.strike-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-four);
    flex-shrink: 0;
}

.player-stats {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.player-runs {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 32px;
    text-align: right;
}

.player-balls {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: left;
}

.player-sr {
    font-size: 12px;
    color: var(--text-dim);
    min-width: 36px;
    text-align: right;
}

.player-boundaries {
    font-size: 11px;
    color: var(--text-dim);
    min-width: 48px;
    text-align: right;
}

/* Bowler divider */
.bowler-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* Bowler stats */
.bowler-stats {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--text-secondary);
}

.bowler-stat {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.bowler-stat-val {
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== INNINGS BREAK ========== */
.innings-break-banner {
    text-align: center;
    padding: 18px 16px;
    margin: 8px 12px;
    background: rgba(255, 165, 0, 0.08);
    border: 1px solid rgba(255, 165, 0, 0.2);
    border-radius: 14px;
}

.innings-break-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-extra);
    margin-bottom: 6px;
}

.innings-break-target {
    font-size: 15px;
    color: var(--text-secondary);
}

.innings-break-target strong {
    color: var(--text-primary);
    font-size: 18px;
}

/* ========== RESULT NOTE ========== */
.result-note {
    text-align: center;
    padding: 10px 16px;
    margin: 8px 12px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-finished);
}

/* ========== UPDATE INDICATOR ========== */
.update-bar {
    display: flex;
    justify-content: center;
    padding: 6px 0 2px;
    font-size: 11px;
    color: var(--text-dim);
}

/* ========== ANIMATIONS ========== */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

@keyframes flash-four {
    0% { background: rgba(0, 212, 255, 0.25); }
    100% { background: var(--bg-card); }
}

@keyframes flash-six {
    0% { background: rgba(255, 0, 110, 0.25); }
    100% { background: var(--bg-card); }
}

@keyframes flash-wicket {
    0% { background: rgba(255, 48, 64, 0.25); }
    100% { background: var(--bg-card); }
}

.ball-badge.dot {
    background: #232d42;
    font-size: 18px;
    color: var(--text-secondary);
}

.ball-badge.ball-pulse {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ball-badge.ball-pulse::after {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-live);
    animation: pulse 1.2s ease-in-out infinite;
}
