/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'PixelFont';
    src: local('Courier New'), local('Courier');
}

:root {
    --lcd-bg: #9ead86;
    --lcd-fg: #1a2a0a;
    --lcd-light: #b5c49e;
    --device-bg: #e8dcc8;
    --device-border: #b8a88a;
    --device-shadow: #8a7a5a;
    --btn-bg: #c8b898;
    --btn-active: #a89878;
    --accent: #d4644a;
    --accent-light: #e8856a;
}

body {
    background: #2a2a3a;
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 20% 80%, #3a3a5a 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, #3a3a5a 0%, transparent 50%);
}

/* === SCREENS === */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* === DEVICE FRAME === */
.device {
    background: var(--device-bg);
    border-radius: 30px 30px 50px 50px;
    padding: 20px;
    box-shadow:
        0 8px 32px rgba(0,0,0,0.4),
        inset 0 2px 0 rgba(255,255,255,0.3),
        0 0 0 3px var(--device-border),
        0 0 0 6px var(--device-shadow);
    max-width: 380px;
    width: 90vw;
    position: relative;
}

.device-top {
    text-align: center;
    padding: 8px 0 12px;
}

.device-logo {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: var(--accent);
    letter-spacing: 6px;
    text-shadow: 1px 1px 0 var(--device-shadow);
}

.device-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--device-shadow);
    padding: 4px 8px 0;
}

/* === LCD SCREEN === */
.lcd {
    background: var(--lcd-bg);
    border-radius: 12px;
    padding: 12px;
    border: 3px solid #6a7a5a;
    box-shadow:
        inset 0 2px 8px rgba(0,0,0,0.2),
        inset 0 0 20px rgba(0,0,0,0.05);
    min-height: 340px;
    position: relative;
    image-rendering: pixelated;
}

/* Scan line effect */
.lcd::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.03) 2px,
        rgba(0,0,0,0.03) 4px
    );
    pointer-events: none;
    border-radius: 10px;
}

/* === TITLE SCREEN === */
.title-content {
    text-align: center;
    padding: 10px 0;
}

.title-egg {
    font-size: 48px;
    margin-bottom: 8px;
    animation: wobble 2s infinite;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.pixel-title {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    color: var(--lcd-fg);
    letter-spacing: 3px;
    margin-bottom: 4px;
}

.pixel-subtitle {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--lcd-fg);
    opacity: 0.7;
    margin-bottom: 12px;
}

.pixel-stats {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--lcd-fg);
    opacity: 0.6;
    margin-top: 8px;
}

/* === PET SELECTOR === */
.pet-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 4px;
}

.pet-choice {
    background: var(--lcd-light);
    border: 2px solid var(--lcd-fg);
    border-radius: 8px;
    padding: 8px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: var(--lcd-fg);
}

.pet-choice:hover, .pet-choice:focus {
    background: #c8d8a8;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pet-choice:active {
    transform: scale(0.95);
}

.pet-preview {
    image-rendering: pixelated;
    width: 48px;
    height: 48px;
}

/* === STATUS BARS === */
.status-bars {
    display: grid;
    gap: 3px;
    margin-bottom: 8px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.stat-icon {
    width: 14px;
    text-align: center;
    color: var(--lcd-fg);
    font-size: 11px;
}

.stat-bar {
    flex: 1;
    height: 8px;
    background: rgba(0,0,0,0.15);
    border-radius: 2px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    background: var(--lcd-fg);
    transition: width 0.5s ease;
    border-radius: 2px;
}

.stat-fill.low {
    animation: blink 0.5s infinite;
}

@keyframes blink {
    50% { opacity: 0.3; }
}

.stat-label {
    width: 24px;
    text-align: right;
    font-size: 10px;
    color: var(--lcd-fg);
    font-family: 'Courier New', monospace;
}

/* === PET DISPLAY === */
.pet-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    position: relative;
}

#pet-canvas {
    image-rendering: pixelated;
    width: 128px;
    height: 128px;
}

.pet-mood {
    font-size: 14px;
    color: var(--lcd-fg);
    font-family: 'Courier New', monospace;
    margin-top: 2px;
    min-height: 18px;
    text-align: center;
}

.pet-message {
    font-size: 11px;
    color: var(--lcd-fg);
    font-family: 'Courier New', monospace;
    text-align: center;
    min-height: 16px;
    opacity: 0.8;
    position: absolute;
    bottom: 0;
    transition: opacity 0.3s;
}

/* === POOP === */
.poop-area {
    position: absolute;
    bottom: 16px;
    right: 16px;
    font-size: 14px;
    display: flex;
    gap: 2px;
}

.poop {
    animation: poopAppear 0.3s ease;
}

@keyframes poopAppear {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* === ACTION BUTTONS === */
.action-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 12px 0 8px;
}

.action-btn {
    background: var(--btn-bg);
    border: 2px solid var(--device-border);
    border-radius: 10px;
    padding: 8px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.1s;
    box-shadow: 0 3px 0 var(--device-shadow);
}

.action-btn:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 0 var(--device-shadow);
}

.action-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--device-shadow);
    background: var(--btn-active);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 18px;
}

.btn-text {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: var(--lcd-fg);
}

/* === DEVICE BUTTONS === */
.device-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 0 4px;
}

.device-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 0 3px 0 #b04a30;
    transition: all 0.1s;
}

.device-btn:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

.device-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #b04a30;
}

/* === DEATH SCREEN === */
.death-content {
    text-align: center;
    padding: 20px 0;
}

#death-canvas {
    image-rendering: pixelated;
    width: 128px;
    height: 128px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* === SLEEPING OVERLAY === */
.sleeping-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.zzz {
    font-size: 28px;
    color: var(--lcd-fg);
    font-family: 'Courier New', monospace;
    animation: float 2s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-15px); opacity: 1; }
}

/* === SPARKLE (for Clawde) === */
.sparkle {
    position: absolute;
    color: var(--lcd-fg);
    font-size: 10px;
    animation: sparkleAnim 1s forwards;
    pointer-events: none;
}

@keyframes sparkleAnim {
    0% { transform: translateY(0) scale(0); opacity: 1; }
    100% { transform: translateY(-30px) scale(1.5); opacity: 0; }
}

/* === RESPONSIVE === */
@media (max-width: 400px) {
    .device {
        padding: 14px;
        border-radius: 24px 24px 40px 40px;
    }

    .lcd {
        min-height: 300px;
        padding: 10px;
    }

    .action-bar {
        gap: 4px;
    }

    .pet-selector {
        gap: 6px;
    }
}

@media (min-height: 800px) {
    .lcd {
        min-height: 380px;
    }
}
