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

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #252542;
    --accent-primary: #00d9ff;
    --accent-secondary: #7b2cbf;
    --accent-gradient: linear-gradient(135deg, #00d9ff 0%, #7b2cbf 100%);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --correct-color: #00ff88;
    --wrong-color: #ff4466;
    --shadow-glow: 0 0 30px rgba(0, 217, 255, 0.3);
}

html {
    font-size: 16px;
}

@media (min-width: 768px) {
    html {
        font-size: 24px;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    overflow-y: auto;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(123, 44, 191, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 217, 255, 0.1) 0%, transparent 50%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 217, 255, 0.03) 2px,
            rgba(0, 217, 255, 0.03) 4px
        );
    pointer-events: none;
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.screen {
    animation: fadeIn 0.5s ease;
}

.hidden {
    display: none !important;
}

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

/* スタート画面 */
#start-screen {
    text-align: center;
}

.title-container {
    margin-bottom: 40px;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 40px rgba(0, 217, 255, 0.5);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.start-info {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 40px;
    border: 1px solid rgba(0, 217, 255, 0.2);
}

.start-info p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 8px;
}

.start-info p:last-child {
    margin-bottom: 0;
    color: var(--accent-primary);
    font-weight: 700;
}

.btn {
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 16px 48px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 50px rgba(0, 217, 255, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
}

/* クイズ画面 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

.progress-container {
    flex: 1;
}

.progress-bar {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

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

.stats {
    display: flex;
    gap: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 12px;
    min-width: 60px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
}

.stat-value.correct {
    color: var(--correct-color);
}

.stat-value.wrong {
    color: var(--wrong-color);
}

.question-container {
    text-align: center;
    margin-bottom: 24px;
}

.question-label {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 12px;
}

.target-number {
    font-size: 5rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 60px rgba(0, 217, 255, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

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

.choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.choice-btn {
    font-family: inherit;
    font-size: 1.2rem;
    padding: 20px;
    background: var(--bg-card);
    border: 2px solid rgba(0, 217, 255, 0.2);
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-appearance: none;
    appearance: none;
}

/* フォーカス状態をリセット（モバイル対応） */
.choice-btn:focus,
.choice-btn:focus-visible {
    outline: none !important;
    border-color: rgba(0, 217, 255, 0.2) !important;
    background: var(--bg-card) !important;
    box-shadow: none !important;
    transform: none !important;
}

/* マウスデバイスでのみhoverスタイルを適用 */
@media (hover: hover) and (pointer: fine) {
    .choice-btn:hover:not(:disabled) {
        border-color: var(--accent-primary);
        background: rgba(0, 217, 255, 0.1);
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 217, 255, 0.2);
    }
}

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

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

.choice-btn.correct {
    background: rgba(0, 255, 136, 0.2);
    border-color: var(--correct-color);
    animation: correctPulse 0.5s ease;
}

.choice-btn.wrong {
    background: rgba(255, 68, 102, 0.2);
    border-color: var(--wrong-color);
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-5px);
    }
    40%, 80% {
        transform: translateX(5px);
    }
}

.feedback {
    text-align: center;
    padding: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    min-height: 36px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback.visible {
    visibility: visible;
    opacity: 1;
}

.feedback.correct {
    color: var(--correct-color);
}

.feedback.wrong {
    color: var(--wrong-color);
}

/* 結果画面 */
#result-screen {
    text-align: center;
    margin-top: auto;
    margin-bottom: auto;
}

.result-container {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid rgba(0, 217, 255, 0.2);
    box-shadow: var(--shadow-glow);
    max-height: none;
}

.result-title {
    font-size: 1.4rem;
    margin-bottom: 12px;
    color: var(--accent-primary);
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-secondary);
    padding: 8px 14px;
    border-radius: 12px;
    flex: 1;
    min-width: 0;
}

.result-stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    white-space: nowrap;
}

.result-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.result-message {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}

.result-message .emoji {
    font-size: 1.8rem;
    display: inline;
    margin-right: 8px;
}

/* 履歴 */
.history {
    margin-bottom: 24px;
    text-align: left;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
}

.history-item.correct {
    border-left: 3px solid var(--correct-color);
}

.history-item.wrong {
    border-left: 3px solid var(--wrong-color);
}

.history-number {
    color: var(--text-secondary);
    min-width: 24px;
}

.history-question {
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 36px;
}

.history-status {
    font-weight: 700;
    min-width: 20px;
}

.history-item.correct .history-status {
    color: var(--correct-color);
}

.history-item.wrong .history-status {
    color: var(--wrong-color);
}

.history-answer {
    color: var(--text-secondary);
    flex: 1;
}

/* レスポンシブ */
@media (max-width: 500px) {
    .title {
        font-size: 2.2rem;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
    }

    .progress-container {
        width: 100%;
    }

    .question-container {
        margin-bottom: 16px;
    }

    .question-label {
        margin-bottom: 8px;
        font-size: 0.9rem;
    }

    .target-number {
        font-size: 3.5rem;
    }

    .choices {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }

    .choice-btn {
        padding: 16px;
    }

    .stats {
        width: 100%;
        justify-content: center;
    }

    .feedback {
        padding: 6px;
        min-height: 30px;
    }

    .result-stats {
        flex-direction: row;
        gap: 8px;
    }

    .result-stat {
        padding: 6px 10px;
    }

    .result-stat-label {
        font-size: 0.65rem;
    }

    .result-stat-value {
        font-size: 0.95rem;
    }
}

/* タブレット向け */
@media (min-width: 768px) {
    .container {
        max-width: 100%;
        padding: 40px 60px;
    }

    .title {
        font-size: 3.5rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .target-number {
        font-size: 6rem;
    }

    .choice-btn {
        font-size: 1.8rem;
        padding: 28px;
        border-radius: 20px;
    }

    .choices {
        gap: 20px;
    }

    .question-label {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .start-info {
        padding: 32px;
        border-radius: 20px;
    }

    .start-info p {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .btn {
        font-size: 1.4rem;
        padding: 20px 60px;
    }

    .stat {
        padding: 10px 20px;
        border-radius: 14px;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .progress-text {
        font-size: 1rem;
    }

    .progress-bar {
        height: 10px;
    }

    .header {
        margin-bottom: 40px;
    }

    .question-container {
        margin-bottom: 32px;
    }

    .feedback {
        font-size: 1.5rem;
        padding: 12px;
        min-height: 48px;
    }

    .result-container {
        padding: 32px;
    }

    .result-title {
        font-size: 2rem;
        margin-bottom: 16px;
    }

    .result-stats {
        gap: 16px;
        margin-bottom: 16px;
    }

    .result-stat {
        padding: 12px 20px;
    }

    .result-stat-label {
        font-size: 1rem;
    }

    .result-stat-value {
        font-size: 1.4rem;
    }

    .result-message {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    .history {
        margin-bottom: 28px;
    }

    .history-item {
        padding: 14px 18px;
        margin-bottom: 10px;
        font-size: 1.3rem;
        border-radius: 12px;
        gap: 12px;
    }

    .history-number {
        min-width: 32px;
    }

    .history-question {
        min-width: 48px;
    }

    .history-status {
        min-width: 28px;
    }
}
