@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600&display=swap');
/* GLOBAL RESET & LOCK */
* {
    box-sizing: border-box; /* Ensures padding/borders don't add to width */
}

html, body {
    width: 100%;
    overflow-x: hidden; /* The Magic Line: Cuts off any side-wobble */
    overscroll-behavior: none; /* Prevents the "bounce" effect on mobile */
    touch-action: pan-y; /* Allows vertical scroll but blocks horizontal swipes */
}
body {
    font-family: 'Fredoka', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    
    /* FLEXBOX CENTERING MAGIC */
    display: flex;
    flex-direction: column;
    align-items: center;     /* Centers horizontally */
    justify-content: flex-start; /* Starts from top (better for mobile scrolling) */
    
    min-height: 100vh;
    padding-top: 20px;       /* Adds a little breathing room at the top */
    padding-bottom: 20px;
    
    width: 100%;             /* Ensures body takes full width of iframe */
}

:root {
    /* Colors */
    --bg-color: #3f0636; /* Deep purple/blue background */
    --text-color: #ffffff;
    --board-bg: #1a1a2e; 
    --tile-bg: #fff56a27;
    --accent: #e84545; /* Red/Pink accent */
    --secondary: #903749;
    
    /* THE MAGIC VARIABLE: We change this in JS to swap images */
    --current-image: url('images/character_00_farty.png');
}

/* Light Theme overrides */
[data-theme="light"] {
    --bg-color: #f4f4f9;
    --text-color: #333;
    --board-bg: #e0e0e0;
    --tile-bg: #fff;
    --accent: #ff6b6b;
    --secondary: #ff4757;
}

body {
    font-family: 'Fredoka', sans-serif; /* Round, friendly font */
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex; 
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding-bottom: 20px;
    transition: background 0.3s;
}

/* Header */
header {
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    backdrop-filter: blur(5px);
    box-sizing: border-box;
    margin-bottom: 20px;
}

header h3 { margin: 0; letter-spacing: 1px; }

/* Stats Bar - "Glass" effect */
.stats-bar {
    display: flex;
    gap: 25px;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 25px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Game Board */
#puzzle-container {
    width: 300px;
    height: 300px;
    max-width: 90vw;
    border: 8px solid var(--text-color);
    position: relative;
    background-color: var(--board-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
}

/* The Tiles */
.tile {
    position: absolute;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Snappy movement */
    background-color: var(--tile-bg);
    
    /* HERE IS THE CHANGE: It uses the variable */
    background-image: var(--current-image); 
    background-repeat: no-repeat;
    
    box-sizing: border-box;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    
    /* Nice inset shadow to make tiles look 3D */
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); 
}

/* Overlay */
#game-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
#game-overlay.active { opacity: 1; pointer-events: all; }
#game-overlay h2 { font-size: 2rem; color: #ffd700; text-shadow: 0 4px 0 rgba(0,0,0,0.5); }

/* Preview Image / Gallery */
.preview-container {
    margin-top: 20px;
    text-align: center;
    position: relative;
}
#image-label {
    margin: 15px 0 5px 0; /* Space above and below */
    font-size: 1.5rem;
    color: var(--accent); /* Use your theme accent color */
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 0 rgba(0,0,0,0.2);
    transition: color 0.3s;
    text-align: center;
}

.clickable-goal {
    width: 80px;
    height: 80px;
    border: 4px solid var(--accent);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.clickable-goal:active { transform: scale(0.9); }
.clickable-goal:hover { border-color: #fff; }

.tap-hint {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

/* Buttons */
.controls {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 320px;
}

.control-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

button, select {
    padding: 10px 18px;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: white;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2); /* Retro "pressable" look */
    transition: transform 0.1s, box-shadow 0.1s;
}

button:active {
    transform: translateY(4px); /* Pushes down */
    box-shadow: 0 0 0 rgba(0,0,0,0.2);
}

select {
    background: var(--text-color);
    color: var(--bg-color);
    border: 2px solid transparent;
}

.btn-easy { background-color: #00b894; }
.btn-med { background-color: #fdcb6e; color: #333; }
.btn-hard { background-color: #d63031; }
.btn-ghost { background: transparent; border: 2px solid var(--text-color); box-shadow: none; color: var(--text-color); font-size: 0.8rem;}

#theme-btn { padding: 0; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 1.2rem;}