/* ==========================================================================
   CHESS PUZZLE APP - STYLE GUIDE & CORE SYSTEM
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
    --bg-app: #121212;
    --bg-card: #1C1C1E;
    --bg-elevated: #2A2A2E;
    --bg-input: #2A2A2E;
    
    --accent-blue: #4C7DF0;
    --accent-hover: #6E97F5;
    --accent-muted: #3A5CC4;
    
    --text-primary: #FFFFFF;
    --text-secondary: #9A9AA0;
    --text-tertiary: #5C5C60;
    
    --board-light: #C9D2E8;
    --board-dark: #7C8DB8;
    --board-highlight: rgba(220, 228, 247, 0.6);
    --board-selected: rgba(76, 125, 240, 0.5);
    --board-last-move: #63718F;

    --color-success: #4CAF7D;
    --color-error: #E0555A;
    --color-warning: #E0A83C;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --radius-pill: 500px;
    --radius-card: 16px;
    --radius-panel: 12px;

    /* Animation easings — "juice" */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);  /* overshoot & settle (pops, taps) */
    --ease-slide: cubic-bezier(0.34, 1.40, 0.50, 1);   /* gentle overshoot for piece slides */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);        /* smooth deceleration (bars) */
}

/* Reset & Base Elements */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #0b0b0c;
    color: var(--text-primary);
    font-family: var(--font-sans);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.desktop-wrapper {
    width: 100%;
    height: 100%;
}

/* Real app root — fills the actual device viewport. Padded by the real OS
   status bar / home indicator via safe-area-inset, not a hand-drawn fake one
   (viewport-fit=cover in index.html is required for these to resolve to real
   values instead of 0). */
.phone-frame {
    width: 100%;
    height: 100%;
    background-color: var(--bg-app);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Desktop/wide-browser web use only — real phones and the Capacitor-wrapped app
   never hit this breakpoint, so it can't affect the app build. Without it,
   .phone-frame stretches edge-to-edge on a wide window and the board (width:
   100% of that) scales up to fill the whole browser, making the existing
   mobile-tuned padding read as nothing. Caps the app at a phone-like column and
   centers it instead, the same pattern most mobile-first web apps use on desktop. */
@media (min-width: 640px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .desktop-wrapper {
        width: 430px;
        max-width: 92vw;
        height: min(100dvh, 900px);
        max-height: 92vh;
    }

    .phone-frame {
        border-radius: 28px;
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.06);
    }
}

/* Navigation Screen Routing Layout */
#screen-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    display: flex;
    flex-direction: column;
    z-index: 1;
    background-color: var(--bg-app);
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    z-index: 2;
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar */
.screen-content::-webkit-scrollbar {
    width: 4px;
}
.screen-content::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 10px;
}

/* Home Header */
.home-header {
    height: 52px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background-color: var(--bg-app);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.header-logo-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-blue);
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

/* UI Card Elements */
.profile-header-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border: 1px solid var(--bg-elevated);
}

.avatar-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-muted);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.profile-meta .username {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.profile-meta .user-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-stats-row {
    display: flex;
    border-top: 1px solid var(--bg-elevated);
    padding-top: 16px;
}

.profile-stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--bg-elevated);
}

.profile-stat-item:last-child {
    border-right: none;
}

.profile-stat-num {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-blue);
}

.profile-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Quick Stats Row */
.quick-stats-row {
    display: flex;
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-panel);
    padding: 12px 8px;
}

.quick-stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--bg-elevated);
}

.quick-stat-item:last-child {
    border-right: none;
}

.qs-num {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.qs-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Button Components */
.btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border-radius: var(--radius-pill);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.18s var(--ease-spring);
    text-align: center;
    width: 100%;
    color: #FFFFFF;
}

.btn:active {
    transform: scale(0.93);
}

/* Tap feedback on icon buttons (bounce back on release) */
.btn-icon {
    transition: transform 0.18s var(--ease-spring), color 0.2s ease, background-color 0.2s ease;
}

.btn-icon:active {
    transform: scale(0.88);
}

.btn-primary {
    background-color: var(--accent-blue);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
}

.btn-secondary:hover {
    background-color: var(--bg-elevated);
}

.btn-danger {
    background-color: transparent;
    border: 1px solid var(--color-error);
    color: var(--color-error);
}

