:root {
    --bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    --accent: #ff6b6b;
    --accent-hover: #ff5252;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --header-height: 60px; /* Reduced header height */
    --bouncy: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Quicksand', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    line-height: 1.4;
    overflow: hidden; /* Prevent scrolling globally */
    height: 100vh;
}

h1, h2, h3 { font-family: 'Quicksand', sans-serif; font-weight: 700; }

/* Game Header - Slimmer */
.game-header {
    height: var(--header-height);
    padding: 0 20px;
    background: white;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.mini-mascot { width: 36px; height: 36px; animation: bounce 2s infinite ease-in-out; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.game-info h1 { font-size: 1.1rem; color: #ff6b6b; margin: 0; }
#word-category { font-size: 0.75rem; color: var(--text-secondary); font-weight: 700; }

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.3s var(--bouncy);
    text-decoration: none;
    color: var(--text-primary);
}

.icon-btn:hover {
    transform: scale(1.1) rotate(5deg);
    border-color: #ff6b6b;
    color: #ff6b6b;
}

/* Container & Layout */
#game-container {
    padding-top: var(--header-height);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column; /* Default: stack vertically on mobile */
    gap: 15px;
    padding: 15px;
    height: calc(100vh - var(--header-height));
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    align-items: center;
}

/* Horizontal Layout for Desktop/Tablet Landscape */
@media (min-width: 850px) {
    main {
        flex-direction: row;
        align-items: stretch;
        gap: 20px;
    }
}

/* Canvas Area - Flexible */
#canvas-wrapper {
    flex: 1.5; /* Larger share for canvas */
    background: #ffffff;
    border-radius: 25px;
    position: relative;
    box-shadow: var(--shadow-soft);
    border: 6px solid #fecdd3;
    overflow: hidden;
    touch-action: none;
    width: 100%;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#paint-canvas { z-index: 1; cursor: crosshair; }
#outline-canvas { z-index: 2; pointer-events: none; opacity: 0.8; }
#instruction-arrows { z-index: 3; pointer-events: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.arrow-hint {
    position: absolute;
    font-size: 2.5rem;
    color: #ff6b6b;
    animation: pointing 1.5s infinite var(--bouncy);
}

@keyframes pointing {
    0%, 100% { transform: translateY(0); opacity: 0.8; }
    50% { transform: translateY(-10px); opacity: 0.4; }
}

/* Controls Area - Sidebar on Desktop */
.controls.glass-card {
    flex: 1; /* Sidebar share */
    background: white;
    padding: 15px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 2px solid #f1f5f9;
    max-width: 100%;
    overflow-y: auto; /* Allow menu scroll only if needed */
    max-height: 100%;
}

.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-group label { font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 0.85rem; color: #64748b; }

/* Compact Palette */
.palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 8px;
}

.color-swatch {
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: 0.2s var(--bouncy);
    position: relative;
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { transform: scale(1.1) translateY(-2px); border-color: #ff6b6b; }
.color-swatch.active::after { content: '✨'; position: absolute; top: -6px; right: -6px; font-size: 0.7rem; }

.rainbow-swatch {
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
    background-size: 200% 200%;
    animation: rainbowShift 3s linear infinite;
}

@keyframes rainbowShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* Patterns */
.patterns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pattern-btn {
    padding: 8px;
    border-radius: 12px;
    background: #f1f5f9;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.8rem;
}

.pattern-btn.active { background: #ff6b6b; color: white; transform: scale(1.05); }

/* Brush Slider - Smaller */
#brush-size { width: 100%; height: 6px; border-radius: 5px; background: #e2e8f0; appearance: none; outline: none; }
#brush-size::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #ff6b6b; cursor: pointer; border: 3px solid white; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }

/* Actions */
.actions { display: flex; gap: 10px; margin-top: auto; }
.actions .icon-btn { flex: 0 0 50px; height: 50px; }

.primary-btn {
    flex: 1;
    height: 50px;
    border-radius: 15px;
    background: #ff6b6b;
    color: white;
    border: none;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #e11d48;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #e11d48; }

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.overlay.active { display: flex; }

.glass-card-modal {
    background: white;
    border-radius: 30px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    border: 5px solid #fecdd3;
    animation: popIn 0.4s var(--bouncy);
}

@keyframes popIn { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Mobile Adjustments - Vertical but Compact */
@media (max-width: 849px) {
    .palette { grid-template-columns: repeat(7, 1fr); }
    #canvas-wrapper { flex: 1.5; min-height: 200px; }
    .controls.glass-card { padding: 10px; gap: 10px; border-radius: 20px; }
    .control-group { gap: 4px; }
    .actions { margin-top: 5px; }
    .game-header { padding: 0 15px; }
}

@media (max-width: 400px) {
    .palette { grid-template-columns: repeat(5, 1fr); }
    .game-info h1 { font-size: 0.9rem; }
    .icon-btn { width: 36px; height: 36px; font-size: 1rem; }
}
