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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --card-background: #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);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

main {
    flex: 1;
}

.card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.setting-group {
    margin-bottom: 20px;
}

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

label {
    font-weight: 500;
    color: var(--text-primary);
}

.reset-btn {
    padding: 4px 8px;
    font-size: 1rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-btn:hover:not(:disabled) {
    background: var(--secondary-hover);
}

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

input[type="range"] {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

.notice {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9rem;
    color: #92400e;
}

#challengeSelector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.challenge-btn {
    flex: 1;
    padding: 10px 20px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.challenge-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

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

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

input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.challenge-text {
    font-size: 1.2rem;
    line-height: 1.8;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.challenge-text ruby {
    font-size: 1.4rem;
}

.challenge-text rt {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

#controls {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.primary-btn, .secondary-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-lg);
}

.primary-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

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

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

.btn-icon {
    font-size: 1.2rem;
}

#waveform {
    width: 100%;
    height: 150px;
    background: var(--text-primary);
    border-radius: 8px;
}

#timer {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-top: 20px;
    color: var(--primary-color);
}

.result-item {
    margin-bottom: 16px;
}

.result-label {
    font-weight: 600;
    color: var(--text-secondary);
    display: inline-block;
    margin-bottom: 4px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-value.score {
    color: var(--success-color);
    font-size: 2rem;
}

.recognized-text {
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    margin-top: 8px;
    min-height: 60px;
}

#recordingPlayer {
    width: 100%;
    margin-bottom: 20px;
}

.recording-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#customChallengeForm {
    margin-top: 20px;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.custom-form-group {
    margin-bottom: 15px;
}

.custom-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9rem;
}

.custom-form-group input,
.custom-form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.custom-form-group input:focus,
.custom-form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

#setCustomBtn {
    margin-top: 10px;
}

#shareCustomUrl {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.share-url-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#customShareUrl {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--background);
    color: var(--text-primary);
}

#copyCustomUrlBtn {
    flex-shrink: 0;
}

#shareCustomUrl small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.score-details {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.score-breakdown {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.score-evaluation {
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
}

.score-evaluation.excellent {
    background: #dcfce7;
    color: #166534;
}

.score-evaluation.good {
    background: #dbeafe;
    color: #1e40af;
}

.score-evaluation.normal {
    background: #fef3c7;
    color: #92400e;
}

.score-evaluation.poor {
    background: #fee2e2;
    color: #991b1b;
}

footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

footer small {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

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

.modal-content {
    background: var(--card-background);
    padding: 32px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content p {
    margin-bottom: 24px;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    h1 {
        font-size: 2rem;
    }
    
    .challenge-btn {
        font-size: 0.9rem;
        padding: 8px 16px;
    }
    
    #controls {
        flex-direction: column;
    }
    
    .primary-btn, .secondary-btn {
        width: 100%;
        justify-content: center;
    }
}