.btn-danger:hover {
    background-color: rgba(224, 85, 90, 0.1);
}

.btn-success {
    background-color: var(--color-success);
}

.btn-success:hover {
    background-color: #5bbd8b;
}

.btn-full-width {
    width: 100%;
}

/* Understated text-only button — used for de-emphasized/secondary actions like
   "Show Solution" or "Clear All", which shouldn't compete visually with a
   primary .btn pill. */
.btn-link {
    background: none;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px;
    text-align: center;
    width: 100%;
}

.btn-link:hover {
    color: var(--accent-blue);
}

/* Play Screen Layout Header */
.play-header {
    height: 60px;
    border-bottom: 1px solid var(--bg-elevated);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background-color: var(--bg-app);
}

.play-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.btn-icon:hover {
    background-color: var(--bg-card);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.play-title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.play-mode-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-blue);
    letter-spacing: 0.5px;
}

.player-elo-bubble {
    background-color: var(--accent-blue);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
}

/* Chess Board Component */
.board-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background-color: var(--bg-card);
    border-radius: var(--radius-panel);
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.square.light {
    background-color: var(--board-light);
}

.square.dark {
    background-color: var(--board-dark);
}

.square.selected {
    background-color: var(--board-selected);
}

.square.highlight {
    background-color: var(--board-highlight);
}

/* From/to squares of the most recently played move, incl. the puzzle's own setup
   move on load — matches the last-move convention every other chess UI uses. */
.square.last-move {
    background-color: var(--board-last-move);
}

/* Simple hint marker */
.square.origin-marker {
    box-shadow: inset 0 0 0 4px rgba(224, 168, 60, 0.85);
}

/* Legal-move markers, shown for the currently selected piece */
.square.legal-move::after {
    content: "";
    position: absolute;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    background-color: rgba(18, 18, 18, 0.28);
    pointer-events: none;
}

.square.legal-capture {
    box-shadow: inset 0 0 0 4px rgba(18, 18, 18, 0.35);
}

.piece {
    width: 90%;
    height: 90%;
    object-fit: contain;
    z-index: 5;
    pointer-events: none;
}

/* Incorrect-move feedback — a small text line under the board, not a full-board
   overlay: a wrong guess shouldn't read as a punishment. Reserves its own height
   at all times so the layout doesn't jump when the text fades in/out. */
.feedback-banner {
    height: 16px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.feedback-banner.show {
    opacity: 1;
}

.feedback-banner span {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-error);
}

/* Play Screen details */
.play-content {
    gap: 12px;
    padding-left: 8px;
    padding-right: 8px;
}

.turn-guidance {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    background-color: var(--bg-card);
    padding: 8px 12px;
    border-radius: 8px;
}

.puzzle-result-summary {
    text-align: center;
    background-color: rgba(76, 175, 125, 0.08);
    border: 1px solid rgba(76, 175, 125, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
}

.puzzle-celebration {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-success);
    margin-bottom: 2px;
    animation: puzzle-celebration-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes puzzle-celebration-pop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.puzzle-result-stats {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.puzzle-result-hint-note {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 2px;
}

.play-controls {
    display: flex;
    gap: 8px;
}

.play-controls .btn {
    padding: 12px;
}

.hint-display-box {
    background-color: rgba(224, 168, 60, 0.08);
    border: 1px solid rgba(224, 168, 60, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary);
}

.text-success {
    color: var(--color-success);
}

/* Filters Screen Elements */
.filter-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--bg-elevated);
    padding-bottom: 16px;
}

.filter-section:last-of-type {
    border-bottom: none;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Groups a cluster of .filter-section blocks under one heavier heading (Puzzle
   Basics / Tactics / Position / Special Moves) so the expanded filter set reads
   as scannable sections, not one long flat stack. */
.filter-group-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 20px 0 4px;
}

.filter-group-title:first-child {
    margin-top: 0;
}

.filters-clear-row {
    display: flex;
    justify-content: flex-end;
}

.btn-clear-filters {
    width: auto;
    padding: 4px 2px;
}

/* Sits outside the scrollable .screen-content (see index.html) so the live
   count + Apply button are always reachable without scrolling past every
   filter section. */
.filters-footer {
    border-top: 1px solid var(--bg-elevated);
    background-color: var(--bg-app);
    padding: 12px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filters-notice {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-panel);
    padding: 10px 12px;
}

