/* -----------------------
    Variables & base styles
    ----------------------- */
:root{
    --bg: #111111;
    --panel-bg-default: #1f1f1f; 
    --panel-bg-glass: rgba(0, 0, 0, 0.6); 
    --panel-border: rgba(255,255,255,0.08);
    --radius: 16px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}
html,body{height:100%; margin:0; background:var(--bg); color: #e6eef6; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; overflow-x: hidden;}
button { font: inherit; }

/* -----------------------
    Background Layers
    ----------------------- */
.starfield{
    position:fixed; inset:0; z-index:-30; pointer-events:none;
    background: #111111; 
    overflow:hidden;
    transition: opacity 0.5s ease;
}
.starfield.hidden { opacity: 0; }

.starfield::before, .starfield::after{
    content:""; position:absolute; inset:0; mix-blend-mode:screen; opacity:0.2;
    background-repeat:repeat;
}
.starfield::before{
    background-image:
    radial-gradient(2px 2px at 10% 20%, rgba(180,180,180,0.3), transparent),
    radial-gradient(1.5px 1.5px at 30% 60%, rgba(160,160,160,0.2), transparent);
    animation: twinkle 6s linear infinite;
}
.starfield::after{
    background-image:
    radial-gradient(1px 1px at 70% 30%, rgba(140,140,140,0.15), transparent);
    transform: scale(2);
    opacity:0.15; filter: blur(1px);
    animation: twinkle 10s linear infinite;
}
@keyframes twinkle {
    0% { transform: translateY(0) translateX(0) scale(1); opacity:0.6; }
    50% { transform: translateY(-8px) translateX(6px) scale(1.02); opacity:1; }
    100% { transform: translateY(0) translateX(0) scale(1); opacity:0.6; }
}

#themeContainer {
    position: fixed; inset: 0; z-index: -20; pointer-events: none; overflow: hidden;
    background-size: cover; background-position: center; background-repeat: no-repeat;
}
#themeVideo {
    position: absolute; top: 50%; left: 50%; width: 100vw; height: 100vh;
    object-fit: cover; transform: translate(-50%, -50%);
}

/* -----------------------
    Minimal Water Layer
    ----------------------- */
#minimalWaterLayer {
    position: fixed; inset: 0; z-index: -10; pointer-events: none;
    display: none; 
    background: #000;
}
.minimal-wave-svg { width: 100%; height: 100%; display: block; }

/* -----------------------
    Layout & Panel
    ----------------------- */
.wrap { position:relative; min-height:100vh; display:flex; align-items:center; justify-content:center; padding:10px; box-sizing:border-box; }
.container { width:100%; max-width:600px; transition: max-width 0.3s ease; }

.panel { 
    border-radius: var(--radius); 
    border:1px solid var(--panel-border); 
    padding:20px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); 
    transition: background 0.3s ease, backdrop-filter 0.3s ease, border 0.3s ease, box-shadow 0.3s ease;
    background: var(--panel-bg-default); 
    position: relative;
}

.header { display:flex; align-items:center; justify-content:space-between; margin-bottom: 10px; }
h1 { margin:0; font-size:20px; font-weight: 600; color: #ffffff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }

/* Settings Icon Button - ROTATION REMOVED */
.btn.icon-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none; 
    width: auto;
}
.btn.icon-btn:hover { opacity: 1; background: transparent; transform: none; }
.btn.icon-btn img { width: 24px; height: 24px; display: block; }

/* -----------------------
    Timers Area
    ----------------------- */
.timers-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px; 
    margin-bottom: 16px; 
    flex-wrap: wrap;
}

.circle-wrap { position:relative; flex:0 0 auto; }
.circle-wrap.main { width:150px; height:150px; } 
.circle-wrap.small { width:100px; height:100px; } 

.water-container { width: 100%; height: 100%; position: relative; }
.water-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
.water-svg path { will-change: d; }

.center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; pointer-events:none; z-index: 10; }

