/**
 * Character Sheet CSS
 * Handles the display and stat-grid within the video cards.
 */

.char-sheet-display {
    position: absolute;
    inset: 0;
    background-color: #09090b;
    background-image:
        radial-gradient(circle at 50% 0%, var(--theme-bg, rgba(24, 24, 27, 0)) 0%, transparent 70%),
        radial-gradient(circle at 50% 50%, rgba(24, 24, 27, 1) 0%, rgba(9, 9, 11, 1) 100%);
    padding: 1rem 1rem 4rem 1rem;
    z-index: 5;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    gap: 0.75rem;
}

.char-sheet-display::after {
    content: "";
    display: block;
    min-height: 2rem;
    width: 100%;
    flex-shrink: 0;
}

.char-sheet-header {
    display: flow-root;
    width: 100%;
}

.char-sheet-portrait {
    float: right;
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease-in-out;
}

.char-sheet-portrait[style*="cursor: pointer"]:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6), 0 0 10px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

/* Sheet View Mode — matches 'me' mood technique:
   solid image-color background + greyscale portrait at 50% opacity on top */
.char-sheet-display.is-sheet-view .char-sheet-portrait {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    object-fit: cover;
    z-index: 1;
    opacity: 0.5;
    filter: grayscale(1) contrast(1.1);
    pointer-events: auto;
}