.filters-notice.error {
    color: var(--color-error);
    border-color: var(--color-error);
}

.filters-count {
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-height: 18px;
}

.filters-count.zero {
    color: var(--color-error);
}

.mode-toggles {
    display: flex;
    background-color: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--bg-elevated);
}

.mode-toggle-btn {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.mode-toggle-btn.active {
    background-color: var(--accent-blue);
    color: #FFFFFF;
}

.elo-bracket-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.elo-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.elo-btn.active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background-color: rgba(76, 125, 240, 0.08);
}

.mode-choice-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-card);
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    transition: transform 0.18s var(--ease-spring), border-color 0.2s ease;
}

.mode-choice-card:active {
    transform: scale(0.97);
}

.mode-choice-card:hover {
    border-color: var(--accent-blue);
}

.mode-choice-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--accent-muted);
    color: var(--accent-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.mode-choice-icon svg {
    width: 22px;
    height: 22px;
}

.mode-choice-text {
    flex: 1;
    min-width: 0;
}

.mode-choice-text h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.mode-choice-text p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.mode-choice-chevron {
    color: var(--text-tertiary) !important;
    flex-shrink: 0;
}

/* Home quick nav row — Insights + Rankings, side by side, deliberately smaller
   than the Puzzles area below since Puzzles is the primary action on Home. */
.home-quick-row {
    display: flex;
    gap: 12px;
}

.quick-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s var(--ease-spring), border-color 0.2s ease;
}

.quick-nav-btn:active {
    transform: scale(0.95);
}

.quick-nav-btn:hover {
    border-color: var(--accent-blue);
}

.quick-nav-btn svg {
    width: 18px;
    height: 18px;
    color: var(--accent-blue);
}

/* Home Puzzles area — the focused, primary entry point for playing */
.home-puzzles-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Leaderboard Screen Elements */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-row {
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-panel);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.leaderboard-row.user-row {
    background-color: rgba(76, 125, 240, 0.08);
    border-color: var(--accent-muted);
}

.row-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-rank {
    width: 24px;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 13px;
}

.leaderboard-row:nth-child(1) .row-rank {
    color: #FFD700; /* Gold */
}
.leaderboard-row:nth-child(2) .row-rank {
    color: #C0C0C0; /* Silver */
}
.leaderboard-row:nth-child(3) .row-rank {
    color: #CD7F32; /* Bronze */
}

.row-name {
    font-weight: 600;
    font-size: 13px;
}

.row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row-rating {
    font-weight: 700;
    font-size: 13px;
    color: var(--accent-blue);
}

.btn-donate {
    display: inline-block;
    background-color: var(--color-success);
    color: #FFFFFF;
    border: none;
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn-donate:hover {
    opacity: 0.85;
}

/* Paywall Screen — periodic interstitial between puzzles for non-PRO users */
.paywall-content {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 32px 24px;
    position: relative;
}

/* Top-right slot that holds the dismiss countdown, then the "x" close button. */
.paywall-dismiss-slot {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paywall-countdown {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1.5px solid var(--text-secondary);
    opacity: 0.6;
}

.paywall-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}

.paywall-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.paywall-close svg {
    width: 20px;
    height: 20px;
}

/* Account / social sign-in buttons (Settings modal) */
.btn-social {
    width: 100%;
    justify-content: center;
    margin-bottom: 8px;
}

.btn-apple {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

.btn-google {
    background: #fff;
    color: #1f1f1f;
    border: 1px solid #dadce0;
}

#account-signed-in .btn {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.btn-danger {
    background: transparent;
    color: #E0555A;
    border: 1px solid #E0555A;
}

.btn-danger:hover {
    background: rgba(224, 85, 90, 0.12);
}

.account-email {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Small muted text button (e.g. Restore Purchases) */
.btn-link-subtle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 4px 0;
    text-decoration: underline;
}

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

/* Mandatory sign-in gate (full-frame overlay, shown when not signed in) */
.signin-gate {
    position: absolute;
    inset: 0;
    z-index: 300;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 28px;
    padding-top: max(40px, env(safe-area-inset-top));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.signin-gate-content {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.signin-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(76, 125, 240, 0.3), rgba(28, 28, 30, 0.6));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    margin-bottom: 20px;
}

.signin-logo svg {
    width: 36px;
    height: 36px;
}

.signin-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
}

