/* General Styles */
body {
    font-family: 'Helvetica Neue', 'Segoe UI', sans-serif;
    text-align: center;
    background-color: #0a0a0e;
    color: #f5f5f7;
    margin: 0;
    padding: 0;
    scale: 0.85;
    background-image: linear-gradient(to bottom, #0a0a0e 0%, #15151f 100%);
    background-attachment: fixed;
}

/* Add subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(18, 18, 40, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 18, 40, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: -1;
}

/* Studio Logo Styling */
.studio-logo {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 210px; /* 30% smaller than 300px */
    height: auto;
    z-index: 1; /* keep under interactive buttons */
    pointer-events: none; /* avoid intercepting taps */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

/* Studio Name Styling */
.studio-name {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 300;
    color: #b0b0b0;
    letter-spacing: 2px;
    z-index: 3;
    margin: 0;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.studio-name img {
    width: 200px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

@media (max-width: 768px) {
    .studio-name img { width: 250px; }
}

@media (max-width: 480px) {
    .studio-name img {
        width: 200px;
    }
}

/* Hide elements with the .hidden class */
.hidden {
    display: none;
}

/* Screens */
.screen {
    display: none; /* Hide all screens by default */
    min-height: 100vh; /* Ensure full height on all screens */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 10px; /* Add horizontal padding for mobile */
    overflow-y: auto; /* Allow scrolling if content exceeds height */
    background-image: radial-gradient(circle at 50% 50%, rgba(30, 30, 50, 0.2) 0%, rgba(10, 10, 14, 0) 70%);
}

/* Show the active screen */
.screen.active {
    display: flex;
}

/* Container for Back Button and Score */
#back-score-container {
    display: flex;
    flex-direction: row-reverse; /* Align items in a row */
    align-items: center; /* Vertically center the items */
    column-gap: 30px;
    width: 100%; /* Ensure it spans the width of the parent */
    margin-bottom: 20px; /* Add spacing below */
  }
  
  /* Back Button in the Alignment Container */
  #back-score-container #back-to-main-menu-from-game {
    margin: 0; /* Reset margins to align properly */
  }
  
  /* Back Button for Clash Mode on Mobile */
#clash-back-button {
    position: absolute;
    top: 10px;
    left: 850px;
    z-index: 10; /* Ensure it stays above other elements */
    background: linear-gradient(135deg, #ff6d00 0%, #e65100 100%);
    color: #ffffff;
    font-size: 16px;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 25px -5px rgba(255, 109, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
}

#clash-back-button:hover {
    background: linear-gradient(135deg, #ff7d00 0%, #f65d00 100%);
    box-shadow: 0 14px 30px -8px rgba(255, 109, 0, 0.5), 0 6px 15px rgba(0, 0, 0, 0.2);
}
  /* Score Display Styling */
  #player-score {
    font-size: 16px;
    color: #ffffff;
    margin-left: 10px; /* Add some spacing from the button */
  }
  

/* Buttons */
button {
    font-size: 18px;
    padding: 15px 30px;
    margin: 10px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: #fff;
    background: linear-gradient(135deg, #00d374 0%, #00a042 100%);
    box-shadow: 0 10px 25px -5px rgba(0, 200, 83, 0.3), 0 4px 8px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 30px -8px rgba(0, 200, 83, 0.4), 0 6px 15px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #00e67c 0%, #00b349 100%);
}

button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 8px 15px -5px rgba(0, 200, 83, 0.35), 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Updated styles for the mode container and options */
.mode-container {
    position: relative;
    top: 15%; /* Move down by 15% */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    flex-wrap: wrap;
    margin-top: 275px; /* Reduced spacing from the title */
    padding: 0 20px; /* Add horizontal padding for mobile */
    z-index: 3; /* ensure buttons appear above title/logo */
}

.mode-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 280px; /* Reduced max width to make it thinner */
}

.mode-option .menu-button {
    width: 210px; /* Adjusted button width to match the thinner option */
    height: 80px;
}

.mode-description {
    margin-top: 10px;
    font-size: 18px; /* Increased font size for better readability */
    color: #e0e0e0;
    text-align: center;
    line-height: 1.5;
}


/* Specific Styling for Back Buttons */
#back-to-main-menu,
#back-to-main-menu-from-game,
#back-to-play-menu {
    background-color: #ff9800; /* Orange */
}

#back-to-main-menu:hover,
#back-to-main-menu-from-game:hover,
#back-to-play-menu:hover {
    background-color: #e65100; /* Darker orange on hover */
}

/* Position the game title consistently across screens */
.game-title {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1300px; /* 200% larger than 650px */
    height: auto;
    margin: 0;
    z-index: 1; /* keep below interactive elements */
    pointer-events: none; /* avoid intercepting taps */
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.6));
}

/* Add subtle ambient glow to logo */
.game-title::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(109, 86, 216, 0.15) 0%, rgba(10, 10, 14, 0) 70%);
    z-index: -1;
    filter: blur(30px);
    pointer-events: none;
}

/* Consistent scale and position for both opening screen and play menu */
#opening-screen .game-title,
#play-menu .game-title {
    top: 35%;
    transform: translate(-50%, -50%) scale(0.3); /* Adjusted scale to compensate for 200% larger base size */
}

/* Responsive adjustments (phones + tablets <=768px) */
@media (max-width: 768px) {
    .studio-logo { width: 140px; top: 6%; }
    .game-title { width: 500px; top: 28%; }
    #opening-screen .game-title, #play-menu .game-title { top: 28%; transform: translate(-50%, -50%) scale(0.52); }
    .mode-container { top: auto; margin-top: 280px; gap: 14px; padding: 0 16px; }
    .mode-option { max-width: 100%; width: 100%; }
    .mode-option .menu-button { width: 100%; max-width: 340px; height: 64px; font-size: 16px; }
    .mode-description { font-size: 14px; padding: 0 10px; min-height: 56px; overflow: visible; word-wrap: break-word; }
}

@media (max-width: 480px) {
    .studio-logo {
        width: 126px; /* 30% smaller for small mobile */
        top: 4%;
    }
    .game-title {
        width: 400px; /* 200% larger base for small mobile */
        top: 25%;
    }
    #opening-screen .game-title,
    #play-menu .game-title {
        top: 25%;
        transform: translate(-50%, -50%) scale(0.6); /* Adjusted scale */
    }
    .mode-container {
        top: auto; /* remove offset */
        margin-top: 220px; /* push buttons further below the logo */
        gap: 10px; /* reduce space between mode blocks */
        padding: 0 10px;
    }
    .mode-option .menu-button {
        height: 60px;
        font-size: 14px;
        padding: 10px 15px;
    }
    .mode-description {
        font-size: 13px;
        line-height: 1.4;
        min-height: 80px;
        overflow: visible;
        word-wrap: break-word;
        margin-bottom: 10px;
    }
    #enter-button {
        top: 50% !important;
        font-size: 16px;
        padding: 12px 25px;
    }
}

/* Specific fix for 425px mobile view alignment */
@media (max-width: 425px) {
    #input-row { margin-left: -50px; }
    /* Keep screen within viewport */
    html, body, .screen { max-width: 100vw; overflow-x: hidden; }
    /* Play menu spacing and stacking */
    #play-menu .game-title { top: 21%; transform: translate(-50%, -50%) scale(0.55); z-index: 0; }
    .mode-container { top: auto; margin-top: 230px; gap: 8px; padding: 0 12px; flex-direction: column; align-items: center; }
    .mode-option { width: 100%; max-width: 100%; }
    .mode-option .menu-button { width: 100%; max-width: 100%; height: 56px; font-size: 15px; margin: 2px 0; }
    .mode-description { font-size: 13px; min-height: 54px; line-height: 1.28; margin: 4px 0 8px; }
    /* Game layout containers */
    #game-container, #grid-wrapper, #main-grid-container, #right-side-container { width: 100%; max-width: 100%; box-sizing: border-box; padding-left: 10px; padding-right: 10px; }
    #daily-challenge-bar { box-sizing: border-box; padding: 8px 12px; }
}