.time-large { font-family: 'Roboto Mono', monospace; font-size:26px; font-weight:700; color: #ffffff; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
.time-medium { font-family: 'Roboto Mono', monospace; font-size:18px; font-weight:700; color: #ffffff; text-shadow: 0 2px 8px rgba(0,0,0,0.8); }
.mode-label { color:#eeeeee; font-size:12px; margin-top:4px; text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }

/* -----------------------
    Minimal Text Display
    ----------------------- */
#minimalDisplay {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
}
#minimalBigTime {
    font-family: 'Roboto Mono', monospace;
    font-size: 100px;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    line-height: 1;
    margin-bottom: 16px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
#minimalQuestionTime {
    font-family: 'Roboto Mono', monospace;
    font-size: 40px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    line-height: 1;
    text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* -----------------------
    Controls Rows
    ----------------------- */
.controls-group {
    display: flex;
    flex-direction: column;
    gap: 8px; 
    margin-bottom: 12px; 
}

.control-row {
    display: flex;
    gap: 8px; 
    width: 100%;
}

.btn { 
    flex: 1;
    display:inline-flex; align-items:center; justify-content:center; 
    padding:10px; 
    border-radius:12px; font-weight:600; font-size: 14px;
    cursor:pointer; user-select:none; border:0; 
    color: #ffffff; background: rgba(50,50,50,0.8); 
    transition: all 0.2s ease; 
    border: 1px solid rgba(255,255,255,0.08); 
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); background: rgba(70,70,70,0.9); border-color: rgba(255,255,255,0.2); }
.btn:active { transform: translateY(0); }

.btn.primary { background: #e0e0e0; color: #000000; border: none; }
.btn.primary:hover { background: #ffffff; }

.btn.break { background: #555; color: #fff; }
.btn.break:hover { background: #666; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.small-btn {
    padding: 6px 16px;
    font-size: 12px;
    border-radius: 8px;
    background: rgba(80,80,80,0.5);
    flex: 0 auto;
}
.small-btn:hover { background: rgba(100,100,100,0.8); }

/* -----------------------
    Stats Area
    ----------------------- */
.stats-area {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 12px; 
}

.progress {
    background: rgba(255,255,255,0.1);
    justify-content: flex-start;
    border-radius: 100px;
    align-items: center;
    position: relative;
    padding: 0 5px;
    display: flex;
    height: 40px;
    width: 100%;
}
.progress-value {
    transition: width 0.7s cubic-bezier(.2,.9,.2,1);
    box-shadow: 0 10px 40px -10px #fff;
    border-radius: 100px;
    background: #fff;
    height: 30px;
    width: 0;
}
.progress-row { margin-bottom: 10px; }
.progress-label-above { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.label-title { font-size: 10px; font-weight: 600; color: #aaa; text-transform: uppercase; letter-spacing: 0.5px; }
.label-count { font-size: 11px; font-weight: 700; color: #fff; font-family: 'Roboto Mono', monospace; }

.dual-timers { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:10px; }
.mini-card { 
    background: rgba(0,0,0,0.2); 
    padding:8px; 
    border-radius:10px; 
    text-align:center; 
    border: 1px solid rgba(255,255,255,0.05); 
}
.mini-card .label { font-size:10px; color: #999; text-transform: uppercase; letter-spacing: 0.5px; }
.mini-card .value { font-weight:700; font-family: 'Roboto Mono', monospace; margin-top:2px; color: #ffffff; font-size: 13px; }

/* -----------------------
    Overlays & Modals
    ----------------------- */
.overlay { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background: rgba(0,0,0,0.85); backdrop-filter: blur(6px); z-index:60; }

/* General Modal Style */
.modal { 
    width:100%; max-width:500px; 
    border-radius:12px; 
    padding:20px; 
    background: #1a1a1a; 
    border:1px solid rgba(255,255,255,0.15); 
    box-shadow: 0 18px 60px rgba(0,0,0,0.8); 
    color: #fff;
    max-height: 90vh;
    overflow-y: auto;
}

/* Hide Scrollbar but keep functionality */
.no-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.no-scrollbar::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

input[type=number], input[type=email], input[type=password], input[type=text], select, textarea, input[type=date] { 
    background: #2a2a2a; 
    color: #eee; 
    border:1px solid #444; 
    padding:10px; 
    border-radius:6px; 
    width:100%; 
    box-sizing:border-box; 
    margin-top: 4px; 
    font-family: inherit;
}
input[type=number]:focus, input[type=email]:focus, input[type=password]:focus, input[type=text]:focus, select:focus, textarea:focus, input[type=date]:focus { outline: none; border-color: #888; }
.disabled-input { opacity: 0.5; pointer-events: none; background: #111; color: #555; border-color: #222;}
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.setting-group { margin-bottom: 12px; }
.muted-label { font-size: 12px; color: #aaa; }

/* Custom Checkbox */
.toggle-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; border: 1px solid #555; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: #aaa; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #eee; border-color: #eee; }
input:checked + .slider:before { transform: translateX(18px); background-color: #1a1a1a; }


/* -----------------------
    Popups (Warning, Reset, Add Question)
    ----------------------- */
.warning-popup, .confirmation-popup {
    position: relative;
    width: 100%;
    max-width: 350px;
    border-radius: 8px; 
    padding: 24px;
    background: #1a1a1a; 
    border: 1px solid #333; 
    text-align: center;
}
.warning-popup .warning-icon { font-size: 32px; margin-bottom: 12px; }
.warning-popup .warning-title, .confirmation-popup .title { font-size: 16px; font-weight: 600; color: #fff; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px;}
.warning-popup .warning-message, .confirmation-popup .message { font-size: 13px; color: #ccc; margin-bottom: 20px; line-height: 1.5; }

.popup-actions { display: flex; gap: 10px; justify-content: center; }
.popup-btn { 
    background: #2a2a2a; border: 1px solid #444; color: #fff; 
    padding: 8px 20px; border-radius: 6px; cursor: pointer; font-size: 12px; text-transform: uppercase; 
}
.popup-btn:hover { background: #3a3a3a; border-color: #fff; }
.popup-btn.primary { background: #e0e0e0; color: #000; border-color: #e0e0e0; font-weight: bold; }
.popup-btn.primary:hover { background: #fff; }

/* -----------------------
    Auth Modal Styles
    ----------------------- */
.auth-google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: #fff; color: #000; border: none; width: 100%; margin-top: 10px;
    position: relative;
}
.auth-google-btn:hover { background: #f0f0f0; transform: translateY(-1px); }
.or-divider {
    text-align: center; margin: 16px 0; position: relative;
}
.or-divider span { background: #1a1a1a; padding: 0 10px; color: #666; font-size: 12px; position: relative; z-index: 1;}
.or-divider::before {
    content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: #333; z-index: 0;
}
.auth-footer { text-align: center; margin-top: 16px; font-size: 12px; color: #888; }
.auth-link { color: #fff; text-decoration: underline; cursor: pointer; }

/* -----------------------
    Add Question & Loader Styling
    ----------------------- */
.custom-file-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    border: 2px dashed #444;
    border-radius: 8px;
    background: #222;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    text-align: center;
    margin-top: 4px;
}
.custom-file-upload:hover { border-color: #888; background: #2a2a2a; color: #fff; }

.loader-container {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 40px 0;
}

/* Circular Loader */
.circular-loader {
    width: 80px;
    height: 80px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

@keyframes spin {
    0% { 
        transform: rotate(0deg);
    }
    100% { 
        transform: rotate(360deg);
    }
}

/* Pulse effect for loader container */
.loader-container .circular-loader::after {
    content: '';
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Question List Items in Editor */
.extracted-list {
    margin-top: 16px;
    max-height: 250px;
    overflow-y: auto;
    border-top: 1px solid #333;
    padding-top: 10px;
    /* Hide scrollbar */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.extracted-list::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

/* Crop Interface Styles */
#cropContainer {
    position: relative;
    user-select: none;
}

#imageWrapper {
    transition: transform 0.1s ease-out;
}

#cropBox {
    pointer-events: all;
    touch-action: none;
}

.crop-handle {
    z-index: 10;
    border-radius: 50%;
    border: 1px solid #000;
    transition: all 0.2s ease;
}

.crop-handle:hover {
    background: #4CAF50 !important;
    transform: scale(1.5);
}

/* Larger touch targets for mobile */
@media (max-width: 768px) {
    .crop-handle {
        width: 16px !important;
        height: 16px !important;
        margin: -8px !important;
    }
    
    .crop-handle[data-position="nw"] {
        top: 0 !important;
        left: 0 !important;
    }
    
    .crop-handle[data-position="ne"] {
        top: 0 !important;
        right: 0 !important;
    }
    
    .crop-handle[data-position="sw"] {
        bottom: 0 !important;
        left: 0 !important;
    }
    
    .crop-handle[data-position="se"] {
        bottom: 0 !important;
        right: 0 !important;
    }
}
.question-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #222;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #333;
}
.drag-handle { cursor: grab; color: #666; font-size: 16px; padding-top: 2px; }
.q-text { flex: 1; font-size: 13px; color: #ddd; line-height: 1.4; outline: none; }
.delete-q { cursor: pointer; color: #666; font-size: 16px; border: none; background: transparent; padding: 0 4px;}
.delete-q:hover { color: #ff5555; }

/* Show List Modal */
.list-section { margin-bottom: 20px; }
.list-section h4 { font-size: 12px; text-transform: uppercase; color: #888; margin: 0 0 8px 0; border-bottom: 1px solid #333; padding-bottom: 4px;}
.view-q-item { 
    font-size: 13px; color: #ccc; margin-bottom: 8px; 
    padding: 8px; background: rgba(255,255,255,0.03); border-radius: 4px;
    display: flex; align-items: center;
}
.view-q-item.completed { color: #666; }
.view-q-item.current { border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.08); color: #fff; font-weight: 500;}

.list-controls { display: flex; gap: 4px; }
.list-btn {
    background: transparent; border: 1px solid #333; color: #888; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.list-btn:hover:not(:disabled) { background: #333; color: #fff; }
.list-btn:disabled { opacity: 0.3; cursor: default; }
.list-btn.del:hover { background: #331111; color: #ff5555; border-color: #552222; }

/* -----------------------
    Break Popup
    ----------------------- */
.break-popup {
    position: relative; 
    width: 900px; 
    height: 320px; 
    padding: 0; 
    overflow: hidden; 
    background: #000;
    border-radius: 12px; 
    border: 1px solid rgba(120,120,120,0.2);
    box-shadow: 0 18px 60px rgba(0,0,0,0.9);
}

/* -----------------------------------
    Rain Animation 
    ----------------------------------- */
.rain-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 12px;
}

.rain-scene { width: 100%; height: 100%; min-height: 250px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); overflow: hidden; position: relative; }
.rain { position: relative; width: 100%; height: 100%; }
.rain:nth-of-type(1) { --duration: 2.7s; --delay: 1s; transform: translate(10%, 10%) scale(0.9); }
.rain:nth-of-type(2) { --duration: 2.1s; --delay: 1.2s; transform: translate(-20%, 40%) scale(1.3); }
.rain:nth-of-type(3) { --duration: 2.3s; --delay: 2s; transform: translate(0%, 50%) scale(1.1); }
.rain:nth-of-type(4) { --duration: 2s; --delay: 4s; transform: translate(0%, -10%) scale(1.2); }
.rain:nth-of-type(5) { --duration: 2.5s; --delay: 0s; transform: translate(10%, 0%) scale(0.9); }
.rain:nth-of-type(6) { --duration: 2s; --delay: 2.7s; transform: translate(-20%, 0%) scale(1); }
.rain:nth-of-type(7) { --duration: 1.8s; --delay: 1.3s; transform: translate(20%, -40%) scale(1.2); }
.rain:nth-of-type(8) { --duration: 2.2s; --delay: 0s; transform: translate(20%, 0%) scale(1); }
.rain:nth-of-type(9) { --duration: 2s; --delay: 0.5s; transform: translate(0%, -10%) scale(1.3); }

.drop { background-color: white; width: 3px; height: 100px; position: absolute; top: calc(50% - 100px); left: calc(50% - 1.5px); animation-name: fall; animation-duration: var(--duration); animation-delay: var(--delay); animation-iteration-count: infinite; animation-timing-function: ease-in; animation-fill-mode: backwards; }
@keyframes fall { 0% { transform: translateY(-120vh); } 45% { transform: translateY(0%); opacity: 1; } 46% { opacity: 0; } 100% { opacity: 0; } }

.waves > div { position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 50%; border: solid white 3px; animation-name: spread; animation-duration: var(--duration); animation-delay: var(--delay); animation-iteration-count: infinite; animation-timing-function: ease-out; animation-fill-mode: backwards; }
.waves > div:nth-child(2) { animation-delay: calc(var(--delay) + 0.3s); animation-timing-function: linear; }
@keyframes spread { 0% { transform: scale(0); opacity: 1; } 40% { transform: scale(0); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

.splash { position: absolute; top: 10%; bottom: 50%; left: 35%; right: 35%; border-radius: 8px; clip-path: polygon(7% 100%, 5% 95%, 3% 80%, 11% 50%, 17% 38%, 23% 44%, 30% 53%, 37% 28%, 40% 29%, 45% 43%, 51% 53%, 59% 36%, 64% 22%, 67% 23%, 70% 34%, 72% 46%, 79% 37%, 83% 37%, 93% 61%, 96% 76%, 96% 94%, 94% 100%); background-color: white; transform-origin: bottom; animation-name: splash; animation-duration: var(--duration); animation-delay: var(--delay); animation-iteration-count: infinite; animation-timing-function: ease-out; animation-fill-mode: backwards; }
@keyframes splash { 0% { transform: scale(0.3, 0); } 49% { transform: scale(0.3, 0); } 50% { transform: scale(0.3, 0.3); } 60% { transform: scale(0.7, 1); } 90% { transform: scale(1, 0); } 100% { transform: scale(1, 0); } }

.particles > div { position: absolute; border-radius: 100%; background-color: rgba(255, 255, 255, 0.9); animation-duration: var(--duration); animation-delay: var(--delay); animation-iteration-count: infinite; animation-timing-function: ease; animation-fill-mode: backwards; }
.particles > div:nth-child(1) { width: 5px; height: 5px; top: 50%; left: 50%; animation-name: jumpLeft; }
.particles > div:nth-child(2) { width: 4px; height: 4px; top: 30%; left: 50%; animation-name: jumpLeft; animation-delay: calc(var(--delay) + 0.1s); }
.particles > div:nth-child(3) { width: 3px; height: 3px; top: 20%; left: 70%; animation-name: jumpRight; animation-delay: calc(var(--delay) + 0.15s); }
.particles > div:nth-child(4) { width: 4px; height: 4px; top: 30%; left: 50%; animation-name: jumpRight; animation-delay: calc(var(--delay) + 0.3s); }

@keyframes jumpLeft {
    0% { transform: translate(0, 0) scale(0); opacity: 0; }
    45% { transform: translate(0, 0) scale(0); opacity: 0; }
    50% { transform: translate(0, 0) scale(1); opacity: 1; }
    80% { transform: translate(-40px, -60px) scale(0.5); opacity: 0.8; }
    100% { transform: translate(-60px, -90px) scale(0); opacity: 0; }
}

@keyframes jumpRight {
    0% { transform: translate(0, 0) scale(0); opacity: 0; }
    45% { transform: translate(0, 0) scale(0); opacity: 0; }
    50% { transform: translate(0, 0) scale(1); opacity: 1; }
    80% { transform: translate(40px, -60px) scale(0.5); opacity: 0.8; }
    100% { transform: translate(60px, -90px) scale(0); opacity: 0; }
}

/* -------------------------------------------
    MINIMALISTIC MODE
    ------------------------------------------- */
body.minimal-mode { background: #000 !important; }
body.minimal-mode #starfield, body.minimal-mode #themeContainer { display: none !important; }
body.minimal-mode #minimalWaterLayer { display: block; }
body.minimal-mode { background: transparent !important; }
body.minimal-mode .timers-area { display: none; }
body.minimal-mode #minimalDisplay { display: block; }
body.minimal-mode .header h1 { display: none; }
body.minimal-mode .header { justify-content: flex-end; position:fixed; top:20px; right:20px; z-index:30;}
body.minimal-mode .panel { background: transparent !important; border: none !important; box-shadow: none !important; backdrop-filter: none !important; width: 100%; max-width: none; padding: 0; }
body.minimal-mode .controls-group { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); width: 300px; z-index: 30; }
body.minimal-mode .stats-area, body.minimal-mode #questionStatus, body.minimal-mode #questionsSection { display: none !important; }
body.minimal-mode .break-popup { width: 100vw; height: 100vh; max-width: none; border-radius: 0; border: none; }

/* -------------------------------------------
    QUESTION TRUNCATION
    ------------------------------------------- */
#questionStatus {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word; 
    max-height: 7.2em; /* Fallback height approx 1.4em * 5 lines */
}

@media (max-width: 600px) {
    .timers-area { gap: 10px; margin-bottom: 12px; }
    .circle-wrap.main { width: 130px; height: 130px; }
    .circle-wrap.small { width: 90px; height: 90px; }
    .time-large { font-size: 22px; }
    .time-medium { font-size: 16px; }
    .break-popup { height: 400px; }
    .time-large { font-size: 32px; }
    #minimalBigTime { font-size: 80px; }
    #minimalQuestionTime { font-size: 30px; }
}

/* -----------------------
    CALENDAR VIEW STYLES
    ----------------------- */
.cal-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.cal-stat-box {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}
.cal-stat-box .lbl { font-size: 10px; color: #aaa; text-transform: uppercase; margin-bottom: 4px; }
.cal-stat-box .val { font-size: 14px; color: #fff; font-weight: 700; font-family: 'Roboto Mono', monospace; }

.cal-date-customizer {
    font-size: 12px;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
}
.cal-date-input {
    background: transparent;
    border: 1px solid #444;
    color: #fff;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 4px;
    width: auto;
}

.cal-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.cal-month-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}
.cal-month-substats {
    display: block;
    font-size: 11px;
    color: #888;
    font-weight: 400;
    margin-top: 2px;
    text-transform: none;
    letter-spacing: 0;
}
.cal-nav-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: #ccc;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.cal-nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

.cal-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-day-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    background: rgba(255,255,255,0.03); /* Dark by default */
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.1s, border-color 0.2s;
    border: 1px solid transparent;
}
.cal-day-cell:hover { transform: scale(1.05); border-color: rgba(255,255,255,0.3); z-index: 2; }
.cal-day-cell.inactive { opacity: 0.3; pointer-events: none; }

.cal-day-num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    color: #ffffff;
    z-index: 2;
}
.cal-day-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.2);
    transition: height 0.3s ease;
    z-index: 1;
}
/* Has data styling */
.cal-day-cell.has-data .cal-day-num { color: #fff; text-shadow: 0 1px 2px #000; }
.cal-day-cell.has-data .cal-day-fill { background: rgba(255,255,255,0.5); }
.cal-day-cell.has-data:hover .cal-day-fill { background: rgba(255,255,255,0.7); }
/* -----------------------
    MOBILE PORTRAIT MODE (height > width)
    ----------------------- */
@media (orientation: portrait) and (max-width: 768px) {
    /* Main panel - transparent with no border */
    .panel {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Header - title to left, buttons to right */
    .header {
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        z-index: 50 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }
    
    .header h1 {
        font-size: 18px !important;
        text-shadow: 0 2px 8px rgba(0,0,0,0.8) !important;
        background: transparent !important;
        padding: 6px 12px !important;
        border-radius: 8px !important;
    }
    
    .header .icon-btn {
        background: transparent !important;
        padding: 8px !important;
        border-radius: 8px !important;
    }
    
    /* Add space at top for fixed header */
    #homeView, #calendarView, #friendsView {
        padding-top: 60px !important;
    }
    
    /* Progress bars - Overall Study */
    .progress-row:nth-child(1) .label-title {
        color: #ffffff !important;
        opacity: 1 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .progress-row:nth-child(1) .label-count {
        opacity: 1 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .progress-row:nth-child(1) .progress {
        background: rgba(255, 255, 255, 0.3) !important;
    }
    
    .progress-row:nth-child(1) .progress-value {
        opacity: 0.9 !important;
    }
    
    /* Progress bars - Questions Solved */
    .progress-row:nth-child(2) .label-title {
        opacity: 1 !important;
        color: #eeeeee !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .progress-row:nth-child(2) .label-count {
        opacity: 1 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .progress-row:nth-child(2) .progress {
        background: rgba(255, 255, 255, 0.3) !important;
    }
    
    .progress-row:nth-child(2) .progress-value {
        opacity: 0.9 !important;
    }
    
    /* Mini cards - Total Left & Avg Time/Q */
    .mini-card {
        background: rgba(0, 0, 0, 0.5) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    .mini-card .label {
        opacity: 0.9 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .mini-card .value {
        opacity: 1 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    /* Overlays - full screen translucent */
    .overlay {
        background: rgba(0, 0, 0, 0.75) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
    }
    
    /* Modals - more transparent background, no border */
    .modal {
        background: rgba(26, 26, 26, 0.85) !important;
        border: none !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    /* Settings modal - NO dark background, only translucent overlay */
    #settingsModal .modal {
        background: transparent !important;
        backdrop-filter: blur(25px) !important;
        -webkit-backdrop-filter: blur(25px) !important;
        box-shadow: none !important;
    }
    
    /* Settings modal inputs and elements - make them visible */
    #settingsModal .modal input,
    #settingsModal .modal select,
    #settingsModal .modal textarea {
        background: rgba(30, 30, 30, 0.7) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    #settingsModal .modal h3,
    #settingsModal .modal .muted-label {
        text-shadow: 0 2px 6px rgba(0,0,0,0.9) !important;
    }
    
    /* Add Question modal adjustments */
    #addQuestionModal .modal {
        background: rgba(20, 20, 20, 0.85) !important;
    }
    
    /* Break popup - full screen immersive */
    .break-popup {
        background: rgba(0, 0, 0, 0.85) !important;
        backdrop-filter: blur(30px) !important;
        -webkit-backdrop-filter: blur(30px) !important;
        border: none !important;
    }
    
    /* Auth modal - translucent */
    #authModal .modal {
        background: rgba(26, 26, 26, 0.9) !important;
    }
    
    /* CALENDAR - White-ish translucent backgrounds */
    .cal-stat-box {
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.25) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    .cal-stat-box .lbl {
        opacity: 1 !important;
        color: #ddd !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .cal-stat-box .val {
        opacity: 1 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .cal-month-title {
        background: rgba(255, 255, 255, 0.15) !important;
        padding: 6px 12px !important;
        border-radius: 8px !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    #calMonthName {
        text-shadow: 0 1px 4px rgba(0,0,0,0.8) !important;
    }
    
    .cal-month-substats {
        opacity: 1 !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
    }
    
    .cal-nav-btn {
        background: rgba(255, 255, 255, 0.15) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    .cal-day-cell {
        background: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        backdrop-filter: blur(5px) !important;
        -webkit-backdrop-filter: blur(5px) !important;
    }
    
    .cal-day-cell.has-data {
        background: rgba(255, 255, 255, 0.2) !important;
        border: 1px solid rgba(255, 255, 255, 0.25) !important;
    }
    
    .cal-day-num {
        text-shadow: 0 1px 3px rgba(0,0,0,0.9) !important;
    }
    
    .cal-day-cell.has-data .cal-day-num {
        text-shadow: 0 1px 4px rgba(0,0,0,1) !important;
    }
}

/* -----------------------
    NO QUESTIONS MODE (targetQuestions = 0)
    ----------------------- */
body.no-questions-mode .circle-wrap.small {
    display: none !important;
}

body.no-questions-mode .progress-row:nth-child(2) {
    display: none !important;
}

body.no-questions-mode .dual-timers .mini-card:nth-child(2) {
    display: none !important;
}

body.no-questions-mode .dual-timers .mini-card:nth-child(1) {
    display: none !important;
}

body.no-questions-mode #questionRow {
    display: none !important;
}

body.no-questions-mode .timers-area {
    justify-content: center !important;
}

body.no-questions-mode .circle-wrap.main {
    width: 220px !important;
    height: 220px !important;
}

body.no-questions-mode .time-large {
    font-size: 48px !important;
}

body.no-questions-mode .mode-label {
    font-size: 16px !important;
}

/* For mobile - much bigger */
@media (max-width: 768px) {
    body.no-questions-mode .circle-wrap.main {
        width: 240px !important;
        height: 240px !important;
    }
    
    body.no-questions-mode .time-large {
        font-size: 50px !important;
    }
}

/* Hide question timer in minimal mode when no questions */
body.minimal-mode.no-questions-mode #minimalQuestionTime {
    display: none !important;
}

/* -----------------------
    NO QUESTIONS WATER LAYER
    ----------------------- */
#noQuestionsWaterLayer {
    position: absolute;
    display: none;
    pointer-events: none;
    z-index: 0;
    background: transparent;
    overflow: hidden;
}

/* Desktop/PC - Show water in no-questions mode */
body.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer {
    display: block !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Hide water when calendar or friends view is open —
   selectors must reach specificity (1,2,1) to beat the show rule above */
body.no-questions-mode.calendar-open #noQuestionsWaterLayer,
body.no-questions-mode.friends-open #noQuestionsWaterLayer,
body.calendar-open #noQuestionsWaterLayer,
body.friends-open #noQuestionsWaterLayer {
    display: none !important;
}

body.no-questions-mode:not(.minimal-mode) .panel {
    position: relative;
    overflow: hidden;
}

body.no-questions-mode:not(.minimal-mode) #homeView {
    position: relative;
}

/* Make all UI elements appear above water */
body.no-questions-mode:not(.minimal-mode) .header,
body.no-questions-mode:not(.minimal-mode) .timers-area,
body.no-questions-mode:not(.minimal-mode) .controls-group,
body.no-questions-mode:not(.minimal-mode) .stats-area,
body.no-questions-mode:not(.minimal-mode) .progress-row {
    position: relative;
    z-index: 10;
}

/* Hide circle timer elements in no-questions mode */
body.no-questions-mode:not(.minimal-mode) .circle-wrap.main .water-container {
    display: none !important;
}

body.no-questions-mode:not(.minimal-mode) .circle-wrap.main svg {
    display: none !important;
}

body.no-questions-mode:not(.minimal-mode) .circle-wrap.main .mode-label {
    display: none !important;
}

/* Show timer as text - centered and large */
body.no-questions-mode:not(.minimal-mode) .circle-wrap.main {
    background: transparent !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto !important;
    height: auto !important;
    position: relative;
    z-index: 10;
}

body.no-questions-mode:not(.minimal-mode) .circle-wrap.main .time-large {
    font-size: 96px !important;
    color: #ffffff !important;
    text-shadow: 0 4px 20px rgba(0,0,0,0.9) !important;
    font-weight: 700 !important;
    letter-spacing: 2px !important;
}

.noq-wave-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* More opaque water */
#noQuestionsWaterLayer path:nth-child(1) {
    fill: rgba(255,255,255,0.25) !important;
}

#noQuestionsWaterLayer path:nth-child(2) {
    fill: rgba(255,255,255,0.18) !important;
}

#noQuestionsWaterLayer path:nth-child(3) {
    fill: rgba(255,255,255,0.12) !important;
}

/* Mobile Portrait - Fill entire screen */
@media (orientation: portrait) and (max-width: 768px) {
    body.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer {
        position: fixed !important;
        display: block !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        z-index: -5;
    }
    
    body.no-questions-mode:not(.minimal-mode) .panel {
        background: transparent !important;
        overflow: visible;
    }
    
    /* More opaque water on mobile */
    body.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer path:nth-child(1) {
        fill: rgba(255,255,255,0.2) !important;
    }
    
    body.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer path:nth-child(2) {
        fill: rgba(255,255,255,0.15) !important;
    }
    
    body.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer path:nth-child(3) {
        fill: rgba(255,255,255,0.1) !important;
    }
    
    /* Timer text on mobile */
    body.no-questions-mode:not(.minimal-mode) .circle-wrap.main .time-large {
        font-size: 80px !important;
        color: #ffffff !important;
        text-shadow: 0 4px 16px rgba(0,0,0,0.95) !important;
        font-weight: 700 !important;
    }

    /* Hide water on mobile when calendar or friends tab is open */
    body.no-questions-mode.calendar-open #noQuestionsWaterLayer,
    body.no-questions-mode.friends-open #noQuestionsWaterLayer,
    body.calendar-open #noQuestionsWaterLayer,
    body.friends-open #noQuestionsWaterLayer {
        display: none !important;
    }
}

/* -----------------------
    NO QUESTIONS SESSION TIMER
    ----------------------- */
#noQuestionsSessionTimer {
    text-align: center;
    margin-top: 30px;
    position: relative;
    z-index: 10;
}

#noQSessionTime {
    font-size: 88px;
    font-weight: 700;
    color: #ffffff;
    font-family: 'Roboto Mono', monospace;
    text-shadow: 0 3px 15px rgba(0,0,0,0.9);
    letter-spacing: 1px;
}

.noq-session-label {
    display: none !important;
}

/* Mobile adjustments for session timer */
@media (orientation: portrait) and (max-width: 768px) {
    #noQSessionTime {
        font-size: 76px;
    }
}

/* Move elements downward and closer together in no-questions mode */
body.no-questions-mode:not(.minimal-mode) #noQuestionsSessionTimer {
    margin-bottom: 50px;
    margin-top: auto;
}

body.no-questions-mode:not(.minimal-mode) .controls-group {
    margin-top: 8px;
    margin-bottom: 8px;
}

body.no-questions-mode:not(.minimal-mode) .stats-area {
    margin-top: 8px;
    margin-bottom: 20px;
}

/* Decrease panel height by 20% (from 600px to 480px) */
body.no-questions-mode:not(.minimal-mode) .panel {
    min-height: 480px;
    display: flex;
    flex-direction: column;
}

/* Add flexbox to push content to bottom */
body.no-questions-mode:not(.minimal-mode) #homeView {
    display: flex;
    flex-direction: column;
    flex: 1;
}

body.no-questions-mode:not(.minimal-mode) .timers-area {
    margin-top: auto;
    display: flex;
    flex-direction: column;
}
/* Make overall study text and progress more opaque */
body.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .label-title {
    color: #ffffff !important;
    opacity: 1 !important;
    font-weight: 600 !important;
}

body.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .label-count {
    opacity: 1 !important;
    font-weight: 700 !important;
}

body.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .progress {
    background: rgba(255, 255, 255, 0.35) !important;
}

body.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .progress-value {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 0.95) !important;
}

/* Mobile spacing adjustments */
@media (orientation: portrait) and (max-width: 768px) {
    body.no-questions-mode:not(.minimal-mode) #noQuestionsSessionTimer {
        margin-bottom: 40px;
    }
    
    body.no-questions-mode:not(.minimal-mode) .controls-group {
        margin-top: 6px;
        margin-bottom: 6px;
    }
    
    body.no-questions-mode:not(.minimal-mode) .stats-area {
        margin-top: 6px;
        margin-bottom: 15px;
    }
}

/* General opacity increase for overall study in no-questions mode */
body.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) {
    opacity: 1 !important;
}

body.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) * {
    opacity: 1 !important;
}

/* Hide new water layer in minimal mode - only show original minimal water */
body.minimal-mode #noQuestionsWaterLayer {
    display: none !important;
}

/* Ensure calendar and friends content is visible */
#calendarView, #friendsView {
    padding: 0;
}

/* ==============================================
   AUTH GATE CARDS
   Shown in calendar / friends when not logged in
   or when username hasn't been created yet.
   ============================================== */

.auth-gate-card {
    position: relative;
    margin: 16px 0;
    padding: 28px 24px 24px;
    border-radius: 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
}

/* Radial background glow */
.auth-gate-glow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Icon badge */
.auth-gate-icon {
    position: relative;
    z-index: 1;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.70);
    margin-bottom: 16px;
    flex-shrink: 0;
}

.auth-gate-title {
    position: relative;
    z-index: 1;
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 8px 0;
    letter-spacing: 0.1px;
}

.auth-gate-desc {
    position: relative;
    z-index: 1;
    font-size: 13px;
    color: rgba(255,255,255,0.50);
    margin: 0 0 18px 0;
    line-height: 1.55;
    max-width: 280px;
}

/* Perks list */
.auth-gate-perks {
    position: relative;
    z-index: 1;
    list-style: none;
    margin: 0 0 22px 0;
    padding: 0;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.auth-gate-perks li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 4px;
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    text-align: left;
}

.auth-gate-perks li svg {
    flex-shrink: 0;
    color: rgba(255,255,255,0.35);
}

/* CTA button */
.auth-gate-btn {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 11px 20px;
    border-radius: 10px;
    background: rgba(255,255,255,0.92);
    color: #000000;
    font-size: 13px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
    box-shadow: 0 2px 12px rgba(255,255,255,0.15);
    font-family: inherit;
}

.auth-gate-btn:hover {
    background: #ffffff;
    box-shadow: 0 6px 22px rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.auth-gate-btn:active {
    transform: translateY(0);
}

/* ==============================================
   DARK UI THEME OVERRIDES  (body.theme-dark-ui)

   Design: Frosted white-glass surfaces, black text,
   white drop-shadows on all text for legibility.
   Settings modal + break popup are never touched
   (scoped via .panel where needed).
   ============================================== */

/* ---- Panel background: white translucent (PC only — mobile overrides below) ---- */
body.theme-dark-ui .panel {
    background: rgba(255,255,255,0.18) !important;
    border-color: rgba(255,255,255,0.30) !important;
    box-shadow: 0 10px 40px rgba(255,255,255,0.06) !important;
}

/* ---- Text: panel title ---- */
body.theme-dark-ui #panelTitle {
    color: rgba(0,0,0,0.88) !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 6px rgba(255,255,255,0.65),
                 0 2px 12px rgba(255,255,255,0.4) !important;
}

/* ---- Timer digits & mode label inside circles ---- */
body.theme-dark-ui .panel .time-large {
    color: rgba(0,0,0,0.92) !important;
    text-shadow: 0 2px 8px rgba(255,255,255,0.7),
                 0 4px 16px rgba(255,255,255,0.4) !important;
}
body.theme-dark-ui .panel .time-medium {
    color: rgba(0,0,0,0.92) !important;
    text-shadow: 0 2px 8px rgba(255,255,255,0.65),
                 0 3px 12px rgba(255,255,255,0.35) !important;
}
/* Override for text INSIDE the circular timers — white so it reads on dark waves */
body.theme-dark-ui .circle-wrap .center .time-large,
body.theme-dark-ui .circle-wrap .center .time-medium {
    color: #ffffff !important;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9),
                 0 4px 16px rgba(0,0,0,0.6) !important;
}
body.theme-dark-ui .circle-wrap .center .mode-label {
    color: rgba(255,255,255,0.85) !important;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8) !important;
}
    color: rgba(0,0,0,0.72) !important;
    text-shadow: 0 1px 5px rgba(255,255,255,0.6),
                 0 2px 8px rgba(255,255,255,0.3) !important;
}

/* ---- Buttons (scoped to .panel — settings modal & break popup untouched) ---- */
body.theme-dark-ui .panel .btn {
    background: rgba(0,0,0,0.55) !important;
    color: #ffffff !important;
    border-color: rgba(0,0,0,0.65) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35) !important;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7) !important;
    opacity: 1 !important;
    transform: none !important;
}
body.theme-dark-ui .panel .btn:hover {
    background: rgba(0,0,0,0.55) !important;
    border-color: rgba(0,0,0,0.65) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35) !important;
    transform: none !important;
}
/* Primary (Start) */
body.theme-dark-ui .panel .btn.primary {
    background: rgba(0,0,0,0.80) !important;
    color: #ffffff !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.55) !important;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7) !important;
    opacity: 1 !important;
    transform: none !important;
}
body.theme-dark-ui .panel .btn.primary:hover {
    background: rgba(0,0,0,0.80) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.55) !important;
    transform: none !important;
}
/* Break button (Start Break) */
body.theme-dark-ui .panel .btn.break {
    background: rgba(0,0,0,0.50) !important;
    color: #ffffff !important;
    border-color: rgba(0,0,0,0.62) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7) !important;
    opacity: 1 !important;
    transform: none !important;
}
body.theme-dark-ui .panel .btn.break:hover {
    background: rgba(0,0,0,0.50) !important;
    transform: none !important;
}
/* Icon buttons — fully transparent, invert PNG icons white→black */
body.theme-dark-ui .panel .btn.icon-btn {
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
body.theme-dark-ui .panel .btn.icon-btn img {
    filter: invert(1) !important;
}

/* ---- Progress bars ---- */
body.theme-dark-ui .panel .progress {
    background: rgba(255,255,255,0.30) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}
body.theme-dark-ui .panel .progress-value {
    background: rgba(0,0,0,0.72) !important;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.7) !important;
}
body.theme-dark-ui .panel .label-title {
    color: rgba(0,0,0,0.60) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.55) !important;
}
body.theme-dark-ui .panel .label-count {
    color: rgba(0,0,0,0.88) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.6) !important;
}

/* ---- Mini cards (Total Left / Avg time) ---- */
body.theme-dark-ui .panel .mini-card {
    background: rgba(255,255,255,0.40) !important;
    border-color: rgba(255,255,255,0.58) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 8px rgba(255,255,255,0.16) !important;
}
body.theme-dark-ui .panel .mini-card .label {
    color: rgba(0,0,0,0.55) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.5) !important;
}
body.theme-dark-ui .panel .mini-card .value {
    color: rgba(0,0,0,0.88) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.55) !important;
}

