:root {
    --bg-color: #0f1020;
    --panel-bg: rgba(30, 30, 40, 0.95);
    --primary-color: #FF5E62;
    /* Warm bright color for Word Search */
    --accent-color: #FF9966;
    --text-color: #ffffff;
    --grid-bg: #ffffff;
    /* White grid background like screenshot */
    --letter-color: #333333;
    --glass-border: rgba(255, 255, 255, 0.1);

    /* Highlight Colors from screenshot */
    --h-blue: #4facfe;
    --h-teal: #00f260;
    --h-pink: #ff758c;
    --h-yellow: #ffdb3b;
    --h-orange: #ff9a44;
    --h-purple: #c471ed;

    --selection-color: rgba(79, 172, 254, 0.5);
    /* Semi-transparent blue for active selection */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    overflow-y: auto;
    min-height: 100vh;

    height: 100dvh;
    touch-action: none;
    /* Prevent scroll while swiping */
    display: flex;
    flex-direction: column;
}

/* Header (Generic PlayMix Header) */
header {
    width: 100%;
    height: 60px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 16, 32, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.back-btn {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 500;
}

.game-title {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.level-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--h-yellow);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Container */
#game-container {
    flex: 1;
    position: relative;
    width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: 60px;
    /* Ad space */
}

/* Theme / Hint Text */
#theme-display {
    margin-bottom: 10px;
    text-align: center;
}

#theme-label {
    font-size: 0.8rem;
    color: #aaa;
    text-transform: uppercase;
}

#theme-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent-color);
}

/* Word Grid */
#word-grid {
    position: relative;
    /* For canvas overlap */
    background: var(--grid-bg);
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
    touch-action: none;
    /* Grid layout defined in JS or inline */
    display: grid;
    gap: 0;
    user-select: none;
    max-width: 95vw;
    max-height: 50vh;
    aspect-ratio: 1/1;
    /* Square grid preferred */
}

/* Letter Cell */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--letter-color);
    font-size: 1.2rem;
    position: relative;
    z-index: 2;
    /* Above highlights */
}

/* Highlight Canvas Overlay */
#highlight-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through */
    z-index: 1;
}

/* Word List at Bottom */
#word-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.word-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s;
    border: 1px solid transparent;
}

.word-item.found {
    background: rgba(0, 242, 96, 0.2);
    color: #fff;
    text-decoration: line-through;
    border-color: var(--h-teal);
    opacity: 0.5;
}

/* Controls */
#controls {
    margin-top: 10px;
    display: flex;
    gap: 15px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.control-btn:active {
    transform: scale(0.9);
}

/* Overlay (Level Complete) */
.overlay-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 16, 32, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.hidden {
    display: none !important;
}

.screen-content {
    background: var(--panel-bg);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--glass-border);
    max-width: 350px;
    width: 90%;
}

.game-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    border-radius: 50px;
    color: white;
    margin-top: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* Banner Ad */
#bottom-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: black;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (max-height: 600px) {
    #word-grid {
        max-height: 45vh;
    }

    #word-list {
        font-size: 0.8rem;
    }

    .cell {
        font-size: 1rem;
    }
}

/* Adsterra Banner - Right Side Bottom (Desktop Only) */
#adsterra-banner {
    position: fixed;
    top: auto;
    bottom: 5px;
    right: 10px;
    transform: none;
    z-index: 9000;
    display: none;
    width: 160px;
    height: 600px;
}

@media (min-width: 1024px) {
    #adsterra-banner {
        display: block;
    }
}