/* Specific fix for 375px mobile view alignment */
@media (max-width: 375px) {
    #input-row {
        margin-left: 0;
    }
    /* Prevent horizontal overflow */
    html, body, .screen { max-width: 100vw; overflow-x: hidden; box-sizing: border-box; }

    /* Fix play menu layout for 375px */
    .mode-container { top: auto; margin-top: 240px; gap: 6px; padding: 0 12px; flex-direction: column; align-items: center; }
    .mode-option { width: 100%; max-width: 100%; }
    .mode-option .menu-button { width: 100%; max-width: 100%; height: 52px; font-size: 14px; margin-top: 2px; margin-bottom: 2px; }
    .mode-description { font-size: 12px; min-height: 48px; padding: 0 6px; line-height: 1.25; margin-top: 2px; margin-bottom: 6px; }
    #play-menu .game-title { top: 19%; transform: translate(-50%, -50%) scale(0.5); z-index: 0; }

    /* Constrain game containers */
    #game-container, #grid-wrapper, #main-grid-container, #right-side-container { width: 100%; max-width: 100%; padding-left: 8px; padding-right: 8px; box-sizing: border-box; }
    #daily-challenge-bar { width: 296px; box-sizing: border-box; padding: 8px 10px; } /* Match grid width: 11*24px + 10*2px + 2*6px */
    #grid { grid-template-columns: repeat(11, 24px); grid-template-rows: repeat(10, 24px); gap: 2px; padding: 6px; }
    #grid.daily-challenge-grid { grid-template-rows: repeat(4, 24px); }

    /* Input row and buttons fit */
    #input-row { grid-template-columns: repeat(11, 24px); grid-template-rows: 24px; gap: 2px; }
    #input-buttons { display: flex; gap: 8px; width: 100%; justify-content: center; }
    #input-buttons button { flex: 1 1 0; min-width: 0; max-width: 48%; font-size: 14px; padding: 10px 8px; }

    /* Small grid shrinks */
    #small-grid-wrapper { width: 100%; padding: 8px; box-sizing: border-box; }
    #small-grid { grid-template-columns: repeat(6, 28px); grid-auto-rows: 28px; gap: 6px; }
}

/* Specific fix for 320px mobile view alignment */
@media (max-width: 320px) {
    #input-row {
        margin-left: 5px;
    }
}
/* Title Styling */
h1 {
    margin-top: 20px;
    font-size: 36px;
    color: #e0e0e0;
}

#difficulty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px; 
}

#difficulty-buttons-container {
    display: flex;
    flex-direction: column; /* Stack buttons vertically */
    margin-top: 15px; /* Add space above buttons */
}
/* Adjust the layout for grid and small grid */
#grid-wrapper {
    display: none;
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    gap: 10px; /* Space between main and small grid */
    margin-top: 10px;
}

/* Game Container Styling */
#game-container {
    display: none;
    justify-content: center;
    align-items: flex-start; /* Align items to start vertically */
    margin: 20px auto; /* Centered horizontally */
    background-color: #12121a;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0px 10px 40px rgba(0, 0, 0, 0.5), 0px 0px 80px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    max-width: 1000px; /* Optional max width */
    flex-direction: column;
    overflow-y: auto; /* Allow scrolling if content exceeds container */
    position: relative; /* Ensure positioning context for absolute elements */
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Ensure grid-wrapper becomes visible when active */
#grid-wrapper.active {
    display: flex;
}

#game-container.active {
    display: flex;
}

/* Main Grid Container Styling */
#main-grid-container {
    display: flex;
    flex-direction: column;
}

/* Grid Styling */
#grid {
    display: grid;
    grid-template-rows: repeat(10, 50px);
    grid-template-columns: repeat(11, 50px);
    gap: 4px;
    background-color: #1a1a25;
    padding: 10px;
    border-radius: 20px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Daily Challenge Grid - Smaller 4-row layout */
#grid.daily-challenge-grid {
    grid-template-rows: repeat(4, 50px);
}

/* Input Area Styling */
#input-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0; /* Remove top margin to align with grid */
}

/* Input Row Styling */
#input-row {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(11, 50px);
    gap: 4px;
    padding: 5px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    background-color: #1a1a25;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}
/* Input Buttons Styling */
#input-buttons {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

#input-buttons button {
    font-size: 18px;
    padding: 10px 20px;
    margin: 0 5px; /* Adjust spacing between buttons */
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    color: #ffffff;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Backspace Button Styling */
#backspace-button {
    background: linear-gradient(135deg, #ff6d00 0%, #e65100 100%);
    box-shadow: 0 10px 25px -5px rgba(255, 109, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
}

#backspace-button:hover {
    background: linear-gradient(135deg, #ff7d00 0%, #f65d00 100%);
    box-shadow: 0 14px 30px -8px rgba(255, 109, 0, 0.5), 0 6px 15px rgba(0, 0, 0, 0.2);
}
/* Rearrange Button Styling */
#rearrange-button {
    background-color: #2196f3; /* Blue color */
    margin-top: 10px; /* Space above the button */
}

#rearrange-button:hover {
    background-color: #1976d2; /* Darker blue on hover */
}

/* Rearrange Animation */
#small-grid.rearrange-animation {
    animation: rearrangeFade 1s;
}

@keyframes rearrangeFade {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
    100% {
        opacity: 1;
    }
}
/* Letter Styling */
.small-letter-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #444; /* Dark background for letters */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.5s ease; /* Transition for FLIP */
}
/* Small Grid Wrapper Styling */
#small-grid-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 20px; /* Space from the main grid */
    padding: 10px;
    border-radius: 15px;
    background-color: #2a2a2a;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  }
#bonus-container {
    display: flex;
    flex-direction: column; /* Align children vertically */
    align-items: center; /* Center the label horizontally */
    padding: 10px;
    background-color: #2a2a2a;
    border-radius: 10px;
}

.bonus-modifiers {
    display: flex; /* Align modifiers horizontally */
    justify-content: center; /* Center the modifiers */
    gap: 10px; /* Space between modifiers */
    margin-top: 10px; /* Space between label and modifiers */
}

.bonus-cell {
    display: flex;
    position: relative;
    flex-direction: column; /* Ensure content inside each cell is stacked */
    align-items: center; /* Center content inside each cell */
    padding: 5px;
    background-color: #444;
    border-radius: 5px;
}

/* Bonus Cell Styling */
.bonus-cell {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    line-height: 50px;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    text-align: center;
    border: 2px solid transparent; /* Reserve space for border */

}

/* Different colors for different bonuses */
.bonus-cell.double-letter {
    background-color: #42a5f5; /* Blue for Double Letter */
    border: 2px solid #42a5f5;
}

.bonus-cell.triple-letter {
    background-color: #ab47bc; /* Purple for Triple Letter */
}

.bonus-cell.double-word {
    background-color: #ef5350; /* Red for Double Word */
}

.bonus-cell.triple-word {
    background-color: #ffd700; /* Gold for Triple Word */
    border: 2px solid #ffd700;
}
/* Available Letters Label */
#available-letters-label, #bonus-label {
    font-size: 16px;
    color: #888; /* Light grey color */
    text-align: center;
    margin-bottom: 8px; /* Space between label and small grid */
}