/* ---- Water SVG circle stroke ---- */
body.theme-dark-ui .water-svg circle {
    stroke: rgba(255,255,255,0.22) !important;
}

/* ---- Wave fills: circle timers → WHITE opacity ---- */
body.theme-dark-ui #mainWave    { fill: rgba(255,255,255,0.78) !important; }
body.theme-dark-ui #mainWave2   { fill: rgba(255,255,255,0.52) !important; }
body.theme-dark-ui #mainWave3   { fill: rgba(255,255,255,0.32) !important; }
body.theme-dark-ui #questionWave  { fill: rgba(255,255,255,0.72) !important; }
body.theme-dark-ui #questionWave2 { fill: rgba(255,255,255,0.50) !important; }
body.theme-dark-ui #questionWave3 { fill: rgba(255,255,255,0.32) !important; }

/* ---- Wave fills: minimal mode → WHITE opacity ---- */
body.theme-dark-ui #minWave1 { fill: rgba(255,255,255,0.78) !important; }
body.theme-dark-ui #minWave2 { fill: rgba(255,255,255,0.52) !important; }
body.theme-dark-ui #minWave3 { fill: rgba(255,255,255,0.32) !important; }

/* ---- Wave fills: no-questions panel flood → BLACK opacity ---- */
body.theme-dark-ui #noqWave1,
body.theme-dark-ui #noQuestionsWaterLayer path:nth-child(1) {
    fill: rgba(0,0,0,0.30) !important;
}
body.theme-dark-ui #noqWave2,
body.theme-dark-ui #noQuestionsWaterLayer path:nth-child(2) {
    fill: rgba(0,0,0,0.20) !important;
}
body.theme-dark-ui #noqWave3,
body.theme-dark-ui #noQuestionsWaterLayer path:nth-child(3) {
    fill: rgba(0,0,0,0.13) !important;
}

