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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    transition: background-color 0.3s ease;
}

/* Day Theme (Default) */
body.day-theme {
    background-color: #F5F5F5;
    color: #2C3E50;
}

body.day-theme #title {
    color: #2C3E50;
}

body.day-theme .score-panel {
    background-color: #FFFFFF;
    border-color: #D0D0D0;
}

body.day-theme .settings-btn {
    background-color: #D0D0D0;
    color: #2C3E50;
}

body.day-theme .settings-btn:active {
    background-color: #B0B0B0;
}

body.day-theme .modal-content {
    background-color: #FFFFFF;
    border-color: #BDC3C7;
}

body.day-theme .separator {
    background-color: #BDC3C7;
}

body.day-theme .team-name,
body.day-theme .total-label {
    color: #2C3E50;
}

body.day-theme .round-num,
body.day-theme .progress-text {
    color: #7F8C8D;
}

body.day-theme .score-value {
    color: #34495E;
}

body.day-theme .leader-score {
    color: #27AE60 !important;
}

/* Night Theme */
body.night-theme {
    background-color: #313131;
    color: #E0E0E0;
}

body.night-theme #title {
    color: #E0E0E0;
}

body.night-theme .score-panel {
    background-color: #2C2C2C;
    border-color: #555555;
}

body.night-theme .settings-btn {
    background-color: #555555;
    color: #E0E0E0;
}

body.night-theme .settings-btn:active {
    background-color: #666666;
}

body.night-theme .modal-content {
    background-color: #2C2C2C;
    border-color: #555555;
    color: #E0E0E0;
}

body.night-theme .separator {
    background-color: #555555;
}

body.night-theme .team-name,
body.night-theme .total-label {
    color: #E0E0E0;
}

body.night-theme .round-num,
body.night-theme .progress-text {
    color: #B0B0B0;
}

body.night-theme .score-value {
    color: #CCCCCC;
}

body.night-theme .leader-score {
    color: #4ADE80 !important;
}

body.night-theme input,
body.night-theme select {
    background-color: #3C3C3C;
    color: #E0E0E0;
    border-color: #555555;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

#title {
    font-size: 28px;
    font-weight: bold;
    flex: 1;
    text-align: center;
}

.settings-btn {
    font-size: 24px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.score-panel {
    flex: 1;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid;
    overflow-y: auto;
}

.score-header {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.score-header-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
    font-weight: bold;
}

.add-score-btn {
    width: 32px;
    height: 32px;
    background-color: #27AE60;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.add-score-btn:active {
    background-color: #229954;
}

.separator {
    height: 2px;
    margin: 15px 0;
}

.round-row {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
    text-align: center;
    align-items: center;
}

.round-num {
    font-size: 15px;
}

.score-value {
    font-size: 15px;
}

.total-row {
    display: grid;
    gap: 10px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    align-items: center;
}

.progress-text {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    border-radius: 10px;
    padding: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid;
    animation: slideUp 0.3s ease;
    position: relative;
}

.modal-small {
    max-width: 300px;
}

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

.modal-content h2 {
    font-size: 22px;
    margin-bottom: 20px;
    text-align: center;
}

.modal-content h3 {
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 15px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    padding: 10px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    width: 100%;
}

#teamNamesContainer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#teamNamesContainer input {
    padding: 10px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.score-input-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.score-input-form label {
    font-size: 16px;
}

.score-input-form input {
    padding: 10px;
    font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.btn {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-apply {
    background-color: #27AE60;
    color: white;
}

.btn-apply:active {
    background-color: #229954;
}

.btn-secondary {
    background-color: #95A5A6;
    color: white;
}

.btn-secondary:active {
    background-color: #7F8C8D;
}

/* Modal Close Button */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background-color: #E74C3C;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 10;
}

.modal-close-btn:active {
    background-color: #C0392B;
}

/* Numpad Styles */
.score-display {
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    padding: 15px;
    border: 2px solid #27AE60;
    border-radius: 8px;
    margin-bottom: 15px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.day-theme .score-display {
    background-color: #F8F9FA;
    color: #2C3E50;
}

body.night-theme .score-display {
    background-color: #3C3C3C;
    color: #E0E0E0;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.numpad-btn {
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    background-color: #95A5A6;
    color: white;
}

body.day-theme .numpad-btn {
    background-color: #BDC3C7;
    color: #2C3E50;
}

body.night-theme .numpad-btn {
    background-color: #4A5568;
    color: #E0E0E0;
}

.numpad-btn:active {
    transform: scale(0.95);
}

body.day-theme .numpad-btn:active {
    background-color: #95A5A6;
}

body.night-theme .numpad-btn:active {
    background-color: #5A6578;
}

.numpad-clear {
    background-color: #E74C3C !important;
    color: white !important;
}

.numpad-clear:active {
    background-color: #C0392B !important;
}

.numpad-ok {
    background-color: #27AE60 !important;
    color: white !important;
}

.numpad-ok:active {
    background-color: #229954 !important;
}

/* Responsive Design */
@media (max-width: 600px) {
    #app {
        padding: 15px;
    }

    #title {
        font-size: 22px;
    }

    .settings-btn {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .score-header-cell {
        font-size: 14px;
    }

    .add-score-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .modal-content {
        width: 95%;
        padding: 15px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Prevent selection and zoom on double-tap */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* iOS Safari specific styles */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}