/* New Small Grid Styling */
#small-grid {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    gap: 10px;
    background-color: #1a1a25;
    padding: 10px;
    border-radius: 15px;
    align-self: center; /* Center the small grid vertically */
    position: relative; /* To enable absolute positioning of letters if needed */
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Small Cell Styling */
.small-cell {
    position: relative;
    width: 40px;
    height: 40px;
    background-color: #303045;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Letter inside small cell */
.small-letter {
    position: relative;
    font-size: 18px;
    font-weight: bold;
    color: #f5f5f7;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Point value in top-right corner */
.small-letter-value {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 12px;
    color: #ffd54f;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

/* Glow effect when letter is in use */
.small-cell.letter-in-use {
    box-shadow: 0 0 10px 2px #b2d096;
    border: 1px solid #fff;
}

/* Hover effect for small cells */
.small-cell:hover {
    transform: scale(1.05) translateY(-2px);
    background-color: #3d3d57;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Cell Styling */
.input-cell,
.cell {
    position: relative; /* Added for z-index to work */
    background-color: #252535;
    border-radius: 10px;
    line-height: 50px;
    font-size: 24px;
    font-weight: bold;
    color: #f5f5f7;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Value Cell Styling */
.value-cell {
    border-radius: 10px;
    line-height: 50px;
    font-size: 24px;
    font-weight: bold;
    color: #e0e0e0;
    background-color: #2f2727;
    text-align: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Styles for player and opponent values in half clash */
.player-value {
    color: #00c853;
    font-size: 16px;
}

.opponent-value {
    color: #ff1744;
    font-size: 16px;
}

/* Adjusting the value cell when showing two values */
.value-cell span {
    display: inline-block;
    margin: 0 2px;
}

.value-cell span + span::before {
    content: '/';
    color: #e0e0e0;
    margin-right: 2px;
}

/* Cell Border */
.cell {
    border: 1px solid #444;
}

/* Hover effect for cells */
.cell:hover {
    transform: scale(1.05);
    background-color: #303045;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Win Animation */
@keyframes win-glow {
    0% {
        box-shadow: 0 0 5px rgba(0, 200, 83, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 25px rgba(0, 200, 83, 0.8);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 5px rgba(0, 200, 83, 0.5);
        transform: scale(1);
    }
}

.win-animation {
    animation: win-glow 0.6s ease-in-out;
}

/* Lose Animation with Tilt and Fade */
@keyframes tilt-fade-out {
    0% {
        transform: rotateZ(0deg) scale(1);
        opacity: 1;
    }
    20% {
        transform: rotateZ(-10deg) scale(1.05);
        opacity: 1;
    }
    50% {
        transform: rotateZ(-10deg) scale(1.05);
        opacity: 1;
    }
    80% {
        transform: rotateZ(-10deg) scale(1.05);
        opacity: 0.5;
    }
    100% {
        transform: rotateZ(-10deg) scale(0.95);
        opacity: 0;
    }
}

/* Use this class for the new losing word effect */
.tilt-fade-out {
    animation: tilt-fade-out 0.8s forwards;
}

/* Lose Animation without Shaking (legacy) */
@keyframes color-fade {
    0% {
        background-color: var(--original-color, #252535);
        opacity: 1;
    }
    100% {
        background-color: var(--transition-color, #757575);
        opacity: 0; /* Instantly fade out at the end */
    }
}

.lose-animation {
    animation: color-fade 0.8s forwards;
}

/* Word Styling */
.player-word {
    background: linear-gradient(135deg, #00b347 0%, #008c37 100%);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(0, 200, 83, 0.4);
}

.opponent-word {
    background: linear-gradient(135deg, #ff3d60 0%, #e01d45 100%);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(255, 23, 68, 0.4);
}

/* Submit and Reset Button Styling */
#submit-word,
#reset-button {
    font-size: 18px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    color: #ffffff;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#submit-word {
    background: linear-gradient(135deg, #00d374 0%, #009d41 100%);
    margin-left: 10px; /* Add some space between input row and button */
}

#reset-button {
    background-color: #ff1744;
    display: none;
}

#submit-word:hover {
    background: linear-gradient(135deg, #00e67c 0%, #00ad47 100%);
}

/* Message Styling */
#message {
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 20px;
    height: 20px;
    font-weight: bold;
    color: #00e676;
    text-align: center;
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
    transition: all 0.3s ease;
}

/* Disabled Input Styling */
.greyed-out {
    background-color: #444;
    color: #888;
}

/* Glow effect for half clash row */
.glow-border {
    box-shadow: 0 0 10px 2px #ffd700;
    border: 2px solid #ffd700;
}

/* Styles for when the input row is locked */
.input-locked {
    opacity: 0.5;
    pointer-events: none;
}

/* Highlight invalid letters in the input row */
.invalid-letter {
    background-color: orange; /* Orange background for invalid letters */
    color: #ffffff;
}

/* Specific Styling for Back Buttons */
#back-to-main-menu-from-game {
    
    top: 10px;
    right: 10px;
}

/* Ascension Bar Container */
#ascension-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #ff3d60 0%, #e01d45 100%);
    color: #ffffff;
    font-size: 1.2em;
    font-weight: bold;
    padding: 8px 25px;
    width: 575px;
    border-radius: 10px;
    margin: 15px 0;
    transition: all 0.5s ease;
    box-shadow: 0 5px 15px rgba(255, 23, 68, 0.3);
}

/* Specific rule to hide Ascension Bar when it has the .hidden class */
#ascension-bar.hidden {
    display: none;
}

/* Daily Challenge Bar */
#daily-challenge-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #9c27b0 0%, #673ab7 100%);
    color: #ffffff;
    font-size: 1.2em;
    font-weight: bold;
    padding: 8px 25px;
    width: 610px; /* Match default grid width: 11*50px + 10*4px + 2*10px */
    border-radius: 10px;
    margin: 15px 0;
    transition: all 0.5s ease;
    box-shadow: 0 5px 15px rgba(156, 39, 176, 0.3);
    box-sizing: border-box;
}

#daily-challenge-bar.hidden {
    display: none;
}

.challenge-progress {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.challenge-score {
    display: flex;
    align-items: center;
    background-color: #000000;
    padding: 5px 10px;
    border-radius: 5px;
}

#bonus-container.hidden {
    display: none;
}
  
/* Ascension Target Section */
.ascension-target {
    display: flex;
    align-items: center;
}
  
/* Ascension Cumulative Section */
.ascension-cumulative {
    display: flex;
    align-items: center;
    background-color: #000000; /* Black background for the cumulative section */
    padding: 5px 10px;
    border-radius: 5px;
}
  
/* Optional: Style for the labels */
.ascension-target span:first-child,
.ascension-cumulative span:first-child {
    margin-right: 5px;
}
  
/* Success and Failure States */
#ascension-bar.success {
    background: linear-gradient(135deg, #00d374 0%, #009d41 100%);
    box-shadow: 0 5px 15px rgba(0, 200, 83, 0.3);
}
  
#ascension-bar.failure {
    background-color: #d32f2f; /* Darker red for failure */
}
  
/* Responsive Design */
@media (max-width: 600px) {
    #ascension-bar {
        flex-direction: column;
        align-items: flex-start;
    }
  
    .ascension-cumulative {
        margin-top: 10px;
    }
}
  
.bonus-selected {
    border: 2px solid #fff;
    box-shadow: 0 0 10px #fff;
}

/* Letter bonuses applied to cells */
.double-letter-cell {
    background-color: #42a5f5;
    border: 2px solid #42a5f5;
    z-index: 2;
}

.triple-letter-cell {
    background-color: #ab47bc !important; /* Light Blue */
    z-index: 2;
}

/* Word bonuses applied to the input row */
.double-word-row .input-cell {
    border: 2px solid #ef5350; /* Red for Double Word */
}

.triple-word-row .input-cell {
    border: 2px solid #ffd700; /* Gold for Triple Word */
}

.bonus-cell.unavailable {
    opacity: 0.5;
    pointer-events: none;
}

/* Modifier Count Styling */
.modifier-count {
    margin-top: 5px;
    font-size: 14px;
    color: #e0e0e0;
}
/* Word bonuses applied to grid cells */
.double-word-cell {
    border: 2px solid #ef5350; /* Red for Double Word */
}

.triple-word-cell {
    border: 2px solid #ffd700; /* Gold for Triple Word */
}

/* Ensure letter bonuses have higher z-index */
.double-letter-cell,
.triple-letter-cell {
    z-index: 2;
}

/* Scale-Up and Sparkle Animation */
@keyframes scaleUpSparkle {
    0% {
        transform: scale(1);
        background-color: #ff1744; /* Original bar color */
    }
    50% {
        transform: scale(1.1); /* Slightly expand */
        background-color: #d32f2f; /* Darker red */
    }
    100% {
        transform: scale(1);
        background-color: #ff1744; /* Back to original color */
    }
}

@keyframes sparkle {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(360deg);
    }
}

/* Apply the scale-up animation to the ascension bar */
.scale-up {
    animation: scaleUpSparkle 1s ease-out;
}

/* Sparkle effect */
.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #ffd700 100%);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 1.5s ease-out;
    box-shadow: 0 0 10px 2px rgba(255, 215, 0, 0.5);
}
/* Right-Side Container Styling */
#right-side-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 115px;
    margin-left: 20px;
    padding: 10px;
    border-radius: 15px;
    margin-top: -150px;

  }
  
  /* Back Button in Right Side */
  #right-side-container #back-to-main-menu-from-game {
    align-self: flex-start; /* Align the button to the top-left */
    margin: 0 0 10px 0; /* Adjust margins for positioning */
    background: linear-gradient(135deg, #ff6d00 0%, #e65100 100%);
    color: #ffffff;
    font-size: 16px;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 25px -5px rgba(255, 109, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
  }
  
  #right-side-container #back-to-main-menu-from-game:hover {
    background: linear-gradient(135deg, #ff7d00 0%, #f65d00 100%);
    background-color: #e65100;
  }

  /* Overlay Styles */
#overlay, #clash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 14, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Ensure it appears above all other elements */
  }
  
  #clash-overlay.hidden {
    display: none;
}
  /* Overlay Content */
  #overlay-content, #clash-overlay-content {
    background-color: #12121a;
    color: #ffffff;
    text-align: center;
    padding: 20px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 100px rgba(0, 0, 0, 0.2);
  }
  
  /* Overlay Title */
  #overlay-title, #clash-overlay-title {
    font-size: 28px;
    margin-bottom: 20px;
    color: #ff9800; /* Highlighted color for the title */
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(255, 152, 0, 0.3);
  }
  
  /* Overlay Score */
  #overlay-score {
    font-size: 18px;
    margin-bottom: 20px;
  }
  
  #overlay.hidden {
    display: none;
}
  /* Buttons in the Overlay */
  #overlay-content .menu-button {
    font-size: 16px;
    padding: 10px 20px;
    margin: 10px;
    background-color: #4caf50; /* Green for Play Again */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: #ffffff;
    transition: transform 0.2s, background-color 0.3s;
  }
  
  /* Optional: Different text colors for win/lose states */
