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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 100%;
    padding: 30px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
}

.nav-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.nav-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: #f0f0f0;
    color: #666;
}

.nav-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

.card-display {
    background: white;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s;
}

.card-display:hover {
    transform: translateY(-5px);
}

.position-number {
    font-size: 48px;
    font-weight: bold;
    color: #667eea;
}

.acaan-question {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.acaan-card {
    font-size: 36px;
    font-weight: bold;
}

.acaan-number {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.card-name {
    font-size: 48px;
    font-weight: bold;
}

.red { color: #e74c3c; }
.black { color: #2c3e50; }

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.control-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #667eea;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.control-btn:hover {
    background: #764ba2;
}

.settings {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

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

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

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

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

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

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(30px);
}

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

.input-btn {
    padding: 15px;
    border: 2px solid #667eea;
    border-radius: 10px;
    background: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
}

.input-btn:hover {
    background: #667eea;
    color: white;
}

.input-btn.selected {
    background: #667eea;
    color: white;
}

.timer {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 20px;
}

.stats-container {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #dee2e6;
}

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

.stat-label {
    font-weight: 600;
    color: #495057;
}

.stat-value {
    color: #667eea;
    font-weight: bold;
}

.progress-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 10px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

.feedback {
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 600;
    display: none;
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    display: block;
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

/* Selection Mode Styles */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.selection-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.selection-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.selection-card.selected {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    color: #333;
    border-color: #667eea;
}

.selection-card .card-pos {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 2px;
    opacity: 0.7;
}

.selection-card .card-value {
    font-size: 18px;
    font-weight: bold;
}

.selection-card.selected .card-pos {
    opacity: 1;
}

.selection-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.selection-info {
    background: #e3f2fd;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 500;
    color: #1565c0;
}

/* Practice Mode Styles */
.practice-select {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: border-color 0.3s;
}

.practice-select:focus {
    outline: none;
    border-color: #667eea;
}

.practice-start {
    text-align: center;
    padding: 40px 20px;
}

.start-info h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 24px;
}

.start-info p {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
}

.start-btn {
    font-size: 18px;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.number-text-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-size: 18px;
    text-align: center;
    background: white;
    transition: border-color 0.3s;
}

.number-text-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Score Summary Modal */
.score-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.score-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.score-header {
    text-align: center;
    margin-bottom: 25px;
}

.score-header h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 24px;
}

.score-stats {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
}

.score-main {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
}

.score-time {
    font-size: 16px;
    color: #666;
}

.incorrect-section {
    margin: 25px 0;
}

.incorrect-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.incorrect-list {
    max-height: 300px;
    overflow-y: auto;
}

.incorrect-item {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.incorrect-question {
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.incorrect-details {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.user-answer {
    color: #e53e3e;
    font-weight: 500;
}

.correct-answer {
    color: #38a169;
    font-weight: 500;
}

.score-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 25px;
}

.perfect-score {
    color: #38a169;
}

/* Timing Analysis */
.timing-section {
    margin: 25px 0;
}

.timing-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.slowest-list {
    max-height: 200px;
    overflow-y: auto;
}

.slowest-item {
    background: #fff8dc;
    border: 1px solid #f0e68c;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slowest-card {
    font-weight: bold;
    color: #333;
}

.slowest-time {
    color: #b8860b;
    font-weight: 500;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }

    .header h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .nav-buttons {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 20px;
        justify-content: center;
    }

    .nav-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 120px;
        padding: 10px 8px;
        font-size: 14px;
        text-align: center;
    }

    .card-display {
        padding: 20px;
        min-height: 150px;
        margin-bottom: 15px;
    }

    .position-number {
        font-size: 48px;
    }

    .card-name {
        font-size: 36px;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
    }

    .control-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }

    .settings {
        padding: 15px;
    }

    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .selection-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .selection-card {
        min-height: 50px;
        padding: 6px;
    }

    .selection-card .card-value {
        font-size: 14px;
    }

    .selection-card .card-pos {
        font-size: 10px;
    }

    .input-grid {
        gap: 8px;
    }

    .input-btn {
        padding: 12px 8px;
        font-size: 28px;
        font-weight: bold;
        min-height: 56px;
        min-width: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        aspect-ratio: 1;
    }

    .number-text-input {
        padding: 12px;
        font-size: 16px;
    }

    .score-content {
        padding: 20px;
        margin: 10px;
    }

    .score-header h2 {
        font-size: 20px;
    }

    .score-main {
        font-size: 24px;
    }

    .score-actions {
        flex-direction: column;
        gap: 10px;
    }

    .score-actions .control-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .nav-buttons {
        gap: 6px;
    }

    .nav-btn {
        flex: 1 1 calc(50% - 3px);
        min-width: 100px;
        padding: 8px 6px;
        font-size: 13px;
    }

    .card-display {
        padding: 15px;
        min-height: 120px;
    }

    .position-number {
        font-size: 36px;
    }

    .card-name {
        font-size: 28px;
    }

    .selection-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .selection-card {
        min-height: 45px;
        padding: 4px;
    }

    .selection-card .card-value {
        font-size: 12px;
    }

    .input-grid {
        gap: 6px;
    }

    .input-btn {
        padding: 10px 6px;
        font-size: 28px;
        font-weight: bold;
        min-height: 52px;
        min-width: 52px;
        display: flex;
        align-items: center;
        justify-content: center;
        aspect-ratio: 1;
    }
}
