:root {
    --primary-blue: #4facfe;
    --secondary-blue: #00f2fe;
    --dark-bg: #111115;
    --glass-bg: rgba(30, 30, 40, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-color: #ffffff;
    --btn-success: #2ecc71; 
    --btn-warning: #e74c3c; 
    --btn-info: #f39c12;    
    --btn-magic: #9b59b6;   
    --btn-refresh: #7f8c8d; 
    
    --ui-zoom: 1;
}

/* --- SCROLLING & BACKGROUND FIX --- */
html {
    /* Apply background here so it never disappears when body is locked */
    background: linear-gradient(135deg, #1e1e2f 0%, #0f2027 100%);
    font-size: calc(16px * var(--ui-zoom)); 
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background: transparent; /* Let html background show through */
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: pan-y;
}

/* Scroll Locked Mode */
body.scroll-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* UI RESET */
button, .action-btn, .tile, .glass-panel {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

/* --- SLIDER STYLING --- */
.scale-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    outline: none;
}
.scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid white;
}
.scale-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid white;
}

/* LAYOUT */
.game-container {
    max-width: 100%;
    min-height: 100vh; 
    margin: 0 auto;
    padding: 0.8rem; 
    padding-top: 0.5rem; 
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: flex-start;
    box-sizing: border-box;
}

.side-panel {
    flex: 1.2;
    min-width: 0; 
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.main-play-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 15rem; 
}

/* GARDEN */
#garden-canvas-container {
    width: 100%;
    height: 40vh; 
    min-height: 250px;
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    cursor: grab;
    background: #111;
}

#garden-canvas { display: block; width: 100%; height: 100%; }

/* GLASS PANELS */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 0.6rem; 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.score-box { font-size: 1.2rem; font-weight: bold; }
.score-val { color: var(--primary-blue); font-size: 1.5rem; margin-left: 0.5rem; }
.refresh-btn { background: var(--btn-refresh); border: none; color: white; padding: 0.4rem 0.8rem; border-radius: 2rem; cursor: pointer; font-weight: bold; font-size: 0.9rem;}

.message-area {
    text-align: center;
    font-size: 1.1rem;
    min-height: 1.2em;
    color: #ffeb3b;
    font-weight: 500;
}

/* CLUE BOX */
.clue-box {
    background: rgba(255, 235, 59, 0.15);
    border: 2px solid rgba(255, 235, 59, 0.5);
    border-radius: 0.8rem;
    padding: 0.4rem;
    text-align: center;
    color: #ffd700;
    font-size: 1.2rem;
    font-weight: bold;
    margin: 0.3rem 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* GRID */
.grid-container {
    display: grid;
    gap: 3px; 
    padding: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    justify-content: center; 
    touch-action: none; 
    align-content: center;
}

.tile {
    width: 100%;
    aspect-ratio: 1;
    background: #ffffff;
    color: #333;
    border-radius: 0.4rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem; 
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s, background 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.tile.selected {
    background: var(--primary-blue);
    color: white;
    border: 2px solid var(--secondary-blue);
}

.tile.hint-flash {
    animation: flash 1s ease-in-out infinite;
    background: #f39c12 !important;
    color: white !important;
}

@keyframes flash {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 10px 0 rgba(243, 156, 18, 1); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(243, 156, 18, 0); }
}

/* CONTROLS */
.current-word-display {
    text-align: center;
    font-size: 2rem; 
    letter-spacing: 3px;
    margin: 0.2rem 0;
    font-weight: bold;
    color: white;
}

.button-row { display: flex; gap: 0.5rem; justify-content: center; width: 100%; }

.action-btn {
    border: none;
    padding: 0.6rem 0.3rem; 
    border-radius: 1rem;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    flex: 1;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.action-btn:active { transform: scale(0.95); }

.icon-btn { flex: 0.5; font-size: 1.2rem; }
.wide-btn { flex: 2; font-size: 1.1rem; }

.action-btn.success { background-color: var(--btn-success); }
.action-btn.warning { background-color: var(--btn-warning); }
.action-btn.info { background-color: var(--btn-info); }
.action-btn.magic { background: linear-gradient(45deg, #9b59b6, #e056fd); border: 1px solid #fff;}

.found-words h3, .garden-area h3 { margin-top: 0; text-align: center; color: #aaa; font-size: 0.9rem; text-transform: uppercase; margin-bottom: 5px; }

.words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    max-height: 80px; 
    overflow-y: auto;
    padding: 2px;
}
.word-tag {
    background: rgba(255,255,255,0.15);
    padding: 0.3rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

/* COMPACT MODE */
body.compact-mode .tile { font-size: 1.5rem; }
body.compact-mode .action-btn { font-size: 0.9rem; }
body.compact-mode .clue-box { font-size: 1rem; }
body.compact-mode .current-word-display { font-size: 1.5rem; }

/* Start Screen */
.start-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(8px); z-index: 999; display: flex; justify-content: center; align-items: center; padding: 20px; }
.start-card { text-align: center; max-width: 400px; width: 100%; }
.start-card h1 { margin-top: 0; color: var(--primary-blue); }
.size-options { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.progress-container { width: 100%; background: rgba(255,255,255,0.1); border-radius: 10px; height: 10px; margin: 10px 0; overflow: hidden; }
.progress-bar { width: 0%; height: 100%; background: var(--primary-blue); transition: width 0.1s; }
.loading-spinner { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: var(--primary-blue); margin: 0 auto 15px; animation: spin 1s infinite; }

/* Mobile Portrait Override */
@media (max-width: 900px) {
    .game-container { flex-direction: column-reverse; }
    .side-panel { flex: 1; }
    .main-play-area { flex: 1; }
    .button-row { flex-wrap: wrap; }
    .wide-btn { flex: 100%; order: 1; }
    .icon-btn { flex: 1; order: 2; }
}