:root {
    --pitch-green: #1d6b3a;
    --pitch-green-dark: #134a27;
    --line-white: #f4f4f0;
    --accent: #e0a800;
    --text: #1c1c1c;
    --muted: #6b6b6b;
    --danger: #b3261e;
    --card-bg: #ffffff;
    --bg: #f1f3ef;
    --border: #d8dcd4;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--pitch-green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.auth-page {
    max-width: 380px;
    margin: 64px auto;
    padding: 32px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.auth-page h1 {
    margin-top: 0;
    text-align: center;
    color: var(--pitch-green-dark);
}

nav.topnav {
    background: var(--pitch-green-dark);
    color: var(--line-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-wrap: wrap;
    gap: 8px;
}

nav.topnav .brand {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--line-white);
}

nav.topnav .links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

nav.topnav .links a {
    color: var(--line-white);
    opacity: 0.85;
    font-size: 0.95em;
}

nav.topnav .links a.active { opacity: 1; font-weight: 600; border-bottom: 2px solid var(--accent); }
nav.topnav .links a:hover { opacity: 1; text-decoration: none; }

nav.topnav .user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
}

nav.topnav .user button {
    background: transparent;
    color: var(--line-white);
    border: 1px solid rgba(244, 244, 240, 0.5);
}

nav.topnav .user button:hover {
    background: rgba(244, 244, 240, 0.15);
}

button, .btn {
    display: inline-block;
    background: var(--pitch-green);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 0.95em;
    cursor: pointer;
}

button:hover, .btn:hover { background: var(--pitch-green-dark); }
button.secondary, .btn.secondary { background: transparent; color: var(--pitch-green-dark); border: 1px solid var(--border); }
button.secondary:hover, .btn.secondary:hover { background: #eef2ec; }
button.danger, .btn.danger { background: var(--danger); }
button.danger:hover { background: #8c1d17; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95em;
    background: white;
    color: var(--text);
}

label {
    display: block;
    font-size: 0.85em;
    color: var(--muted);
    margin-bottom: 4px;
    margin-top: 12px;
}

.field { margin-bottom: 4px; }

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

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.action-panels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.penalty-pips-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.penalty-pips-name {
    flex: 0 0 120px;
    font-weight: 600;
}

.penalty-pips {
    flex: 1;
    font-size: 1.4em;
    letter-spacing: 4px;
}

.penalty-pips-score {
    font-weight: 700;
    font-size: 1.2em;
    min-width: 28px;
    text-align: right;
}

.penalty-turn {
    font-weight: 600;
    margin-top: 12px;
}

.penalty-result {
    font-weight: 700;
    color: var(--pitch-green-dark);
    margin-top: 12px;
}

.bracket-scroll {
    overflow-x: auto;
    padding-bottom: 10px;
}

.bracket-rounds {
    display: flex;
    gap: 50px;
    align-items: flex-start;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    min-width: 220px;
    flex-shrink: 0;
}

.bracket-round-title {
    text-align: center;
    margin: 0 0 12px;
    font-size: 1em;
}

.bracket-round-grid {
    display: grid;
    grid-template-columns: 1fr;
}

.bracket-match-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.bracket-match {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    width: 100%;
    font-size: 0.85em;
}

.bracket-slot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
}

.bracket-winner {
    font-weight: 700;
    color: var(--pitch-green-dark);
}

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

.bracket-actions {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.85em;
}

.bracket-actions .btn, .bracket-actions button {
    font-size: 0.8em;
    padding: 4px 8px;
}

.bracket-connector-in {
    position: absolute;
    left: -25px;
    top: 25%;
    bottom: 25%;
    width: 25px;
    border: 2px solid var(--border);
    border-right: none;
}

.bracket-connector-stub {
    position: absolute;
    left: -25px;
    top: 50%;
    width: 25px;
    height: 2px;
    background: var(--border);
    transform: translateY(-1px);
}

.bracket-stub-out {
    position: absolute;
    right: -25px;
    top: 50%;
    width: 25px;
    height: 2px;
    background: var(--border);
    transform: translateY(-1px);
}

h1, h2, h3 { color: var(--pitch-green-dark); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92em;
}

th { background: #eef2ec; color: var(--pitch-green-dark); }

tr:last-child td { border-bottom: none; }

.error-text { color: var(--danger); font-size: 0.9em; margin-top: 8px; min-height: 1.2em; }
.success-text { color: var(--pitch-green-dark); font-size: 0.9em; margin-top: 8px; }
.muted { color: var(--muted); font-size: 0.88em; }

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: #eef2ec;
    color: var(--pitch-green-dark);
    font-size: 0.78em;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.score-display { font-weight: 700; font-size: 1.1em; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { background: transparent; color: var(--muted); border-radius: 0; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--pitch-green-dark); border-bottom-color: var(--accent); }
.tabs button:hover { background: #eef2ec; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
    background: var(--card-bg); border-radius: var(--radius); padding: 24px;
    width: 90%; max-width: 480px; max-height: 85vh; overflow-y: auto;
}
.hidden { display: none !important; }

.pitch-view {
    position: relative;
    background: var(--pitch-green);
    color: var(--line-white);
    border: 3px solid var(--line-white);
    border-radius: var(--radius);
    min-height: 300px;
    margin-bottom: 20px;
    overflow: hidden;
}

.pitch-halfway-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: var(--line-white);
    transform: translateX(-50%);
}

.pitch-side {
    position: absolute;
    top: 15%;
    bottom: 15%;
    width: 27%;
    min-width: 150px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--line-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
}

.pitch-side-home { left: 0; border-left: none; }
.pitch-side-away { right: 0; border-right: none; }

.pitch-side h2 { color: var(--line-white); margin: 0 0 8px; font-size: 1.3em; }
.pitch-side .pitch-team-name { opacity: 0.85; font-size: 0.85em; margin: 0; }
.pitch-score { font-size: 3em; font-weight: 800; line-height: 1; }

.pitch-clock-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid var(--line-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

#penalty-score-display {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--line-white);
    margin: 0;
}

@media (max-width: 640px) {
    .pitch-view {
        min-height: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 20px 12px;
    }
    .pitch-halfway-line { display: none; }
    .pitch-side {
        position: static;
        width: 100%;
        min-width: 0;
        margin-bottom: 12px;
    }
    .pitch-clock-circle {
        position: static;
        transform: none;
        margin: 12px 0;
    }
    #penalty-score-display { position: static; margin-top: 10px; }
}

.pitch-clock-circle .clock-time {
    font-size: 1.7em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.pitch-clock-circle .clock-stage {
    font-size: 0.72em;
    opacity: 0.85;
    margin-top: 4px;
    text-align: center;
    padding: 0 6px;
}

.control-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 16px 0;
}

.event-feed {
    max-height: 320px;
    overflow-y: auto;
}

.event-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
}

.event-row:last-child { border-bottom: none; }

.live-badge {
    display: inline-block;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 0.78em;
    font-weight: 600;
}

.squad-section {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.squad-list {
    list-style: none;
    padding: 0;
    margin: 0 0 8px;
}

.squad-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.9em;
}
