:root {
    --primary-color: #1A535C;
    --secondary-color: #4ECDC4;
    --background-color: #F7FFF7;
    --accent-color: #FF6B6B;
    --warning-color: #FFE66D;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --paper-texture: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23f0f0f0' fill-opacity='0.1'%3E%3Ccircle cx='7' cy='7' r='1'/%3E%3Ccircle cx='27' cy='27' r='1'/%3E%3Ccircle cx='47' cy='47' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

[data-theme="dark"] {
    --background-color: #2c2c2c;
    --text-color: #f0f0f0;
    --border-color: #555;
    --paper-texture: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23404040' fill-opacity='0.1'%3E%3Ccircle cx='7' cy='7' r='1'/%3E%3Ccircle cx='27' cy='27' r='1'/%3E%3Ccircle cx='47' cy='47' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background-color);
    background-image: var(--paper-texture);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: 80px;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.section.active {
    display: block;
}

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

.welcome-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    text-align: center;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.welcome-card h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.welcome-card p {
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.quick-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-width: 120px;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

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

.btn-success {
    background: #28a745;
    color: white;
}

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

.btn-danger {
    background: var(--accent-color);
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.recent-matches {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.recent-matches h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.match-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--background-color);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.match-item:last-child {
    margin-bottom: 0;
}

.match-info-item {
    flex: 1;
}

.match-info-item h4 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.match-info-item p {
    color: #666;
    font-size: 0.9rem;
}

.match-score {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--accent-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.match-setup {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.match-setup h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-align: center;
}

.custom-rules {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: 10px;
    border: 2px dashed var(--secondary-color);
    margin-top: 1rem;
}

.custom-rules h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.match-active {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.match-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.scoreboard {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: center;
    margin-bottom: 2rem;
    text-align: center;
}

.player-score h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.score {
    font-size: 4rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.score-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.score-controls .btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    min-width: auto;
}

.vs-divider {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.match-info {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.match-info p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.match-info p:last-child {
    margin-bottom: 0;
}

.match-actions {
    text-align: center;
}

.history-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.history-filters select {
    flex: 1;
    min-width: 200px;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: white;
}

.history-list {
    display: grid;
    gap: 1rem;
}

.history-item {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-item-header h4 {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.history-item-date {
    color: #666;
    font-size: 0.9rem;
}

.history-item-score {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.history-item-details {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.tournament-form {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.tournament-form h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.tournament-item {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tournament-header h3 {
    color: var(--primary-color);
    font-size: 1.4rem;
}

.tournament-status {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.tournament-status.active {
    background: var(--secondary-color);
    color: white;
}

.tournament-status.completed {
    background: var(--accent-color);
    color: white;
}

.tournament-bracket {
    margin-top: 1.5rem;
}

.bracket-round {
    margin-bottom: 2rem;
}

.bracket-round h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.2rem;
}

.bracket-matches {
    display: grid;
    gap: 1rem;
}

.bracket-match {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid var(--border-color);
}

.bracket-match.completed {
    border-color: var(--secondary-color);
}

.bracket-match-players {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.bracket-match-player {
    font-weight: 600;
}

.bracket-match-player.winner {
    color: var(--secondary-color);
}

.bracket-match-score {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-color);
}

.settings-group {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.settings-group h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
}

.setting-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.faq-section {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin: 2rem 0;
    border: 1px solid var(--border-color);
}

.faq-section h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.faq-container {
    display: grid;
    gap: 1rem;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 1rem;
    background: var(--background-color);
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.faq-question:hover {
    background: var(--secondary-color);
    color: white;
}

.faq-question[aria-expanded="true"] {
    background: var(--secondary-color);
    color: white;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-icon {
    font-size: 1.2rem;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.faq-answer {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
}

.faq-answer[hidden] {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 1rem;
    }
    to {
        opacity: 1;
        max-height: 200px;
        padding: 1rem;
    }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    transition: color 0.3s ease;
    padding: 0.5rem;
    border-radius: 10px;
    min-width: 60px;
}

.nav-item:hover {
    color: var(--secondary-color);
    background: rgba(78, 205, 196, 0.1);
}

.nav-item.active {
    color: var(--secondary-color);
    background: rgba(78, 205, 196, 0.1);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.8rem;
    font-weight: 600;
}

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #666;
    font-size: 0.9rem;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.winner-announcement {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    margin: 2rem 0;
    box-shadow: var(--shadow);
    animation: celebration 0.6s ease-in-out;
}

@keyframes celebration {
    0% { transform: scale(0.9); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.winner-announcement h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.winner-announcement p {
    font-size: 1.2rem;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .scoreboard {
        grid-template-columns: 1fr auto 1fr;
        gap: 1rem;
    }
    
    .score {
        font-size: 3rem;
    }
    
    .vs-divider {
        font-size: 1.5rem;
    }
    
    .quick-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .history-filters {
        flex-direction: column;
    }
    
    .history-filters select {
        min-width: auto;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .match-header {
        flex-direction: column;
        text-align: center;
    }
    
    .tournament-header {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0.5rem;
    }
    
    .welcome-card,
    .match-setup,
    .match-active,
    .settings-group,
    .tournament-form,
    .tournament-item,
    .faq-section {
        padding: 1rem;
    }
    
    .score {
        font-size: 2.5rem;
    }
    
    .scoreboard {
        gap: 0.5rem;
    }
    
    .score-controls .btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

.pulse {
    animation: pulse 0.3s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
