:root {
    /* Minimalist Dark Theme Palette */
    --bg-color: #1a1b1e;
    --surface-color: #2b2d31;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-color: #ff9f43;
    /* Orange */
    --accent-glow: rgba(255, 159, 67, 0.3);
    --danger-color: #ff4757;
    --border-color: #3f4146;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", monospace;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Layout Grid */
.app-container {
    width: 100%;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-layout {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    /* Prevent it from getting too wide on huge screens */
}

/* Panels */
.left-panel,
.right-panel {
    background: rgba(255, 255, 255, 0.02);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-panel {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

/* Center Stage */
.center-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}

.minimal-header {
    position: absolute;
    top: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.simple-explainer {
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    max-width: 400px;
}

/* Stats & Graph */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.score-card {
    background: var(--surface-color);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.score-card .label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.score-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

#session-timer {
    font-size: 3.5rem;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(255, 165, 0, 0.3);
    margin-bottom: 5px;
}

#session-score {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-family: 'Share Tech Mono', monospace;
    margin-bottom: 10px;
}

.progress-graph {
    margin-top: 20px;
    background: var(--surface-color);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.progress-graph svg {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
}

#graph-line {
    filter: drop-shadow(0 0 4px var(--accent-glow));
}

.graph-dot {
    fill: var(--accent-color);
    stroke: var(--bg-color);
    stroke-width: 2;
}

.graph-dot.today {
    fill: var(--text-primary);
    stroke: var(--accent-color);
    stroke-width: 2;
}

.graph-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 0 2px;
}

/* Hide mobile controls on desktop */
@media (min-width: 901px) {

    .mobile-panel-toggle,
    .panel-overlay {
        display: none;
    }
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .app-layout {
        position: relative;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        overflow: hidden;
    }

    .left-panel,
    .right-panel {
        position: fixed;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: transform 0.3s ease;
        width: 80%;
        max-width: 300px;
        background: var(--bg-color);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }

    .left-panel {
        left: 0;
        transform: translateX(-100%);
    }

    .left-panel.active {
        transform: translateX(0);
    }

    .right-panel {
        right: 0;
        transform: translateX(100%);
    }

    .right-panel.active {
        transform: translateX(0);
    }

    .center-stage {
        padding: 10px;
        grid-column: 1;
        grid-row: 1;
    }

    /* Mobile Panel Toggle Buttons */
    .mobile-panel-toggle {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        padding: 15px 8px;
        border-radius: 0 8px 8px 0;
        cursor: pointer;
        z-index: 99;
        font-size: 1.2rem;
        transition: all 0.2s;
    }

    .mobile-panel-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .mobile-panel-toggle.left {
        left: 0;
    }

    .mobile-panel-toggle.right {
        right: 0;
        border-radius: 8px 0 0 8px;
    }

    /* Overlay for panels */
    .panel-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .panel-overlay.active {
        opacity: 1;
        pointer-events: all;
    }
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: transparent;
    z-index: 10;
    width: 100%;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    background: var(--accent-color);
    border-radius: 6px;
    mask: url('favicon.png') no-repeat center / contain;
    -webkit-mask: url('favicon.png') no-repeat center / contain;
}

h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.score-group {
    display: flex;
    gap: 10px;
}

.daily-score-pill,
.total-score-pill {
    background: var(--surface-color);
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.daily-score-pill .label,
.total-score-pill .label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.daily-score-pill .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-color);
    font-family: var(--font-mono);
}

.total-score-pill .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Main Stage */
.focus-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 100px;
    /* Increased gap further */
}

.focus-title {
    font-size: 1.3rem;
    /* Slightly smaller */
    color: var(--text-secondary);
    font-weight: 400;
    text-align: center;
    max-width: 400px;
    margin-bottom: 30px;
    /* Adjusted margin */
    line-height: 1.5;
}

.highlight-text {
    font-weight: 700;
    color: var(--text-primary);
}