.win-text {
    color: #00c853; /* Green */
}
.lose-text {
    color: #ff1744; /* Red */
}
  #overlay-content .menu-button:hover {
    transform: scale(1.1);
    background-color: #388e3c; /* Darker green on hover */
  }
  
  #share-button {
    background-color: #2196f3; /* Blue for Share */
  }
  
  #share-button:hover {
    background-color: #1976d2; /* Darker blue on hover */
  }
  
  /* Fade-in Animation - Removed to prevent logo shifting */
  
 /* Glow animation for grid cells */
@keyframes enhanced-glow {
    0% {
        box-shadow: 0 0 5px rgba(0, 200, 83, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 200, 83, 0.7),
                    inset 0 0 8px rgba(0, 200, 83, 0.4);
    }
    100% {
        box-shadow: 0 0 5px rgba(0, 200, 83, 0.4);
    }
}

.grid-cell-glow {
    animation: enhanced-glow 1.8s ease-in-out infinite;
}

/* Red Glow Animation for Grid Cells */
@keyframes red-glow {
    0% {
        box-shadow: 0 0 5px 2px #d32f2f;
        background-color: #ff1744;
    }
    50% {
        box-shadow: 0 0 8px 5px #d32f2f;
        background-color: #ff5252;
    }
    100% {
        box-shadow: 0 0 5px 2px #d32f2f;
        background-color: #ff1744;
    }
}

.grid-cell-red-glow {
    animation: red-glow 0.9s ease-in-out;
}

.ascension-level {
    background-color: #d32f2f; /* Redder background color */
    color: #ffffff;
    padding: 5px 10px;
    border-radius: 5px;
    margin-right: 10px; /* Add some spacing between level and target */
}
/* Oscillating color fill effect */
/* Shimmer effect: switch to non-intrusive box-shadow pulse to avoid clashing with modifier backgrounds */
.shimmer-effect {
    /* Do not touch background; use subtle glow */
    box-shadow: inset 0 0 0 2px rgba(255, 213, 79, 0.6), 0 0 6px rgba(255, 213, 79, 0.4);
    animation: shimmerPulse 1.4s ease-in-out infinite;
}

@keyframes shimmerPulse {
    0% {
        box-shadow: inset 0 0 0 1px rgba(255, 213, 79, 0.4), 0 0 2px rgba(255, 213, 79, 0.2);
    }
    50% {
        box-shadow: inset 0 0 0 3px rgba(255, 213, 79, 0.85), 0 0 10px rgba(255, 213, 79, 0.55);
    }
    100% {
        box-shadow: inset 0 0 0 1px rgba(255, 213, 79, 0.4), 0 0 2px rgba(255, 213, 79, 0.2);
    }
}

 /* For the 10th input cell (index 9, but nth-child(10) in CSS) */
#input-row .input-cell:nth-child(10) {
    position: relative; /* Ensure positioning context for the pseudo-element */
}

/* Only show +10 if the 10th input cell is empty */
#input-row .input-cell:nth-child(10):empty::after {
    content: '+10';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.3); /* Light grey, semi-transparent */
    font-size: 18px;
    font-weight: bold;
    pointer-events: none;
    text-shadow: 1px 1px 2px #333333;
}
/* LEGAL OVERLAY (full screen) */
#legal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); /* Dark background behind overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Above everything else */
  }
  
  #legal-overlay.hidden {
    display: none;
  }
  
  /* Container that holds the entire legal content (header + scrollable body) */
  #legal-overlay-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh; /* prevents overlay from exceeding 90% of viewport height */
    background-color: #1c1c1c;
    color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* so only .legal-body scrolls, not the header */
  }
  
  /* Sticky header bar that always shows the "X" */
  .legal-header {
    position: sticky;
    top: 0;
    background-color: #1c1c1c; /* match overlay content color */
    border-bottom: 1px solid #444;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
  }
  
  /* The close button */
  #legal-close-button {
    background: none;
    border: none;
    color: #ccc;
    font-size: 22px;
    cursor: pointer;
  }
  
  /* Scrollable body area for the long text */
  .legal-body {
    padding: 20px;
    max-height: calc(80vh - 60px); /* subtract header's approximate height */
    overflow-y: auto;
  }
  
  /* Simple fade-in animation */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: scale(0.9);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
 



  /* Base styles (default view) already apply here */

