:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --accent: #ff6b35;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --border: #444444;
    --x-color: #000000;
    --bluesky-color: #00bcd4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 2.5rem;
}

.disclaimer {
    background-color: var(--bg-secondary);
    border: 1px solid var(--warning);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.disclaimer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.social-links {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.status-bar {
    display: grid;
    /* *** UPDATED: The new, robust grid layout *** */
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    min-height: 120px;
}

.status-section {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.status-info {
    text-align: center;
}

.status-info > div:first-child {
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.refresh-info {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 6px;
}

.timezone-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.3;
}

.buttons-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.buttons-section p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
}

.links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.events-section {
    display: flex;
    flex-direction: column;
    /* *** UPDATED: This now centers the content within its flexible grid column *** */
    align-items: center; 
    justify-content: center;
    height: 100%;
}

.events-header {
    font-weight: 700;
    color: var(--accent);
    font-size: 1.4rem;
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: 1px;
}

.events-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.events-horizontal {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.event-item {
    text-align: center;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    min-width: 200px;
    max-width: 240px;
    flex-shrink: 0;
}

.current-event {
    border-color: var(--success);
}

.upcoming-event {
    border-color: var(--warning);
}

.event-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.current-event .event-title {
    color: var(--success);
}

.upcoming-event .event-title {
    color: var(--warning);
}

.event-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-time:last-child {
    margin-bottom: 0;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-weight: 500;
    border: 2px solid transparent;
}

.social-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.x-link {
    background-color: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

.x-link:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
}

.bluesky-link {
    background-color: var(--bluesky-color);
    color: #ffffff;
    border-color: var(--bluesky-color);
}

.bluesky-link:hover {
    background-color: #00acc1;
    border-color: #00acc1;
    transform: translateY(-2px);
}

.loading, .error {
    text-align: center;
    padding: 40px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin: 20px 0;
}

.retry-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 15px;
    transition: background-color 0.3s;
}

.retry-btn:hover {
    background-color: #e55a2e;
}

.section {
    margin-bottom: 50px;
}

.section h2 {
    color: var(--accent);
    margin-bottom: 10px;
    font-size: 1.8rem;
    text-align: center;
}

.section-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

.regions-toggle {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.regions-toggle:hover {
    background-color: #e55a2e;
    transform: translateY(-1px);
}

.section-last-updated {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 25px;
}

/* Queue Section Header with Button */
.queue-section-header {
    position: relative;
    margin-bottom: 25px;
    min-height: 70px;
}

.twitch-chat-button {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #9146ff, #772ce8);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(145, 70, 255, 0.3);
    z-index: 1;
}

.twitch-chat-button:hover {
    background: linear-gradient(135deg, #8B42FF, #6B2BC4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(145, 70, 255, 0.4);
}

.twitch-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.queue-section-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
}

.queue-section-info h2 {
    margin-bottom: 5px;
    text-align: center;
}

.queue-section-info .section-last-updated {
    margin-bottom: 0;
    text-align: center;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-tertiary);
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    color: var(--accent);
    margin: 0;
    font-size: 1.4rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background-color: var(--error);
    color: white;
}

.modal-body {
    padding: 25px;
}

.step {
    margin-bottom: 30px;
}

.step:last-child {
    margin-bottom: 20px;
}

.step h4 {
    color: var(--accent);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.step p {
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.6;
}

.step ol {
    margin-left: 20px;
    color: var(--text-secondary);
}

.step ol li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.step a {
    color: var(--accent);
    text-decoration: none;
}

.step a:hover {
    text-decoration: underline;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-group select optgroup {
    color: var(--accent);
    font-weight: 600;
    font-style: normal;
    background-color: var(--bg-secondary);
}

.form-group select option {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    padding: 8px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

.command-output {
    display: flex;
    gap: 10px;
    align-items: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
}

.command-output code {
    flex: 1;
    background: none;
    color: #60a5fa;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

.copy-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

.copy-btn:hover {
    background-color: #e55a2e;
}

.copy-btn.copied {
    background-color: var(--success);
}

.example-image {
    width: 100%;
    max-width: 363px;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin: 15px 0 5px 0;
}

.advanced-section {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0 20px 0;
}

.advanced-section h5 {
    color: var(--accent);
    margin-bottom: 10px;
    font-size: 1rem;
}

.advanced-section p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.advanced-section code {
    background-color: var(--bg-primary);
    color: #60a5fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.disclaimer-text {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--warning);
    border-radius: 6px;
    padding: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Region Status Styles */
.regions-container {
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 2000px; /* Large value for expanded state */
}

.regions-container.collapsed {
    max-height: 200px;
    cursor: pointer;
}

.regions-container.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent, var(--bg-primary));
    pointer-events: none;
    z-index: 10;
}

.regions-container {
    position: relative;
}

.continents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.continent {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.continent h3 {
    color: var(--accent);
    margin-bottom: 15px;
    font-size: 1.3rem;
    text-align: center;
}

.region-item {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.region-item:last-child {
    border-bottom: none;
}

.region-status-and-info {
    display: flex;
    align-items: center;
}

.region-status {
    margin-right: 10px;
    font-size: 1rem;
}

.region-info {
    flex: 1;
}

.region-name {
    font-weight: 500;
    color: var(--text-primary);
}

.region-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.last-seen {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-left: 0;
    width: 100%;
}

.disabled-regions-explanation {
    margin-top: 20px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: white;
    font-size: 0.9rem;
    text-align: left;
}

.info-icon {
    color: var(--text-secondary);
    font-weight: bold;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Queue Times Styles */
.queue-modes {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.queue-mode {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.queue-mode-header {
    background-color: var(--bg-tertiary);
    padding: 15px 20px;
    border-bottom: 2px solid var(--accent);
}

.queue-mode-title {
    color: var(--accent);
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

.table-container {
    overflow-x: auto;
}

.queue-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.queue-table th {
    background-color: var(--bg-tertiary);
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    width: 25%; /* Equal width columns to fix alignment */
}

.queue-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    width: 25%; /* Equal width columns to fix alignment */
}

.queue-table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

.queue-table tbody tr:last-child td {
    border-bottom: none;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-online {
    background-color: var(--success);
}

.status-offline {
    background-color: var(--error);
}

.queue-time {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.time-short {
    background-color: rgba(76, 175, 80, 0.2);
    color: var(--success);
}

.time-medium {
    background-color: rgba(255, 152, 0, 0.2);
    color: var(--warning);
}

.time-long {
    background-color: rgba(244, 67, 54, 0.2);
    color: var(--error);
}

.time-unknown {
    background-color: rgba(128, 128, 128, 0.2);
    color: var(--text-secondary);
}

.time-error {
    background-color: rgba(244, 67, 54, 0.3);
    color: var(--error);
}

.time-dead {
    background-color: rgba(100, 100, 100, 0.3);
    color: #888888;
}

.table-region-name {
    font-weight: 500;
}

footer {
    text-align: center;
    margin-top: 40px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Mobile Responsiveness for Status Bar */
@media (max-width: 768px) {
    .status-bar {
        grid-template-columns: 1fr;
        justify-content: center; /* Center items in mobile view */
        gap: 20px;
        text-align: center;
        min-height: auto;
    }
    
    .status-section,
    .events-section {
        order: 0;
    }
    
    .buttons-section {
        order: 1;
    }
    
    .events-horizontal {
        flex-direction: column;
        gap: 15px;
    }
    
    .event-item {
        min-width: auto;
        width: 100%;
        max-width: 280px;
    }
    
    .event-time {
        white-space: normal;
    }
    
    .status-info > div:first-child {
        font-size: 1.2rem;
    }
    
    .refresh-info {
        font-size: 0.95rem;
    }
    
    .timezone-info {
        font-size: 0.8rem;
    }
    
    .events-header {
        font-size: 1.2rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .regions-container.collapsed {
        max-height: 200px;
    }
    
    /* Queue section mobile adjustments */
    .queue-section-header {
        position: static;
        min-height: auto;
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
	.twitch-chat-button {
		position: static;
		align-self: center;
		font-size: 0.95rem;
		padding: 12px 16px;
	}
    
    .queue-section-info {
        align-items: center;
    }
    
    .queue-section-info h2 {
        text-align: center;
    }
    
    .queue-section-info .section-last-updated {
        text-align: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .command-output {
        flex-direction: column;
        gap: 10px;
    }
    
    .command-output code {
        text-align: center;
    }
    
    .example-image {
        max-width: 100%;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 2rem;
    }

    .section h2 {
        font-size: 1.5rem;
    }

    .continents-grid {
        grid-template-columns: 1fr;
    }

    .continent {
        padding: 15px;
    }

    .queue-table {
        font-size: 0.9rem;
    }

    .queue-table th,
    .queue-table td {
        padding: 8px 6px;
    }

    .disclaimer {
        padding: 12px;
    }

    .disclaimer p {
        font-size: 0.8rem;
    }

    .section-last-updated {
        font-size: 0.8rem;
    }

    .social-links {
        padding: 15px;
    }

    .links {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .social-link {
        width: 100%;
        max-width: 250px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    .queue-table {
        font-size: 0.8rem;
        min-width: 500px; /* Slightly smaller min-width for mobile */
    }

    .queue-table th,
    .queue-table td {
        padding: 6px 4px;
    }

    .queue-time {
        min-width: 40px;
        padding: 2px 6px;
        font-size: 0.9rem;
    }

    .continent h3 {
        font-size: 1.1rem;
    }

    .region-status {
        font-size: 0.9rem;
    }

    .region-name {
        font-size: 0.9rem;
    }

    .region-location {
        font-size: 0.75rem;
    }

    .last-seen {
        font-size: 0.75rem;
    }

    .disabled-regions-explanation {
        font-size: 0.8rem;
    }

    .social-links p {
        font-size: 0.85rem;
    }

    .social-link {
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    .social-icon {
        font-size: 1rem;
    }

    .social-links {
        padding: 15px;
    }
    
    .status-bar {
        gap: 15px;
    }
    
    .event-item {
        padding: 6px 10px;
        max-width: 260px;
    }
    
    .event-title {
        font-size: 0.8rem;
    }
    
    .event-time {
        font-size: 0.7rem;
    }
    
    .status-info > div:first-child {
        font-size: 1.1rem;
    }
    
    .refresh-info {
        font-size: 0.9rem;
    }
    
    .timezone-info {
        font-size: 0.75rem;
    }
    
    .events-header {
        font-size: 1.1rem;
    }
    
    .regions-container.collapsed {
        max-height: 180px;
    }
    
	.twitch-chat-button {
		font-size: 0.9rem;
		padding: 10px 14px;
	}

	.twitch-logo {
		width: 18px;
		height: 18px;
	}
}