:root {
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    /* Default Fallbacks - These are overridden by render.php */
    --accent: #2563eb; 
    --accent-glow: rgba(37, 99, 235, 0.2);
    
    --danger: #ef4444;
    --radius: 24px;
    --font-main: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    touch-action: pan-x pan-y; 
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-main);
    background: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

/* --- Layer 1: Background Canvas --- */
#bg-canvas {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0;
    opacity: 0.6;
    pointer-events: none;
}

/* --- Layer 2: Background Cogs --- */
.cogs-layer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1; 
    pointer-events: none;
    overflow: hidden;
}

.cog { position: absolute; opacity: 0.6; }

.cog-large-1 { width: 250px; top: -50px; right: -80px; animation: rotate 80s infinite linear; }
.cog-large-2 { width: 180px; bottom: -40px; left: 10%; animation: rotate 60s infinite linear reverse; }
.cog-small-1 { width: 80px; top: 20%; right: 15%; animation: rotate 30s infinite linear reverse; }
.cog-small-2 { width: 60px; bottom: 30%; left: -20px; animation: rotate 25s infinite linear; }

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Main Card --- */
.app-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 20px;
}

.main-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius);
    padding: 40px 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

/* Typography */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 20px;
}

.pulse { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; animation: pulse 2s infinite; }

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #111827 0%, #374151 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p { color: var(--text-secondary); line-height: 1.6; font-size: 1rem; margin-bottom: 30px; }

/* --- Interaction Module --- */
.interaction-module {
    background: #f9fafb;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    position: relative;
}

.character-zone { height: 120px; width: 100%; position: relative; margin-bottom: -10px; overflow: visible; }

.character-mover {
    position: absolute; bottom: 0; transform: translateX(-50%);
    height: 100%; width: auto; transition: left 0.1s linear; 
    will-change: left; display: flex; justify-content: center; align-items: flex-end;
}

.hammer-character {
    height: 100%; width: auto; object-fit: contain; transform-origin: bottom center;
    animation: hammer-motion 1.5s infinite ease-in-out;
}

@keyframes hammer-motion {
    0% { transform: rotate(-5deg) translateY(0); }
    50% { transform: rotate(5deg) translateY(2px); }
    100% { transform: rotate(-5deg) translateY(0); }
}

.progress-wrapper { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; position: relative; z-index: 2; }
.progress-bar-bg { flex-grow: 1; height: 12px; background: #e5e7eb; border-radius: 10px; overflow: hidden; position: relative; }

.progress-bar-fill {
    height: 100%;
    /* Gradient adapted to use the dynamic accent */
    background: linear-gradient(90deg, var(--accent) 0%, #ffffff 50%, var(--accent) 100%);
    background-size: 200% 100%;
    border-radius: 10px;
    transition: width 0.1s linear; 
    animation: shimmer 1.5s infinite linear;
}

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

.progress-text {
    font-weight: 700; font-family: monospace; color: var(--accent);
    min-width: 50px; text-align: right; display: inline-block;
    transform-origin: center right; backface-visibility: hidden; will-change: transform;
}

@keyframes popText {
    0% { transform: scale(1); }
    40% { transform: scale(1.4); filter: brightness(1.2); } 
    100% { transform: scale(1); }
}

.text-surge { animation: popText 0.2s cubic-bezier(0.25, 1, 0.5, 1) forwards; }

.completion-message {
    display: none; text-align: center; font-size: 0.85rem; color: var(--text-secondary);
    background: #f3f4f6; padding: 8px; border-radius: 8px; margin-bottom: 10px;
    border: 1px dashed #d1d5db; animation: fadeIn 0.5s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* BUTTON STYLES & ANIMATION */
.primary-btn {
    width: 100%; padding: 16px; border: none; border-radius: 16px;
    background: var(--accent); color: white; font-size: 1rem; font-weight: 600;
    cursor: pointer; position: relative; overflow: hidden;
    transition: all 0.1s ease;
    box-shadow: 0 4px 12px var(--accent-glow);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Both :active (desktop) and .pressed (mobile JS) trigger this */
.primary-btn:active, .primary-btn.pressed { transform: scale(0.95); filter: brightness(0.9); }
.primary-btn:hover { filter: brightness(1.1); }

/* Action Grid */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.action-card {
    background: white; border: 1px solid #e5e7eb; padding: 15px;
    border-radius: 16px; cursor: pointer; text-decoration: none;
    color: var(--text-primary); transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 8px;
    touch-action: manipulation;
    position: relative; /* Important for absolute inner elements */
    min-height: 100px; /* Ensure consistent button height */
}

.action-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

/* ICON WRAPPERS - THE FIX FOR SIZING */
.icon-fixed-wrapper {
    width: 100%;
    height: 32px; /* Fixed vertical space allocated for the icon */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon { font-size: 1.5rem; line-height: 1; }

.custom-icon-img { 
    /* Absolute centering ensures it doesn't push the wrapper size */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    object-fit: contain; 
    /* Width/Height are set inline by PHP based on slider */
}

.label { font-size: 0.8rem; font-weight: 600; z-index: 2; position: relative; }

/* --- Modals --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(5px);
    z-index: 100; display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
    touch-action: none; 
}

.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-card {
    position: relative; background: white; width: 90%; max-width: 400px;
    padding: 30px; border-radius: 20px; box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    transform: translateY(20px); transition: transform 0.3s;
}
.modal-overlay.active .modal-card { transform: translateY(0); }
.job-card { border-top: 5px solid var(--danger); }
.fake-form .form-group { margin-bottom: 15px; text-align: left; }
.fake-form label { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 5px; }
.fake-form input, .fake-form textarea { width: 100%; padding: 10px; border: 1px solid #e5e7eb; border-radius: 8px; background: #f9fafb; }
.close-modal-x {
    position: absolute; top: 10px; right: 15px; background: none; border: none;
    font-size: 1.5rem; color: #9ca3af; cursor: pointer; line-height: 1;
}
.close-modal-x:hover { color: var(--danger); }

@media (max-width: 480px) {
    h1 { font-size: 2rem; }
    .action-grid { grid-template-columns: 1fr; }
}