/* Optional: Target screens larger than 1920px (HD resolution) */
@media (min-width: 1920px) {


    body {
        font-size: 1em; /* Ensure no scaling issues */
        scale: 1;
    }

    #game-container {
        display: none;
        justify-content: center;
        align-items: center;
        margin: 0px;
        background-color: #1c1c1c;
        padding: 10px;
        border-radius: 20px;
        box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.5);
        max-width: 2000px;
        flex-direction: column;
        overflow-y: auto;
        position: relative;
    }

    #ascension-bar {
        display: flex;
        background-color: #ff1744;
        color: #ffffff;
        font-size: 1.2em;
        font-weight: bold;
        padding: 5px 20px;
        width: 560px;
        position: relative;
        right: 240px;
        border-radius: 5px;
        margin: 10px 0;
        transition: background-color 0.5s ease;
        justify-content: space-between;
    
    }

    #grid {
        grid-template-columns: repeat(11, 50px); /* Keep default grid sizes */
        grid-template-rows: repeat(10, 50px);
        gap: 4px; /* Consistent gaps */
    }

    #input-row {
        grid-template-columns: repeat(11, 50px);
        grid-template-rows: 50px;
        gap: 4px;
    }

    #small-grid {
        grid-template-columns: repeat(6, 50px); /* Default sizes for small grid */
        grid-auto-rows: 50px;
        gap: 10px;
    }

    #bonus-container {
        flex-direction: row; /* Default horizontal layout */
        gap: 10px; /* Consistent spacing */
    }

    .bonus-cell {
        width: 50px; /* Default size */
        height: 50px;
        font-size: 14px;
    }

    .cell {
        font-size: 24px; /* Default font size */
    }

  

    button {
        font-size: 18px;
        padding: 15px 30px;
    }

    .menu-button {
        font-size: 18px;
        padding: 12px 24px;
    }

    #message {
        font-size: 20px;
    }

    #clash-back-button {
        position: static;
        top: 10px;
        left: 850px;
        z-index: 10;
        background-color: #ff9800;
        color: #ffffff;
        font-size: 16px;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
        transition: background-color 0.3s ease;
    }
}


/* Tablets: max-width 768px */
@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
        align-items: center;
        max-width: 100%;
        margin: 0;
        padding: 15px;
    }

    #grid-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    #grid {
        grid-template-columns: repeat(11, 28px); /* Slightly larger grid */
        grid-template-rows: repeat(10, 28px);
        gap: 3px;
    }

    #daily-challenge-bar {
        width: 338px; /* Match grid width: 11*28px + 10*3px */
    }

    .cell {
        display: flex;
    justify-content: center; /* Horizontal alignment */
    align-items: center;    /* Vertical alignment */
    position: relative;
    line-height: normal;
        font-size: 18px;
        font-weight: bold;
        color: #e0e0e0;
        border-radius: 2px;
        text-align: center;
        transition: transform 0.3s ease, background-color 0.3s ease;
        border: 0px solid #444;
    }

    #input-row {
        grid-template-columns: repeat(11, 28px);
        grid-template-rows: 28px;
        gap: 2.5px;
    }

    #small-grid-wrapper {
        padding: 10px;
        margin-left: 0;
        width: 100%; /* Utilize full width */
    }

    #small-grid {
        display: grid;
        grid-template-columns: repeat(6, 35px);
        grid-auto-rows: 35px;
        gap: 10px;
    }

    #available-letters-label {
        font-size: 14px;
    }

    #bonus-container {
        flex-direction: row;
        gap: 10px; /* More spacing for tablets */
        padding: 10px;
    }

    .bonus-cell {
        width: 35px;
        height: 35px;
        font-size: 14px;
        line-height: 35px;
    }

    #ascension-bar {
        width: 375px; /* Fully utilize space */
        height: 28px;
        font-size: 0.9em;
        padding: 4px;
    }

    #input-buttons button {
        font-size: 16px;
        padding: 10px 15px;
    }

    .menu-button {
        font-size: 18px;
        padding: 12px 24px;
    }

    #back-score-container {
        position: absolute;
        top: 10px;
        right: -5px;
        display: flex;
        align-items: center;
        column-gap: 70px;
        z-index: 10;
        flex-direction: row;
        justify-content: space-around;
    }

    #right-side-container {
        margin-left: 0;
         margin-top: 20px; 
        gap: 5px;
        width: 100%;
        align-items: center;
        
    }

    .input-cell {
    
        line-height: normal;       
        font-size: 24px;
            font-weight: bold;
           
        }

    #input-row .input-cell:nth-child(10):empty::after {
        font-size: 10px;   
    }
    #clash-back-button {
        position: absolute;
        top: 5px;
        left: 5px;
        z-index: 10;
        background-color: #ff9800;
        color: #ffffff;
        font-size: 16px;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
        transition: background-color 0.3s ease;
    }
    @media (max-width: 480px) {
      #clash-back-button,
      #back-to-main-menu-from-game,
      #back-to-play-menu,
      #back-to-main-menu,
      #rearrange-button {
        font-size: 8.8px !important; /* 45% smaller than 16px */
        padding: 5.5px 8.25px !important; /* 45% smaller than 10px 15px */
        border-radius: 2.75px !important;
      }
      #rearrange-button {
        top: 2px !important;
        right: 2px !important;
        width: auto !important;
        height: auto !important;
      }
    }
    
    #message {
        font-size: 15px;
        width: 350px;
        height: 28px;
    }
}
 

@media (max-width: 600px) {
    /* Make the main container vertical on mobile */
    #game-container {
      flex-direction: column;
      align-items: center;
      max-width: 100%; 
      margin: 0;
      padding: 10px;
    }
  
    /* Stack grid and right-side-container vertically */
    #grid-wrapper {
      flex-direction: column;
      gap: 20px;
      width: 100%;
      max-width: 100%;
    }

    .mode-option {
        display: flex;
        flex-direction: column;
        align-items: center;
        max-width: 500px;
    }

    /* NOTE: .mode-container spacing handled by more specific breakpoints above */

     /* Adjust font size for the play menu buttons */
     .menu-button {
        font-size: 20px; /* Increase font size for better readability */
        padding: 15px 25px; /* Adjust padding to maintain button proportions */
    }
    #enter-button {
        font-size: 20px; /* Increase font size for better readability */
        padding: 15px 25px; /* Adjust padding to maintain button proportions */
    }

      /* Back Button for Clash Mode on Mobile */
#clash-back-button {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 10; /* Ensure it stays above other elements */
    background-color: #ff9800;
    color: #ffffff;
    font-size: 16px;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
    #bonus-container {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        padding: 10px;
        background-color: #2a2a2a;
        border-radius: 10px;
    }

    /* Ensure all primary containers fit the viewport width */
    #main-grid-container,
    #right-side-container {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Input buttons row responsive */
    #input-buttons {
        display: flex;
        gap: 10px;
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
        padding: 8px 0;
    }
    #input-buttons button {
        flex: 1 1 0;
        min-width: 0; /* allow shrink */
        max-width: 48%;
        font-size: 14px;
        padding: 10px 8px;
    }

    .bonus-modifiers {
        display: flex;
        justify-content: center;
        gap: 10px;
        margin-top: 0px; 
    }
    .bonus-cell {
        width: 50px;
        height: 30px;
       line-height: 15px;
       border-radius: 0px;
        font-size: 14px;
        font-weight: bold;
        color: #fff;
        border: 2px solid transparent;
    }

    .small-cell {
        position: relative;
        width: 35px;
        height: 35px;
        background-color: #555;
        border-radius: 8px;
        transition: transform 0.3s ease, background-color 0.3s ease;
    }

    #input-area {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 0;
        z-index: 20;
        margin-bottom: 50px;
    }

    #input-buttons button {
        font-size: 16px;
        padding: 8px 15px;
        margin: 0 5px;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        transition: background-color 0.3s ease, transform 0.2s ease;
        color: #ffffff;
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    }
    #bonus-label {
        padding: 5px;
    }
    /* Adjust grid sizing for mobile screens */
    #grid {
      grid-template-columns: repeat(11, 30px); /* smaller cells */
      grid-template-rows: repeat(10, 30px);
      gap: 2px;
    }
    
    /* Daily Challenge grid mobile adjustments */
    #grid.daily-challenge-grid {
      grid-template-rows: repeat(4, 30px);
    }
    
    /* Daily Challenge bar mobile layout */
    #daily-challenge-bar {
      width: 350px; /* Match grid width: 11*30px + 10*2px */
      padding: 8px 12px;
      font-size: 14px;
      margin: 5px 0;
    }
    
    #daily-challenge-bar .challenge-info {
      font-size: 12px;
    }
    
    /* Game container mobile spacing for Daily Challenge */
    #game-container {
      padding: 5px;
    }
    
    #main-grid-container {
      margin-top: 10px;
    }
    
    #input-row {
    grid-template-columns: repeat(11, 30px);
    grid-template-rows: 30px;
      }
    /* Smaller buttons on mobile */
    button {
      font-size: 14px;
      padding: 10px 15px;
    }
  
    /* Right-side-container below the grid */
    #right-side-container {
      margin-left: 0;
      /*margin-top: 20px;*/
      gap: 5px;
      width: 100%;
      align-items: center;
      margin-top: -70px;
    }
  
    /* Adjust small-grid for mobile */
    #small-grid {
        display: grid;
        grid-template-columns: repeat(6, 35px);
        grid-auto-rows: 35px;
        gap: 10px;
    }
  
    /* Ascension bar scaled down */
    #ascension-bar {
        display: flex;
      width: 80%;
      font-size: 1em;
      padding: 5px;
      align-items: flex-end;