.char-sheet-display.is-sheet-view {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 3.5rem;
    overflow-x: hidden;
    position: relative;
    height: 100%;
    /* Solid image-color base — fully opaque so no dark card background bleeds through.
       Matches the me-mood which sets its own solid background at the same colour. */
    background-color: var(--theme-inner-hex, #3b82f6);
    background-image: none;
}

/* No ::after overlay needed — colour lives on the element itself */
.char-sheet-display.is-sheet-view::after {
    content: none;
}

.char-sheet-display.is-sheet-view .char-sheet-header {
    order: 2;
    /* Bio header block goes below stats */
}

.char-sheet-display.is-sheet-view .char-sheet-content {
    position: relative;
    z-index: 10;
    margin-top: 0;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.75rem;
    border-radius: 8px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
}

.char-sheet-display.is-sheet-view .char-stats-grid {
    order: 1;
    /* Stats go first */
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    box-sizing: border-box;
    gap: 0.2rem 0.4rem;
    /* Reduced gap to bring things together and prevent horizontal overflow */
    margin-top: auto;
    margin-bottom: 0.2rem;
    /* Bio sits completely flush immediately below stats */
}

/* Make typical stats inline and read like "Strength 10 +0" */
.char-sheet-display.is-sheet-view .stat-display-item {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
    /* Restore border */
    padding: 0.1rem 0.2rem;
    /* Reduced vertical padding */
    border-radius: 6px;
    box-sizing: border-box;
    /* Prevent padding from breaking horizontal fit */
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    /* allow long stats to wrap instead of cutting off */
    align-items: baseline;
    gap: 0rem 0.3rem;
    line-height: 1.1;
}

.char-sheet-display.is-sheet-view .stat-display-item:has(.stat-progress-bar),
.char-sheet-display.is-sheet-view .stat-display-item:has(.stat-hp-slider) {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0rem 0.3rem;
    line-height: 1.1;
}

.char-sheet-display.is-sheet-view .stat-display-item:has(.stat-progress-bar) .stat-display-dual,
.char-sheet-display.is-sheet-view .stat-display-item:has(.stat-hp-slider) .stat-display-dual {
    justify-content: flex-start;
}

.char-sheet-display.is-sheet-view .stat-display-item:has(.stat-progress-bar) .stat-progress-bar,
.char-sheet-display.is-sheet-view .stat-display-item:has(.stat-hp-slider) .stat-hp-slider {
    width: 100%;
}

.char-sheet-display.is-sheet-view .scroll-spacer {
    display: none !important;
}

.char-sheet-display.is-sheet-view .stat-display-label {
    width: auto;
    margin-bottom: 0;
    font-size: 0.7rem;
    /* Slightly bigger than bio text */
    color: var(--theme-text, #e2e8f0);
    font-weight: 600;
}

.char-sheet-display.is-sheet-view .stat-display-dual {
    gap: 0.25rem;
    margin-top: 0;
}

.char-sheet-display.is-sheet-view .stat-display-slash {
    display: none;
    /* Drop the parenthesis/slash */
}

.char-sheet-display.is-sheet-view .stat-display-current {
    background: transparent;
    border: none;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    padding: 0;
}

.char-sheet-display.is-sheet-view .stat-display-mod {
    font-size: 0.7rem;
    font-weight: 800;
}

.char-sheet-display.is-sheet-view input.stat-tracked-input {
    width: 2.5rem;
    text-align: left;
    -moz-appearance: textfield;
    appearance: textfield;
    cursor: text;
}

.char-sheet-display.is-sheet-view input.stat-tracked-input::-webkit-outer-spin-button,
.char-sheet-display.is-sheet-view input.stat-tracked-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.char-sheet-display.is-sheet-view input.stat-tracked-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 0 4px;
}

.char-sheet-display.is-sheet-view .stat-display-max {
    background: transparent;
    border: none;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    padding: 0;
}


.char-sheet-content {
    white-space: pre-wrap;
    min-height: min-content;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e2e8f0;
    margin-top: 1.5rem;
}

.char-sheet-content:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.char-sheet-content:empty::before {
    content: attr(data-placeholder);
    color: var(--primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
    opacity: 0.6;
    pointer-events: none;
    display: block;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Stats Grid */
.char-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.stat-display-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    position: relative;
    transition: all 0.2s ease;
}

.stat-inline-label {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
    width: 100%;
    margin-bottom: 0.2rem;
}

.stat-inline-label:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.stat-delete-btn {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border: 2px solid #0f172a;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.stat-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.15) rotate(90deg);
}

.add-stat-item {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.02);
    min-height: 40px;
    margin-top: 0.25rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.add-stat-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.stat-inline-value-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-inline-value {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    width: 100%;
}

.stat-inline-value:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.stat-inline-track {
    cursor: pointer;
    opacity: 0.3;
}

.stat-inline-track:checked {
    opacity: 1;
}

.stat-inline-value-max,
.stat-inline-value-current {
    width: 32px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.65rem;
    text-align: center;
    border-radius: 4px;
    padding: 2px;
    appearance: textfield;
}

.stat-inline-value-max::-webkit-outer-spin-button,
.stat-inline-value-max::-webkit-inner-spin-button,
.stat-inline-value-current::-webkit-outer-spin-button,
.stat-inline-value-current::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stat-inline-value-current {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    font-weight: bold;
}

.stat-inline-slash,
.stat-display-slash {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
    user-select: none;
    padding: 0 4px;
}

.stat-progress-bar {
    width: 100%;
    height: 4px;
    background: #000;
    overflow: hidden;
    margin-top: 4px;
    border-radius: 3px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-progress-fill {
    height: 100%;
    background: #ef4444;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
    float: right;
}

/* ── Interactive HP range slider (presented / non-edit view) ──────────────── */
.stat-hp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    margin-top: 5px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    /* Red fill right-of-thumb via gradient keyed to --hp-pct */
    background: linear-gradient(to right,
            #1e293b 0%,
            #1e293b var(--hp-pct, 100%),
            #ef4444 var(--hp-pct, 100%),
            #ef4444 100%);
    border: 1px solid rgba(255, 255, 255, 0.07);
    transition: background 0.1s;
}

.stat-hp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-hp-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-hp-slider:hover::-webkit-slider-thumb,
.stat-hp-slider:active::-webkit-slider-thumb {
    transform: scale(1.25);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
}

.stat-display-dual {
    display: flex;
    align-items: baseline;
    gap: 0.1rem;
    justify-content: center;
}

.stat-display-max {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.stat-display-current {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--primary);
}

/* Management buttons are hidden if we can't edit or are in read-only sheet-view mode */
.video-wrapper:not([id="local-video-wrapper"]):not(.is-gm) .add-stat-item,
.video-wrapper:not([id="local-video-wrapper"]):not(.is-gm) .theme-selector-item,
.video-wrapper:not([id="local-video-wrapper"]):not(.is-gm) .stat-delete-btn,
.char-sheet-display.is-sheet-view .add-stat-item,
.char-sheet-display.is-sheet-view .theme-selector-item,
.char-sheet-display.is-sheet-view .stat-delete-btn {
    display: none !important;
}

.add-stat-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.add-stat-btn:hover {
    color: #fff;
}

/* Theme Selector Styles */
.theme-selector-item {
    justify-content: center;
    padding: 0.5rem;
}

.theme-palette {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}

.theme-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.5rem;
}

.theme-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid transparent;
    /* outer ring = text color, set inline */
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 0;
    box-shadow: 0 0 0 0px rgba(255, 255, 255, 0);
}

.theme-swatch:hover {
    transform: scale(1.15);
}

.theme-swatch.selected {
    transform: scale(1.15);
    /* White glow behind the swatch — border stays as the outer text-color ring */
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 10px rgba(255, 255, 255, 0.5);
}

/* No-style swatch: transparent circle with ✕ */
.theme-swatch-none {
    background: transparent !important;
    border: 2px solid rgba(255, 255, 255, 0.35) !important;
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.theme-swatch-none:hover {
    border-color: rgba(255, 255, 255, 0.7) !important;
    color: white;
}

.theme-swatch-none.selected {
    border-color: rgba(255, 255, 255, 0.7) !important;
    color: white;
}

/* Dynamic Sheet View Theming
   --primary    = inner (bg accent) color, for interactive elements & progress bars
   --theme-text = outer (text label) color, for stat label text
   --theme-bg   = inner color as a translucent tint for the sheet background     */

.char-sheet-display {
    --theme-text: #93c5fd;
    --theme-bg: rgba(30, 41, 59, 0);
}

/* default: blue outer */

.char-sheet-display[data-theme="none"] {
    --primary: #6366f1;
    --theme-text: #ffffff;
    --theme-bg: rgba(15, 23, 42, 0);
}

.char-sheet-display[data-theme="blue"] {
    --primary: #3b82f6;
    --theme-text: #93c5fd;
    --theme-bg: rgba(29, 78, 216, 0.28);
}

.char-sheet-display[data-theme="red"] {
    --primary: #ef4444;
    --theme-text: #fca5a5;
    --theme-bg: rgba(185, 28, 28, 0.28);
}

.char-sheet-display[data-theme="green"] {
    --primary: #10b981;
    --theme-text: #6ee7b7;
    --theme-bg: rgba(6, 95, 70, 0.28);
}

.char-sheet-display[data-theme="purple"] {
    --primary: #8b5cf6;
    --theme-text: #c4b5fd;
    --theme-bg: rgba(109, 40, 217, 0.28);
}

.char-sheet-display[data-theme="gold"] {
    --primary: #f59e0b;
    --theme-text: #92400e;
    --theme-bg: rgba(180, 83, 9, 0.28);
}

.char-sheet-display[data-theme="dark"] {
    --primary: #475569;
    --theme-text: #cbd5e1;
    --theme-bg: rgba(15, 23, 42, 0.6);
}

.char-sheet-display[data-theme="teal"] {
    --primary: #0d9488;
    --theme-text: #99f6e4;
    --theme-bg: rgba(13, 148, 136, 0.25);
}

.char-sheet-display[data-theme="rose"] {
    --primary: #e11d48;
    --theme-text: #fda4af;
    --theme-bg: rgba(190, 18, 60, 0.28);
}

.char-sheet-display[data-theme="yellow-blue"] {
    --primary: #1d4ed8;
    --theme-text: #fde047;
    --theme-bg: rgba(29, 78, 216, 0.3);
}

.char-sheet-display[data-theme="navy-teal"] {
    --primary: #0f766e;
    --theme-text: #5b8dd9;
    --theme-bg: rgba(15, 118, 110, 0.28);
}

.char-sheet-display[data-theme="orange-black"] {
    --primary: #1c1c2e;
    --theme-text: #f97316;
    --theme-bg: rgba(17, 24, 39, 0.85);
}

.char-sheet-display[data-theme="maroon-peach"] {
    --primary: #f4845f;
    --theme-text: #c0392b;
    --theme-bg: rgba(244, 132, 95, 0.22);
}

.char-sheet-display[data-theme="purple-aqua"] {
    --primary: #38bdf8;
    --theme-text: #7c3aed;
    --theme-bg: rgba(56, 189, 248, 0.22);
}

.char-sheet-display[data-theme="navy-orange"] {
    --primary: #f97316;
    --theme-text: #3b5bdb;
    --theme-bg: rgba(249, 115, 22, 0.25);
}

.char-sheet-display[data-theme="bluegrey-sapphire"] {
    --primary: #2e5cb8;
    --theme-text: #78909c;
    --theme-bg: rgba(46, 92, 184, 0.25);
}

.char-sheet-display[data-theme="powder-chetwode"] {
    --primary: #5a7fc7;
    --theme-text: #b6d0e2;
    --theme-bg: rgba(90, 127, 199, 0.25);
}

.char-sheet-display[data-theme="inferno"] {
    --primary: #c51f05;
    --theme-text: #c51f05;
    --theme-bg: rgba(249, 184, 13, 0.3);
    --theme-inner-hex: #f9b80d;
}

.char-sheet-display[data-theme="depths"] {
    --primary: #00a8e0;
    --theme-text: #00a8e0;
    --theme-bg: rgba(0, 0, 0, 0.5);
    --theme-inner-hex: #000000;
}

.char-sheet-display[data-theme="flesh"] {
    --primary: #f0ae88;
    --theme-text: #f0ae88;
    --theme-bg: rgba(124, 46, 40, 0.3);
    --theme-inner-hex: #7c2e28;
}

.char-sheet-display[data-theme="stone"] {
    --primary: #969891;
    --theme-text: #969891;
    --theme-bg: rgba(188, 214, 225, 0.3);
    --theme-inner-hex: #bcd6e1;
}

.char-sheet-display[data-theme="acid"] {
    --primary: #474748;
    --theme-text: #474748;
    --theme-bg: rgba(178, 255, 38, 0.25);
    --theme-inner-hex: #b2ff26;
}

.char-sheet-display[data-theme="petal"] {
    --primary: #e6899a;
    --theme-text: #e6899a;
    --theme-bg: rgba(196, 193, 179, 0.3);
    --theme-inner-hex: #c4c1b3;
}

.char-sheet-display[data-theme="sand"] {
    --primary: #e2b67f;
    --theme-text: #e2b67f;
    --theme-bg: rgba(163, 58, 25, 0.3);
    --theme-inner-hex: #a33a19;
}

.char-sheet-display[data-theme="blood"] {
    --primary: #bc0024;
    --theme-text: #bc0024;
    --theme-bg: rgba(0, 0, 0, 0.5);
    --theme-inner-hex: #000000;
}

.char-sheet-display[data-theme="mystic"] {
    --primary: #bc89ff;
    --theme-text: #bc89ff;
    --theme-bg: rgba(94, 69, 128, 0.3);
    --theme-inner-hex: #5e4580;
}

/* Stat labels use the outer (text) ring color */
.stat-inline-label,
.stat-display-label {
    color: var(--theme-text, var(--primary));
}

/* Numbers always white for legibility */
.stat-display-max,
.stat-display-current,
.stat-display-mod,
.stat-inline-value-max,
.stat-inline-value-current,
.char-sheet-display.is-sheet-view .stat-display-max,
.char-sheet-display.is-sheet-view .stat-display-current,
.char-sheet-display.is-sheet-view .stat-display-mod {
    color: #ffffff !important;
}

/* Portrait tinting is handled by the ::after overlay on .is-sheet-view —
   no per-theme filter rules needed. The --primary variable per theme
   provides the true color tint automatically. */

/* 'none' theme: suppress the tint overlay and restore natural portrait color */
.char-sheet-display[data-theme="none"].is-sheet-view::after {
    display: none;
}

.char-sheet-display[data-theme="none"].is-sheet-view .char-sheet-portrait {
    filter: none;
    opacity: 0.45;
}

/* Inline Footer (Optional Contextual Controls) */
.char-sheet-footer {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    display: flex;
    justify-content: flex-start;
    gap: 0.35rem;
    padding: 0.35rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.inline-submit-btn,
.inline-cancel-btn {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s;
}

.inline-submit-btn {
    background: var(--primary);
    border: none;
    color: white;
}

.inline-submit-btn:hover {
    background: var(--primary-hover, #4f46e5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.inline-cancel-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.inline-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.video-wrapper.is-editing {
    box-shadow: 0 0 0 2px var(--primary), 0 0 20px rgba(99, 102, 241, 0.2);
}

/* ===========================================
   Stats System — Grid Layout & Item Styling
   =========================================== */

/* Containers: 2-col grid on wide screens */
.char-stats-grid,
.char-stats-editor,
.hub-stats-editor,
.create-stats-editor {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem 0.6rem;
    align-items: start;
}

/* Single column on mobile / narrow contexts */
@media (max-width: 600px) {
    .char-stats-grid,
    .char-stats-editor,
    .hub-stats-editor,
    .create-stats-editor {
        grid-template-columns: 1fr;
    }
}

/* Base stat card */
.stat-display-item {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    position: relative;
    min-width: 0;
}

/* --- Edit mode elements --- */

.stat-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.15);
    border: none;
    color: #ef4444;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.stat-display-item:hover .stat-delete-btn {
    opacity: 1;
}

.stat-inline-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary, #6366f1);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    width: calc(100% - 20px);
}

.stat-inline-value-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.stat-inline-value-max,
.stat-inline-value-current {
    width: 3rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-main, #f1f5f9);
    font-size: 0.85rem;
    padding: 2px 4px;
    text-align: center;
}

.stat-inline-slash {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
}

.stat-progress-bar {
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.2rem;
    background: #000;
}

.stat-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: #ef4444;
    transition: width 0.3s ease;
}

