* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none; /* Prevent scrolling while dragging */
}

body {
    background-color: #0b0c10;
    background-image: url('bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: #e0e0e0;
    font-family: 'Lora', serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

body::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 10, 25, 0.7);
    z-index: 0;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 100%;
    max-height: 900px;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: opacity 0.4s ease;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

/* Typography */
.glow-text {
    font-family: 'Cinzel', serif;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 140, 0, 0.5);
    text-align: center;
}

.title-text {
    font-size: 3.5rem;
    margin-bottom: 20px;
    margin-top: 100px;
}

/* Start / Win Screens */
#screen-start, #screen-win {
    justify-content: center;
    align-items: center;
    background: transparent;
}

#screen-start p, #screen-win p {
    font-size: 1.2rem;
    margin-bottom: 40px;
    color: #bca0dc;
    text-align: center;
}

.stars {
    font-size: 2.5rem;
    margin: 20px 0;
    filter: drop-shadow(0 0 10px gold);
}

/* Buttons */
.btn {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 15px 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    background: linear-gradient(135deg, #4b0082, #8a2be2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4), inset 0 0 10px rgba(255,255,255,0.2);
    border: 1px solid #bca0dc;
}

.btn:active {
    transform: scale(0.95);
}

.icon-btn {
    background: rgba(75, 0, 130, 0.6);
    border: 1px solid #8a2be2;
    color: white;
    font-size: 1.5rem;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
}
.icon-btn:active {
    transform: scale(0.9) rotate(-15deg);
}

.text-btn {
    background: none;
    border: none;
    color: #bca0dc;
    font-family: 'Lora', serif;
    font-size: 1rem;
    margin-top: auto;
    padding: 15px;
    cursor: pointer;
    text-decoration: underline;
}

/* Game Layout */
#game-header {
    text-align: center;
    margin-bottom: 10px;
    padding-top: 10px;
}

.level-info {
    font-family: 'Cinzel', serif;
    color: #ffd700;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.category-name {
    font-size: 1.5rem;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin-top: 5px;
}

/* Progress Area */
#progress-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-grow: 0;
    min-height: 100px;
}

.word-slot-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.slot {
    width: 28px;
    height: 34px;
    background: rgba(20, 15, 30, 0.6);
    border: 1px solid rgba(138, 43, 226, 0.4);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: bold;
    color: transparent;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.slot.filled {
    background: rgba(138, 43, 226, 0.3);
    border-color: #ffd700;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.4);
}

/* Current Word Display */
#current-word-display {
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
}

#current-word-text {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #fff;
    letter-spacing: 4px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px rgba(138, 43, 226, 0.8);
    min-width: 20px;
}

/* Board Area - For absolute positioned falling blocks */
#board-area {
    flex-grow: 1;
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 360px;
}

/* Letter Tiles */
.tile {
    position: absolute;
    width: 48px;
    height: 48px;
    background: linear-gradient(145deg, #2a1b38, #1a1025);
    border: 2px solid #5a3b78;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    font-weight: bold;
    color: #e0e0e0;
    cursor: grab;
    box-shadow: 0 4px 0 #150d1e, 0 6px 10px rgba(0,0,0,0.5);
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), left 0.4s ease, transform 0.2s, background 0.2s, border-color 0.2s, color 0.2s, opacity 0.3s;
    user-select: none;
    z-index: 10;
}

.tile.selected {
    border-color: #ffd700;
    color: #ffd700;
    background: linear-gradient(145deg, #4b0082, #3a0066);
    box-shadow: 0 4px 0 #2a004d, 0 0 15px rgba(138, 43, 226, 0.8);
    transform: scale(1.1);
    z-index: 20;
}

.tile.correct {
    transform: scale(0) rotate(180deg);
    opacity: 0;
    pointer-events: none;
}

/* Draw line container */
#line-svg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

polyline {
    fill: none;
    stroke: rgba(255, 215, 0, 0.6);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 10px rgba(138, 43, 226, 0.8));
}

/* Controls */
#controls-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 10px 20px 20px;
}

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

.shake {
    animation: shake 0.4s;
}

.word-glow-correct {
    color: #00ff88 !important;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.8) !important;
}

.word-glow-wrong {
    color: #ff3366 !important;
    text-shadow: 0 0 20px rgba(255, 51, 102, 0.8) !important;
}