flex-direction: row;
margin: 0px;
height: 25px;
    }
    
    #small-grid-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 5px;
        margin-left: 0px;
        border-radius: 15px;
        background-color: #2a2a2a;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        position: relative; /* To position the button within this container */
    }
    
    #rearrange-button {
        position: absolute;
        top: -2px; /* Adjust as needed for spacing */
        right: 5px; /* Align to the top-right corner */
        background-color: #2196f3; /* Keep existing button styles */
        font-size: 14px; /* Adjust size for mobile */
        padding: 8px 12px; /* Adjust padding for compact size */
        z-index: 10; /* Ensure it appears above other elements */
    }
    
    #available-letters-label {
        margin-bottom: 10px; /* Add spacing between text and grid */
        margin-top: 10px;
        font-size: 14px; /* Adjust size if needed */
        text-align: center;
    }
    
    small-letter-value {
        position: absolute;
        top: 2px;
        right: 2px;
        font-size: 12px;
        color: #e5e0b6;
    }
    /* Adjust font sizes for mobile */
    h1.game-title, #overlay-title {
      font-size: 24px;
    }
  
    .game-title {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        font-size: 48px;
        color: #e5e0b6;
        margin: 0;
        transform: translateX(-50%);
    }
    #message {
      font-size: 16px;
      height: 12px; /* Let it grow if needed */
    }
  
    /* Overlay more mobile-friendly */
    #overlay-content {
        width: 100%;
        transform: translateY(-70px);
        max-width: 300px;
        scale: .8;
    }

    #right-side-container #back-to-main-menu-from-game {
        align-self: flex-start;
        /* margin: 0 0 10px 0; */
        background-color: #ff9800;
        color: #ffffff;
        font-size: 16px;
        padding: 10px 15px;
        border-radius: 5px;
        top: 5px;
    left: 5px;
    z-index: 10;
        cursor: pointer;
        transition: background-color 0.3s ease;
    }

    .input-cell, .cell {
        position: relative;
        border-radius: 5px;
line-height: normal;       
 font-size: 24px;
        font-weight: bold;
        color: #e0e0e0;
        text-align: center;
        transition: transform 0.3s ease, background-color 0.3s ease;
        border: 0px solid #444;
    }

        #back-score-container {
            position: absolute;
            top: 0px;
            right: -20px;
            display: flex;
            align-items: center;
            column-gap: 150px;
            z-index: 10;
            flex-direction: row;
            justify-content: space-around;
    }
  }






/* Larger Phones: max-width 480px */
@media (max-width: 480px) {

    .game-title {
        position: absolute;
        left: 50%;
        font-size: 48px;
        color: #e5e0b6;
        margin: 0;
        transform: translate(-50%, -90px);
    }
    /* NOTE: .mode-container and .mode-option spacing handled by more specific breakpoint above */

    #game-container {
        flex-direction: column;
        align-items: center;
        max-width: 100%;
        margin: 0;
        padding: 10px;
    }

    #grid-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    #grid {
        grid-template-columns: repeat(11, 25px); /* Slightly larger grid */
        grid-template-rows: repeat(10, 25px);
        gap: 2px;
    }

    #grid.daily-challenge-grid {
        grid-template-rows: repeat(4, 25px);
    }

    #daily-challenge-bar {
        width: 295px; /* Match grid width: 11*25px + 10*2px */
    }

    #input-row {
        grid-template-columns: repeat(11, 25px);
        grid-template-rows: 25px;
        gap: 1px;
    }

    #small-grid-wrapper {
        padding: 7px;
        margin-left: 0;
        width: 100%; /* Utilize full width */
    }
 

    #small-grid {
        display: grid;
        grid-template-columns: repeat(6, 35px);
        grid-auto-rows: 35px;
        gap: 10px;
    }

    #available-letters-label {
        font-size: 12px;
    }

    #bonus-container {
        flex-direction: row; /* Horizontal layout */
        gap: 6px; /* Adjust spacing */
        padding: 5px;
    }

    .bonus-cell {
        width: 30px;
        height: 30px;
        font-size: 12px;
        line-height: 30px;
    }

    .cell {
        display: flex;
    justify-content: center; /* Horizontal alignment */
    align-items: center;    /* Vertical alignment */
    position: relative;
    line-height: normal;
        font-size: 18px;
        font-weight: bold;
        color: #e0e0e0;
        text-align: center;
        transition: transform 0.3s ease, background-color 0.3s ease;
        border: 0px solid #444;
    }

    
    #ascension-bar {
        width: 95%; /* Fit larger screens */
        height: 24px;
        font-size: 0.8em;
        padding: 3px;
    }

    #input-buttons button {
        font-size: 14px; /* Adjust button size */
        padding: 8px 10px;
    }

    .menu-button {
        font-size: 16px;
        padding: 10px 20px;
    }

    #back-score-container {
    
            position: absolute;
            top: 0px;
            right: -5px;
            display: flex;
            align-items: center;
            column-gap: 120px;
            z-index: 10;
            flex-direction: row;
            justify-content: space-around;
        
    }

    #message {
        font-size: 12px;
        height: 12px;
    }

    #input-row .input-cell:nth-child(10):empty::after {
        font-size: 10px;   
    }
}

/* Small Phones: max-width 360px */
@media (max-width: 360px) {

    .game-title {
        position: absolute;
        left: 50%;
        font-size: 48px;
        color: #e5e0b6;
        margin: 0;
        transform: translate(-50%, -90px);
    }
    /* NOTE: .mode-container and .mode-option spacing handled by 375px breakpoint above */

    #game-container {
        flex-direction: column;
        align-items: center;
        max-width: 100%;
        margin: 0;
        padding: 5px;
    }

    #grid-wrapper {
        flex-direction: column;
        gap: 10px; /* Compact spacing */
    }

    #grid {
        grid-template-columns: repeat(11, 18px); /* Smaller grid */
        grid-template-rows: repeat(10, 18px);
        gap: 1px; /* Minimized gap */
    }

    #grid.daily-challenge-grid {
        grid-template-rows: repeat(4, 18px);
    }

    #daily-challenge-bar {
        width: 208px; /* Match grid width: 11*18px + 10*1px */
    }

    #input-row {
        grid-template-columns: repeat(11, 18px);
        grid-template-rows: 18px;
    }

    #small-grid-wrapper {
        padding: 5px;
        margin-left: 0;
        width: 90%; /* Ensure it fits the screen */
    }

    #small-grid {
        display: grid;
        grid-template-columns: repeat(6, 20px); /* Adjust to fit two rows */
        grid-auto-rows: 20px;
        gap: 3px; /* Minimized gap */
    }

    #available-letters-label {
        font-size: 10px; /* Adjusted font size */
    }

    #bonus-container {
        flex-direction: column; /* Stack vertically */
        align-items: center;
        gap: 3px; /* Reduced gap */
        padding: 3px; /* Compact padding */
    }

    .bonus-cell {
        width: 25px; /* Smaller bonus cells */
        height: 25px;
        font-size: 10px;
        line-height: 25px;
    }

    #ascension-bar {
        width: 90%; /* Fit smaller screens */
        height: 18px;
        font-size: 0.7em;
        padding: 2px;
    }
    #message {
        font-size: 12px;
        height: 12px;
    }
    #input-row .input-cell:nth-child(10):empty::after {
        font-size: 10px;   
    }

}

  /* Small Phones: max-width 320px */
