:root {
    --bg-gradient: radial-gradient(circle at 60% 40%, #1e1e24 0%, #000000 100%);
    --phone-body: #2c2c2c;
    --phone-metal: linear-gradient(135deg, #444, #222);
    --phone-accent: #ff4500;
    /* Walkman orange */
    --kpad-text: #ffffff;
    --screen-bg: #8baabe;
    --led-backlight: rgba(255, 100, 0, 0.6);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-gradient);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
}

/* Background animated elements */
body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 69, 0, 0.05) 0%, transparent 40%);
    animation: rotate 60s linear infinite;
    z-index: -1;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.main-container {
    perspective: 1200px;
}

.phone-container {
    width: 340px;
    height: auto;
    min-height: 700px;
    /* Reduced from 850px fixed */
    background: #1a1a1a;
    border-radius: 40px;
    position: relative;
    /* Realistic metallic finish */
    background: linear-gradient(90deg, #333 0%, #1a1a1a 15%, #1a1a1a 85%, #333 100%);
    box-shadow:
        -5px 0 10px rgba(0, 0, 0, 0.8),
        5px 0 10px rgba(0, 0, 0, 0.8),
        0 30px 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    padding: 25px 25px 40px 25px;
    /* Increased bottom padding slightly to give "chin" look but auto height removes excess */
    border: 1px solid #000;
}

/* Bezel Reflection */
.phone-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: 40px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 10;
}