.signin-tagline {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.signin-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 28px;
    max-width: 300px;
}

.signin-gate .btn-social {
    max-width: 300px;
}

.signin-legal {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 20px;
}

.paywall-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(76, 125, 240, 0.25) 0%, rgba(28, 28, 30, 0.5) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-blue);
    margin-bottom: 4px;
}

.paywall-icon svg {
    width: 30px;
    height: 30px;
}

.paywall-title {
    font-size: 20px;
    font-weight: 700;
}

.paywall-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 280px;
}

/* Modals System CSS */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
    padding: 20px;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-card);
    width: 100%;
    max-width: 320px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(15px);
    transition: transform 0.25s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.modal-overlay:not(.hidden) .modal-card {
    transform: translateY(0);
}

.scrollable-modal {
    max-height: 85%;
    overflow-y: auto;
    padding: 0;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--bg-elevated);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: var(--bg-card);
    z-index: 10;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.btn-close-modal svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--bg-elevated);
    background-color: var(--bg-card);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

.modal-desc {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
    margin-bottom: 4px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Settings Layout Forms */
.setting-section {
    border-bottom: 1px solid var(--bg-elevated);
    padding-bottom: 14px;
}

.setting-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-blue);
    margin-bottom: 8px;
}

.setting-desc {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input {
    background-color: var(--bg-input);
    border: 1px solid var(--bg-elevated);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 8px;
    outline: none;
    font-size: 13px;
    font-family: var(--font-sans);
}

.input-group input:focus {
    border-color: var(--accent-blue);
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
}

/* Simulated switch toggle styling */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-elevated);
    transition: 0.3s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider-round {
    background-color: var(--accent-blue);
}

input:checked + .slider-round:before {
    transform: translateX(20px);
}

/* Helper utilities */
.hidden {
    display: none !important;
}

.flex-1 {
    flex: 1;
}

/* Insights Themes ELO list styles */
.insights-themes-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid var(--bg-elevated);
    padding-top: 16px;
}

/* Used on screen-insights, where each list already sits under a
   .filter-group-title heading — the border-top divider would be redundant. */
.insights-themes-list.no-border {
    border-top: none;
    padding-top: 0;
    margin-top: 4px;
}

.tag-elo-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tag-elo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
}

.tag-elo-label {
    color: var(--text-primary);
    text-transform: capitalize;
}

.tag-elo-val {
    color: var(--text-secondary);
    font-size: 12px;
}

.elo-bar-container {
    height: 8px;
    background-color: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
}

.elo-bar-fill {
    height: 100%;
    background-color: var(--accent-blue);
    border-radius: 4px;
    transition: width 0.7s var(--ease-out), background-color 0.4s ease;
    width: 0%;
}

/* Count-up "pop" on stat numbers (applied by animateNumber()) */
@keyframes num-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}

.num-pop {
    display: inline-block;
    animation: num-pop 0.4s var(--ease-spring);
}

/* Accessibility: honor the OS "reduce motion" setting — tame every animation/transition. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

.elo-bar-fill.strength-high {
    background-color: var(--color-success);
}

.elo-bar-fill.strength-medium {
    background-color: var(--accent-blue);
}

.elo-bar-fill.strength-low {
    background-color: var(--color-warning);
}

/* Diverging (centered-at-0) variant used by the relative-to-your-ELO Insights bars */
.elo-bar-container.diverging {
    position: relative;
}

.elo-bar-container.diverging::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--bg-primary);
    transform: translateX(-50%);
    z-index: 1;
}

.elo-bar-fill.diverging {
    position: absolute;
    top: 0;
    height: 100%;
}

.tag-elo-val.strength-high {
    color: var(--color-success);
}

.tag-elo-val.strength-medium {
    color: var(--accent-blue);
}

.tag-elo-val.strength-low {
    color: var(--color-warning);
}

/* Wrapped layout for filter option buttons */
.mode-toggles.wrap {
    flex-wrap: wrap;
    gap: 6px;
    background-color: transparent;
    border: none;
    padding: 0;
}

.mode-toggles.wrap .mode-toggle-btn {
    flex: initial;
    width: calc(50% - 3px); /* 2 columns */
    background-color: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    border-radius: 8px;
}

.mode-toggles.wrap .mode-toggle-btn.active {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}