@media (max-width: 320px) {

    .game-title {
        position: absolute;
        left: 50%;
        font-size: 48px;
        color: #e5e0b6;
        margin: 0;
        transform: translate(-50%, -90px);
    }
    /* NOTE: .mode-container and .mode-option spacing handled by more specific breakpoints above */
    #game-container {
        flex-direction: column;
        align-items: center;
        max-width: 100%;
        margin: 0;
        padding: 5px;
    }

    #grid-wrapper {
        flex-direction: column;
        gap: 10px; /* Compact spacing */
    }

    #grid {
        grid-template-columns: repeat(11, 23px); /* Smaller grid */
        grid-template-rows: repeat(10, 23px);
        gap: 1px; /* Minimized gap */
    }

    #grid.daily-challenge-grid {
        grid-template-rows: repeat(4, 23px);
    }

    #daily-challenge-bar {
        width: 263px; /* Match grid width: 11*23px + 10*1px */
    }

    #input-row {
        grid-template-columns: repeat(11, 23px);
        grid-template-rows: 23px;
        gap: 1px;
    }

    #input-row .input-cell:nth-child(10):empty::after {
        font-size: 10px;   
    }
    #small-grid-wrapper {
        padding: 10px;
        margin-left: 0;
        width: 100%;
    }

    #small-grid {
        display: grid;
        grid-template-columns: repeat(6, 28px);
        grid-auto-rows: 28px;
        gap: 10px;
    }

    #available-letters-label {
        font-size: 10px; /* Adjusted font size */
    }

    #bonus-container {
        flex-direction: column; /* Stack vertically */
        align-items: center;
        gap: 3px; /* Reduced gap */
        padding: 3px; /* Compact padding */
    }

    .bonus-cell {
        width: 25px; /* Smaller bonus cells */
        height: 25px;
        font-size: 10px;
        line-height: 25px;
    }

    #ascension-bar {
        width: 100%; /* Fit smaller screens */
        height: 24px;
        font-size: 0.7em;
        padding: 2px;
    }
    #message {
        font-size: 10px;
        height: 12px;
        width: 90%;
    }
    #input-buttons button {
        font-size: 12px; /* Compact button size */
        padding: 6px 8px;
    }

    .menu-button {
        font-size: 14px; /* Smaller font size */
        padding: 8px 16px; /* Adjust padding */
    }

    #back-score-container {
        position: absolute;
        top: 5px;
        right: -5px;
        display: flex;
        align-items: center;
        column-gap: 150px;
        z-index: 10;
        flex-direction: row;
        justify-content: space-around;
        scale: .9;
    }


.cell {
    position: relative; /* Added for z-index to work */
    font-size: 20px;
    font-weight: bold;
    color: #e0e0e0;
    text-align: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.input-cell {
    
line-height: normal;       
font-size: 20px;
    font-weight: bold;
   
}


}

/* Enhanced Letter Placement Animation */
@keyframes letterPlaced {
    0% {
        transform: scale(1.2) translateY(-5px);
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    }
    50% {
        transform: scale(1.1) translateY(0);
    }
    100% {
        transform: scale(1);
        text-shadow: none;
    }
}

.letter-placed {
    animation: letterPlaced 0.3s ease-out;
}

/* Word Submission Success Animation */
@keyframes wordSuccess {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.05);
        filter: brightness(1.3);
        box-shadow: 0 0 15px rgba(0, 200, 83, 0.6);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

.word-success {
    animation: wordSuccess 0.6s ease-out;
}

/* Enhanced Bonus Application Animation */
@keyframes bonusApplied {
    0% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.15) rotate(-5deg);
    }
    75% {
        transform: scale(1.15) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.bonus-applied {
    animation: bonusApplied 0.4s ease-in-out;
}

/* Sparkle Effect for High-Value Words */
@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    pointer-events: none;
}

/* Enhanced Invalid Word Shake */
@keyframes invalidShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.invalid-shake {
    animation: invalidShake 0.4s ease-in-out;
}

/* Letter Hover Effect Enhancement */
.small-cell:hover .small-letter {
    transform: translateY(-2px);
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

/* Enhanced Win Animation */
@keyframes win-celebration {
    0% {
        transform: scale(1);
        box-shadow: 0 0 5px #00c853;
    }
    25% {
        transform: scale(1.1) rotate(-2deg);
        box-shadow: 0 0 20px #00c853;
    }
    75% {
        transform: scale(1.1) rotate(2deg);
        box-shadow: 0 0 20px #00c853;
    }
    100% {
        transform: scale(1) rotate(0);
        box-shadow: 0 0 5px #00c853;
    }
}

.win-animation {
    animation: win-celebration 0.8s ease-in-out;
}

/* Enhanced Bonus Selection Animation */
@keyframes bonusSelect {
    0% {
        transform: scale(1);
        box-shadow: none;
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }
}

.bonus-selected {
    animation: bonusSelect 0.4s ease-out forwards;
}

/* Enhanced Grid Glow Animation */
@keyframes enhanced-glow {
    0% {
        box-shadow: 0 0 5px rgba(0, 200, 83, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 200, 83, 0.7),
                    inset 0 0 8px rgba(0, 200, 83, 0.4);
    }
    100% {
        box-shadow: 0 0 5px rgba(0, 200, 83, 0.4);
    }
}

.grid-cell-glow {
    animation: enhanced-glow 1.8s ease-in-out infinite;
}

/* Score Increment Animation */
@keyframes scoreIncrement {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) translateY(-10px);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) translateY(-20px);
        opacity: 0;
    }
}

.score-increment {
    position: absolute;
    animation: scoreIncrement 0.8s ease-out forwards;
    color: #00c853;
    font-weight: bold;
    pointer-events: none;
}

/* Enhanced Button Hover Animation */
button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Floating Points Animation */
@keyframes floatingPoints {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-30px) scale(1.2);
        opacity: 0;
    }
}

.floating-points {
    position: absolute;
    animation: floatingPoints 1s ease-out forwards;
    pointer-events: none;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

/* Special styling for enter button */
#enter-button {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    box-shadow: 0 10px 25px -5px rgba(76, 175, 80, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
    font-size: 20px;
    font-weight: 700;
    padding: 18px 40px;
}