.focus-circle-container {
    position: relative;
    width: 300px;
    height: 300px;
    flex-shrink: 0;
    background: var(--surface-color);
    border-radius: 50%;

    /* Circular Focus Area */
    /* Focus Tips */
    .focus-tips {
        display: flex;
        gap: 20px;
        margin-top: 40px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .tip-item {
        display: flex;
        align-items: center;
        gap: 10px;
        background: rgba(255, 255, 255, 0.03);
        padding: 10px 15px;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.05);
        max-width: 250px;
    }

    .tip-icon {
        font-size: 1.2rem;
    }

    .tip-item p {
        font-size: 0.85rem;
        color: var(--text-secondary);
        margin: 0;
        line-height: 1.3;
    }

    .tip-sub {
        font-size: 0.75rem;
        opacity: 0.7;
    }

    box-shadow: 0 0 0 1px var(--border-color),
    0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: transform 0.3s ease,
    box-shadow 0.3s ease;
}

.mining .focus-circle-container {
    transform: scale(1.02);
    box-shadow: 0 15px 50px var(--accent-glow);
}

.flywheel-container {
    width: 80%;
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-color);
}

.flywheel {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.turbine {
    transform-origin: 50px 50px;
    /* Default speed, will be overridden by JS */
    animation: spin var(--spin-speed, 10s) linear infinite;
}

.core {
    transform-origin: 50px 50px;
    transition: transform 0.1s;
}

.core.pulse {
    animation: pulse 0.3s ease-out;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(2);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.focus-status {
    position: absolute;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#session-timer {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 500;
    color: var(--text-primary);
}

.hashrate-badge {
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    color: var(--accent-color);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Controls */
.action-area {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
}

.btn {
    border: none;
    padding: 16px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary-action {
    background: var(--accent-color);
    color: #1a1b1e;
    /* Dark text on orange */
    box-shadow: 0 4px 20px rgba(255, 159, 67, 0.2);
}

.btn.primary-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 159, 67, 0.3);
}

.btn.secondary-action {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn.secondary-action:hover:not(:disabled) {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* Drawer (Leaderboard) */
.drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: var(--surface-color);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.drawer.active {
    right: 0;
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
}

#leaderboard-list {
    list-style: none;
}

#leaderboard-list li {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

#leaderboard-list li span:last-child {
    font-weight: 600;
    color: var(--accent-color);
}

/* Overlay (Onboarding) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Changed from center to allow scrolling */
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    /* Enable scrolling */
    padding: 20px;
    /* Add padding to prevent edge touching */
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

#auth-modal {
    z-index: 1100;
    /* Ensure it appears above onboarding overlay */
}

.onboarding-card {
    background: var(--surface-color);
    width: 90%;
    max-width: 450px;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin: auto;
    /* Center vertically when height allows */
}

.onboarding-card h2 {
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.step {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.step-icon {
    font-size: 2rem;
    background: #F5F5F7;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
}

.step h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.step p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.login-form input {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background: #F9F9F9;
}

.login-form input:focus {
    outline: none;
    border-color: var(--text-primary);
    background: #fff;
}

/* Explainer Section */
.explainer-section {
    margin-top: 40px;
    text-align: left;
    max-width: 550px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.explainer-section h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-align: center;
}

.explainer-section .tagline {
    font-size: 1rem;
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: 25px;
    text-align: center;
}

.explainer-body p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 25px;
}

.explainer-list h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.explainer-list ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.explainer-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.explainer-list li strong {
    color: var(--text-primary);
}

.list-icon {
    font-size: 1.2rem;
    line-height: 1;
    min-width: 24px;
}

.footer-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 20px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    margin-bottom: 20px;
}

/* Adjust main stage to accommodate extra content */
.focus-stage {
    justify-content: flex-start;
    /* Allow scrolling if needed */
    overflow-y: auto;
    padding-bottom: 40px;
}

/* Group Controls */
.leaderboard-controls {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#leaderboard-select {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    background: var(--surface-color);
    color: var(--text-primary);
}

.group-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-primary);
}

/* Modals */
.modal-card {
    background: var(--surface-color);
    width: 90%;
    max-width: 400px;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.modal-card h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.modal-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-actions .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn.primary {
    background: var(--accent-color);
    color: #1a1b1e;
    font-weight: 600;
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

#create-group-btn,
#join-group-btn {
    position: relative;
    z-index: 2000;
    pointer-events: auto;
}

/* Hide group actions when onboarding is active */
#onboarding-overlay.active~.app-layout .right-panel .group-actions {
    display: none;
}