* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
    /* iOS safe area support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    background-color: #fff;
}

header {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    color: white;
    padding: 1.5rem 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Link Input Section - Always visible */
.link-input-section {
    display: flex !important;
    visibility: visible !important;
    gap: 0.5rem;
    margin: 1rem;
    padding: 0.75rem;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 2px solid #ff0000;
    min-height: 60px;
    align-items: center;
}

.video-link-input {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.9rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.3s;
}

.video-link-input:focus {
    border-color: #ff0000;
}

.play-link-button {
    background-color: #ff0000;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.play-link-button:hover {
    background-color: #cc0000;
}

.play-link-button:active {
    transform: scale(0.98);
}

/* Auth Section */
.auth-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 2rem 1rem;
}

.auth-button {
    background-color: #4285f4;
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.auth-button:hover {
    background-color: #357ae8;
    transform: translateY(-1px);
}

.auth-button:active {
    transform: translateY(0);
}

.auth-hint {
    margin-top: 1rem;
    color: #666;
    font-size: 0.9rem;
    text-align: center;
}

/* App Content */
.app-content {
    padding: 1rem;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
}

.date-filter {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    background-color: white;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
    min-width: 140px;
}

.date-filter:hover {
    border-color: #ff0000;
}

.date-filter:focus {
    border-color: #ff0000;
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.refresh-button {
    background-color: #ff0000;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.refresh-button:hover {
    background-color: #cc0000;
}

.loading {
    color: #666;
    font-size: 0.9rem;
}

.version-badge {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* Video Player */
.video-player-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex !important;
    flex-direction: column;
    /* iOS safe area support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.video-player-container.hidden {
    display: none !important;
}

.player-header {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.close-button {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#player-title {
    color: white;
    font-size: 1rem;
    font-weight: 500;
    flex: 1;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#video-player {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    min-height: 0; /* Important for flexbox */
}

#video-player iframe,
#video-player #youtube-player-div {
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    width: 100%;
    height: 100%;
}

#video-player #youtube-player-div {
    position: relative;
}

/* Subscriptions List */
.subscriptions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 2rem;
}

.video-item {
    display: flex;
    gap: 1rem;
    background-color: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.video-item:active {
    transform: scale(0.98);
}

.video-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.video-thumbnail {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.video-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.video-channel {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.video-date {
    font-size: 0.75rem;
    color: #999;
}

/* Error Message */
.error-message {
    background-color: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border-left: 4px solid #c33;
}

/* No Videos Message */
.no-videos-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.25rem;
    }

    .link-input-section {
        flex-direction: column;
        gap: 0.5rem;
    }

    .play-link-button {
        width: 100%;
    }

    .video-thumbnail {
        width: 100px;
        height: 75px;
    }

    .video-title {
        font-size: 0.9rem;
    }

    .video-channel {
        font-size: 0.8rem;
    }

    .player-header {
        padding: 0.75rem;
    }

    #player-title {
        font-size: 0.9rem;
    }
}

/* Landscape orientation for video player */
@media (orientation: landscape) and (max-height: 500px) {
    .player-header {
        padding: 0.5rem;
    }

    #player-title {
        font-size: 0.85rem;
    }

    #video-player {
        padding: 0.5rem;
    }
}

