body {
    font-family: 'Noto Sans', sans-serif;
    background-image: url('https://images.pexels.com/photos/256417/pexels-photo-256417.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2');
    background-size: cover; background-position: center; background-attachment: fixed;
    color: #333; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; padding: 1rem;
}

/* --- Screens & Overlays --- */
#level-selection-screen, #game-over-screen { background-color: rgba(255, 255, 255, 0.97); padding: 2rem 3rem; border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); text-align: center; width: 90%; max-width: 500px; }
#level-selection-screen h1, #game-over-screen h2 { color: #337ab7; margin-top: 0; font-size: 2rem; }
.level-buttons { display: flex; justify-content: center; gap: 1rem; margin: 2rem 0; }
.level-btn, #play-again-btn { padding: 1rem 2rem; border: none; border-radius: 10px; font-size: 1.2rem; font-weight: 700; cursor: pointer; color: white; transition: transform 0.2s, box-shadow 0.2s; }
.level-btn:hover, #play-again-btn:hover { transform: translateY(-3px); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.level-btn[data-difficulty="easy"] { background-color: #5cb85c; }
.level-btn[data-difficulty="medium"] { background-color: #f0ad4e; }
.level-btn[data-difficulty="hard"] { background-color: #d9534f; }
#play-again-btn { background-color: #5bc0de; margin-top: 1rem; }
.level-info p { margin: 0.5rem 0; color: #555; }
#final-score { font-size: 4rem; font-weight: 700; color: #337ab7; margin: 1rem 0; }

#times-up-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: flex; justify-content: center; align-items: center; z-index: 100; }
.times-up-text { font-size: 6rem; font-weight: 700; color: #d9534f; text-shadow: 3px 3px 0 #fff; animation: popIn 0.5s ease-out, fadeOut 1s 2s ease-in forwards; }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Main Game Container --- */
#game-container { position: relative; overflow: hidden; background-color: rgba(255, 255, 255, 0.95); padding: 2rem; border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); width: 90%; max-width: 700px; text-align: center; }
header { text-align: center; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 2px solid #eee; }
header h1 { margin: 0; }
.powered-by { font-size: 0.75rem; font-weight: 400; color: #777; text-decoration: none; display: block; }
.powered-by:hover { text-decoration: underline; }
.instructions-es { background-color: #f0f4f8; color: #555; border-radius: 8px; padding: 0.2rem 1rem; text-align: center; font-size: 0.9rem; margin-top: 1rem; }

/* --- Dashboard --- */
.dashboard { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; background: #f8f9fa; border-radius: 12px; margin-bottom: 1rem; }
#score-board-container { position: relative; }
#score-board, #timer-display, #hint-btn { padding: 0.5rem 1rem; border-radius: 20px; font-weight: 700; }
#score-board { background-color: #5bc0de; color: white; }
#timer-display { background-color: #337ab7; color: white; transition: background-color 0.5s; }
#timer-display.low-time { background-color: #d9534f; }
.score-feedback { position: absolute; top: -20px; right: -20px; font-size: 1.5rem; font-weight: 700; animation: fadeAndRise 1.5s ease-out forwards; }
@keyframes fadeAndRise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }
.score-feedback.plus { color: #28a745; }
.score-feedback.minus { color: #dc3545; }
.hint-attempts-container { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
#hint-btn { background-color: #ffc107; color: #333; display: flex; align-items: center; gap: 8px; border: none; cursor: pointer; }
#hint-btn svg { fill: #333; width: 18px; height: 18px; }
#attempts-tracker { background-color: #6c757d; color: white; padding: 0.3rem 0.8rem; font-size: 0.8rem; border-radius: 20px; }

/* --- Puzzle Area --- */
#level-indicator { font-weight: 700; color: #007bff; text-transform: capitalize; font-size: 1.2rem; margin-bottom: 0.25rem; }
.puzzle-area h2 { margin-top: 0; margin-bottom: 0.5rem; font-size: 1.1rem; }
#jumbled-sentence { font-style: italic; color: #d9534f; margin-bottom: 1.5rem; font-size: 1.4rem; font-weight: 700; }
.answer-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; margin-bottom: 1.5rem; min-height: 50px; }
.word-group { display: flex; gap: 4px; }
.grid-cell { width: 38px; height: 38px; border: 2px solid #bdc3c7; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 1.4rem; font-weight: 700; text-transform: uppercase; background-color: #ecf0f1; transition: background-color 0.2s; }
.grid-cell.filled { cursor: pointer; background-color: #e8f4f8; }
.grid-cell.filled:hover { background-color: #f8e8e8; }
.grid-cell.hinted { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; cursor: not-allowed; }
.letter-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 1.5rem; align-items: center; }
.letter-tile { width: 45px; height: 45px; background-color: #337ab7; color: white; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 1.6rem; font-weight: 700; cursor: pointer; transition: all 0.2s; user-select: none; }
.letter-tile:hover { background-color: #286090; transform: scale(1.1); }
.letter-tile[style*="visibility: hidden"] { visibility: hidden; }
.backspace-key { height: 45px; width: 65px; background-color: #f77f00; color: white; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.backspace-key:hover { background-color: #e67e00; }
.backspace-key svg { width: 24px; height: 24px; fill: white; }

/* --- Controls --- */
.controls { display: flex; flex-wrap: wrap; justify-content: center; }
.controls button { padding: 0.8rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: background-color 0.2s; margin: 5px; }
.controls button:disabled { background-color: #bdc3c7; cursor: not-allowed; }
#skip-btn { background-color: #a0a0a0; color: white; }
#next-btn, #back-btn { background-color: #5bc0de; color: white; }
#home-btn { background-color: #777; color: white; }
.feedback { margin-top: 1rem; font-size: 1.2rem; font-weight: 700; min-height: 30px; }
.feedback.correct { font-size: 2rem; animation: popIn 0.3s ease-out; }
.feedback.incorrect { color: #c9302c; }
.feedback .explanation { font-size: 1rem; font-weight: 400; color: #333; margin-top: 10px; text-align: left; background: #f0f4f8; padding: 10px; border-radius: 8px; }
.hidden { display: none !important; }

/* --- NEW Confetti Animation --- */
#confetti-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 101; }
.confetti-piece { position: absolute; width: 8px; height: 16px; opacity: 0; }
.confetti-piece.fall-1 { animation: fall-1 3s ease-out forwards; }
.confetti-piece.fall-2 { animation: fall-2 3s ease-out forwards; }
.confetti-piece.fall-3 { animation: fall-3 3s ease-out forwards; }
@keyframes fall-1 { from { top: -20px; opacity: 1; transform: rotate(0deg); } to { top: 100%; opacity: 1; transform: rotate(360deg); } }
@keyframes fall-2 { from { top: -20px; opacity: 1; transform: rotate(-120deg); } to { top: 100%; opacity: 1; transform: rotate(240deg); } }
@keyframes fall-3 { from { top: -20px; opacity: 1; transform: rotate(120deg); } to { top: 100%; opacity: 1; transform: rotate(-240deg); } }