/* Sidebar styles */
.counter-sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    width: min-content;
    height: min-content;
    max-height: calc(100vh - 20px);
    background: linear-gradient(135deg, rgba(var(--bg-color-r), var(--bg-color-g), var(--bg-color-b), 0.98) 0%, rgba(var(--bg-color-r), var(--bg-color-g), var(--bg-color-b), 0.95) 100%);
    backdrop-filter: blur(20px);
    border-left: 2px solid rgba(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b), 0.3);
    border-top: 2px solid rgba(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b), 0.3);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease, left 0.3s ease, right 0.3s ease;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.counter-sidebar.open {
    transform: translateX(0);
}

.counter-sidebar.left {
    left: 0;
    right: auto;
    border-left: none;
    border-right: 2px solid rgba(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b), 0.3);
    transform: translateX(-100%);
}

.counter-sidebar.left.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 24px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b), 0.2);
}

.sidebar-header h2 {
    margin: 0;
    color: rgb(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b));
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.sidebar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.position-btn {
    background: none;
    border: none;
    color: rgb(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b));
    font-size: 1.4rem;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 5px;
    line-height: 1;
    pointer-events: auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.close-btn {
    background: none;
    border: none;
    color: rgb(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b));
    font-size: 1.8rem;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.2s ease;
    padding: 5px;
    line-height: 1;
    pointer-events: auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.position-btn:hover,
.position-btn:active {
    opacity: 0.7;
}

.close-btn:hover,
.close-btn:active {
    opacity: 0.7;
}

.counter-display {
    font-family: 'DSEG7ClassicMini', monospace;
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    text-align: center;
    margin: 0 0 12px 0;
    line-height: 1;
    letter-spacing: 4px;
    background: rgba(255, 255, 255, 0.08);
    padding: 20px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.counter-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.counter-btn {
    background: linear-gradient(135deg, rgb(var(--secondary-text-color-r), var(--secondary-text-color-g), var(--secondary-text-color-b)), rgba(var(--secondary-text-color-r), var(--secondary-text-color-g), var(--secondary-text-color-b), 0.8));
    color: rgb(var(--bg-color-r), var(--bg-color-g), var(--bg-color-b));
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.counter-btn:hover,
.counter-btn:active {
    transform: translateY(-2px);
}

.counter-btn.reset {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgb(var(--tertiary-text-color-r), var(--tertiary-text-color-g), var(--tertiary-text-color-b)), rgba(var(--tertiary-text-color-r), var(--tertiary-text-color-g), var(--tertiary-text-color-b), 0.8));
    color: rgb(var(--bg-color-r), var(--bg-color-g), var(--bg-color-b));
}

/* Toggle button */
.toggle-btn {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: linear-gradient(135deg, rgb(var(--secondary-text-color-r), var(--secondary-text-color-g), var(--secondary-text-color-b)), rgba(var(--secondary-text-color-r), var(--secondary-text-color-g), var(--secondary-text-color-b), 0.8));
    border-radius: 0;
    border: none;
    border-left: 2px solid rgba(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b), 0.3);
    color: rgb(var(--bg-color-r), var(--bg-color-g), var(--bg-color-b));
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    z-index: 999;
    pointer-events: auto;
    transition: all 0.3s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    touch-action: manipulation;
}

.toggle-btn.left {
    left: 0;
    right: auto;
    border-left: none;
    border-right: 2px solid rgba(var(--primary-text-color-r), var(--primary-text-color-g), var(--primary-text-color-b), 0.3);
}

.toggle-text {
    font-size: 1rem;
    letter-spacing: 2px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 999;
    transition: background 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.open {
    pointer-events: auto;
}