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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #1a0a00;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.2s ease, visibility 0s linear 1.2s;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 1.2s ease, visibility 0s linear 0s;
    z-index: 2;
}

.bg-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    z-index: 0;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
    z-index: 50;
    justify-content: flex-end;
}

.login-box {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 32px;
    margin-bottom: 12%;
    background: none;
    max-width: 320px;
    width: 100%;
}

.login-input-wrap {
    display: flex;
    width: 100%;
    gap: 8px;
}

.login-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(90, 50, 20, 0.85);
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 14px;
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    -webkit-appearance: none;
}

.login-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}

.login-input:focus {
    border-color: #ffd700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}

.login-submit {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #b42814, #e04820);
    border: 2px solid #ffd700;
    border-radius: 14px;
    color: #ffd700;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
    box-shadow: 0 4px 12px rgba(180, 40, 20, 0.4);
}

.login-submit:active {
    transform: scale(0.9);
}

.login-error {
    color: #ff6b6b;
    font-size: 12px;
    margin-top: 10px;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s, transform 0.3s;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.login-error.visible {
    opacity: 1;
    transform: translateY(0);
}

.login-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    margin-top: 10px;
    text-align: center;
    font-style: italic;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.login-box.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-12px); }
    30% { transform: translateX(10px); }
    45% { transform: translateX(-8px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
}

/* ===== SPLASH SCREEN ===== */
#splash {
    cursor: pointer;
}

.splash-tap-hint {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    z-index: 10;
    animation: hint-float 3s ease-in-out infinite;
}

.splash-text {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 20px;
    font-weight: 400;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: rgba(160, 140, 100, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.splash-line {
    display: block;
    width: 28px;
    height: 1px;
    background: rgba(160, 140, 100, 0.4);
}

@keyframes hint-float {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.75; }
    50% { transform: translateX(-50%) translateY(-3px); opacity: 0.95; }
}

/* ===== PLAYER SCREEN ===== */
.player-content {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding-top: 28%;
}

.day-badge {
    background: none;
    color: rgba(180, 160, 120, 0.75);
    font-size: 15px;
    font-weight: 700;
    padding: 6px 22px;
    border-radius: 20px;
    border: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.4);
    margin-bottom: 20px;
    animation: badge-pop 0.6s ease-out 1.5s both;
}

@keyframes badge-pop {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.stage-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    padding: 20px;
}

.play-circle {
    width: 80px;
    height: 80px;
    background: none;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.play-circle:active {
    transform: scale(0.92);
}

.play-triangle {
    font-size: 32px;
    color: rgba(180, 160, 120, 0.7);
    margin-left: 4px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.play-label {
    color: rgba(180, 160, 120, 0.7);
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 2px 6px rgba(0,0,0,0.4);
    letter-spacing: 1.5px;
}

/* ===== HISTORY BUTTON ===== */
.history-btn {
    position: absolute;
    bottom: max(5%, env(safe-area-inset-bottom, 16px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: none;
    color: rgba(180, 160, 120, 0.6);
    border: none;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
}

.history-btn:active {
    transform: translateX(-50%) scale(0.95);
    opacity: 0.7;
}

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

/* ===== VIDEO OVERLAY ===== */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0s linear 0s;
}

#video-overlay {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.close-video-btn {
    position: absolute;
    top: max(16px, env(safe-area-inset-top, 16px));
    right: 16px;
    z-index: 110;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.close-video-btn:active {
    opacity: 0.6;
}

/* ===== HISTORY OVERLAY ===== */
#history-overlay {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.history-panel {
    width: 100%;
    max-height: 85vh;
    background: linear-gradient(180deg, #2a1208 0%, #1a0a00 100%);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-top: 3px solid #ffd700;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#history-overlay.active .history-panel {
    transform: translateY(0);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.15);
}

.history-header h2 {
    color: #ffd700;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
}

.close-history-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-history-btn:active {
    opacity: 0.6;
}

.history-list {
    padding: 16px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.12);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:active {
    transform: scale(0.97);
    background: rgba(255, 215, 0, 0.1);
}

.history-item-day {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #b42814, #e04820);
    border: 2px solid #ffd700;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-item-day-num {
    color: #ffd700;
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
}

.history-item-day-label {
    color: rgba(255, 215, 0, 0.7);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-item-info {
    flex: 1;
}

.history-item-title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.history-item-date {
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    margin-top: 3px;
}

.history-item-play {
    width: 36px;
    height: 36px;
    background: rgba(180, 40, 20, 0.5);
    border: 2px solid #ffd700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #ffd700;
    font-size: 14px;
}

/* ===== NO VIDEO STATE ===== */
.no-video-msg {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    line-height: 1.6;
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/* ===== SAFE AREAS (iPhone Notch) ===== */
@supports (padding-top: env(safe-area-inset-top)) {
    .close-video-btn {
        top: calc(env(safe-area-inset-top) + 8px);
    }
    .history-btn {
        bottom: calc(env(safe-area-inset-bottom) + 12px);
    }
}