.phone-top {
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.speaker-grill {
    width: 80px;
    height: 6px;
    background: #000;
    border-radius: 4px;
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
    background-image: radial-gradient(#333 1px, transparent 0);
    background-size: 3px 3px;
    margin-bottom: 8px;
}

.brand-logo {
    color: #aaa;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 1);
    font-family: sans-serif;
}

/* SCREEN */
.screen-container {
    background: #000;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 0 0 2px #2a2a2a, inset 0 0 15px rgba(0, 0, 0, 0.9);
    margin-bottom: 10px;
    position: relative;
    z-index: 5;
}

.screen {
    width: 100%;
    height: 260px;
    background: #000;
    position: relative;
    overflow: hidden;
    color: white;
    font-family: 'Inter', sans-serif;
    image-rendering: pixelated;
    /* Retro feel */
    perspective: 1000px;
}

/* Screen reflection */
.screen::before {
    content: '';
    position: absolute;
    top: -100%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 20;
}

.status-bar {
    height: 24px;
    background: linear-gradient(to bottom, rgba(50, 50, 50, 0.8), rgba(0, 0, 0, 0));
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    align-items: center;
    font-size: 11px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

/* CONTROLS AREA */
.controls-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

/* Nav Cluster */
.nav-cluster {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto auto;
    gap: 10px;
    justify-items: center;
    align-items: center;
    padding-bottom: 0px;
}

.btn-soft,
.btn-call,
.btn-end {
    width: 55px;
    height: 30px;
    border-radius: 6px;
    background: linear-gradient(to bottom, #444, #2a2a2a);
    border: none;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 2px 5px rgba(0, 0, 0, 0.4),
        0 4px 0 #111;
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.05s;
    text-transform: uppercase;
    font-weight: 600;
}

.btn-soft:active,
.btn-call:active,
.btn-end:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #111;
}

.btn-soft span,
.btn-call span,
.btn-end span {
    pointer-events: none;
}

.btn-call {
    color: #5eff5e;
    border-bottom: 2px solid #3a5c3a;
}

.btn-end {
    color: #ff5e5e;
    border-bottom: 2px solid #5c3a3a;
}

/* D-PAD */
.btn-dpad-center {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #444, #111);
    border: 2px solid #555;
    color: var(--phone-accent);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    z-index: 2;
    font-size: 18px;
    display: grid;
    place-items: center;
    position: relative;
    grid-column: 2;
    grid-row: 2;
}

.dpad-ring {
    grid-column: 2;
    grid-row: 2;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(from 45deg, #2a2a2a, #444, #2a2a2a, #444, #2a2a2a);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.8), 0 2px 5px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
}

.dpad-btn {
    position: absolute;
    width: 25px;
    height: 25px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.dpad-btn:active {
    color: var(--phone-accent);
}

.btn-dpad-up {
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.btn-dpad-down {
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.btn-dpad-left {
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.btn-dpad-right {
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
}

/* Keypad Grid */
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 10px 5px;
    background: #252525;
    border-radius: 8px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.btn-num {
    height: 38px;
    background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
    border: 1px solid #111;
    border-top: 1px solid #444;
    border-radius: 4px;
    color: #eee;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.05s;
    text-shadow: 0 -1px 1px rgba(0, 0, 0, 1);
    position: relative;
}

.btn-num::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.1s;
}

.btn-num:active {
    background: #000;
    border-color: #000;
    transform: scale(0.95);
    color: var(--phone-accent);
    text-shadow: 0 0 8px var(--phone-accent);
}

.btn-num:active::after {
    opacity: 1;
}

.btn-num .sub {
    font-size: 7px;
    color: #888;
    margin-top: -3px;
    font-weight: 300;
}

/* Music Controls */
.music-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.btn-music {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(to bottom, #e05e00, #a04000);
    border: 2px solid #502000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3);
    transition: transform 0.05s;
}

.btn-music:active {
    transform: scale(0.9);
    background: linear-gradient(to bottom, #a04000, #e05e00);
}

/* WALKMAN APP STYLES */
.walkman-app {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #000;
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.walkman-header {
    background: #ff4500;
    color: white;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.walkman-logo {
    background: white;
    color: #ff4500;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

/* List View */
.song-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}

.song-item {
    padding: 8px 10px;
    border-bottom: 1px solid #333;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.song-item.active {
    background: #333;
    color: #ff4500;
}

.song-item.playing-indicator {
    background: #222;
}

.song-icon {
    font-size: 12px;
    opacity: 0.7;
}

/* Player View */
.player-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    background: radial-gradient(circle at center, #221100 0%, #000 100%);
}

.album-art {
    width: 120px;
    height: 120px;
    background: #333;
    border: 2px solid #555;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #555;
    box-shadow: 0 5px 15px rgba(255, 69, 0, 0.2);
}

.song-info {
    text-align: center;
    margin-bottom: 20px;
}

.song-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 69, 0, 0.5);
}

.song-status {
    font-size: 10px;
    color: #ff4500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.progress-bar {
    width: 80%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    margin-bottom: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #ff4500;
    width: 0%;
    /* JS will update this */
}

.time-display {
    width: 80%;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #888;
}

.controls-hint {
    margin-top: auto;
    margin-bottom: 10px;
    font-size: 9px;
    color: #555;
    display: flex;
    gap: 10px;
}

/* SCREEN CONTENTS */
#app-view {
    height: 100%;
    width: 100%;
    position: relative;
}

.home-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    color: white;
    justify-content: space-between;
    padding-top: 40px;
    padding-bottom: 5px;
    background: url('https://images.unsplash.com/photo-1550684848-fac1c5b4e853?q=80&w=800&auto=format&fit=crop') center/cover;
}

.home-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 0;
}

.home-content {
    z-index: 1;
    text-align: center;
    width: 100%;
}

.clock-large {
    font-size: 52px;
    font-weight: 100;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    font-family: 'Inter', sans-serif;
    letter-spacing: -2px;
}

.date-small {
    font-size: 13px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.home-footer {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 1);
    z-index: 1;
}

/* MENU GRID */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 30px 10px 10px;
    height: 100%;
    /* Subtle animation for menu open */
    animation: menu-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(20, 20, 20, 0.95);
}

@keyframes menu-pop {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.1s;
}

.menu-item.active {
    background: rgba(255, 69, 0, 0.3);
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.2);
    border: 1px solid rgba(255, 69, 0, 0.5);
}

.menu-icon {
    font-size: 24px;
}


/* Responsive Design */
@media (max-width: 360px) {
    .phone-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        transform: scale(0.9);
    }

    .screen {
        height: 220px;
    }

    .controls-area {
        gap: 10px;
    }

    .btn-num {
        height: 45px;
        /* Larger hit targets for touch */
    }
}

/* 3D Transitions */
.screen-content {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.anim-flip-out {
    animation: flipOut 0.4s cubic-bezier(0.455, 0.03, 0.515, 0.955) forwards;
}

.anim-flip-in {
    animation: flipIn 0.4s cubic-bezier(0.455, 0.03, 0.515, 0.955) forwards;
}

@keyframes flipOut {
    from {
        transform: rotateY(0deg);
        opacity: 1;
    }

    to {
        transform: rotateY(-90deg);
        opacity: 0.5;
    }
}

@keyframes flipIn {
    from {
        transform: rotateY(90deg);
        opacity: 0.5;
    }

    to {
        transform: rotateY(0deg);
        opacity: 1;
    }
}