#enter-button:hover {
    background: linear-gradient(135deg, #66BB6A 0%, #4CAF50 100%);
    box-shadow: 0 14px 30px -8px rgba(76, 175, 80, 0.5), 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* Daily Challenge Button - Special styling */
.daily-challenge-button {
    background: linear-gradient(135deg, #8A2BE2, #9370DB);
    color: white;
    border: 2px solid #7B68EE;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-weight: 700;
}

.daily-challenge-button.completed {
    background: linear-gradient(135deg, #32CD32, #228B22);
    border: 2px solid #006400;
}

.daily-challenge-button.failed {
    background: linear-gradient(135deg, #DC143C, #B22222);
    border: 2px solid #8B0000;
}

.daily-challenge-button.attempted {
    background: linear-gradient(135deg, #FF8C00, #FF6347);
    border: 2px solid #FF4500;
}

/* Daily Challenge Modal */
.daily-challenge-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.daily-challenge-modal.show {
    opacity: 1;
}

.daily-challenge-modal-content {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    border: 2px solid #444;
    position: relative;
}

.daily-challenge-modal-content h2 {
    color: #ffffff;
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.daily-challenge-modal-content p {
    color: #e0e0e0;
    margin: 0 0 25px 0;
    font-size: 16px;
    line-height: 1.5;
    white-space: pre-line;
}

.modal-close-x {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close-x:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.modal-ok-button {
    background: linear-gradient(135deg, #8A2BE2, #9370DB);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.modal-ok-button:hover {
    background: linear-gradient(135deg, #9370DB, #8A2BE2);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.4);
    transform: translateY(-2px);
}

.modal-ok-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(138, 43, 226, 0.2);
}

.daily-challenge-button:hover {
    background: linear-gradient(135deg, #ab47bc 0%, #9c27b0 100%);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.4);
    border-color: #9c27b0;
}

.daily-challenge-button:active {
    background: linear-gradient(135deg, #673ab7 0%, #5e35b1 100%);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.2);
}

/* Enhanced letter bonuses applied to cells */
.double-letter-cell {
    background: linear-gradient(135deg, #42a5f5 0%, #1976d2 100%);
    border: 1px solid rgba(66, 165, 245, 0.3);
    z-index: 2;
    box-shadow: 0 0 15px rgba(66, 165, 245, 0.4);
}

.triple-letter-cell {
    background: linear-gradient(135deg, #ab47bc 0%, #7b1fa2 100%) !important;
    z-index: 2;
    box-shadow: 0 0 15px rgba(171, 71, 188, 0.4);
}

/* Word bonuses applied to grid cells */
.double-word-cell {
    border: 2px solid #ef5350;
    box-shadow: 0 0 15px rgba(239, 83, 80, 0.4);
}

.triple-word-cell {
    border: 2px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

/* Enhanced bonus selection */
.bonus-selected {
    border: 2px solid #fff;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    transform: translateY(-3px);
}

/* Enhance overlay content for better readability */
#overlay-score, #overlay-level, #overlay-progress {
    font-size: 18px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

/* Modern cookie consent banner */
#cookie-consent-banner {
    background-color: rgba(18, 18, 30, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
}

#cookie-consent-accept {
    background: linear-gradient(135deg, #00d374 0%, #00a042 100%);
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#cookie-consent-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Legal overlay modern styling */
#legal-overlay-content {
    background-color: #12121a;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.legal-header {
    background-color: #12121a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#legal-button {
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

#legal-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Enhanced glow effect for half clash row */
.glow-border {
    box-shadow: 0 0 15px 2px rgba(255, 215, 0, 0.5);
    border: 2px solid #ffd700;
}

/* Enhanced floating points animation */
.floating-points {
    font-size: 22px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

/* Enhanced score display */
#player-score {
    font-size: 16px;
    color: #f5f5f7;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Enhanced letter placement */
.letter-placed {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* New Typing Animation for Letters */
@keyframes typingPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); filter: brightness(1.2); }
    100% { transform: scale(1); }
}

.typing-animation {
    animation: typingPulse 0.2s ease-out;
}

/* Letter Drop Animation */
@keyframes letterDrop {
    0% { 
        transform: translateY(-15px); 
        opacity: 0; 
    }
    70% { 
        transform: translateY(2px); 
        opacity: 1; 
    }
    85% { 
        transform: translateY(-1px); 
    }
    100% { 
        transform: translateY(0); 
    }
}

.letter-drop {
    animation: letterDrop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1.2) forwards;
}

/* Word Grid Placement Animation */
@keyframes wordPlacement {
    0% { 
        transform: translateY(-5px) scale(0.95);
        filter: brightness(0.8);
        opacity: 0.7;
    }
    60% { 
        transform: translateY(2px) scale(1.03);
        filter: brightness(1.2);
        opacity: 1;
    }
    100% { 
        transform: translateY(0) scale(1);
        filter: brightness(1);
    }
}

.word-placement {
    animation: wordPlacement 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Row Clear Animation */
@keyframes rowClear {
    0% { transform: scale(1); }
    30% { transform: scale(1.03); filter: brightness(1.2); }
    100% { 
        transform: scale(0.95);
        opacity: 0; 
    }
}

.row-clear {
    animation: rowClear 0.7s ease-in forwards;
}

/* Message Popup Animation */
@keyframes messagePopup {
    0% { 
        transform: translateY(10px) scale(0.8);
        opacity: 0;
    }
    15% { 
        transform: translateY(-5px) scale(1.1);
        opacity: 1;
    }
    80% { 
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% { 
        transform: translateY(0) scale(1);
        opacity: 0;
    }
}

.message-popup {
    animation: messagePopup 2s ease-out forwards;
}

/* Board Shake on Error */
@keyframes boardShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50% { transform: translateX(-2px); }
    20%, 40%, 60% { transform: translateX(2px); }
    70% { transform: translateX(-1px); }
    80% { transform: translateX(1px); }
    90% { transform: translateX(-1px); }
}

.board-shake {
    animation: boardShake 0.5s ease-in-out;
}

/* Success Pulse for Ascension Progress */
@keyframes ascensionPulse {
    0% { transform: scale(1); }
    50% { 
        transform: scale(1.03);
        box-shadow: 0 0 20px rgba(0, 230, 118, 0.5);
        background-color: rgba(0, 230, 118, 0.9);
    }
    100% { transform: scale(1); }
}

.ascension-pulse {
    animation: ascensionPulse 1s ease-in-out;
}

/* Letter Matching Highlight */
@keyframes letterMatch {
    0% { background-color: inherit; }
    30% { 
        background-color: rgba(109, 86, 216, 0.7);
        box-shadow: 0 0 12px rgba(109, 86, 216, 0.5);
    }
    100% { background-color: inherit; }
}

.letter-match {
    animation: letterMatch 0.8s ease-out;
}

/* Opponent Move Warning Flash */
@keyframes opponentWarning {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 23, 68, 0); }
    50% { box-shadow: 0 0 20px rgba(255, 23, 68, 0.6); }
}

.opponent-warning {
    animation: opponentWarning 1.2s ease-in-out infinite;
}

/* Score Update Bounce */
@keyframes scoreUpdate {
    0% { transform: scale(1); }
    50% { 
        transform: scale(1.15);
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    }
    100% { transform: scale(1); }
}

.score-update {
    animation: scoreUpdate 0.5s cubic-bezier(0.2, 0.8, 0.2, 1.2);
}

/* Grid Cell Reveal Animation */
@keyframes cellReveal {
    0% {
        transform: rotateY(90deg) scale(0.9);
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.cell-reveal {
    animation: cellReveal 0.4s cubic-bezier(0.3, 1, 0.3, 1) forwards;
    backface-visibility: hidden;
    perspective: 800px;
}

/* Enhanced Bonus Selection Effect */
@keyframes bonusSelectPulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    }
    50% { 
        transform: scale(1.1) translateY(-3px);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.5), 0 5px 15px rgba(0, 0, 0, 0.3);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    }
}

.bonus-selection-active {
    animation: bonusSelectPulse 1.2s ease-in-out infinite;
}

/* Accessibility: visible focus outlines (non-destructive) */
/* Uses outline to avoid shifting layout */
button:focus-visible,
.menu-button:focus-visible,
a:focus-visible,
.cell:focus-visible,
.input-cell:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid #ffd54f;
    outline-offset: 2px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
  /* Ensure popups are still readable without animation */
  .message-popup { animation: none !important; opacity: 1 !important; }
}

/* Layering: keep overlays above cookie banner */
#overlay, #clash-overlay, #legal-overlay { z-index: 1000; }
#cookie-consent-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 900; /* Below overlays, above game UI */
}