/* ---- No-questions big countdown ---- */
body.theme-dark-ui.no-questions-mode:not(.minimal-mode) .circle-wrap.main .time-large {
    color: rgba(0,0,0,0.92) !important;
    text-shadow: 0 2px 10px rgba(255,255,255,0.7),
                 0 4px 20px rgba(255,255,255,0.4) !important;
}
body.theme-dark-ui #noQSessionTime {
    color: rgba(0,0,0,0.92) !important;
    text-shadow: 0 2px 10px rgba(255,255,255,0.65),
                 0 4px 18px rgba(255,255,255,0.38) !important;
}

/* ---- No-questions overall study progress bar ---- */
body.theme-dark-ui.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .label-title {
    color: rgba(0,0,0,0.62) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.55) !important;
    opacity: 1 !important;
}
body.theme-dark-ui.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .label-count {
    color: rgba(0,0,0,0.88) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.6) !important;
    opacity: 1 !important;
}
body.theme-dark-ui.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .progress {
    background: rgba(255,255,255,0.30) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}
body.theme-dark-ui.no-questions-mode:not(.minimal-mode) .progress-row:nth-child(1) .progress-value {
    background: rgba(0,0,0,0.72) !important;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.6) !important;
    opacity: 1 !important;
}

/* ---- Calendar tab ---- */
body.theme-dark-ui .cal-stat-box {
    background: rgba(255,255,255,0.37) !important;
    border-color: rgba(255,255,255,0.55) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 8px rgba(255,255,255,0.12) !important;
}
body.theme-dark-ui .cal-stat-box .lbl {
    color: rgba(0,0,0,0.55) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.5) !important;
}
body.theme-dark-ui .cal-stat-box .val {
    color: rgba(0,0,0,0.90) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.55) !important;
}
body.theme-dark-ui .cal-month-title {
    color: rgba(0,0,0,0.88) !important;
    text-shadow: 0 1px 5px rgba(255,255,255,0.6) !important;
}
body.theme-dark-ui .cal-month-substats {
    color: rgba(0,0,0,0.55) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.45) !important;
}
body.theme-dark-ui .cal-nav-btn {
    background: rgba(255,255,255,0.34) !important;
    border-color: rgba(255,255,255,0.52) !important;
    color: rgba(0,0,0,0.75) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.5) !important;
}
body.theme-dark-ui .cal-nav-btn:hover {
    background: rgba(255,255,255,0.52) !important;
    color: rgba(0,0,0,0.92) !important;
}
body.theme-dark-ui .cal-grid-header {
    color: rgba(0,0,0,0.50) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.45) !important;
}
body.theme-dark-ui .cal-day-cell {
    background: rgba(255,255,255,0.18) !important;
    border-color: rgba(255,255,255,0.32) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}
