:root {
    --bg-color: #fcfcfc;
    --ink-color: #000000;
    --border-width: 3px;
    --border-radius-blob: 255px 15px 225px 15px / 15px 225px 15px 255px;
    --border-style: solid;
    --font-hand: 'Patrick Hand', 'ZCOOL KuaiLe', cursive, system-ui;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    margin: 0;
    padding: 20px;
    background-color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: var(--font-hand);
}

#app-container {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

/* Device Frame Simulation */
#device-frame {
    background-color: #333;
    padding: 20px 20px 60px 20px;
    border-radius: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    border: 4px solid #111;
}

.device-branding {
    color: #666;
    text-align: center;
    margin-top: 15px;
    font-family: monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 480x480 Screen */
.screen-square {
    width: 480px;
    height: 480px;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
    border: var(--border-width) solid var(--ink-color);
    /* No rounded corners on the screen itself, it's a display panel */
    color: var(--ink-color);
}

/* Layers */
#layer-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* subtle paper texture noise if needed, or just plain */
    background-image:
        radial-gradient(#e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.1;
}

#layer-content {
    position: absolute;
    top: 28px;
    /* Below status bar */
    left: 0;
    width: 100%;
    height: calc(100% - 28px);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

#layer-status-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    border-bottom: 2px solid var(--ink-color);
    background-color: var(--bg-color);
    font-size: 14px;
    font-weight: bold;
}

#layer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    /* Let clicks pass unless active */
}

/* Design System Utilities */
.hand-drawn-box {
    border: var(--border-width) solid var(--ink-color);
    border-radius: 10px;
    /* default */
    padding: 10px;
    background: #fff;
    box-shadow: 2px 2px 0px var(--ink-color);
}

.focus-active {
    outline: none;
    position: relative;
    border-width: 5px !important;
}

/* Add a pseudo-element arrow for focus */
.focus-active::after {
    content: '◄';
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    animation: wiggle 1s infinite alternate;
}

@keyframes wiggle {
    from {
        transform: translateY(-50%) translateX(0);
    }

    to {
        transform: translateY(-50%) translateX(-5px);
    }
}

/* Typography styles */
h1 {
    font-size: 36px;
    margin: 0 0 10px 0;
    font-weight: 900;
}

h2 {
    font-size: 28px;
    margin: 0 0 10px 0;
    font-weight: 800;
}

p {
    font-size: 18px;
    line-height: 1.4;
    margin: 0 0 10px 0;
}

/* Control Panel */
#controls-panel {
    background: #fff;
    padding: 20px;
    border-radius: 20px;
    width: 300px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin: 20px 0;
}

.dpad-mid {
    display: flex;
    gap: 5px;
}

.dpad-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
    border: 2px solid #333;
    background: #eee;
    border-radius: 8px;
    cursor: pointer;
}

.dpad-btn:active {
    background: #ccc;
    transform: scale(0.95);
}

.dpad-btn.center {
    background: #333;
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
}

.big-btn {
    width: 60px;
    height: 60px;
}

#debug-state-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}


/* Animations */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.anim-float {
    animation: float 3s ease-in-out infinite;
}

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

    to {
        transform: rotate(360deg);
    }
}

.anim-spin {
    animation: spin 2s linear infinite;
    display: inline-block;
}

@keyframes paper-out {
    0% {
        height: 0;
    }

    100% {
        height: 120px;
    }
}

.paper-printing {
    background: white;
    border: 2px solid black;
    border-top: none;
    width: 200px;
    margin: 0 auto;
    animation: paper-out 3s linear forwards;
    overflow: hidden;
    position: relative;
}

@keyframes draw-line {
    0% {
        width: 0;
    }

    100% {
        width: 100%;
    }
}

.progress-bar-fill {
    height: 100%;
    background: #000;
    transition: width 0.3s;
}

/* Wobbly Border Effect */
.wobbly {
    border-radius: var(--border-radius-blob);
}

/* Specific Screen Styles */
.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #000;
    border-radius: 4px;
}