/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
    --transition: all 0.2s ease-in-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text-primary);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="number"].error {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Games Section */
.games-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.game-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.game-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* Players Section */
.players-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.player-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.player-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* Score Input Section */
.score-inputs {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.round-info {
    margin-bottom: 8px;
}

.round-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

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

.score-input-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

.score-input {
    width: 100%;
}

.score-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

#submitScoresBtn {
    flex: 1;
    min-width: 150px;
}

#newRoundBtn {
    flex: 1;
    min-width: 150px;
}

/* History Section */
.history-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.history-controls select {
    flex: 1;
    min-width: 150px;
}

.score-history {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 600px;
    overflow-y: auto;
}

.round-card {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 16px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.round-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.round-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.round-header > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.round-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.round-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.round-number {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
}

.round-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.delete-game-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.delete-game-btn:hover {
    transform: scale(1.1);
}

.round-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--card-bg);
    border-radius: calc(var(--border-radius) / 2);
}

.rank {
    font-weight: 700;
    color: var(--text-primary);
    min-width: 40px;
}

.score-entry .player-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}

.score-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 60px;
    text-align: right;
}

/* Empty Message */
.empty-message {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px;
}

/* Scrollbar Styling */
.score-history::-webkit-scrollbar {
    width: 8px;
}

.score-history::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.score-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.score-history::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .history-controls {
        flex-direction: column;
    }

    .history-controls select,
    .history-controls button {
        width: 100%;
    }

    .round-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    section {
        padding: 16px;
    }

    header h1 {
        font-size: 1.75rem;
    }
}