body.theme-dark-ui .cal-day-cell:hover {
    border-color: rgba(255,255,255,0.70) !important;
    background: rgba(255,255,255,0.32) !important;
}
body.theme-dark-ui .cal-day-num {
    color: rgba(0,0,0,0.82) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.55) !important;
}
body.theme-dark-ui .cal-day-fill {
    background: rgba(0,0,0,0.22) !important;
}
body.theme-dark-ui .cal-day-cell.has-data {
    background: rgba(255,255,255,0.28) !important;
    border-color: rgba(255,255,255,0.48) !important;
}
body.theme-dark-ui .cal-day-cell.has-data .cal-day-fill {
    background: rgba(0,0,0,0.55) !important;
}
body.theme-dark-ui .cal-day-cell.has-data:hover .cal-day-fill {
    background: rgba(0,0,0,0.68) !important;
}
body.theme-dark-ui .cal-day-cell.has-data .cal-day-num {
    color: rgba(0,0,0,0.92) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.55) !important;
}

/* ---- Auth-gate cards (friends & calendar login/username prompts) ---- */
body.theme-dark-ui .auth-gate-card {
    background: rgba(255,255,255,0.34) !important;
    border-color: rgba(255,255,255,0.52) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: 0 4px 20px rgba(255,255,255,0.12) !important;
}
body.theme-dark-ui .auth-gate-card::before,
body.theme-dark-ui .auth-gate-glow {
    background: radial-gradient(circle, rgba(255,255,255,0.10) 0%, transparent 70%) !important;
}
body.theme-dark-ui .auth-gate-icon {
    background: rgba(255,255,255,0.47) !important;
    border-color: rgba(255,255,255,0.68) !important;
    color: rgba(0,0,0,0.72) !important;
}
body.theme-dark-ui .auth-gate-title {
    color: rgba(0,0,0,0.92) !important;
    text-shadow: 0 1px 5px rgba(255,255,255,0.65),
                 0 2px 10px rgba(255,255,255,0.35) !important;
}
body.theme-dark-ui .auth-gate-desc {
    color: rgba(0,0,0,0.62) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.5) !important;
}
body.theme-dark-ui .auth-gate-perks li {
    color: rgba(0,0,0,0.68) !important;
    border-bottom-color: rgba(0,0,0,0.10) !important;
    text-shadow: 0 1px 3px rgba(255,255,255,0.45) !important;
}
body.theme-dark-ui .auth-gate-perks li svg {
    color: rgba(0,0,0,0.52) !important;
    filter: drop-shadow(0 1px 2px rgba(255,255,255,0.5)) !important;
}
body.theme-dark-ui .auth-gate-btn {
    background: rgba(0,0,0,0.78) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35) !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5) !important;
}
body.theme-dark-ui .auth-gate-btn:hover {
    background: rgba(0,0,0,0.92) !important;
    box-shadow: 0 6px 22px rgba(0,0,0,0.45) !important;
}

