:root {
    --red: #e31837;
    --blue: #0033a0;
    --green: #009639;
    --yellow: #ffb81c;
    --black: #000000;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f4f9;
    margin: 0;
    padding: 20px;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}
.admin-toggle-btn {
    background-color: #34495e;
    color: white;
    padding: 7px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    border: none;
    font-weight: bold;
}
.admin-toggle-btn.logged-in { background-color: var(--green); }

.setup-header-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #eef2f7;
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #cbd5e1;
    flex-wrap: wrap;
    gap: 10px;
}
.year-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cloud-status-badge {
    font-size: 12px;
    font-weight: bold;
    color: #166534;
    background: #dcfce7;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid #bbf7d0;
}

header { text-align: center; margin-bottom: 20px; }
header img { max-width: 280px; height: auto; }

nav { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
button {
    padding: 8px 12px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: var(--blue);
    color: white;
    font-weight: bold;
}
button:hover { background-color: #002277; }
button:disabled { background-color: #cccccc; cursor: not-allowed; }
input[type="text"], input[type="number"], select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.tab-content { display: none; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.active-tab { display: block; }

.split-view { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
@media(max-width: 900px) { .split-view { grid-template-columns: 1fr; } }

.class-section { border: 3px solid var(--black); padding: 15px; border-radius: 5px; background: #fff; }
.c1-border { border-color: var(--blue); }
.c2-border { border-color: var(--red); }
.class-title { font-size: 1.2em; font-weight: bold; margin-bottom: 15px; width: 100%; box-sizing: border-box; text-align: center; }

.team-edit-row { display: flex; gap: 5px; margin-bottom: 8px; }
.team-edit-row input { flex-grow: 1; }
.btn-remove { background-color: var(--red); }
.btn-warning { background-color: #e67e22; }
.btn-warning:hover { background-color: #d35400; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: center; }
th { background-color: var(--black); color: white; }
.medal-cell { font-weight: bold; font-size: 14px; min-width: 35px; }

.timer-controls {
    background: #eef;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    text-align: center;
    border: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
}
.timer-display { font-size: 1.5em; font-weight: bold; min-width: 120px; text-align: center; color: var(--black); font-family: monospace; }
.match-timer-btn { background-color: var(--blue); color: white; border: none; border-radius: 3px; font-size: 10px; padding: 3px 6px; cursor: pointer; margin-left: 5px; }
.match-timer-btn:hover { background-color: #002277; }

.award-status { font-size: 12px; margin-top: 8px; padding: 6px; border-radius: 4px; text-align: center; font-weight: bold; background: #eee; }
.status-awarded { background: #e8f8f5; color: #117a65; border: 1px solid #a3e4d7; }

.bracket-wrapper { position: relative; margin-top: 15px; }

.event-podium-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(4px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 25; transition: opacity 0.25s ease, visibility 0.25s ease;
    border-radius: 6px; box-shadow: 0 4px 15px rgba(0,0,0,0.12); pointer-events: auto;
}
.bracket-wrapper:hover .event-podium-overlay {
    opacity: 0 !important; visibility: hidden !important; pointer-events: none !important;
}

.podium-container { display: flex; align-items: flex-end; justify-content: center; gap: 10px; width: 100%; max-width: 380px; margin: 10px auto; min-height: 170px; }
.podium-step { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; text-align: center; }
.podium-team-title { font-size: 12px; font-weight: bold; color: #111; margin-bottom: 6px; word-break: break-word; padding: 3px 6px; background: #ffffff; border: 1px solid #ddd; border-radius: 4px; width: 90%; box-shadow: 0 2px 4px rgba(0,0,0,0.08); line-height: 1.2; }
.podium-team-sub { font-size: 10px; color: #666; font-weight: normal; display: block; }
.podium-block { width: 100%; border-radius: 6px 6px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; font-weight: 900; box-shadow: 0 4px 10px rgba(0,0,0,0.15); text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.step-gold .podium-block { height: 115px; background: linear-gradient(135deg, #ffd700 0%, #cca000 100%); font-size: 32px; }
.step-silver .podium-block { height: 80px; background: linear-gradient(135deg, #d5d8dc 0%, #95a5a6 100%); font-size: 26px; }
.step-bronze .podium-block { height: 55px; background: linear-gradient(135deg, #edbb99 0%, #cd7f32 100%); font-size: 22px; }
.podium-hover-hint { font-size: 11px; color: #666; font-style: italic; margin-top: 8px; background: #eee; padding: 3px 10px; border-radius: 12px; }

.bracket { display: flex; justify-content: space-between; margin-top: 5px; overflow-x: auto; gap: 5px; min-height: 200px; }
.round { display: flex; flex-direction: column; justify-content: space-around; min-width: 165px; flex: 1; }
.match { border: 2px solid #ccc; border-radius: 5px; margin: 5px 0; background: #fafafa; }
.team { padding: 6px; border-bottom: 1px solid #ccc; cursor: pointer; min-height: 26px; font-size: 12px; transition: background 0.2s; display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.team:last-child { border-bottom: none; }
.team:hover:not(.locked) { background-color: #e0e0e0; }
.team-name-text { flex-grow: 1; word-break: break-word; }
.locked { cursor: default; }

.match-time-input { width: 60px; padding: 2px 4px; font-size: 10px; font-family: monospace; font-weight: bold; text-align: center; border: 1px solid #bbb; border-radius: 3px; background: #fff; color: #111; margin-right: 3px; }
.match-time-input:focus { border-color: var(--blue); outline: none; background: #ffffe0; }

.dq-flag-btn { background: transparent; border: none; cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; opacity: 0.35; filter: grayscale(100%); transition: transform 0.15s, opacity 0.15s, filter 0.15s; }
.dq-flag-btn:hover { opacity: 1; filter: grayscale(0%); transform: scale(1.3); }
.dq-flag-btn.is-dq { opacity: 1; filter: grayscale(0%); transform: scale(1.15); }
.dq-active { background-color: #fbeae8 !important; border-color: #e74c3c !important; }
.dq-active .team-name-text { text-decoration: line-through !important; color: #c0392b !important; font-weight: bold !important; }
.dq-badge { background-color: var(--red); color: white; font-size: 9px; padding: 1px 4px; border-radius: 3px; font-weight: bold; margin-right: 5px; letter-spacing: 0.5px; text-decoration: none !important; display: inline-block; }

.lost-team .team-name-text { text-decoration: line-through !important; opacity: 0.45; color: #666; }
.winner { background-color: var(--green); color: white; font-weight: bold; }
.winner .team-name-text { color: white; }
.winner .match-time-input { background: #e8f8f5; border-color: #117a65; }

.medal-gold { background: linear-gradient(135deg, #fff3b0 0%, #ffd700 50%, #cca000 100%) !important; color: #4a3400 !important; font-weight: 900 !important; border-color: #cca000 !important; box-shadow: inset 0 0 6px rgba(255, 215, 0, 0.7); }
.medal-gold .team-name-text { color: #4a3400 !important; }
.medal-silver { background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 50%, #b8b8b8 100%) !important; color: #2b2b2b !important; font-weight: 900 !important; border-color: #a0a0a0 !important; box-shadow: inset 0 0 6px rgba(200, 200, 200, 0.7); }
.medal-silver .team-name-text { color: #2b2b2b !important; }
.medal-bronze { background: linear-gradient(135deg, #fce0cd 0%, #e8a87c 50%, #cd7f32 100%) !important; color: #3d1c02 !important; font-weight: 900 !important; border-color: #b87333 !important; box-shadow: inset 0 0 6px rgba(205, 127, 50, 0.7); }
.medal-bronze .team-name-text { color: #3d1c02 !important; }
.medal-badge-tag { font-size: 9px; font-weight: bold; padding: 1px 4px; border-radius: 3px; background: rgba(255, 255, 255, 0.85); margin-right: 4px; display: inline-block; text-decoration: none !important; }

.team select { width: 100%; box-sizing: border-box; padding: 3px; font-size: 11px; border: 1px solid var(--blue); border-radius: 3px; background: #fff; cursor: pointer; }
.relay-pair { display: flex; align-items: center; gap: 2px; width: 100%; }
.relay-pair select { width: 48%; font-size: 10px; padding: 2px; }
.relay-pair span { font-size: 10px; font-weight: bold; color: #555; }

@keyframes pulseSuspense { 0% { background-color: #fafafa; color: #888; } 50% { background-color: var(--yellow); color: black; font-weight: bold; } 100% { background-color: #fafafa; color: #888; } }
.suspense { animation: pulseSuspense 1.5s infinite; text-align: center; font-weight: bold; cursor: default; }
.match-title { font-size: 10px; text-align: center; background: #eee; border-bottom: 1px solid #ccc; padding: 4px 2px; min-height: 18px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; }

.controls { margin-bottom: 10px; display: flex; gap: 5px; flex-wrap: wrap; }
.points-action-bar { display: flex; gap: 8px; margin-top: 10px; }
.points-action-bar button { flex: 1; }
.points-btn { background-color: var(--green); }

.event-embed { max-width: 800px; margin: 0 auto 25px auto; text-align: center; font-size: 14px; }
.event-embed a { color: var(--blue); text-decoration: none; font-weight: 500; }
.event-embed a:hover { text-decoration: underline; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.88); z-index: 10000; display: none; align-items: center; justify-content: center; }
.modal-card { background: #fff; padding: 30px; border-radius: 12px; text-align: center; max-width: 520px; width: 92%; box-shadow: 0 10px 30px rgba(0,0,0,0.5); position: relative; overflow: hidden; }
.modal-event-title { font-size: 16px; color: #666; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.modal-matchup-names { font-size: 20px; font-weight: bold; margin-bottom: 15px; color: #222; }
.dramatic-display { min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 10px 0; }
.countdown-num { font-size: 90px; font-weight: 900; line-height: 1; animation: zoomPulse 0.8s ease-out; }
@keyframes zoomPulse { 0% { transform: scale(0.3); opacity: 0; } 50% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.cd-3 { color: var(--red); } .cd-2 { color: var(--yellow); } .cd-1 { color: var(--blue); } .cd-go { color: var(--green); font-size: 85px; }
.clock-active { font-size: 65px; font-weight: bold; font-family: monospace; color: var(--black); }
.flag-box { font-size: 55px; animation: waveFlag 0.6s infinite alternate; }
@keyframes waveFlag { 0% { transform: rotate(-10deg) scale(1); } 100% { transform: rotate(10deg) scale(1.15); } }
.fanfare-banner { background: linear-gradient(135deg, #ffb81c, #ff9900); color: #000; padding: 12px; border-radius: 8px; font-size: 20px; font-weight: 900; box-shadow: 0 4px 15px rgba(255, 184, 28, 0.4); margin: 10px 0; animation: fanfarePop 0.5s ease-out; }
@keyframes fanfarePop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.fanfare-sub { font-size: 13px; font-weight: normal; margin-top: 3px; color: #333; }
#confetti-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10001; }
.modal-btn-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }
.modal-winner-btn { padding: 14px; font-size: 16px; background-color: var(--green); border-radius: 6px; }
.modal-winner-btn:hover { background-color: #0e702e; }
.modal-winner-btn.auto-champion { background: linear-gradient(135deg, #009639, #00702a); border: 2px solid var(--yellow); box-shadow: 0 0 10px rgba(0, 150, 57, 0.5); font-weight: 900; }
.btn-stop-team { background-color: var(--red); font-size: 14px; padding: 12px 10px; border-radius: 6px; flex: 1; min-width: 140px; word-break: break-word; }
.btn-stop-team:hover { background-color: #a91228; }
.btn-team-stopped { background-color: var(--green) !important; color: white !important; cursor: default; }
.btn-early-stop { background-color: #e67e22; font-size: 13px; padding: 8px 16px; border-radius: 5px; }
.btn-early-stop:hover { background-color: #d35400; }

.admin-only { display: none !important; }
body.is-admin .admin-only { display: flex !important; }
body.is-admin button.admin-only { display: inline-block !important; }
