:root {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --surface-light: #2C2C2C;
    --text-primary: #FFFFFF;
    --text-secondary: #AAAAAA;

    --team-a-color-def: #E63946;
    --team-b-color-def: #457B9D;

    --primary-color: #4CC9F0;
    --success-color: #2ECC71;
    --danger-color: #E74C3C;
    --warning-color: #F1C40F;

    --font-heading: 'Chakra Petch', sans-serif;
    --font-body: 'Inter', sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    /* App feel */
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow-y: auto;
}

/* View System */
.view {
    display: none;
    min-height: 100%;
    background: var(--bg-color);
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility */
.hidden {
    display: none !important;
}

.card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

button {
    cursor: pointer;
    border: none;
    font-family: var(--font-heading);
    transition: all 0.2s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: #000;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    text-decoration: underline;
    font-size: 0.9rem;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

/* Setup View */
.setup-container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.app-header {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--primary-color);
    letter-spacing: 2px;
}

.teams-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.team-config {
    border-top: 4px solid var(--team-accent);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px;
    background: var(--surface-light);
    border: 1px solid #444;
    border-radius: 6px;
    color: white;
    font-size: 1rem;
}

.form-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    background: none;
}

.player-inputs input {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    background: var(--surface-light);
    border: 1px solid #333;
    border-radius: 4px;
    color: #ddd;
    font-size: 0.9rem;
}

.actions {
    text-align: center;
    margin-top: 20px;
    padding-bottom: 40px;
}

.large {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
}

/* Match View */
#view-match {
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.match-header {
    background: var(--surface-color);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.team-score {
    text-align: center;
    font-family: var(--font-heading);
}

.team-score .score {
    font-size: 2.5rem;
    font-weight: 700;
    display: block;
    line-height: 1;
}

.team-score .team-name {
    font-size: 0.8rem;
    opacity: 0.8;
}

.timer-display {
    text-align: center;
}

.main-time {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stoppage-time {
    color: var(--warning-color);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
}

.timer-controls {
    margin-top: 5px;
}

.btn-icon {
    background: var(--surface-light);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    margin: 0 5px;
}

.match-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.possession-area {
    flex: 2;
    display: flex;
    width: 100%;
}

.btn-possession {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    border: 4px solid transparent;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.btn-possession.active {
    opacity: 1;
    color: white;
    flex: 1.2;
    /* Grow slightly */
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.btn-possession .label {
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.btn-possession .team-name-display {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.btn-possession .possession-stat {
    font-size: 1rem;
    font-family: var(--font-heading);
}

.goal-area {
    flex: 1;
    background: #000;
    display: flex;
    align-items: stretch;
    padding: 10px;
    gap: 10px;
}

.btn-goal {
    flex: 1;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 900;
    background: var(--surface-light);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.match-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 10px;
    gap: 10px;
}

.large-act {
    padding: 20px 10px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #000;
    border-radius: var(--radius-sm);
    min-width: 120px;
}

.btn-warning {
    background: var(--warning-color);
}

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

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    text-align: center;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.btn-player-select {
    background: var(--surface-light);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    border: 2px solid transparent;
}

.btn-player-select .num {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.btn-player-select .p-name {
    font-size: 0.6rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 5px;
}

/* Stats View & Exports */
.stats-container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.final-score-card {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.big-score {
    font-size: 3rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.vs-divider {
    margin: 0 30px;
    font-weight: 700;
    opacity: 0.5;
}

.progress-comp {
    margin-top: 10px;
}

.progress-bar-container {
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
}

.p-bar {
    height: 100%;
    transition: width 0.5s ease;
}

.stat-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-top: 5px;
    color: var(--text-secondary);
}

.timeline {
    border-left: 2px solid #333;
    padding-left: 20px;
    margin: 20px 0;
}

.timeline-item {
    margin-bottom: 15px;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .teams-grid {
        grid-template-columns: 1fr;
    }

    .main-time {
        font-size: 2.2rem;
    }

    .possession-area {
        flex-direction: row;
    }

    .btn-possession .team-name-display {
        font-size: 1rem;
    }

    #view-match {
        /* Prevent scroll on match screen */
        overflow: hidden;
    }
}