:root {
    --primary: #2563eb;
    --success: #059669;
    --error: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --border: #cbd5e1;
    --hi-5: #e0f2fe;
    --curr-rd-bg: #fff7ed;
    --pickup-border: #1e3a8a;
    --used-type: #fef3c7;
    --used-border: #d97706;
    --version: "0.1.27";
}

body {
    font-family: system-ui, sans-serif;
    margin: 0;
    background: var(--bg);
    color: #0f172a;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* SETUP */
#setup-screen {
    padding: 20px;
    overflow-y: auto;
    height: 100vh;
    box-sizing: border-box;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.setup-card {
    background: white;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.setup-card input {
    width: 90%;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    color: inherit;
}

.setup-card input.hidden-input {
    display: none;
}

.editable-team {
    border: none;
    border-bottom: 2px solid var(--primary);
    font-size: 1.2rem;
    font-weight: bold;
    width: 100%;
    margin-bottom: 10px;
    background: transparent;
    color: inherit;
}

#setup-screen h2 {
    margin-top: 0;
}

.mode-select-container {
    display: flex;
    background: #e2e8f0;
    border-radius: 99px;
    padding: 4px;
    width: fit-content;
    margin: 15px auto;
}

.mode-select-container input {
    display: none;
}

.mode-select-container label {
    padding: 10px 24px;
    cursor: pointer;
    border-radius: 99px;
    font-weight: bold;
    color: #64748b;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-select-container input:checked + label {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#setup-screen .setup-start-match-btn {
    background: var(--primary);
    width: 100%;
    padding: 16px;
    color: white;
    font-weight: bold;
}

#setup-screen .setup-load-match-container {
    text-align: center;
    margin-top: 20px;
}

#setup-screen .load-match-label {
    background: #64748b;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
}

#version-display {
    position: fixed;
    bottom: 10px;
    right: 10px;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: bold;
    pointer-events: none;
}

#game-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* SETTINGS */
.settings-gear {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

#settings-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.settings-header {
    background: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.settings-header h2 {
    margin: 0;
}

.close-settings-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
}

.settings-content {
    overflow-y: auto;
    padding: 20px;
    flex-grow: 1;
}

.settings-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 5px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

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

/* WIDGETS */
.inc-dec-widget {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inc-dec-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #f1f5f9;
    font-weight: bold;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inc-dec-val {
    font-weight: bold;
    width: 20px;
    text-align: center;
}

/* TOGGLE SWITCH */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* GRID */
.stats-view {
    display: grid;
    grid-template-columns: 85px 1fr 80px;
    height: 50%;
    background: white;
    border-bottom: 2px solid var(--border);
    font-size: 0.6rem;
}

.names-col, .totals-col {
    overflow: hidden;
}

.rounds-viewport {
    overflow-x: auto;
    scroll-behavior: smooth;
}

table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
}

td {
    border: 1px solid var(--border);
    height: 20px;
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
}

.col-round {
    width: 35px;
    min-width: 35px;
}

.header-row {
    background: #1e293b;
    color: white;
    font-weight: bold;
}

.t-a-row {
    background: #fff1f2;
}

.t-b-row {
    background: #f0f9ff;
}

.bench-row {
    opacity: 0.35;
    background: #f8fafc;
}

.sum-row {
    background: #e2e8f0;
    font-weight: bold;
}

.type-row {
    background: #f1f5f9;
    font-weight: bold;
    color: var(--primary);
}

.hi-5 {
    background: var(--hi-5) !important;
    color: inherit;
}

.curr-rd-col {
    background: var(--curr-rd-bg) !important;
}

.active-round-head {
    background: var(--warning) !important;
    color: white;
}

/* CORRECTION HIGHLIGHTS */
.stats-view.in-correction td:not(.correcting-col) {
    opacity: 0.1;
    cursor: pointer;
}

.correcting-col {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    opacity: 1 !important;
}

.danger-cell {
    outline: 2px solid var(--error);
    outline-offset: -2px;
    font-weight: bold;
    color: var(--error);
}

.success-cell {
    outline: 2px solid var(--success);
    outline-offset: -2px;
    font-weight: bold;
    color: var(--success);
}

@keyframes dual-danger {
    0%, 49% {
        outline-color: var(--error);
        color: var(--error);
    }
    50%, 100% {
        outline-color: var(--success);
        color: var(--success);
    }
}

.dual-danger-cell {
    outline: 2px solid var(--error);
    outline-offset: -2px;
    font-weight: bold;
    animation: dual-danger 2s infinite;
}

.pickup-cell {
    outline: 2px solid var(--pickup-border);
    outline-offset: -2px;
}

.round-btn {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* ACTION ZONE */
.action-zone {
    flex-grow: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#in-game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.top-ctrls {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
}

.type-btns {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.btn-tiny {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    color: inherit;
    font-size: 0.9rem;
    font-weight: bold;
}

.btn-tiny.active {
    background: #1e3a8a !important;
    color: white !important;
    border-color: #1e3a8a !important;
}

.btn-tiny.used {
    background: var(--used-type);
    border-color: var(--used-border);
    color: var(--used-border);
}

.btn-tiny.maxed {
    background: #6b7280 !important;
    border-color: #9ca3af !important;
    color: #ffffff !important;
}

#round-label {
    display: none;
}

#bench-ui {
    border: 2px dashed var(--warning);
    padding: 8px;
    border-radius: 8px;
    background: #fff;
}

#bench-ui .bench-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#end-game-btns-ui {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    justify-content: center;
}

.split-layout {
    flex: 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.buzzer-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.buzzer {
    flex: 1;
    display: block;
    padding: 12px 5px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    font-weight: bold;
    text-align: center;
    font-size: 0.85rem;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.buzzer.team-a-buzzer {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #881337;
}

.buzzer.team-b-buzzer {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0c4a6e;
}

.buzzer.active-sel {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.buzzer.pickup-sel {
    border-color: var(--success);
    background: #dcfce7;
    animation: pulse 1s infinite;
}

.buzzer.is-disabled {
    color: #f87171;
    text-decoration: line-through;
    opacity: 0.5;
}

.btn-primary-bg {
    background: var(--primary);
}

.btn-success-bg {
    background: var(--success);
}

.btn-error-bg {
    background: var(--error);
}

.btn-neutral-bg {
    background: #555555;
}

.btn-act {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: none;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}

/* Utility buttons (Sub, Save, Toggle) */
.util-btn {
    background: #555555;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.75rem;
    cursor: pointer;
}

#action-buttons-container {
    display: flex;
    gap: 8px;
    flex: 0 0 50px;
}

/* NOTIFICATIONS */
#notification-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    max-width: 80%;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    border: 2px solid var(--primary);
    color: inherit;
}

#notification-message {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: #1e293b;
}

.notification-content button {
    width: 100px;
    padding: 10px;
    display: inline-flex;
}
