* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
    overflow-x: hidden;
}

.app-container {
    max-width: 400px;
    margin: 0 auto;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4757;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #2ed573;
    animation: none;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Remote Container */
.remote-container {
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
}

/* Power Button */
.power-section {
    display: flex;
    justify-content: center;
}

.power-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff4757, #ff3742);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
    transition: all 0.2s;
}

.power-btn svg {
    width: 24px;
    height: 24px;
}

.power-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.5);
}

/* Navigation */
.nav-section {
    display: flex;
    justify-content: center;
}

.nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 8px;
    width: 180px;
    height: 180px;
}

.nav-btn {
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:nth-child(1) { grid-column: 2; grid-row: 1; } /* Up */
.nav-btn:nth-child(2) { grid-column: 1; grid-row: 2; } /* Left */
.nav-btn:nth-child(3) { grid-column: 2; grid-row: 2; } /* OK */
.nav-btn:nth-child(4) { grid-column: 3; grid-row: 2; } /* Right */
.nav-btn:nth-child(5) { grid-column: 2; grid-row: 3; } /* Down */

.nav-btn.ok {
    background: linear-gradient(135deg, #6B2C91, #9b59b6);
    font-size: 0.9rem;
    font-weight: 600;
}

.nav-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.nav-btn.ok:active {
    background: linear-gradient(135deg, #5a2379, #8e44ad);
}

/* Control Buttons */
.control-row {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.control-btn {
    flex: 1;
    max-width: 120px;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
}

.control-btn.home {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.control-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.control-btn.home:active {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

/* Volume Controls */
.volume-section {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.volume-btn {
    flex: 1;
    max-width: 80px;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
}

.volume-btn.mute {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.volume-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.volume-btn.mute:active {
    background: linear-gradient(135deg, #c0392b, #a93226);
}

/* Playback Controls */
.playback-section {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.playback-btn {
    flex: 1;
    max-width: 80px;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
}

.playback-btn.play-pause {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.playback-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.playback-btn.play-pause:active {
    background: linear-gradient(135deg, #229954, #28b463);
}

/* Apps Section */
.apps-section {
    width: 100%;
}

.apps-section h3 {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.9;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.app-btn {
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.app-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.app-name {
    font-size: 0.8rem;
    font-weight: 500;
}

.app-btn.netflix .app-icon {
    background: #e50914;
}

.app-btn.disney .app-icon {
    background: #113ccf;
}

.app-btn.hulu .app-icon {
    background: #1ce783;
}

.app-btn.prime .app-icon {
    background: #00a8e1;
}

.app-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 1000;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    max-width: 350px;
    width: 90%;
    color: #333;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.setting-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
}

.setting-group button {
    padding: 10px 20px;
    background: #6B2C91;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.setting-group button:hover {
    background: #5a2379;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1001;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.toast.show {
    opacity: 1;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Button Press Effect */
button {
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:active::before {
    width: 200px;
    height: 200px;
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
        border: none;
    }
    
    .remote-container {
        padding: 20px 15px;
    }
    
    .nav-grid {
        width: 160px;
        height: 160px;
    }
    
    .control-btn {
        font-size: 0.8rem;
        padding: 10px 12px;
    }
    
    .volume-btn, .playback-btn {
        padding: 12px;
    }
}

@media (max-height: 700px) {
    .remote-container {
        gap: 20px;
    }
    
    .nav-grid {
        width: 150px;
        height: 150px;
    }
}

/* PWA specific styles */
@media (display-mode: standalone) {
    .app-container {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: rgba(30, 30, 30, 0.95);
        color: #fff;
    }
    
    .setting-group input[type="text"] {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
        color: #fff;
    }
    
    .close-btn {
        color: #ccc;
    }
}
