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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* ホーム画面専用のコンテナ */
#home-screen .container {
    max-width: 700px;
}

/* 章別ドリル選択画面のコンテナ */
#drill-select-screen .container {
    max-width: 700px;
}

/* 復習リスト画面のコンテナ */
#review-list-screen .container {
    max-width: 900px;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 40px 20px;
}

.screen.active {
    display: block;
}

h1 {
    text-align: center;
    color: white;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
}

h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.subtitle {
    text-align: center;
    color: white;
    font-size: 1.1em;
    margin-bottom: 30px;
    opacity: 0.9;
}

.card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 30px;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.btn {
    padding: 18px 30px;
    font-size: 1.15em;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    width: 100%;
    text-align: center;
}

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

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

.btn-exam {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    font-size: 1.2em;
    padding: 20px 30px;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-secondary:hover {
    background: #f5f5ff;
    border-color: #667eea;
}

.btn-back {
    background: #e0e0e0;
    color: #666;
}

.btn-back:hover {
    background: #d0d0d0;
}

.btn-warning {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #c92a2a 100%);
    color: white;
}

.btn-flag {
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 100%);
    color: white;
}

.admin-link {
    text-align: center;
    margin-top: 40px;
}

.admin-link a {
    color: white;
    text-decoration: none;
    font-size: 0.95em;
    opacity: 0.8;
    transition: all 0.3s;
    padding: 8px 16px;
    border-radius: 5px;
}

.admin-link a:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Question count badge */
.question-count-badge {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 15px 20px;
    margin: 20px auto;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.count-label {
    font-size: 1em;
    color: #666;
    margin-right: 10px;
}

.count-number {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

/* Legend card */
.legend-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 20px;
    margin: 20px auto;
    max-width: 500px;
}

.legend-list {
    list-style: none;
    padding: 0;
}

.legend-list li {
    display: flex;
    align-items: center;
    margin: 10px 0;
    font-size: 1em;
}

.dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 15px;
    display: inline-block;
}

.dot.gray { background-color: #ccc; }
.dot.orange { background-color: #ff9800; }
.dot.green { background-color: #4caf50; }
.dot.red { background-color: #f44336; }

/* Exam screen */
.exam-header {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.timer {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

.question-counter {
    font-size: 1.1em;
    color: #666;
}

.exam-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    padding: 30px;
}

.question-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.question-status {
    font-size: 0.9em;
    color: #999;
    margin-bottom: 15px;
}

.question-text {
    font-size: 1.3em;
    line-height: 1.8;
    margin-bottom: 30px;
    color: #333;
    font-weight: 500;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.choice {
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.choice:hover {
    border-color: #667eea;
    background: #f5f5ff;
}

.choice.selected {
    border-color: #667eea;
    background: #e8ebff;
    font-weight: 600;
}

.navigation-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    max-height: 80vh;
    overflow-y: auto;
    position: sticky;
    top: 100px;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.question-link {
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.question-link.unanswered {
    background-color: #e0e0e0;
    color: #666;
}

.question-link.later {
    background-color: #ff9800;
    color: white;
}

.question-link.answered {
    background-color: #4caf50;
    color: white;
}

.question-link.flagged {
    background-color: #f44336;
    color: white;
}

.question-link.current {
    box-shadow: 0 0 0 3px #667eea;
}

/* Result screen */
.result-summary {
    background: white;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.result-summary h2 {
    color: #333;
    margin-bottom: 20px;
}

.result-details {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.result-item {
    border-bottom: 1px solid #e0e0e0;
    padding: 20px 0;
}

.result-item:last-child {
    border-bottom: none;
}

/* Review list */
.review-stats {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.review-filters {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.review-items {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.review-item {
    border-bottom: 1px solid #e0e0e0;
    padding: 15px 0;
}

.review-item:last-child {
    border-bottom: none;
}

.badge {
    background: #f44336;
    color: white;
    border-radius: 50%;
    padding: 3px 9px;
    font-size: 0.75em;
    font-weight: bold;
    margin-left: 8px;
    display: inline-block;
    min-width: 22px;
    text-align: center;
    vertical-align: middle;
    line-height: 1.4;
}

/* Overlay */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Responsive */
@media (max-width: 768px) {
    #home-screen .container,
    #drill-select-screen .container,
    #review-list-screen .container {
        max-width: 100%;
        padding: 20px;
    }
    
    .exam-container {
        grid-template-columns: 1fr;
    }
    
    .navigation-panel {
        position: static;
        max-height: none;
    }
    
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .container {
        padding: 15px;
    }
    
    .button-group {
        gap: 12px;
        margin: 20px 0;
    }
    
    .btn {
        padding: 16px 20px;
        font-size: 1em;
    }
    
    .btn-exam {
        font-size: 1.1em;
        padding: 18px 20px;
    }
    
    .legend-card {
        padding: 15px;
    }
    
    .question-count-badge {
        padding: 12px 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }
    
    .subtitle {
        font-size: 0.95em;
    }
    
    .btn {
        padding: 14px 20px;
        font-size: 0.95em;
    }
    
    .btn-exam {
        font-size: 1em;
        padding: 16px 20px;
    }
    
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }
    
    .legend-list li {
        font-size: 0.9em;
    }
}