/* ===========================================
   すうじあそび - Number Game
   =========================================== */
/* Mobile Responsive Fixes */
@media (max-width: 480px) {
    .game-header {
        padding: 60px 10px 10px;
    }
    .level-badge {
        font-size: 0.9rem;
        padding: 5px 10px;
    }
    .home-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 10px;
        left: 10px;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Zen Maru Gothic', sans-serif;
    touch-action: none;
    user-select: none;
}

body {
    background: linear-gradient(180deg, #E1F5FE 0%, #B3E5FC 50%, #81D4FA 100%);
}

.home-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    border: 3px solid #4FC3F7;
}

#game-container {
    max-width: 500px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.game-header {
    padding: 55px 15px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-badge {
    background: #FF5722;
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: bold;
}

.progress-display {
    background: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 3px 0 #BDBDBD;
}

#correct-count {
    color: #4CAF50;
}

/* Question Area */
.question-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    align-items: center;
    gap: 20px;
    min-height: 0; /* Allow shrinking */
    overflow-y: auto;
}

.instruction-text {
    background: white;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.comparison-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
}

.comparison-box {
    flex: 1;
    height: 100%;
    max-height: 400px;
    min-height: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 6px solid white;
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.comparison-box:active {
    transform: scale(0.98);
}

.comparison-box.correct {
    border-color: #4CAF50;
    background: #E8F5E9;
}

.comparison-box.wrong {
    border-color: #FF5252;
    background: #FFEBEE;
}

.item-tray {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 8px;
}

.vs-label {
    background: #FF5252;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
    box-shadow: 0 5px 15px rgba(255,82,82,0.4);
    flex-shrink: 0;
}

.number-tag {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #29B6F6;
    color: white;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
}

.number-tag.hidden { display: none; }

/* Count Area */
.count-area {
    flex: 1;
    background: white;
    border-radius: 25px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.count-item {
    font-size: 3.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.count-item.counted {
    transform: scale(1.2);
    filter: drop-shadow(0 0 10px #FFD700);
    animation: countPop 0.3s ease-out;
}

@keyframes countPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.4);
    }

    100% {
        transform: scale(1.2);
    }
}

/* Answer Area */
.answer-area {
    background: white;
    padding: 20px;
    border-radius: 25px 25px 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.answer-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.answer-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.1s;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

.answer-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.2);
}

.answer-btn.correct {
    animation: correctPulse 0.5s ease-out;
}

@keyframes correctPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.answer-btn.wrong {
    animation: wrongShake 0.4s ease-in-out;
}

@keyframes wrongShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

/* Button Colors */
.btn-1 {
    background: linear-gradient(135deg, #EF5350 0%, #E53935 100%);
}

.btn-2 {
    background: linear-gradient(135deg, #FF7043 0%, #F4511E 100%);
}

.btn-3 {
    background: linear-gradient(135deg, #FFCA28 0%, #FFB300 100%);
}

.btn-4 {
    background: linear-gradient(135deg, #66BB6A 0%, #43A047 100%);
}

.btn-5 {
    background: linear-gradient(135deg, #42A5F5 0%, #1E88E5 100%);
}

.btn-6 {
    background: linear-gradient(135deg, #AB47BC 0%, #8E24AA 100%);
}

.btn-7 {
    background: linear-gradient(135deg, #EC407A 0%, #D81B60 100%);
}

.btn-8 {
    background: linear-gradient(135deg, #5C6BC0 0%, #3949AB 100%);
}

.btn-9 {
    background: linear-gradient(135deg, #26A69A 0%, #00897B 100%);
}

.btn-10 {
    background: linear-gradient(135deg, #78909C 0%, #546E7A 100%);
}

/* Particles */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

.particle {
    position: absolute;
    font-size: 2rem;
    animation: particleFly 1s ease-out forwards;
}

@keyframes particleFly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.overlay.hidden {
    display: none;
}

.feedback-content {
    text-align: center;
    animation: feedbackPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes feedbackPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.feedback-icon {
    font-size: 6rem;
    margin-bottom: 15px;
}

.feedback-text {
    font-size: 2rem;
    font-weight: bold;
    color: white;
}

.clear-modal {
    background: white;
    border-radius: 30px;
    padding: 30px;
    text-align: center;
    animation: modalPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 320px;
    width: 90%;
}

@keyframes modalPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.clear-banner {
    width: 180px;
    margin-bottom: 10px;
}

.clear-modal h2 {
    font-size: 1.5rem;
    color: #4CAF50;
    margin-bottom: 15px;
}

.clear-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: #29B6F6;
}

.stat-label {
    font-size: 0.85rem;
    color: #666;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50 0%, #43A047 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 0 #2E7D32;
}

.btn-secondary {
    background: #EEEEEE;
    color: #333;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
}

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(4px);
    box-shadow: none;
}