/* Base & Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #6C63FF;
    --primary-hover: #5A52D5;
    --secondary: #00E676;
    --bg-dark: #0F0A1A;
    --text-main: #FFFFFF;
    --text-muted: #A098B6;
    --glass-bg: rgba(35, 25, 55, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --danger: #FF3B30;
    --guide-color: rgba(0, 230, 118, 0.8);
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Background effects */
.glass-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(108, 99, 255, 0.15) 0%, rgba(15, 10, 26, 1) 40%);
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff, #a098b6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.app-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    flex: 1;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.upload-area {
    border: 2px dashed rgba(108, 99, 255, 0.5);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(108, 99, 255, 0.05);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.upload-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.upload-icon {
    width: 32px;
    height: 32px;
    stroke: var(--primary);
}

.control-group h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Custom Toggles */
.toggle {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    cursor: pointer;
    position: relative;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    margin-right: 12px;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.label-text {
    font-size: 0.95rem;
    user-select: none;
}

/* Slider Style */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.slider-container label {
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

#scaleValue {
    color: var(--text-main);
    font-weight: 500;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(108, 99, 255, 0.5);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 3rem;
}

.preview-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 400px;
}

.icon-container {
    position: relative;
    transition: width 0.1s, height 0.1s;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.icon-view-box {
    position: relative;
    width: 100%;
    height: 100%;
}

.icon-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Masks & Overlays */
.mask-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.mask-layer.active {
    opacity: 1;
}

.ios-mask-layer svg,
.android-mask-layer svg {
    width: 100%;
    height: 100%;
    fill: rgba(15, 10, 26, 0.85);
    /* Semi-transparent mask color to show overlap */
}

.ios-mask-layer svg path {
    fill: rgba(255, 59, 48, 0.5);
    mix-blend-mode: multiply;
}

.android-mask-layer svg path {
    fill: rgba(0, 230, 118, 0.5);
    mix-blend-mode: multiply;
}

/* In a real scenario to completely hide the outside, we'd use solid bg color 
 * Here the user wants to see what's masked out. Semi-transparent red/green helps.
 */

.guide-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.guide-layer.active {
    opacity: 1;
}

.safe-zone-box {
    position: absolute;
    top: 16.666%;
    left: 16.666%;
    width: 66.666%;
    height: 66.666%;
    border: 2px dashed var(--secondary);
    border-radius: 50%;
    /* standard play store safe zone inner circle */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.safe-zone-box::after {
    /* iOS safe zone rect roughly 80% */
    content: '';
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    border: 1px dotted rgba(255, 255, 255, 0.5);
    border-radius: 17.5%;
}

.grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
}

.grid-line.vertical {
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
}

.grid-line.horizontal {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: translateY(-50%);
}

/* Context Previews */
.context-previews {
    display: flex;
    gap: 3rem;
    width: 100%;
    justify-content: center;
}

.context-mockup {
    text-align: center;
}

.context-mockup h4 {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.mockup-screen {
    width: 120px;
    height: 160px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.app-icon-small {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ios-clip,
.android-clip {
    width: 60px;
    height: 60px;
    background-size: cover;
    background-position: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1024 1024'%3E%3Crect width='1024' height='1024' fill='%236C63FF'/%3E%3C/svg%3E");
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Approximation using clip-path for previews */
.ios-clip {
    /* iOS actual squircle is complex, but this 22.5% radius is a close CSS approx */
    border-radius: 22.5%;
}

.android-clip {
    border-radius: 50%;
}

.app-label {
    font-size: 0.75rem;
    color: #fff;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .context-previews {
        flex-direction: row;
        flex-wrap: wrap;
    }
}