/* --- Read-only display elements --- */

.stat-display-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary, #6366f1);
}

.stat-display-dual {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.stat-display-max,
.stat-display-current {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main, #f1f5f9);
}

.stat-display-slash {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
}

.stat-display-mod {
    font-size: 0.8rem;
    font-weight: 600;
}

.stat-tracked-input {
    width: 3rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: var(--text-main, #f1f5f9);
    font-size: 0.85rem;
    padding: 2px 4px;
    text-align: center;
}

/* HP range slider */
.stat-hp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(
        to right,
        #ef4444 0%,
        #ef4444 var(--hp-pct, 100%),
        rgba(255, 255, 255, 0.15) var(--hp-pct, 100%),
        rgba(255, 255, 255, 0.15) 100%
    );
    margin-top: 0.3rem;
    cursor: pointer;
    outline: none;
    border: none;
}

.stat-hp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    cursor: pointer;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.stat-hp-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

/* ===========================================
   Colour Wheel Style Pickers
   =========================================== */

/* Theme selector row and Add Stat row span full grid width */
.theme-selector-item,
.add-stat-item {
    grid-column: 1 / -1;
}

/* Bottom spacer inside the stats grid */
.scroll-spacer {
    grid-column: 1 / -1;
    height: 6rem;
    flex-shrink: 0;
}

/* Picker row: label + circle input side-by-side */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.1rem 0;
}

.color-picker-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.color-picker-label span {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.4);
}

.color-picker-label input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transition: border-color 0.2s;
}

.color-picker-label input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 3px;
    border-radius: 50%;
}

.color-picker-label input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.color-picker-label input[type="color"]:hover {
    border-color: rgba(255, 255, 255, 0.4);
}

/* Add Stat button */
.add-stat-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.5rem;
    transition: all 0.15s;
}

.add-stat-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
}
