/* T3: Ghép Từ Thành Câu - Style */
body {
    background: linear-gradient(135deg, #A8E6CF 0%, #DCEDC1 100%);
    font-family: 'Nunito', sans-serif;
    user-select: none; -webkit-user-select: none;
    overflow-x: hidden; height: 100vh; touch-action: manipulation;
}

h1, h2, h3 { font-family: 'Baloo 2', cursive; color: #1B5E20; }

.game-wrapper {
    max-width: 800px; margin: 0 auto; padding: 20px;
    height: 100%; display: flex; flex-direction: column;
}

.back-btn {
    display: inline-flex; align-items: center; gap: 8px; font-weight: 700;
    color: #388E3C; background: #fff; padding: 8px 16px; border-radius: 99px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); align-self: flex-start; margin-bottom: 5px;
    transition: transform 0.2s;
}
.back-btn:active { transform: scale(0.95); }

.game-header { text-align: center; margin-bottom: 15px; }
.game-header h1 { font-size: 2.2rem; margin-bottom: 5px; text-shadow: 2px 2px 0 #FFF;}
.game-header p { font-size: 1.1rem; color: #4CAF50; margin-bottom: 10px; font-weight: 700; background: rgba(255,255,255,0.7); display: inline-block; padding: 5px 20px; border-radius: 20px;}

.score-board {
    display: inline-block; padding: 6px 20px; border-radius: 99px;
    font-weight: 800; font-size: 1.2rem; background: #FFD54F; color: #E65100;
    box-shadow: 0 4px 0px #FFB300;
}

.pop-text.pop { animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0%{transform: scale(1);} 50%{transform: scale(1.5);} 100%{transform: scale(1);} }

/* Vùng Bảng đang ghép */
.game-area {
    flex: 1; display: flex; flex-direction: column; gap: 20px; position: relative;
}

.sentence-board {
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(5px);
    border: 4px dashed #81C784; border-radius: 20px; padding: 20px;
    min-height: 150px; display: flex; flex-direction: column; justify-content: space-between;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05); position: relative;
    transition: all 0.3s;
}

.sentence-board.success { border-color: #4CAF50; background: #E8F5E9; transform: scale(1.02); }
.sentence-board.error { border-color: #EF5350; background: #FFEBEE; animation: shake 0.4s; }

.placeholder-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #9E9E9E; font-size: 1.2rem; font-style: italic; font-weight: 600;
    pointer-events: none; transition: opacity 0.2s;
}
.built-sentence:not(:empty) + .actions + .placeholder-text { opacity: 0; }
.built-sentence:not(:empty) ~ .placeholder-text { opacity: 0; } /* Fallback */

.built-sentence {
    display: flex; flex-wrap: wrap; gap: 10px; flex: 1; align-content: flex-start;
}

.word-chip {
    background: #4A90E2; color: white; padding: 8px 16px; border-radius: 12px;
    font-family: 'Baloo 2', cursive; font-size: 1.4rem; font-weight: 700;
    box-shadow: 0 4px 0px #2A6EBB; animation: popIn 0.3s;
}

.actions {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px;
}

.btn-action {
    border: none; padding: 8px 15px; border-radius: 10px; font-weight: 700;
    font-size: 1.1rem; cursor: pointer; color: white; transition: transform 0.1s;
    font-family: 'Nunito', sans-serif; box-shadow: 0 4px 0px rgba(0,0,0,0.2);
}
.btn-action:active { transform: translateY(4px); box-shadow: 0 0px 0px; }
.btn-action:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 0 4px 0px rgba(0,0,0,0.2); }

.btn-submit { background: #4CAF50; box-shadow: 0 4px 0px #2E7D32; }
.btn-undo { background: #FF9800; box-shadow: 0 4px 0px #E65100; }

/* Vùng bong bóng mây */
.sky-zone {
    flex: 1; background: url('data:image/svg+xml;utf8,<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="%23ffffff20"/></svg>') 0 0/100px 100px;
    border-radius: 20px; box-shadow: inset 0 0 20px rgba(0,0,0,0.1); position: relative;
    overflow: hidden; padding: 20px; display: flex; flex-wrap: wrap; gap: 15px; align-content: flex-start; justify-content: center;
}

.bubble {
    background: radial-gradient(circle at 30% 30%, #fff, #A0DEFF);
    border-radius: 50%; color: #1E6B9B; font-family: 'Baloo 2', cursive;
    font-size: 1.5rem; font-weight: 800; padding: 15px 30px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1), inset -5px -5px 15px rgba(0,0,0,0.1);
    cursor: pointer; position: relative; border: 2px solid #fff;
    transition: transform 0.2s, opacity 0.2s;
    animation: floating 3s infinite ease-in-out;
}

.bubble:nth-child(odd) { animation-duration: 3.5s; animation-direction: reverse; }
.bubble:nth-child(3n) { animation-duration: 4s; }

.bubble:active { transform: scale(0.9); }
.bubble.selected { transform: scale(0); opacity: 0; pointer-events: none;}

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

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

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 1000;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-content {
    background: white; padding: 40px; border-radius: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2); transform: scale(0.8); transition: transform 0.3s;
    max-width: 90%; width: 400px;
}
.modal-overlay.show .modal-content { transform: scale(1); }
.modal-icon { font-size: 5rem; margin-bottom: 10px; text-shadow: 0 10px 20px rgba(0,0,0,0.2); animation: popIn 1s infinite alternate;}
.text-pop { animation: popIn 1s infinite alternate; }

.btn-primary {
    background: #4CAF50; color: white; border: none; padding: 12px 30px;
    font-size: 1.2rem; font-family: 'Baloo 2', cursive; border-radius: 99px;
    cursor: pointer; box-shadow: 0 6px 0px #2E7D32; margin: 5px;
}
.btn-secondary {
    display: inline-block; background: #E2E8F0; color: #4A5568; margin: 5px;
    border: none; padding: 12px 30px; font-size: 1.2rem; font-family: 'Baloo 2', cursive;
    border-radius: 99px; cursor: pointer; box-shadow: 0 6px 0px #CBD5E0;
}

@media (max-width: 600px) {
    .game-header h1 { font-size: 1.8rem; }
    .game-header p { font-size: 0.95rem; }
    .bubble { font-size: 1.2rem; padding: 10px 20px; }
    .word-chip { font-size: 1.2rem; padding: 6px 12px; }
}