/* ---- Misc in-panel text ---- */
body.theme-dark-ui .panel #questionStatus {
    color: rgba(0,0,0,0.68) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.5) !important;
}
body.theme-dark-ui .panel #bonusNotice {
    color: rgba(0,0,0,0.82) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.55) !important;
}
body.theme-dark-ui .panel #pendingNotice {
    color: rgba(0,0,0,0.62) !important;
    text-shadow: 0 1px 4px rgba(255,255,255,0.48) !important;
}

/* ---- Mobile portrait overrides for dark-ui themes ---- */
@media (orientation: portrait) and (max-width: 768px) {
    /* Panel stays transparent on mobile — overrides the PC white panel rule above */
    body.theme-dark-ui .panel {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    body.theme-dark-ui .panel .progress-row:nth-child(1) .label-title,
    body.theme-dark-ui .panel .progress-row:nth-child(2) .label-title {
        color: rgba(0,0,0,0.65) !important;
        text-shadow: 0 1px 4px rgba(255,255,255,0.6) !important;
    }
    body.theme-dark-ui .panel .progress-row:nth-child(1) .label-count,
    body.theme-dark-ui .panel .progress-row:nth-child(2) .label-count {
        color: rgba(0,0,0,0.88) !important;
        text-shadow: 0 1px 4px rgba(255,255,255,0.65) !important;
    }
    body.theme-dark-ui .panel .progress-row:nth-child(1) .progress,
    body.theme-dark-ui .panel .progress-row:nth-child(2) .progress {
        background: rgba(255,255,255,0.32) !important;
        backdrop-filter: blur(6px) !important;
        -webkit-backdrop-filter: blur(6px) !important;
    }
    body.theme-dark-ui .panel .progress-row:nth-child(1) .progress-value,
    body.theme-dark-ui .panel .progress-row:nth-child(2) .progress-value {
        background: rgba(0,0,0,0.72) !important;
        opacity: 1 !important;
    }
    body.theme-dark-ui .panel .mini-card {
        background: rgba(255,255,255,0.44) !important;
        border-color: rgba(255,255,255,0.62) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
    }
    body.theme-dark-ui .cal-stat-box {
        background: rgba(255,255,255,0.40) !important;
        border-color: rgba(255,255,255,0.58) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
    }
    body.theme-dark-ui .cal-month-title {
        background: rgba(255,255,255,0.32) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    body.theme-dark-ui .cal-nav-btn {
        background: rgba(255,255,255,0.38) !important;
        border-color: rgba(255,255,255,0.55) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }
    body.theme-dark-ui .cal-day-cell {
        background: rgba(255,255,255,0.20) !important;
        border-color: rgba(255,255,255,0.35) !important;
        backdrop-filter: blur(6px) !important;
        -webkit-backdrop-filter: blur(6px) !important;
    }
    body.theme-dark-ui .cal-day-cell.has-data {
        background: rgba(255,255,255,0.30) !important;
        border-color: rgba(255,255,255,0.48) !important;
    }
    body.theme-dark-ui .header #panelTitle {
        color: rgba(0,0,0,0.88) !important;
        font-weight: 700 !important;
        text-shadow: 0 2px 8px rgba(255,255,255,0.65),
                     0 3px 14px rgba(255,255,255,0.38) !important;
    }
    body.theme-dark-ui.no-questions-mode:not(.minimal-mode) .circle-wrap.main .time-large {
        color: rgba(0,0,0,0.92) !important;
        text-shadow: 0 2px 10px rgba(255,255,255,0.7),
                     0 4px 18px rgba(255,255,255,0.4) !important;
    }
    /* specificity (1,3,2) matches the base white rule — source order wins */
    body.theme-dark-ui.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer path:nth-child(1) {
        fill: rgba(0,0,0,0.26) !important;
    }
    body.theme-dark-ui.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer path:nth-child(2) {
        fill: rgba(0,0,0,0.17) !important;
    }
    body.theme-dark-ui.no-questions-mode:not(.minimal-mode) #noQuestionsWaterLayer path:nth-child(3) {
        fill: rgba(0,0,0,0.10) !important;
    }
    body.theme-dark-ui .panel .btn {
        background: rgba(0,0,0,0.55) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        color: #ffffff !important;
        text-shadow: 0 1px 4px rgba(0,0,0,0.7) !important;
        opacity: 1 !important;
        transform: none !important;
    }
    body.theme-dark-ui .panel .btn.primary {
        background: rgba(0,0,0,0.80) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        transform: none !important;
    }
}