/* ==================== リセット・基本設定 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Kosugi Maru', 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ==================== ゲームコンテナ ==================== */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== ヘッダー ==================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.home-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.stage-indicator {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.stage-number {
    background: rgba(255, 255, 255, 0.2);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* プログレスバー */
.progress-container {
    text-align: center;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 10%;
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

/* スコア表示 */
.score-display {
    text-align: center;
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    color: #8b4513;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.score-label {
    font-size: 0.8rem;
    display: block;
}

.score-value {
    font-size: 1.2rem;
}

.stars-display {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 1.5rem;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
    transition: all 0.3s ease;
}

.star.earned {
    animation: starGlow 1s ease-in-out;
}

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

/* ==================== メイン画面 ==================== */
.game-main {
    flex: 1;
    padding: 0 20px 20px;
}

/* ==================== スタート画面 ==================== */
.start-screen {
    text-align: center;
    color: white;
}

.character-intro {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.character {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.speech-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    position: relative;
    font-size: 1.1rem;
    line-height: 1.6;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 15px solid #667eea;
}

/* ステージ選択 */
.stage-selection h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.stage-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 20px;
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    color: #333;
}

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

.stage-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.stage-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.stage-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #667eea;
}

.stage-desc {
    font-size: 1rem;
    color: #666;
    margin-bottom: 10px;
}

.stage-difficulty {
    font-size: 1.2rem;
    color: #ffd700;
}

/* ==================== ゲーム画面 ==================== */
.game-screen {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    min-height: 500px;
}

.problem-area {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.character-guide {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #e8f4fd 0%, #f0f8ff 100%);
    border-radius: 15px;
    border-left: 5px solid #667eea;
}

.character-guide .character {
    font-size: 2.5rem;
    animation: bounce 2s ease-in-out infinite;
}

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

.guide-text {
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

/* 数式表示 */
.math-problem {
    text-align: center;
    margin: 40px 0;
}

.equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.number-display, .answer-slot {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 3rem;
    font-weight: 700;
    width: 100px;
    height: 100px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.answer-slot {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    border: 3px dashed rgba(255, 255, 255, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

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

.operator, .equals {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
}

/* 選択肢グリッド */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    margin: 30px 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.option-btn {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 20px;
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.option-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.option-btn.correct {
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    animation: correctPulse 0.6s ease-in-out;
}

.option-btn.incorrect {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: shake 0.5s ease-in-out;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* アクションボタン */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.btn-primary, .btn-secondary {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: 2px solid #667eea;
}

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

/* ==================== ビジュアルエリア ==================== */
.visual-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ビジュアル計算エリア */
.visual-calculation {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.visual-calculation h4 {
    text-align: center;
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600;
}

.block-workspace {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0fe 100%);
    border-radius: 15px;
    border: 2px dashed rgba(102, 126, 234, 0.3);
}

.number1-area, .number2-area, .result-area {
    text-align: center;
    min-height: 120px;
}

.area-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

.blocks-container {
    min-height: 80px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
}

.blocks-container.highlight {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

.plus-sign, .equals-sign {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    text-align: center;
}

.result-display {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 計算ブロック */
.calc-block {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.calc-block:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.calc-block.dragging {
    z-index: 1000;
    transform: scale(1.2);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.calc-block.num1 {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.calc-block.num2 {
    background: linear-gradient(135deg, #4ecdc4 0%, #26d0ce 100%);
}

.calc-block.result {
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    color: #8b4513;
}

.calc-block.animating {
    animation: blockMove 1s ease-in-out;
}

@keyframes blockMove {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.2); }
    100% { transform: translateY(0) scale(1); }
}

/* 大きな数字用のブロック表示 */
.number-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.tens-row, .ones-row {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
}

.group-label {
    font-size: 0.7rem;
    color: #666;
    font-weight: 600;
}

/* ブロック行 */
.block-row {
    display: flex;
    gap: 3px;
    justify-content: center;
    margin-bottom: 5px;
}

/* ブロックコントロール */
.block-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.magic-effects {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 20px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.counting-help {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.counting-objects {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.count-object {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    animation: pop 0.5s ease-in-out;
}

@keyframes pop {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ドロップゾーンのスタイル */
.drop-zone {
    border: 3px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    color: #667eea;
    font-weight: 600;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    border-color: #4ecdc4;
    background: rgba(78, 205, 196, 0.2);
    transform: scale(1.05);
}

/* 計算結果のアニメーション */
.result-animation {
    animation: resultReveal 1.5s ease-in-out;
}

@keyframes resultReveal {
    0% { 
        opacity: 0; 
        transform: scale(0.5) rotate(-10deg); 
    }
    60% { 
        opacity: 1; 
        transform: scale(1.2) rotate(5deg); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1) rotate(0deg); 
    }
}

/* 大きな数字での十の位と一の位表示 */
.digit-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    margin: 10px 0;
}

.digit-row {
    display: flex;
    gap: 5px;
    align-items: center;
}

.digit-label {
    font-size: 0.8rem;
    color: #666;
    min-width: 40px;
    font-weight: 600;
}

.hundred-blocks, .ten-blocks, .one-blocks {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.hundred-block {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.ten-block {
    width: 35px;
    height: 15px;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border-radius: 4px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
}

.one-block {
    width: 15px;
    height: 15px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-radius: 50%;
}

/* ==================== 結果画面 ==================== */
.result-screen {
    text-align: center;
    color: white;
    padding: 40px;
}

.result-character .character {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: celebration 1s ease-in-out;
}

@keyframes celebration {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-5deg); }
    75% { transform: scale(1.2) rotate(5deg); }
}

.result-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    color: #333;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    margin: 0 auto;
}

.result-title {
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
}

.stat-stars {
    font-size: 2rem;
}

.result-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

/* ==================== パーティクルエフェクト ==================== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    font-size: 1.5rem;
    animation: particleFloat 3s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0.5);
    }
}

/* ==================== レスポンシブデザイン ==================== */
@media (max-width: 968px) {
    .game-screen {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .header-left, .header-right {
        width: 100%;
        justify-content: center;
    }
    
    .block-workspace {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }
    
    .plus-sign, .equals-sign {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .equation {
        gap: 10px;
    }
    
    .number-display, .answer-slot {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }
    
    .operator, .equals {
        font-size: 2rem;
    }
    
    .stage-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .stage-btn {
        padding: 20px 10px;
    }
    
    .character {
        font-size: 4rem !important;
    }
}

@media (max-width: 480px) {
    .game-main {
        padding: 0 10px 10px;
    }
    
    .problem-area {
        padding: 20px;
    }
    
    .options-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .option-btn {
        padding: 15px;
        font-size: 1.5rem;
    }
    
    .result-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        max-width: 200px;
    }
}

/* ==================== ポイント獲得アニメーション ==================== */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.points-earned-message {
    animation: slideInRight 0.5s ease-out;
}

.points-earned-message .points-icon {
    font-size: 1.2em;
    animation: bounce 0.6s ease-in-out infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-3px);
    }
}