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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e0e0e0;
    --text-primary: #1a1a1a;
    --text-secondary: #333333;
    --border-color: #d0d0d0;
    --hover-bg: #e8e8e8;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --text-primary: #e0e0e0;
    --text-secondary: #ffffff;
    --border-color: #3a3a3a;
    --hover-bg: #333333;
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Remove default button focus styles */
button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

button:focus,
button:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2rem;
    text-align: center;
    flex: 1;
    color: var(--text-secondary);
}

.theme-toggle {
    background: transparent;
    border: none;
    border-radius: 50%;
    padding: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-primary);
    line-height: 1;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    color: var(--text-secondary);
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.9);
}

.stats-container {
    background-color: var(--bg-secondary);
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 30px;
    transition: background-color 0.3s ease;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats-header h2 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 0;
}

.youtube-toggle {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease, opacity 0.3s ease;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.youtube-toggle:focus {
    outline: none !important;
    box-shadow: none !important;
}

.youtube-toggle:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.youtube-toggle svg {
    width: 20px;
    height: 20px;
    fill: #ff0000;
    transition: fill 0.3s ease, opacity 0.3s ease;
}

/* Only apply hover effects on devices that support hover (not touch devices) */
@media (hover: hover) {
    .youtube-toggle:hover {
        background: var(--hover-bg);
        border-color: #ff0000;
        transform: scale(1.05);
    }

    .youtube-toggle:hover svg {
        fill: #cc0000;
    }
}

.youtube-toggle:active {
    transform: scale(0.95);
}

.youtube-toggle.active {
    background: rgba(255, 0, 0, 0.1);
    border-color: #ff0000;
}

.youtube-toggle.active svg {
    opacity: 1;
}

/* Only apply hover effects on devices that support hover (not touch devices) */
@media (hover: hover) {
    .youtube-toggle.active:hover {
        background: rgba(255, 0, 0, 0.2);
    }
}

.youtube-toggle:not(.active) svg {
    opacity: 0.7;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.stat-card {
    text-align: center;
    padding: 15px;
    background-color: var(--bg-primary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    opacity: 0.8;
    word-wrap: break-word;
    hyphens: auto;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-secondary);
}

.updated-info {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-primary);
    opacity: 0.7;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.table-section {
    margin-top: 20px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.table-header h2 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 0;
}

.table-toggle {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    line-height: 1;
}

.table-toggle:hover {
    background: var(--hover-bg);
    border-color: var(--text-primary);
    transform: scale(1.05);
}

.table-toggle:active {
    transform: scale(0.95);
}

.table-toggle span {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.table-container {
    overflow-x: auto;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    padding: 20px;
    transition: background-color 0.3s ease;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background-color: var(--bg-tertiary);
}

th {
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: bold;
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    word-break: break-word;
}

.cell-max {
    background-color: rgba(244, 67, 54, 0.2);
    font-weight: bold;
    color: #f44336;
}

[data-theme="dark"] .cell-max {
    background-color: rgba(244, 67, 54, 0.3);
    color: #e57373;
}

.cell-min {
    background-color: rgba(76, 175, 80, 0.2);
    font-weight: bold;
    color: #4caf50;
}

[data-theme="dark"] .cell-min {
    background-color: rgba(76, 175, 80, 0.3);
    color: #81c784;
}

tbody tr:hover {
    background-color: var(--hover-bg);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Mobile responsive */
@media (max-width: 767px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 0;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: 1.5rem;
        line-height: 1.2;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }
    
    .stats-container {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .stats-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .stats-header h2 {
        font-size: 1.1rem;
    }
    
    .youtube-toggle {
        width: 40px;
        height: 40px;
        padding: 8px;
        flex-shrink: 0;
    }
    
    .youtube-toggle svg {
        width: 22px;
        height: 22px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-label {
        font-size: 0.8rem;
        margin-bottom: 6px;
        line-height: 1.3;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .updated-info {
        font-size: 0.8rem;
        padding-top: 12px;
    }
    
    .table-header {
        margin-bottom: 12px;
    }
    
    .table-header h2 {
        font-size: 1.1rem;
    }
    
    .table-toggle {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    .table-container {
        padding: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.8rem;
        min-width: 100%;
    }
    
    th {
        padding: 8px 6px;
        font-size: 0.75rem;
    }
    
    td {
        padding: 8px 6px;
        font-size: 0.75rem;
    }
}

/* Tablet responsive */
@media (min-width: 768px) and (max-width: 1023px) {
    body {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .stats-container {
        padding: 18px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    table {
        font-size: 0.95rem;
    }
    
    th, td {
        padding: 10px;
    }
}

/* Desktop responsive */
@media (min-width: 1024px) {
    .header h1 {
        font-size: 2.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    table {
        font-size: 1rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .theme-toggle,
    .youtube-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    
    .theme-toggle:active,
    .youtube-toggle:active {
        transform: scale(0.95);
    }
    
    /* Disable hover effects on touch devices - hover can persist after tap */
    /* On touch devices, hover should NEVER change border to red - only .active class should */
    .theme-toggle:hover,
    .youtube-toggle:hover {
        transform: none !important;
        background: var(--bg-primary) !important;
        border-color: var(--border-color) !important;
    }
    
    .youtube-toggle:hover svg {
        fill: #ff0000 !important;
    }
    
    /* On touch devices, hover should never override the border color */
    /* The border color should only come from .active class, not from hover */
    .youtube-toggle.active:hover {
        background: rgba(255, 0, 0, 0.1) !important;
        /* Keep border from .active class, don't let hover override it */
        border-color: #ff0000 !important;
    }
    
    /* Force all hover states to use default border, except when active */
    .youtube-toggle:not(.active):hover {
        border-color: var(--border-color) !important;
    }
    
    .theme-toggle:focus,
    .youtube-toggle:focus {
        outline: none !important;
        box-shadow: none !important;
        border-color: var(--border-color) !important;
    }
    
    .youtube-toggle.active:focus {
        border-color: #ff0000 !important;
    }
    
    .theme-toggle:focus-visible,
    .youtube-toggle:focus-visible {
        outline: none !important;
        box-shadow: none !important;
    }
}

/* Mobile-specific focus removal and hover disable */
@media (max-width: 767px) {
    .youtube-toggle:focus,
    .youtube-toggle:focus-visible,
    .youtube-toggle:active:focus {
        outline: none !important;
        box-shadow: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* Disable hover effects on mobile - hover can persist after tap */
    .youtube-toggle:hover {
        background: var(--bg-primary) !important;
        border-color: var(--border-color) !important;
        transform: none !important;
    }
    
    .youtube-toggle:hover svg {
        fill: #ff0000 !important;
    }
    
    /* Only show red border when active, not on hover */
    .youtube-toggle.active:hover {
        background: rgba(255, 0, 0, 0.1) !important;
        border-color: #ff0000 !important;
    }
    
    /* Ensure non-active buttons never show red border on hover */
    .youtube-toggle:not(.active):hover {
        border-color: var(--border-color) !important;
    }
}

/* Landscape mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

