:root {
    --bg-dark: #0f1115;
    --bg-card: rgba(25, 28, 36, 0.7);
    --bg-card-hover: rgba(35, 39, 50, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;

    --accent-red: #ef4444;
    /* Team color */
    --accent-red-hover: #dc2626;
    --accent-red-glow: rgba(239, 68, 68, 0.3);

    --event-meeting: #8b5cf6;
    --event-dry: #f59e0b;
    --event-video: #ec4899;
    --event-goalies: #06b6d4;
    --event-practice: #10b981;
    --event-game: #ef4444;
    --event-warmup: #3b82f6;

    --font-main: 'Inter', sans-serif;

    --time-col-width: 60px;
    --day-min-width: 140px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(239, 68, 68, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.05), transparent 25%);
}

.calendar-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100vw;
    margin: 0 auto;
    position: relative;
    padding: 1rem;
}

/* Header Styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(to right, #fff, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.week-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

#currentWeekRange {
    font-size: 1.125rem;
    font-weight: 600;
    min-width: 210px;
    text-align: center;
}

button {
    cursor: pointer;
    font-family: var(--font-main);
    outline: none;
    transition: all 0.2s ease;
}

#refreshTimer {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--accent-red);
    font-variant-numeric: tabular-nums;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#refreshTimer::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 0 15px var(--accent-red-glow);
}

.btn-primary:hover {
    background: var(--accent-red-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-red-glow);
}

/* Grid Styles */
.grid-wrapper {
    flex: 1;
    display: flex;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow-y: auto;
    overflow-x: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    /* Custom scrollbar */
}

.grid-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.grid-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.grid-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.time-axis {
    width: var(--time-col-width);
    flex-shrink: 0;
    position: sticky;
    left: 0;
    background: rgba(15, 17, 21, 0.95);
    z-index: 10;
    border-right: 1px solid var(--border-color);
}

.time-slot-label {
    height: var(--hour-slot-height, 120px);
    /* default to 120px */
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.time-slot-label span {
    position: absolute;
    top: -10px;
    right: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.days-container {
    display: flex;
    flex: 1;
    min-width: 100%;
}

.day-column {
    flex: 1 1 auto;
    min-width: 80px;
    /* Forces horizontal scrolling on very narrow screens instead of compression */
    border-right: 1px solid var(--border-color);
    position: relative;
    display: flex;
    flex-direction: column;
}

.day-column:last-child {
    border-right: none;
}

.day-header {
    height: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: rgba(25, 28, 36, 0.95);
    z-index: 5;
    backdrop-filter: blur(8px);
}

.day-header.today {
    color: var(--accent-red);
}

.day-name {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.day-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.day-header.today .day-date {
    color: var(--accent-red);
}

.day-content {
    position: relative;
    flex: 1;
    /* Removed linear-gradient grid because gaps make line heights non-linear */
    min-height: var(--content-total-height, 100%);
}

.grid-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.03);
    z-index: 0;
}

.grid-gap-fill {
    position: absolute;
    left: 0;
    right: 0;
    height: 30px;
    background: repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.02) 10px,
            rgba(0, 0, 0, 0) 10px,
            rgba(0, 0, 0, 0) 20px);
    z-index: 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.time-gap-divider {
    height: 30px;
    position: relative;
    background: repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.02) 10px,
            rgba(0, 0, 0, 0) 10px,
            rgba(0, 0, 0, 0) 20px);
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

/* Event Blocks */
.event-block {
    position: absolute;
    left: 4px;
    /* overridden by inline but kept as fallback */
    right: 4px;
    border-radius: 6px;
    padding: 2px 4px;
    font-size: 0.70rem;
    overflow: hidden;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-left: 3px solid;
    transition: transform 0.2s, box-shadow 0.2s, z-index 0s;
    display: flex;
    flex-direction: column;
    z-index: 2;
    cursor: pointer;
}

.event-block:hover {
    transform: scale(1.02);
    z-index: 10 !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.event-title {
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    margin-bottom: 2px;
}

.event-time {
    font-size: 0.65rem;
    opacity: 0.8;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.event-game-teams {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin-top: auto;
    white-space: normal;
}

.event-block.expanded {
    height: auto !important;
    min-height: max-content;
    z-index: 50 !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
}

.event-block.expanded .event-title,
.event-block.expanded .event-time,
.event-block.expanded .event-game-teams {
    white-space: normal;
    overflow: visible;
}

/* Specific Event Colors */
.type-sraz {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--event-meeting);
    color: #c4b5fd;
}

.type-sucha {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--event-dry);
    color: #fcd34d;
}

.type-video {
    background: rgba(236, 72, 153, 0.2);
    border-color: var(--event-video);
    color: #f9a8d4;
}

.type-brankari {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--event-goalies);
    color: #67e8f9;
}

.type-trenink {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--event-practice);
    color: #6ee7b7;
}

.type-zapas {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--event-game);
    color: #fca5a5;
}

.type-rozbrusleni {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--event-warmup);
    color: #93c5fd;
}

/* Scroll Indicators */
.col-indicator {
    position: sticky;
    align-self: center;
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 8px 6px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: bold;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: normal;
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 85%;
    min-width: 60px;
    max-width: 100px;
    margin: 0 auto;
    cursor: pointer;
    line-height: 1.2;
}

.col-indicator.up {
    top: 40vh;
    margin-bottom: -40px;
    /* Prevent height from pushing event content */
}

.col-indicator.down {
    bottom: 40vh;
    margin-top: -40px;
    /* Prevent height from pushing event content */
}

/* Overlays */
.loading-overlay,
.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 17, 21, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active,
.error-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-overlay p {
    font-size: 1.25rem;
    font-weight: 600;
    margin-left: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-box {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-box svg {
    color: var(--accent-red);
    margin-bottom: 1rem;
}

.error-box h3 {
    margin-bottom: 0.5rem;
}

.error-box p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Animations loading events */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.event-block {
    animation: fadeInUp 0.4s ease forwards;
}