/* Global Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: #000000;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

/* Screen Navigation Views */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1;
    overflow: hidden;
}

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

/* Pairing & Standby Cards */
#pairing-screen, #standby-screen {
    background-color: #0f172a;
}

.card {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 85%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #ffffff;
}

.card p {
    color: #94a3b8;
    margin-bottom: 24px;
    font-size: 15px;
    line-height: 1.5;
}

.code-display {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: 8px;
    color: #38bdf8;
    background-color: #0f172a;
    border: 2px dashed #0284c7;
    padding: 16px 24px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-family: monospace;
}

.btn {
    background-color: #0284c7;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn:active {
    background-color: #0369a1;
}

.small-text {
    font-size: 13px;
    color: #64748b;
    margin-top: 16px;
}

/* Download Progress Overlay */
.download-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.96);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.download-overlay-card {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 36px 48px;
    text-align: center;
    width: 90%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.download-overlay-card h3 {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    margin-top: 16px;
    margin-bottom: 8px;
}

.download-overlay-card p {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background-color: #0f172a;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid #334155;
}

.progress-bar {
    height: 100%;
    background: #0284c7;
    width: 0%;
    border-radius: 999px;
    transition: width 0.2s ease-out;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #0284c7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Playback Engine */
.fullscreen-container {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #000000;
}

.media-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.media-element.active {
    opacity: 1;
    z-index: 2;
}

/* Orientation Rotation Support */
.rotate-portrait {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 100vh !important;
    height: 100vw !important;
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: center center !important;
}

/* Overlay Widgets Layer */
.widgets-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.widget {
    position: absolute;
    transition: opacity 0.3s ease-in-out;
}

/* Clock Widget (Sleek Background-Free Floating Typography) */
.widget-clock {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    color: #ffffff;
}

.widget-clock.top-left { top: 28px; left: 32px; text-align: left; }
.widget-clock.top-right { top: 28px; right: 32px; text-align: right; }
.widget-clock.bottom-left { bottom: 28px; left: 32px; text-align: left; }
.widget-clock.bottom-right { bottom: 28px; right: 32px; text-align: right; }

.has-ticker .widget-clock.bottom-left { bottom: 74px !important; }
.has-ticker .widget-clock.bottom-right { bottom: 74px !important; }

.clock-time {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 1.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace, sans-serif;
    color: #38bdf8;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 20px rgba(56, 189, 248, 0.35);
}

.clock-date {
    font-size: 14px;
    color: #e2e8f0;
    margin-top: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* QR Code Widget */
.widget-qr {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}

.widget-qr.top-left { top: 28px; left: 32px; }
.widget-qr.top-right { top: 28px; right: 32px; }
.widget-qr.bottom-left { bottom: 28px; left: 32px; }
.widget-qr.bottom-right { bottom: 28px; right: 32px; }

.has-ticker .widget-qr.bottom-left { bottom: 74px !important; }
.has-ticker .widget-qr.bottom-right { bottom: 74px !important; }

/* Ticker Widget */
.widget-ticker {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: rgba(15, 23, 42, 0.92);
    border-top: 2px solid #0284c7;
    display: flex;
    align-items: center;
    overflow: hidden;
    color: #ffffff;
    font-size: 18px;
    font-weight: 500;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.ticker-badge {
    background: #0284c7;
    color: #ffffff;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1.5px;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.3);
}

.ticker-content-wrapper {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.ticker-text-scroll {
    display: inline-block;
    padding-left: 100%;
    animation: marquee-scroll 25s linear infinite;
    will-change: transform;
}

@keyframes marquee-scroll {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}
