html {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

:root {
    /* UI Font */
    --font-ui: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* Background */
    --bg-primary: #1a1a2e;
    --bg-mid: #16213e;
    --bg-deep: #0f3460;
    --glow-a: rgba(91, 156, 245, 0.18);
    --glow-b: rgba(108, 92, 231, 0.2);

    /* Panels / cards / modals */
    --panel-bg: rgba(255, 255, 255, 0.05);
    --panel-border: rgba(255, 255, 255, 0.1);
    --modal-bg-start: #2c3e50;
    --modal-bg-end: #1a252f;
    --select-bg: rgba(44, 62, 80, 0.8);
    --select-bg-hover: rgba(44, 62, 80, 1);

    /* Accent colors */
    --accent: #5b9cf5;
    --accent-rgb: 91, 156, 245;
    --accent-secondary: #4a7fe0;
    --accent-secondary-dark: #3a6acc;

    /* Focus ring */
    --focus-ring: rgba(91, 156, 245, 0.2);

    /* Slot highlight */
    --slot-highlight-bg: rgba(91, 156, 245, 0.3);
    --slot-highlight-border: #5b9cf5;

    /* Hint system */
    --hint-glow: rgba(91, 156, 245, 0.8);
    --hint-ghost-border: rgba(91, 156, 245, 0.6);
    --hint-ghost-bg: rgba(91, 156, 245, 0.1);

    /* Hint banner border */
    --hint-banner-border: rgba(91, 156, 245, 0.3);

    /* Journey badges */
    --badge-unlocked-bg: rgba(91, 156, 245, 0.2);
    --badge-unlocked-color: #5b9cf5;
    --badge-completed-bg: rgba(74, 127, 224, 0.2);
    --badge-completed-color: #4a7fe0;

    /* Resume button */
    --resume-bg-start: #4a7fe0;
    --resume-bg-end: #3a6acc;
    --resume-shadow: rgba(91, 156, 245, 0.3);

    /* Puzzle board */
    --board-bg: rgba(255, 255, 255, 0.1);
    --board-border-dashed: rgba(255, 255, 255, 0.2);

    /* Semantic colors */
    --color-success: #22c55e;
    --color-success-text: #34d399;
    --color-success-light: #6ee7a0;
    --color-gold: #FFE566;

    /* Overlay / backdrop */
    --overlay-modal: rgba(0, 0, 0, 0.8);
    --overlay-heavy: rgba(0, 0, 0, 0.88);

    /* Celebration float text gradient */
    --float-text-top: #c8e6ff;
    --float-text-bottom: #1e50d4;
}

body.warm-theme {
    --bg-primary: #1f1410;
    --bg-mid: #2a1a10;
    --bg-deep: #3a2215;
    --glow-a: rgba(245, 166, 35, 0.2);
    --glow-b: rgba(200, 100, 50, 0.18);

    --modal-bg-start: #3a2518;
    --modal-bg-end: #261810;
    --select-bg: rgba(60, 40, 25, 0.8);
    --select-bg-hover: rgba(70, 48, 30, 1);

    --accent: #f5a623;
    --accent-rgb: 245, 166, 35;
    --accent-secondary: #e88a30;
    --accent-secondary-dark: #d07520;

    --focus-ring: rgba(245, 166, 35, 0.2);

    --slot-highlight-bg: rgba(245, 166, 35, 0.3);
    --slot-highlight-border: #f5a623;

    --hint-glow: rgba(245, 166, 35, 0.8);
    --hint-ghost-border: rgba(245, 166, 35, 0.6);
    --hint-ghost-bg: rgba(245, 166, 35, 0.1);

    --hint-banner-border: rgba(245, 166, 35, 0.3);

    --badge-unlocked-bg: rgba(245, 166, 35, 0.2);
    --badge-unlocked-color: #f5a623;
    --badge-completed-bg: rgba(232, 138, 48, 0.2);
    --badge-completed-color: #e88a30;

    --resume-bg-start: #e88a30;
    --resume-bg-end: #d07520;
    --resume-shadow: rgba(232, 138, 48, 0.3);


    /* Celebration float text gradient */
    --float-text-top: #ffe566;
    --float-text-bottom: #c8450a;
}

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

button,
input,
select,
textarea,
label {
    font-family: inherit;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-primary);
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M0 0h28v9.8C28 9.8 24.5 9.8 24.5 13.5S28 17.2 28 17.2V28H17.2C17.2 28 17.2 24.5 13.5 24.5S9.8 28 9.8 28H0V17.2C0 17.2 3.5 17.2 3.5 13.5S0 9.8 0 9.8z' fill='%23ffffff' fill-opacity='0.025'/%3E%3Cpath d='M40 40h28v9.8c0 0-3.5 0-3.5 3.7s3.5 3.7 3.5 3.7V68H57.2c0 0 0-3.5-3.7-3.5S49.8 68 49.8 68H40V57.2c0 0 3.5 0 3.5-3.7S40 49.8 40 49.8z' fill='%23ffffff' fill-opacity='0.025'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 15% 15%, var(--glow-a) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 85%, var(--glow-b) 0%, transparent 55%),
        linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-mid) 50%, var(--bg-deep) 100%);
    height: 100%;
    color: #fff;
    overflow: hidden;
    overscroll-behavior: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 35px;
    padding: 20px 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-mascot {
    width: 96px;
    height: 96px;
    object-fit: contain;
    filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.3));
}

.puzzle-icon {
    position: relative;
    width: 50px;
    height: 50px;
}

.puzzle-icon .piece {
    position: absolute;
    font-size: 1.8rem;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
}

.puzzle-icon .piece-1 {
    top: 0;
    left: 0;
    animation-delay: 0s;
}

.puzzle-icon .piece-2 {
    top: 12px;
    left: 18px;
    transform: rotate(45deg);
    animation-delay: 1.5s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-5px) rotate(5deg);
    }
}

.puzzle-icon .piece-2 {
    animation-name: float2;
}

@keyframes float2 {

    0%,
    100% {
        transform: translateY(0) rotate(45deg);
    }

    50% {
        transform: translateY(-5px) rotate(50deg);
    }
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header h1 .highlight {
    background: linear-gradient(135deg, #f39c12 0%, #e74c3c 50%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    letter-spacing: 1px;
    margin-top: 5px;
}

/* Game Area Layout (3-column) */
.game-area {
    display: flex;
    flex-wrap: nowrap;
    /* Prevent wrapping so sidebars stay on sides */
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
    width: 100%;
    max-width: 1400px;
    /* Increased to fit 3 columns */
    margin: 0 auto;
}

/* Left Sidebar Styles */
.controls-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    position: relative;
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.07) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 20px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.18),
        0 12px 32px rgba(0, 0, 0, 0.12);
}

.sidebar-title {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    font-weight: 600;
}

/* Full width buttons for sidebar */
.btn-full {
    width: 100%;
    justify-content: center;
    margin-bottom: 12px;
}

.btn-full:last-child {
    margin-bottom: 0;
}

/* Updated Select Styles for sidebar */
.select-wrapper {
    margin-bottom: 15px;
}

.select-wrapper:last-child {
    margin-bottom: 0;
}

.select-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

select {
    width: 100%;
    /* re-using existing select styling */
}



/* Button Styles */
.btn-primary,
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.btn-primary,
.btn-secondary,
.btn-reference {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.28);
    color: #fff;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-reference:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.17);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.btn-primary:active,
.btn-secondary:active,
.btn-reference:active {
    transform: translateY(1px);
    background: rgba(255, 255, 255, 0.07);
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(0, 0, 0, 0.2) inset;
}

/* Specific active state for Reference button toggle */
.btn-reference.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.25) 100%);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1) inset;
}

.btn-reference {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Reference Overlay Styles */
.reference-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-heavy);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.2s ease-out;
}

.reference-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.reference-image {
    max-width: 85vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.1);
    animation: referenceZoomIn 0.2s ease-out;
}

@keyframes referenceZoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.reference-hint {
    margin-top: 25px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    padding: 10px 25px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 30px;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-icon-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.btn-icon-img.muted {
    opacity: 0.35;
}

.btn-text {
    letter-spacing: 0.5px;
}

/* Select Wrapper Styles */
.select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.select-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

select {
    padding: 10px 16px;
    font-size: 0.95rem;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--select-bg);
    color: #fff;
    min-width: 140px;
}

select:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: var(--select-bg-hover);
}

select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

#imageUpload {
    display: none;
}

.puzzle-container {
    background: var(--board-bg);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: visible;
    flex: 1 1 auto;
    min-width: 400px;
    min-height: 400px;
    max-width: 600px;
    height: 600px;
    position: relative;
}

/* Free-form board styles */
.puzzle-container.free-form-board {
    display: block;
    flex-shrink: 0;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.18),
        0 12px 32px rgba(0, 0, 0, 0.12);
    cursor: default;
    min-height: auto;
}

.board-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

.board-placeholder p {
    margin: 10px 0;
    font-size: 1.2rem;
}

.board-placeholder .hint {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.25);
}

.pieces-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 260px;
    flex-shrink: 0;
    overflow: visible;
    gap: 16px;
}

.pieces-title {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
    margin-top: 0;
    font-size: 1rem;
    font-weight: normal;
    display: none;
}

.pieces-container {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    max-width: 260px;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: visible;
    display: grid;
    gap: 10px;
    align-content: flex-start;
    justify-content: center;
    justify-items: center;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.18),
        0 12px 32px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
}

/* Dynamic grid columns will be set via JS */
.pieces-container.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.pieces-container.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.pieces-container.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.pieces-container.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

/* Tray slot - holds piece in place */
.tray-slot {
    position: relative;
    flex-shrink: 0;
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

/* Magnetic snap animation - piece slides into place */
.tray-slot.magnetic-insert {
    /* Slot appears instantly at full size */
    opacity: 1;
}

.tray-slot.magnetic-insert .puzzle-piece {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.tray-slot.inserting {
    opacity: 0;
    transform: scale(0.5);
}

.tray-slot.empty {
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.tray-slot.holding {
    /* Slot holds space while piece is being dragged.
       Use outline instead of border to avoid changing box size and causing tray reflow. */
    background: rgba(255, 255, 255, 0.03);
    outline: 2px dashed rgba(255, 255, 255, 0.15);
    outline-offset: -2px;
    border-radius: 8px;
}

.tray-slot.removing {
    opacity: 0;
    transform: scale(0.8);
    width: 0 !important;
    min-width: 0;
    padding: 0;
    margin: 0;
    gap: 0;
}

.puzzle-slot {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.puzzle-slot.highlight {
    background: var(--slot-highlight-bg);
    border-color: var(--slot-highlight-border);
}

.puzzle-slot.filled {
    border: none;
}

/* Jigsaw mode styles */
.puzzle-container.jigsaw-mode {
    overflow: visible;
}

.puzzle-piece {
    cursor: pointer;
    transition: filter 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    filter: drop-shadow(2px 4px 4px rgba(0, 0, 0, 0.5)) drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.25));
    background: transparent;
}

/* Square pieces (no SVG) */
.puzzle-piece:not(:has(svg)) {
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.3), inset -1px -1px 2px rgba(0, 0, 0, 0.3);
}

.puzzle-piece.tray-piece {
    position: relative;
    flex-shrink: 0;
}

.puzzle-piece.free-piece {
    position: absolute;
    cursor: pointer;
}

.puzzle-piece:hover {
    filter: drop-shadow(4px 6px 8px rgba(0, 0, 0, 0.55)) drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.3)) brightness(1.08);
}

.puzzle-piece:not(:has(svg)):hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.puzzle-piece.dragging {
    opacity: 0.9;
    cursor: pointer;
    filter: drop-shadow(6px 10px 14px rgba(0, 0, 0, 0.55)) drop-shadow(2px 4px 4px rgba(0, 0, 0, 0.3));
}

.puzzle-piece:not(:has(svg)).dragging {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.puzzle-piece.selected {
    filter: brightness(1.2);
}

/* Joined pieces — fade internal edges for seamless look */
.puzzle-piece.joined .piece-outline {
    stroke: rgba(0, 0, 0, 0.08);
    stroke-width: 0.6;
    transition: stroke 0.4s ease, stroke-width 0.4s ease;
}

.puzzle-piece.joined .piece-bevel-dark {
    stroke: rgba(0, 0, 0, 0.1);
    stroke-width: 1.2;
    transition: stroke 0.4s ease, stroke-width 0.4s ease;
}

.puzzle-piece.joined .piece-bevel-light {
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 1.2;
    transition: stroke 0.4s ease, stroke-width 0.4s ease;
}

.puzzle-piece.joined .piece-lighting {
    opacity: 0.3;
    transition: opacity 0.4s ease;
}

.puzzle-piece.joined {
    filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.2)) saturate(1.1) brightness(1.02);
}

.puzzle-piece.placed {
    cursor: default;
    pointer-events: none;
    transform: none;
    filter: none;
}

.puzzle-piece.placed.joined {
    filter: saturate(1.1) brightness(1.02);
}

.puzzle-piece.placed:hover {
    transform: none;
    box-shadow: none;
    filter: none;
}

.puzzle-piece.snapped {
    animation: snapPulse 0.3s ease;
}

.puzzle-piece.completed {
    animation: winPieceGlow 1.6s ease-out forwards;
}

@keyframes winPieceGlow {
    0%   { filter: brightness(1.0); }
    22%  { filter: brightness(1.6) drop-shadow(0 0 14px rgba(255,215,0,0.95)) drop-shadow(0 0 28px rgba(255,165,0,0.55)); }
    55%  { filter: brightness(1.18) drop-shadow(0 0 7px rgba(255,215,0,0.5)); }
    100% { filter: brightness(1.0); }
}

.puzzle-reveal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-heavy);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1999;
    animation: revealFadeIn 0.5s ease forwards;
}

.puzzle-reveal-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.3), 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: revealScaleUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    cursor: pointer;
}

.puzzle-reveal-image {
    max-width: 50vw;
    max-height: 72vh;
    min-width: 300px;
    min-height: 200px;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    transition: filter 0.35s ease;
}

.puzzle-reveal-wrapper:hover .puzzle-reveal-image {
    filter: brightness(0.22);
}

.puzzle-reveal-caption {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 24px 56px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.82) 0%, transparent 100%);
    text-align: center;
    animation: revealCaptionIn 0.7s ease-out 1.3s both;
    transition: opacity 0.35s ease;
}

.puzzle-reveal-wrapper:hover .puzzle-reveal-caption {
    opacity: 0;
}

.puzzle-reveal-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 215, 0, 0.75);
    margin-bottom: 6px;
}

.puzzle-reveal-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.9), 0 0 32px rgba(255, 200, 50, 0.35);
}

@keyframes revealCaptionIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.puzzle-reveal-continue {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 11px 28px;
    border-radius: 100px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
}

.puzzle-reveal-continue.visible {
    opacity: 0.7;
    pointer-events: auto;
    cursor: pointer;
}

/* Description overlay — floats on top of darkened image on hover */
.puzzle-reveal-desc-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.puzzle-reveal-wrapper:hover .puzzle-reveal-desc-overlay {
    opacity: 1;
}

.puzzle-reveal-desc-text {
    font-size: 0.92rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.9);
    text-align: left;
    max-height: 100%;
    overflow-y: auto;
}

.puzzle-reveal-desc-text p {
    margin: 0 0 12px;
}

.puzzle-reveal-desc-text p:last-child {
    margin-bottom: 0;
}

.puzzle-reveal-desc-text::-webkit-scrollbar {
    width: 4px;
}

.puzzle-reveal-desc-text::-webkit-scrollbar-track {
    background: transparent;
}

.puzzle-reveal-desc-text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
}

@media (max-width: 768px) {
    .puzzle-reveal-image {
        max-width: 85vw;
        max-height: 60vh;
        min-width: 200px;
        min-height: 150px;
    }
}

@keyframes revealFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes revealScaleUp {
    0% {
        transform: scale(0.15);
        opacity: 0;
    }

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

.sidebar-stat {
    margin-bottom: 12px;
}

.sidebar-stat:last-child {
    margin-bottom: 0;
}

.sidebar-stat > span {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
}

.stat-icon {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Progress Bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    border-radius: 8px;
    width: 100%;
}

.progress-bar {
    flex: 1;
    height: 14px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: linear-gradient(90deg, #f5a623, #e08a10);
    border-radius: 7px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Charging shimmer sweep */
.progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    border-radius: 7px;
    z-index: 1;
    background: linear-gradient(90deg,
            transparent 0%,
            transparent 40%,
            rgba(255, 255, 255, 0.45) 50%,
            transparent 60%,
            transparent 100%);
    background-size: 200% 100%;
    animation: progressShimmer 2.5s ease-in-out infinite;
}

@keyframes progressShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.accuracy-display {
    justify-content: center;
}

.accuracy-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.accuracy-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Progress Bar: Heartbeat style ──────────────────────────────────────────
 * Scoped to [data-progress-style="heartbeat"] on the .progress-bar element.
 * Swap styles by changing PROGRESS_BAR_STYLE in js/progress-bar.js and
 * adding a matching CSS block here.
 * ─────────────────────────────────────────────────────────────────────────── */

/* Solid colour fill that shifts blue → amber → gold as pct increases */
.progress-bar[data-progress-style="heartbeat"]::after {
    background: var(--progress-color, hsl(215, 70%, 58%));
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Idle wave — shown at 0% until the first snap lands.
   A subtle highlight sweeps back and forth across the empty track. */
@keyframes pb-idle-wave {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

.progress-bar.pb-idle {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.12) 35%,
        rgba(255, 255, 255, 0.30) 50%,
        rgba(255, 255, 255, 0.12) 65%,
        rgba(255, 255, 255, 0.12) 100%);
    background-size: 200% 100%;
    animation: pb-idle-wave 2s ease-in-out infinite alternate;
}

/* Heartbeat scaleY keyframes — three strengths (defined after pb-idle so they
   win the cascade when both classes are present during the startup kick) */
@keyframes pb-hb-normal {
    0%   { transform: scaleY(1);    }
    28%  { transform: scaleY(1.55); }
    56%  { transform: scaleY(0.90); }
    80%  { transform: scaleY(1.07); }
    100% { transform: scaleY(1);    }
}

@keyframes pb-hb-mid {
    0%   { transform: scaleY(1);    }
    22%  { transform: scaleY(2.1);  }
    48%  { transform: scaleY(0.81); }
    70%  { transform: scaleY(1.17); }
    87%  { transform: scaleY(0.97); }
    100% { transform: scaleY(1);    }
}

@keyframes pb-hb-strong {
    0%   { transform: scaleY(1);    }
    18%  { transform: scaleY(3.0);  }
    42%  { transform: scaleY(0.73); }
    62%  { transform: scaleY(1.30); }
    78%  { transform: scaleY(0.92); }
    90%  { transform: scaleY(1.06); }
    100% { transform: scaleY(1);    }
}

.progress-bar.pb-hb-normal {
    animation: pb-hb-normal 0.42s ease-out;
    transform-origin: center;
}
.progress-bar.pb-hb-mid {
    animation: pb-hb-mid 0.56s ease-out;
    transform-origin: center;
}
.progress-bar.pb-hb-strong {
    animation: pb-hb-strong 0.75s ease-out;
    transform-origin: center;
}

/* Milestone burst particles */
.pb-burst-particle {
    position: fixed;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--burst-color, gold);
    pointer-events: none;
    z-index: 9005;
    box-shadow: 0 0 5px 2px var(--burst-color, gold);
}

/* Enhanced Snap Animation */
@keyframes bounceSnap {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.15);
    }

    50% {
        transform: scale(0.95);
    }

    70% {
        transform: scale(1.05);
    }

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

.puzzle-piece.snapped {
    animation: bounceSnap 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
}

/* ── Magnitude-based cluster snap effects ───────────────────────────────── */

/* Cluster bounce: applied to every piece in the merged group (Tier 2 + 3).
   Slightly bigger than the single-piece bounceSnap so it reads as distinct.
   Defined after .puzzle-piece.snapped so it wins the !important cascade. */
@keyframes cluster-bounce {
    0%   { transform: scale(1); }
    25%  { transform: scale(1.2); }
    55%  { transform: scale(0.92); }
    78%  { transform: scale(1.07); }
    100% { transform: scale(1); }
}

.puzzle-piece.cluster-bounce {
    animation: cluster-bounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
}

/* Glow burst: soft radial bloom (Tier 3 only) */
@keyframes snap-glow-burst {
    0%   { transform: translate(-50%, -50%) scale(0.1); opacity: 0.7; }
    55%  { transform: translate(-50%, -50%) scale(0.85); opacity: 0.4; }
    100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0;   }
}

.snap-glow-burst {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 8999;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--snap-color, #00d4aa) 0%, transparent 68%);
    animation: snap-glow-burst 0.85s ease-out forwards;
}

/* Cluster glow pulse: sweeps the entire merged group's boundary */
@keyframes cluster-glow-pulse {
    0%   { filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.2)) saturate(1.1) brightness(1.02); }
    40%  { filter: drop-shadow(0 0 16px var(--snap-color, #00d4aa)) saturate(1.6) brightness(1.35); }
    100% { filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.2)) saturate(1.1) brightness(1.02); }
}

.puzzle-piece.cluster-glow {
    animation: cluster-glow-pulse 0.8s ease-out forwards;
}

/* Float text: pops from screen centre (Tier 3 only).
   Animation is driven entirely by the Web Animations API in snap.js. */
.snap-float-text {
    position: fixed;
    pointer-events: none;
    z-index: 9001;
    font-family: 'Lilita One', cursive;
    font-size: 86px;
    letter-spacing: 0.05em;
    white-space: nowrap;
    /* Top-to-bottom color gradient */
    background: linear-gradient(to bottom,
        var(--float-text-top),
        var(--float-text-bottom));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    /* Use filter drop-shadow instead of text-shadow.
       text-shadow bleeds through the transparent fill and paints the letters black.
       drop-shadow operates on the already-painted gradient shape, so it
       outlines and depths the visible colored text. Shadows chain in order:
       each one casts a shadow of (element + all previous shadows). */
    filter:
        drop-shadow(-3px  0px 0px #000)
        drop-shadow( 3px  0px 0px #000)
        drop-shadow( 0px -3px 0px #000)
        drop-shadow( 0px  3px 0px #000)
        drop-shadow( 5px  5px 0px rgba(0, 0, 0, 0.90))
        drop-shadow( 8px  8px 0px rgba(0, 0, 0, 0.60))
        drop-shadow(11px 11px 0px rgba(0, 0, 0, 0.35))
        drop-shadow( 0px  0px 18px var(--float-text-top))
        drop-shadow( 0px  0px 35px var(--float-text-bottom));
}

/* Candy Crush-style bouncy button animation */
@keyframes candy-bounce {
    0% {
        transform: scale(1);
    }

    15% {
        transform: scale(0.82, 1.1);
    }

    30% {
        transform: scale(1.12, 0.9);
    }

    45% {
        transform: scale(0.96, 1.03);
    }

    60% {
        transform: scale(1.04, 0.98);
    }

    75% {
        transform: scale(0.99, 1.01);
    }

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

.btn-bounce {
    animation: candy-bounce 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

/* Continuous idle pulse for major buttons (Candy Crush style) */
@keyframes btn-idle-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.035);
    }
}

.btn-modal-primary:not(:disabled),
.btn-primary:not(:disabled) {
    animation: btn-idle-pulse 2s ease-in-out infinite;
}

.btn-modal-primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
    animation: none;
    transform: translateY(-2px);
}

.btn-modal-primary:active:not(:disabled),
.btn-primary:active:not(:disabled) {
    animation: none;
    transform: translateY(1px);
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(160, 90, 0, 0.2),
        0 1px 0 rgba(0, 0, 0, 0.2) inset;
}

.btn-modal-secondary:not(:disabled) {
    animation: btn-idle-pulse 2.4s ease-in-out 0.3s infinite;
}

.btn-modal-secondary:hover:not(:disabled) {
    animation: none;
}

.btn-modal-secondary:active:not(:disabled) {
    animation: none;
    transform: translateY(1px);
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(0, 0, 0, 0.2) inset;
}

.btn-modal-primary.btn-bounce,
.btn-modal-secondary.btn-bounce,
.btn-primary.btn-bounce {
    animation: candy-bounce 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-modal);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    overflow: hidden;
    overscroll-behavior: none;
}

.modal.hidden {
    display: none;
}

.modal-content {
    position: relative;
    overflow: hidden;
    overscroll-behavior-y: none;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M0 0h28v9.8C28 9.8 24.5 9.8 24.5 13.5S28 17.2 28 17.2V28H17.2C17.2 28 17.2 24.5 13.5 24.5S9.8 28 9.8 28H0V17.2C0 17.2 3.5 17.2 3.5 13.5S0 9.8 0 9.8z' fill='%23ffffff' fill-opacity='0.02'/%3E%3Cpath d='M40 40h28v9.8c0 0-3.5 0-3.5 3.7s3.5 3.7 3.5 3.7V68H57.2c0 0 0-3.5-3.7-3.5S49.8 68 49.8 68H40V57.2c0 0 3.5 0 3.5-3.7S40 49.8 40 49.8z' fill='%23ffffff' fill-opacity='0.02'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 20% 0%, var(--glow-a) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, var(--glow-b) 0%, transparent 60%),
        linear-gradient(160deg, var(--bg-mid), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 28px 32px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: bounceIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
    will-change: transform, opacity;
}

.modal-content::before {
    content: '';
    position: absolute;
    inset: 0;
    background: conic-gradient(from 0deg at 50% 50%,
            transparent 0deg,
            rgba(255, 255, 255, 0.02) 60deg,
            transparent 120deg,
            rgba(243, 156, 18, 0.03) 180deg,
            transparent 240deg,
            rgba(108, 92, 231, 0.02) 300deg,
            transparent 360deg);
    transform-origin: center;
    animation: modalShimmer 12s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes modalShimmer {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.modal-dismiss {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.modal-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.modal-dismiss.hidden {
    display: none;
}

@keyframes bounceIn {
    0% {
        transform: scale3d(0.5, 0.5, 1);
        opacity: 0;
    }

    100% {
        transform: scale3d(1, 1, 1);
        opacity: 1;
    }
}

/* Ensure all direct modal content sits above the shimmer pseudo-element */
.modal-content > * {
    position: relative;
    z-index: 1;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #f39c12;
}

.modal-content p {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.modal-content .btn-modal-primary {
    margin-top: 20px;
}

/* ── Landing Page ─────────────────────────────────────────────────────────── */

.landing-page {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-page.hidden {
    display: none;
}

.landing-settings-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.5rem;
    line-height: 48px;
    text-align: center;
    padding: 0;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.15s;
}
.landing-settings-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* Full-bleed background image, dimmed */
.landing-bg {
    position: absolute;
    inset: 0;
    background: url('../assets/images/bg_mosaic.jpg') center / cover no-repeat;
    filter: brightness(0.6) sepia(0.45) saturate(1.3);
    z-index: 0;
}

/* Dark centre vignette — pulls focus inward to content, hides bg seams */
.landing-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 80% at 50% 50%, rgba(0,0,0,0.62) 0%, transparent 100%),
        radial-gradient(ellipse at 50% 40%, transparent 20%, rgba(0,0,0,0.35) 100%);
    z-index: 0;
    pointer-events: none;
}

/* Dismiss button (top-right, shown only when a game is in progress) */
.landing-dismiss {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.landing-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.landing-dismiss.hidden {
    display: none;
}

/* Main content column */
.landing-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
    width: 100%;
    max-width: 420px;
    padding: 0 24px;
}

/* Hero: mascot + title */
.landing-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.landing-mascot {
    width: 148px;
    height: 148px;
    object-fit: contain;
    filter: drop-shadow(0 8px 28px rgba(0, 0, 0, 0.65));
}

.landing-title h1 {
    font-family: 'Lilita One', 'Poppins', sans-serif;
    font-size: 3.4rem;
    font-weight: 400;
    letter-spacing: 2px;
    line-height: 1.15;
    white-space: nowrap;
    background: linear-gradient(180deg, #e8f0ff 0%, #a8c8f0 50%, #7ba8d8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 3px 0 rgba(30, 60, 120, 0.5))
            drop-shadow(0 6px 16px rgba(0, 0, 0, 0.3));
    padding-bottom: 4px;
    margin-bottom: 0;
}

.landing-title h1 .highlight {
    background: linear-gradient(180deg, #fff2b8 0%, #ffcc44 40%, #ff9922 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-tagline {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.45);
    font-style: italic;
    letter-spacing: 1px;
    margin-top: 14px;
}

/* Buttons float directly on the background */
.landing-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.landing-panel .btn-modal-secondary {
    display: inline-grid;
    grid-template-columns: 28px auto;
    justify-content: center;
    gap: 8px;
}
.landing-panel .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
}

/* Utility dock — Shop, Stats, Achievements */
.landing-dock {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.landing-dock-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-top-color: rgba(255, 255, 255, 0.22);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.landing-dock-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.landing-dock-btn:active {
    transform: translateY(1px);
}

.landing-dock-icon {
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-dock-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Landing page buttons — base styles already match; override golden primary to glass */
.landing-panel .btn-modal-primary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255,255,255,0.08) inset;
    text-shadow: none;
}

.landing-panel .btn-modal-primary:hover {
    background: rgba(255, 255, 255, 0.17);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255,255,255,0.12) inset;
}

/* Collections — slightly larger to establish hierarchy */
.landing-panel #adventureBtn {
    padding: 16px 28px;
    font-size: 1.05rem;
    border-color: rgba(255, 255, 255, 0.24);
    border-top-color: rgba(255, 255, 255, 0.38);
}


/* Shared nav-header title — Shop, Collections, Make Your Own, episode titles */
.modal-nav-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

/* Setup Modal */
.setup-content {
    width: min(340px, 94vw);
    max-height: 88vh;
    overflow-y: hidden;
    overscroll-behavior-y: none;
    text-align: left;
}

.setup-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.setup-header h2 {
    margin: 0;
}

.setup-header-spacer {
    width: 50px;
    flex-shrink: 0;
}

.setup-image-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0 16px;
    position: relative;
}

.setup-form {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
}

.setup-image-preview {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: pointer;
}

.setup-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.setup-image-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    border-radius: 12px;
}

.setup-image-preview:hover .setup-image-upload-overlay {
    opacity: 1;
}

.setup-image-upload-overlay .btn-icon {
    font-size: 1.4rem;
}

.setup-start-btn {
    width: 100%;
    height: 50px;
    padding: 0 10px;
    margin-top: 4px;
}

.setup-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.setup-row .setup-row-label {
    padding-top: 6px;
}

.setup-row-label {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.setup-row select {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: auto;
    width: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.setup-row select:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
}

.setup-row select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: none;
}

.setup-row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.setup-piece-count {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    white-space: nowrap;
}


#setupImageUpload {
    display: none;
}

/* ── Journey Modal ─────────────────────────────────────────── */
.journey-content {
    min-width: 540px;
    max-width: 620px;
    max-height: 92vh;
    overflow-y: hidden;
    overscroll-behavior-y: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
    text-align: left;
}
.journey-content::-webkit-scrollbar { width: 4px; }
.journey-content::-webkit-scrollbar-track { background: transparent; }
.journey-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* Header */
.journey-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.journey-header-center {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.journey-header-center h2 {
    margin: 0 0 3px;
    letter-spacing: 0.3px;
    color: #fff;
}

.journey-theme-name {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
}

.journey-back-btn {
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    padding: 8px 18px;
    border-radius: 12px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.journey-back-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.95);
}

/* Resume button — right side of header */
.journey-resume-btn-wrap {
    flex-shrink: 0;
}

/* When hidden, acts as invisible spacer matching the back button width */
.journey-resume-btn-wrap.hidden {
    display: block !important;
    visibility: hidden;
    width: 36px;
}

.journey-resume-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    border-radius: 9px;
    border: none;
    background: linear-gradient(135deg, var(--resume-bg-start), var(--resume-bg-end));
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 10px var(--resume-shadow);
    white-space: nowrap;
}

.journey-resume-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px var(--resume-shadow);
}

.resume-btn-icon { font-size: 0.7rem; }
.resume-btn-label { letter-spacing: 0.02em; }

/* ── Theme picker ─────────────────────────────────────────── */
.journey-theme-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
}

.journey-theme-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.journey-theme-card--coming-soon,
.journey-theme-card--locked {
    cursor: default;
    opacity: 0.35;
    filter: brightness(0.5);
}

.journey-theme-card--coming-soon:hover,
.journey-theme-card--locked:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.09);
    transform: none;
}

@keyframes themeUnlock {
    0%   { border-color: rgba(255, 215, 0, 0); background: rgba(255, 215, 0, 0); box-shadow: 0 0 0 rgba(255, 215, 0, 0); transform: scale(1); }
    10%  { border-color: rgba(255, 215, 0, 0.6); background: rgba(255, 215, 0, 0.08); box-shadow: 0 0 24px rgba(255, 215, 0, 0.3); transform: scale(1.03); }
    25%  { border-color: rgba(255, 215, 0, 0.2); background: rgba(255, 215, 0, 0.02); box-shadow: 0 0 8px rgba(255, 215, 0, 0.1); transform: scale(1); }
    40%  { border-color: rgba(255, 215, 0, 0.5); background: rgba(255, 215, 0, 0.06); box-shadow: 0 0 20px rgba(255, 215, 0, 0.25); transform: scale(1.02); }
    55%  { border-color: rgba(255, 215, 0, 0.15); background: rgba(255, 215, 0, 0.01); box-shadow: 0 0 6px rgba(255, 215, 0, 0.08); transform: scale(1); }
    70%  { border-color: rgba(255, 215, 0, 0.4); background: rgba(255, 215, 0, 0.04); box-shadow: 0 0 16px rgba(255, 215, 0, 0.2); transform: scale(1.01); }
    85%  { border-color: rgba(255, 215, 0, 0.1); background: rgba(255, 215, 0, 0.01); box-shadow: 0 0 4px rgba(255, 215, 0, 0.05); transform: scale(1); }
    100% { border-color: rgba(255, 215, 0, 0); background: rgba(255, 215, 0, 0); box-shadow: none; transform: scale(1); }
}

.theme-unlock-anim {
    animation: themeUnlock 2.4s ease-out;
}

.journey-theme-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.journey-theme-card-thumb {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 0;
    flex-shrink: 0;
}

.journey-theme-card-lock {
    margin-left: auto;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.journey-theme-card--locked .journey-theme-card-thumb {
    filter: brightness(0.5) grayscale(0.5);
}

.journey-theme-card-info {
    flex: 1;
    min-width: 0;
    padding: 12px 14px 12px 0;
}

.journey-theme-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 3px;
}

.journey-theme-card-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 5px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.journey-theme-card-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.journey-theme-progress-bar {
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.journey-theme-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
    transition: width 0.4s ease;
}

/* ── Episode list ─────────────────────────────────────────── */
.journey-episodes {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Chapter row */
.journey-chapter {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    padding: 22px 0;
}

.journey-chapter + .journey-chapter {
    border-top: 1px solid rgba(255, 255, 255, 0.065);
}

.journey-chapter.locked {
    pointer-events: none;
}
/* Dim everything inside a locked chapter EXCEPT the unlock button,
   since opacity on the parent would compound and can't be undone by children */
.journey-chapter.locked .journey-chapter-title,
.journey-chapter.locked .journey-chapter-status,
.journey-chapter.locked .journey-puzzle-strip {
    opacity: 0.35;
}

/* Chapter body */
.journey-chapter-body {
    flex: 1;
    min-width: 0;
}

.journey-chapter-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 13px;
    gap: 10px;
}

.journey-chapter-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.1px;
}

.journey-chapter-status {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 10px;
    border-radius: 20px;
}

.journey-chapter-status.completed {
    background: rgba(52, 211, 153, 0.13);
    color: var(--color-success-text);
    border: 1px solid rgba(52, 211, 153, 0.22);
}

.journey-chapter-status.unlocked {
    background: none;
    color: transparent;
    border: none;
}

.journey-chapter-status.locked {
    background: none;
    color: transparent;
    border: none;
}

/* ── Puzzle strip ─────────────────────────────────────────── */
.journey-puzzle-strip {
    display: flex;
    gap: 10px;
}

.journey-puzzle-slot {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.journey-puzzle-slot .journey-puzzle-card {
    flex: unset;
    width: 100%;
}

.journey-puzzle-title {
    font-size: 0.65rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
    letter-spacing: 0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.journey-puzzle-card {
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    background: rgba(0, 0, 0, 0.35);
}

.journey-puzzle-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.2s ease;
}

/* Available */
.journey-puzzle-card.unlocked:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 255, 255, 0.28);
}

/* Completed */
.journey-puzzle-card.completed {
    border-color: rgba(52, 211, 153, 0.28);
}

.journey-puzzle-card.completed img {
    filter: brightness(0.72) saturate(0.85);
}

.journey-puzzle-card.completed:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.38);
    border-color: rgba(52, 211, 153, 0.5);
}

/* Locked */
.journey-puzzle-card.locked {
    cursor: not-allowed;
}

.journey-puzzle-card.locked img {
    filter: brightness(0.18) grayscale(1);
}

/* Grid-size chip (top-left corner) */
.journey-puzzle-grid-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    background: rgba(0, 0, 0, 0.68);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 5px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Completed: gradient footer with time */
.journey-puzzle-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 8px 7px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.journey-puzzle-done-icon {
    font-size: 0.78rem;
    color: var(--color-success-text);
    font-weight: 700;
}

.journey-puzzle-time {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.72);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Gallery view button on completed cards */
.journey-puzzle-view-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.15s;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}
.journey-puzzle-view-btn svg {
    width: 16px;
    height: 16px;
}
.journey-puzzle-card.completed:hover .journey-puzzle-view-btn {
    opacity: 1;
}
.journey-puzzle-view-btn:hover {
    background: rgba(var(--accent-rgb, 255, 255, 255), 0.35);
    color: #fff;
}

/* Gallery overlay — side-by-side image + text */
.puzzle-gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--overlay-heavy, rgba(0, 0, 0, 0.88));
    display: flex;
    align-items: center;
    justify-content: center;
    animation: revealFadeIn 0.35s ease;
}
.puzzle-gallery-wrapper {
    display: flex;
    align-items: stretch;
    max-width: 80vw;
    max-height: 80vh;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(var(--accent-rgb, 255, 255, 255), 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: revealScaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    background: rgba(20, 20, 35, 0.95);
}
.puzzle-gallery-image {
    max-width: 50vw;
    max-height: 80vh;
    min-width: 240px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}
.puzzle-gallery-text {
    width: 280px;
    flex-shrink: 0;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    overscroll-behavior-y: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.puzzle-gallery-text::-webkit-scrollbar { width: 4px; }
.puzzle-gallery-text::-webkit-scrollbar-track { background: transparent; }
.puzzle-gallery-text::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.puzzle-gallery-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(var(--accent-rgb, 255, 215, 0), 0.75);
    margin-bottom: 8px;
    text-align: center;
}
.puzzle-gallery-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 16px;
    line-height: 1.3;
    text-align: center;
}
.puzzle-gallery-desc {
    flex: 1;
    font-size: 0.88rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.7);
}
.puzzle-gallery-desc p {
    margin: 0 0 12px;
}
.puzzle-gallery-desc p:last-child {
    margin-bottom: 0;
}
.puzzle-gallery-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1.4rem;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    transition: color 0.15s;
    z-index: 1;
}
.puzzle-gallery-close:hover {
    color: rgba(255, 255, 255, 0.7);
}
.puzzle-gallery-bottom-close {
    display: none;
}
.puzzle-gallery-continue {
    margin-top: 12px;
    padding: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s;
    flex-shrink: 0;
    text-align: center;
}
.puzzle-gallery-continue:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* Locked: centered lock icon */
.journey-puzzle-lock {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0.45;
}

/* Win Modal — centered over the reveal image */
.win-modal-content {
    text-align: center;
    overflow: hidden;
    width: min(400px, 92vw);
}

.win-modal-content::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 200px;
    background: radial-gradient(ellipse, rgba(245, 166, 35, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.win-trophy {
    font-size: 2.4rem;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #ffe082, #e8961a 70%);
    box-shadow: 0 0 0 5px rgba(245, 166, 35, 0.2), 0 8px 28px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    animation: win-trophy-pop 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.4) 0.1s both;
}

@keyframes win-trophy-pop {
    0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}

.win-modal-content h2 {
    font-size: 2.2rem;
    background: linear-gradient(180deg, #ffe082 0%, #f5a623 55%, #d07010 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 10px rgba(245, 166, 35, 0.4));
}

.win-subtitle {
    color: rgba(255, 255, 255, 0.65);
    font-size: 1rem;
    margin-bottom: 12px;
}

.win-puzzle-title {
    font-size: 1.55rem;
    font-weight: 800;
    background: linear-gradient(180deg, #ffe082 0%, #f5a623 55%, #d07010 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 8px rgba(245, 166, 35, 0.45));
    letter-spacing: 0.3px;
    margin-bottom: 18px;
    animation: winTitleReveal 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) 0.15s both;
}

@keyframes winTitleReveal {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.win-stats-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-bottom: 4px;
}

.win-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.88);
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Ad reward button */
.btn-ad-reward {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 28px;
    margin-top: 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.1));
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ad-reward:hover {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3), rgba(76, 175, 80, 0.15));
    transform: translateY(-1px);
}

.btn-ad-reward:disabled {
    opacity: 0.35;
    cursor: default;
    transform: none;
}

.btn-ad-icon {
    font-size: 0.8rem;
}

/* Win Modal Buttons */
.win-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.win-buttons .btn-modal-primary,
.win-buttons .btn-modal-secondary {
    width: 100%;
    height: 50px;
    padding: 0 10px;
    white-space: nowrap;
    box-sizing: border-box;
    margin: 0;
}


.win-buttons .hidden {
    display: none;
}

/* Hint Banner */
.hint-banner {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--modal-bg-start), var(--modal-bg-end));
    border: 1px solid var(--hint-banner-border);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 1500;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    white-space: nowrap;
}

.hint-banner.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.hint-banner.hidden {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.hint-banner-icon {
    font-size: 1.3rem;
}

.hint-banner-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.btn-hint {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-hint.accept {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-hint.accept:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.24);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-hint.decline {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-hint.decline:hover {
    background: rgba(255, 255, 255, 0.17);
}

/* Tier 1 — NUDGE — warm amber */
.hint-banner[data-tier="1"] {
    border-color: rgba(245, 166, 35, 0.3);
}

/* Tier 2 — GUIDE */
.hint-banner[data-tier="2"] {
    border-color: rgba(235, 120, 80, 0.4);
}

/* Tier 3 — PLACE */
.hint-banner[data-tier="3"] {
    border-color: rgba(255, 200, 50, 0.4);
}

/* Premium Gate Modal */
.premium-banner {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--modal-bg-start), var(--modal-bg-end));
    border: 1px solid rgba(243, 156, 18, 0.35);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 1500;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    white-space: nowrap;
}

.premium-banner.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.premium-banner.hidden {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.premium-banner-icon {
    font-size: 1.3rem;
}

.premium-banner-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}



/* Hint Highlight Effects */
.puzzle-piece.hint-highlight {
    animation: hintPulse 1s ease-in-out infinite;
    z-index: 100 !important;
    filter: drop-shadow(0 0 12px var(--hint-glow)) drop-shadow(0 0 4px rgba(var(--accent-rgb), 0.6)) !important;
}

@keyframes hintPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.6)) drop-shadow(0 0 3px rgba(var(--accent-rgb), 0.4));
    }

    50% {
        filter: drop-shadow(0 0 16px rgba(var(--accent-rgb), 1)) drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.8));
    }
}

/* Ghost preview for piece placement */
.placement-ghost {
    position: absolute;
    pointer-events: none;
    z-index: 999;
    opacity: 0.4;
}

/* While a piece is being moved, disable pointer events on all real pieces */
.piece-moving,
.piece-moving * {
    cursor: grabbing !important;
}

.piece-moving .puzzle-piece:not(.placement-ghost) {
    pointer-events: none;
}

/* Ghost outline on board for GUIDE tier */
.hint-ghost {
    position: absolute;
    border: 2px dashed var(--hint-ghost-border);
    border-radius: 4px;
    background: var(--hint-ghost-bg);
    animation: ghostPulse 1.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 50;
}

@keyframes ghostPulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}

/* Quit/Danger Button */
.btn-danger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-top-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.25),
        0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.btn-danger:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.35),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.btn-danger:active {
    transform: translateY(1px);
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(0, 0, 0, 0.15) inset;
}

/* Sidebar button hidden state */
.btn-full.hidden {
    display: none;
}

/* (Journey resume banner removed — resume is now in the header) */

/* Modal Button Variants */
.btn-modal-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    background: linear-gradient(180deg, #f5a623 0%, #e08a10 50%, #c87a0a 100%);
    border-top: 1px solid rgba(255, 220, 140, 0.5);
    border-bottom: 1px solid rgba(120, 60, 0, 0.3);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 14px rgba(224, 138, 16, 0.4),
        0 2px 0 rgba(160, 90, 0, 0.35),
        0 1px 0 rgba(255, 230, 160, 0.3) inset;
    width: 100%;
}

.btn-modal-primary:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #fdb938 0%, #e8961a 50%, #d08510 100%);
    box-shadow:
        0 8px 28px rgba(224, 138, 16, 0.5),
        0 3px 0 rgba(160, 90, 0, 0.35),
        0 1px 0 rgba(255, 230, 160, 0.4) inset;
}

.btn-modal-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.28);
    color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.btn-modal-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.17);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.btn-modal-secondary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-modal-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.28);
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s ease;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.btn-modal-outline:hover {
    background: rgba(255, 255, 255, 0.17);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
}


/* Draw Pile Indicator */
.draw-pile-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: auto;
    padding: 14px 16px;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-radius: 12px;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.18),
        0 12px 32px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 260px;
    box-sizing: border-box;
}

.draw-pile-indicator.hidden {
    display: none;
}

.pile-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.pile-count {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 700;
    font-size: 0.95rem;
}

/* Stacked deck container */
.pile-stack {
    position: relative;
    width: 52px;
    height: 46px;
    flex-shrink: 0;
}

/* Individual cards in the stack */
.pile-card {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.pile-card img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    opacity: 0.7;
}

/* Bottom card — most offset */
.pile-card--3 {
    top: 0;
    left: 10px;
    transform: rotate(8deg);
    opacity: 0.4;
}

/* Middle card */
.pile-card--2 {
    top: 2px;
    left: 4px;
    transform: rotate(-4deg);
    opacity: 0.6;
}

/* Top card */
.pile-card--1 {
    top: 5px;
    left: 6px;
    transform: rotate(1deg);
    opacity: 0.85;
}

/* Golden Piece */
.puzzle-piece.golden {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 3px rgba(255, 180, 0, 0.6));
    animation: goldenPulse 1.5s ease-in-out infinite;
    position: relative;
}

.puzzle-piece.golden::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    background: url('../assets/icons/golden-charge-512.png') center / contain no-repeat;
    pointer-events: none;
    z-index: 20;
    animation: goldenStar 1.2s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
}

@keyframes goldenPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 3px rgba(255, 180, 0, 0.6));
    }

    50% {
        filter: drop-shadow(0 0 14px rgba(255, 215, 0, 1)) drop-shadow(0 0 6px rgba(255, 180, 0, 0.9));
    }
}

@keyframes goldenStar {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0.9;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3) rotate(20deg);
        opacity: 1;
    }
}

/* Golden piece activation flash */
.puzzle-piece.golden-activated {
    animation: goldenActivate 0.6s ease-out forwards;
}

.puzzle-piece.golden-activated::after {
    display: none;
}

@keyframes goldenActivate {
    0% {
        filter: drop-shadow(0 0 25px rgba(255, 215, 0, 1)) brightness(1.8);
    }

    50% {
        filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6)) brightness(1.3);
    }

    100% {
        filter: none;
    }
}

/* Neighbor pieces pulled in by golden piece */
.puzzle-piece.golden-snap-in {
    animation: goldenSnapIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

@keyframes goldenSnapIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
        filter: brightness(2) drop-shadow(0 0 15px rgba(255, 215, 0, 0.8));
    }

    60% {
        opacity: 1;
        transform: scale(1.1);
        filter: brightness(1.3) drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 0px rgba(255, 215, 0, 0));
    }
}

/* Golden piece appearing on board after a snap */
.puzzle-piece.golden-appearing {
    animation: goldenAppear 0.8s ease-out forwards;
}

@keyframes goldenAppear {
    0% {
        filter: brightness(1) drop-shadow(0 0 0px rgba(255, 215, 0, 0));
    }

    30% {
        filter: brightness(1.8) drop-shadow(0 0 20px rgba(255, 215, 0, 1));
    }

    100% {
        filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 3px rgba(255, 180, 0, 0.6));
    }
}

/* ======= Item Bar ======= */

.item-bar-section.hidden,
.item-armed-indicator.hidden {
    display: none;
}

.item-bar-section {
    transition: opacity 0.3s ease;
    padding: 16px;
}

.item-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.item-slot {
    position: relative;
    width: auto;
    border-radius: 14px;
    border: 2px solid rgba(var(--accent-rgb, 255, 255, 255), 0.08);
    background: rgba(var(--accent-rgb, 255, 255, 255), 0.07);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px 8px;
    gap: 4px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

.item-slot:not(.placeholder):not(:disabled):hover {
    transform: scale(1.04);
    background: rgba(var(--accent-rgb, 255, 255, 255), 0.14);
    border-color: rgba(var(--accent-rgb, 255, 255, 255), 0.2);
}

.item-slot:not(.placeholder):not(:disabled):active {
    transform: scale(0.96);
}

.item-slot:disabled {
    opacity: 0.35;
    cursor: default;
    box-shadow: none;
    animation: none;
}
.item-slot-locked {
    opacity: 0.35;
    pointer-events: auto;
    cursor: help;
}
.item-slot-locked .item-icon {
    filter: grayscale(1);
}

.item-slot.placeholder {
    opacity: 0.2;
    cursor: default;
    border-style: dashed;
}

.item-slot.armed:not(:disabled) {
    border: 2px solid rgba(255, 215, 0, 0.9);
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.5), inset 0 0 12px rgba(255, 215, 0, 0.1);
    animation: itemArmedPulse 2s ease-in-out infinite;
}

.item-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(var(--accent-rgb, 128, 128, 128), 0.35));
}

.item-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}
.item-slot[data-item-id="golden_charge"] .item-label { color: rgba(255, 215, 0, 0.85); }
.item-slot[data-item-id="precision_pick"] .item-label { color: rgba(100, 200, 255, 0.85); }
.item-slot[data-item-id="focus_mode"] .item-label { color: rgba(167, 139, 250, 0.85); }
.item-slot[data-item-id="vacancy_fill"] .item-label { color: rgba(76, 175, 80, 0.85); }

/* Armed label becomes brighter */
.item-slot.armed:not(:disabled) .item-label { color: rgba(255, 215, 0, 0.9); }

.armed-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: -3px;
}

.item-count {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    background: none;
    border: none;
    border-radius: 0;
    min-width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    text-align: center;
    line-height: 1;
    pointer-events: none;
}

@keyframes itemArmedPulse {
    0%, 100% {
        box-shadow: 0 0 16px rgba(255, 215, 0, 0.5), inset 0 0 12px rgba(255, 215, 0, 0.1);
    }
    50% {
        box-shadow: 0 0 28px rgba(255, 215, 0, 0.8), inset 0 0 16px rgba(255, 215, 0, 0.15);
    }
}

/* Precision Pick — cyan armed variant */
.item-slot.armed[data-item-id="precision_pick"]:not(:disabled) {
    border: 2px solid rgba(100, 200, 255, 0.9);
    background: rgba(100, 200, 255, 0.15);
    box-shadow: 0 0 16px rgba(100, 200, 255, 0.5), inset 0 0 12px rgba(100, 200, 255, 0.1);
    animation: itemArmedPulseCyan 2s ease-in-out infinite;
}
.item-slot.armed[data-item-id="precision_pick"]:not(:disabled) .item-label {
    color: rgba(100, 200, 255, 0.9);
}

@keyframes itemArmedPulseCyan {
    0%, 100% {
        box-shadow: 0 0 16px rgba(100, 200, 255, 0.5), inset 0 0 12px rgba(100, 200, 255, 0.1);
    }
    50% {
        box-shadow: 0 0 28px rgba(100, 200, 255, 0.8), inset 0 0 16px rgba(100, 200, 255, 0.15);
    }
}

/* Precision Pick selection mode — eligible pieces */
.precision-pick-active .puzzle-piece.tray-piece.precision-eligible {
    cursor: crosshair;
}

.precision-pick-active .puzzle-piece.tray-piece.precision-eligible:hover {
    filter: drop-shadow(0 0 8px rgba(100, 200, 255, 0.6));
    transform: scale(1.05);
    transition: filter 0.15s, transform 0.15s;
}

/* Precision Pick selection mode — ineligible pieces dimmed */
.precision-pick-active .puzzle-piece.tray-piece.precision-ineligible {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.5);
    transition: opacity 0.2s, filter 0.2s;
}

.precision-pick-active .puzzle-piece.tray-piece.precision-ineligible:hover {
    filter: grayscale(0.5);
    transform: none;
}

/* Shake animation for rejected precision pick click */
@keyframes precisionReject {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.precision-reject {
    animation: precisionReject 0.4s ease-out !important;
}

/* Locked precision pick — not-allowed cursor everywhere except the tray */
.precision-pick-locked .puzzle-container,
.precision-pick-locked .controls-sidebar {
    cursor: not-allowed;
}


/* Flash the tray panel to redirect attention when user clicks outside */
@keyframes precisionTrayFlash {
    0%   { box-shadow: 0 0 0 2px rgba(100, 200, 255, 0.9); }
    50%  { box-shadow: 0 0 0 5px rgba(100, 200, 255, 0.5); }
    100% { box-shadow: 0 0 0 0px rgba(100, 200, 255, 0); }
}

.precision-pick-flash {
    animation: precisionTrayFlash 0.45s ease-out !important;
}

/* Focus Mode — purple armed variant */
.item-slot.armed[data-item-id="focus_mode"]:not(:disabled) {
    border: 2px solid rgba(167, 139, 250, 0.9);
    background: rgba(167, 139, 250, 0.15);
    box-shadow: 0 0 16px rgba(167, 139, 250, 0.5), inset 0 0 12px rgba(167, 139, 250, 0.1);
    animation: itemArmedPulsePurple 2s ease-in-out infinite;
}
.item-slot.armed[data-item-id="focus_mode"]:not(:disabled) .item-label {
    color: rgba(167, 139, 250, 0.9);
}

@keyframes itemArmedPulsePurple {
    0%, 100% {
        box-shadow: 0 0 16px rgba(167, 139, 250, 0.5), inset 0 0 12px rgba(167, 139, 250, 0.1);
    }
    50% {
        box-shadow: 0 0 28px rgba(167, 139, 250, 0.8), inset 0 0 16px rgba(167, 139, 250, 0.15);
    }
}

/* Vacancy Fill — green armed variant */
.item-slot.armed[data-item-id="vacancy_fill"]:not(:disabled) {
    border: 2px solid rgba(76, 175, 80, 0.9);
    background: rgba(76, 175, 80, 0.15);
    box-shadow: 0 0 16px rgba(76, 175, 80, 0.5), inset 0 0 12px rgba(76, 175, 80, 0.1);
    animation: itemArmedPulseGreen 2s ease-in-out infinite;
}
.item-slot.armed[data-item-id="vacancy_fill"]:not(:disabled) .item-label {
    color: rgba(76, 175, 80, 0.9);
}

@keyframes itemArmedPulseGreen {
    0%, 100% {
        box-shadow: 0 0 16px rgba(76, 175, 80, 0.5), inset 0 0 12px rgba(76, 175, 80, 0.1);
    }
    50% {
        box-shadow: 0 0 28px rgba(76, 175, 80, 0.8), inset 0 0 16px rgba(76, 175, 80, 0.15);
    }
}

/* Item tooltip — custom styled tooltip on hover */
.item-tooltip {
    position: fixed;
    z-index: 10002;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 220px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(20, 20, 35, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.item-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.item-tooltip-arrow {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: rgba(20, 20, 35, 0.92);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.item-tooltip-name {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.item-tooltip-desc {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}
/* Per-item accent colors */
.item-tooltip[data-item="golden_charge"] .item-tooltip-name { color: rgba(255, 215, 0, 0.95); }
.item-tooltip[data-item="golden_charge"] { border-color: rgba(255, 215, 0, 0.25); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(255, 215, 0, 0.08); }
.item-tooltip[data-item="golden_charge"] .item-tooltip-arrow { border-color: rgba(255, 215, 0, 0.25); }

.item-tooltip[data-item="precision_pick"] .item-tooltip-name { color: rgba(100, 200, 255, 0.95); }
.item-tooltip[data-item="precision_pick"] { border-color: rgba(100, 200, 255, 0.25); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(100, 200, 255, 0.08); }
.item-tooltip[data-item="precision_pick"] .item-tooltip-arrow { border-color: rgba(100, 200, 255, 0.25); }

.item-tooltip[data-item="focus_mode"] .item-tooltip-name { color: rgba(167, 139, 250, 0.95); }
.item-tooltip[data-item="focus_mode"] { border-color: rgba(167, 139, 250, 0.25); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(167, 139, 250, 0.08); }
.item-tooltip[data-item="focus_mode"] .item-tooltip-arrow { border-color: rgba(167, 139, 250, 0.25); }

.item-tooltip[data-item="vacancy_fill"] .item-tooltip-name { color: rgba(76, 175, 80, 0.95); }
.item-tooltip[data-item="vacancy_fill"] { border-color: rgba(76, 175, 80, 0.25); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 20px rgba(76, 175, 80, 0.08); }
.item-tooltip[data-item="vacancy_fill"] .item-tooltip-arrow { border-color: rgba(76, 175, 80, 0.25); }

/* Vacancy Fill — ghost preview follows cursor, snaps to valid position */
.vacancy-ghost {
    position: absolute;
    pointer-events: none;
    z-index: 999;
    opacity: 0.7;
    background-image: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45)) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25)) !important;
    /* No transition — follows cursor instantly */
}

/* Square pieces: translucent fill within rounded rect */
.vacancy-ghost:not(:has(svg)) {
    background-color: rgba(76, 175, 80, 0.45) !important;
}

/* Jigsaw pieces: hide image, fill piece shape with translucent color */
.vacancy-ghost image {
    display: none;
}

.vacancy-ghost .piece-lighting {
    fill: rgba(76, 175, 80, 0.5) !important;
}

/* Restore bevels at reduced opacity — creates raised-edge depth illusion */
.vacancy-ghost .piece-bevel-dark {
    display: block;
    opacity: 0.35;
}

.vacancy-ghost .piece-bevel-light {
    display: block;
    opacity: 0.5;
}

.vacancy-ghost.ghost-snapped {
    opacity: 0.85;
    filter: drop-shadow(0 0 14px rgba(76, 175, 80, 0.85)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35)) !important;
}

/* Vacancy Fill — crosshair cursor on board in target mode */
.vacancy-fill-active {
    cursor: crosshair;
}

/* Vacancy Fill — disable tray while active */
.vacancy-fill-locked .puzzle-piece.tray-piece {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.5);
    transition: opacity 0.2s, filter 0.2s;
}

/* Item active — disable sidebar buttons (reference, settings, back, shop) */
body.item-mode-active #showReferenceBtn,
body.item-mode-active #settingsBtn,
body.item-mode-active #quitJourneyBtn,
body.item-mode-active #goldBadge {
    pointer-events: none;
    opacity: 0.35;
}

/* Vacancy Fill — rejection shake on board */
.vacancy-reject {
    animation: precisionReject 0.4s ease-out !important;
}

/* Golden Charge — yellow glow on dragged/selected piece when golden charge is armed */
.golden-charge-glow {
    filter: drop-shadow(0 0 14px rgba(255, 210, 0, 0.95)) drop-shadow(0 0 6px rgba(255, 160, 0, 0.6)) saturate(1.2) !important;
}

/* Focus Mode — emphasize dragged piece or click-to-move ghost */
.focus-mode-active .puzzle-piece.dragging,
.focus-mode-active .puzzle-piece.placement-ghost {
    opacity: 1 !important;
    filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.9)) drop-shadow(0 0 6px rgba(255, 255, 255, 0.4)) saturate(1.3) !important;
}

/* Focus Mode — highlight nearby snap targets during drag */
.focus-snap-target {
    filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.85)) drop-shadow(0 0 5px rgba(255, 255, 255, 0.35)) !important;
    opacity: 1 !important;
    transform: scale(1.03);
    transition: filter 0.15s, opacity 0.15s, transform 0.15s;
}

/* Focus Mode — very close to snapping */
.focus-snap-close {
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 1)) drop-shadow(0 0 8px rgba(255, 255, 255, 0.6)) !important;
    opacity: 1 !important;
    transform: scale(1.06);
    transition: filter 0.15s, opacity 0.15s, transform 0.15s;
}

/* Focus Mode timer bar */
.focus-timer-bar {
    height: 3px;
    background: rgba(167, 139, 250, 0.7);
    border-radius: 2px;
    margin-top: 6px;
    transition: width 0.25s linear;
}

/* Precision Pick fly animation */
.precision-flying {
    transition: left 0.4s cubic-bezier(0.22, 1, 0.36, 1), top 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 9999 !important;
    filter: drop-shadow(0 0 12px rgba(100, 200, 255, 0.7));
}

/* Armed indicator */
.item-armed-indicator {
    display: none;
}

/* Win modal reward line */
.win-reward-line {
    color: rgba(255, 215, 0, 0.95);
    font-weight: 600;
    margin-top: 12px;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.win-reward-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    animation: rewardSlideIn 0.35s ease forwards;
}

@keyframes rewardSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.win-reward-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 1px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.win-unlock-card {
    width: 100%;
    margin-top: 8px;
    padding: 14px 18px;
    border-radius: 12px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
    text-align: left;
    opacity: 0;
    animation: rewardUnlockPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.win-unlock-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.win-unlock-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}
.win-unlock-title {
    font-weight: 800;
    font-size: 1rem;
    color: rgba(255, 215, 0, 0.95);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}
.win-unlock-desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    margin-bottom: 6px;
}
.win-unlock-sample {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-success-text, #66bb6a);
}
@keyframes rewardUnlockPop {
    0%   { opacity: 0; transform: translateY(12px) scale(0.8); }
    60%  { opacity: 1; transform: translateY(-4px) scale(1.05); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Responsive layout: compress sidebars, never stack to column ─────────────
 *
 * The 3-column layout (sidebar | board | tray) is preserved at all widths.
 * Sidebars compress progressively as the window narrows.  Below 780 px the
 * browser shows a horizontal scrollbar rather than collapsing the layout.
 *
 * Breakpoints:
 *   < 1200 px  sidebars 220 px
 *   < 1000 px  sidebars 185 px, gaps/padding tighten
 *   <  860 px  sidebars 155 px, further padding reduction, items wrap to 2×2
 *   <  780 px  body min-width floor → horizontal scroll, layout never breaks
 */

body {
    min-width: 780px; /* horizontal scroll rather than layout collapse */
}

@media (max-width: 1200px) {
    .controls-sidebar {
        width: 220px;
    }
    .pieces-panel {
        width: 220px;
    }
    .pieces-container {
        max-width: 220px;
    }
    /* Stack clock and gold badge vertically — not enough horizontal room */
    .sidebar-stat--timer {
        flex-direction: column;
        gap: 6px;
    }
    .sidebar-stat--timer #timer {
        justify-content: center;
    }
    .sidebar-stat--timer .gold-badge {
        width: 100%;
        justify-content: center;
    }
    .sidebar-stat--timer .gold-badge .gold-icon {
        width: 34px;
        height: 34px;
    }
    /* Item bar is already 2×2 by default */
}

@media (max-width: 1000px) {
    .game-area {
        gap: 12px;
        padding: 12px;
    }
    .controls-sidebar {
        width: 185px;
        gap: 12px;
    }
    .sidebar-section {
        padding: 14px;
    }
    .pieces-panel {
        width: 185px;
    }
    .pieces-container {
        max-width: 185px;
    }
}

@media (max-width: 860px) {
    .game-area {
        gap: 8px;
        padding: 8px;
    }
    .controls-sidebar {
        width: 155px;
        gap: 8px;
    }
    .sidebar-section {
        padding: 10px;
    }
    .sidebar-title {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }
    .pieces-panel {
        width: 155px;
    }
    .pieces-container {
        max-width: 155px;
        padding: 8px;
        gap: 6px;
    }
    .puzzle-container {
        min-width: 260px;
    }

    /* Tighten gold badge padding in narrow sidebar */
    .sidebar-stat--timer .gold-badge {
        padding: 7px 10px;
    }
}

/* Settings Modal */
.settings-content {
    min-width: 320px;
    max-width: 400px;
    text-align: center;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0 0;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
.settings-debug { display: none; }
.debug-mode .settings-debug { display: flex; }

.settings-nickname-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.settings-nickname-input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    min-width: 0;
}

.settings-nickname-input:focus {
    border-color: var(--accent, #4a90d9);
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    flex-shrink: 0;
}

.settings-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.settings-icon-emoji {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.settings-toggle {
    padding: 6px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.28);
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: #fff;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255,255,255,0.06) inset;
}

.settings-toggle:hover {
    background: rgba(255, 255, 255, 0.17);
    border-color: rgba(255, 255, 255, 0.3);
}

.settings-select {
    padding: 6px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    min-width: 0;
    flex-shrink: 1;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    appearance: auto;
}

.settings-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}

.settings-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Account row ── */
#accountLabel {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Inline page viewer (privacy/terms) ── */
.page-viewer-content {
    width: min(540px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior-y: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.page-viewer-content::-webkit-scrollbar { width: 4px; }
.page-viewer-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.page-viewer-body {
    padding: 4px 8px 16px;
    font-size: 0.9rem;
    line-height: 1.7;
    text-align: left;
}
.page-viewer-body h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 20px 0 6px;
    color: rgba(255,255,255,0.95);
}
.page-viewer-body p,
.page-viewer-body li {
    font-size: 0.88rem;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.75);
}
.page-viewer-body ul { padding-left: 18px; }
.page-viewer-body a { color: #f39c12; }

.settings-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition: color 0.2s ease;
}

.settings-link:hover {
    color: rgba(255, 255, 255, 0.8);
}

.settings-link-sep {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.8rem;
}

/* Cookie consent banner */
.cookie-banner {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--modal-bg-start), var(--modal-bg-end));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 2100;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    white-space: nowrap;
}

.cookie-banner.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.cookie-banner.hidden {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.cookie-banner-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.cookie-opt-out {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.cookie-opt-out:hover {
    color: rgba(255, 255, 255, 0.7);
}

/* =================================================================
   CANDY THEME (unused — glossy 3D buttons, activate by adding
   class="candy-theme" to <body> or a wrapper element)
   ================================================================= */

.candy-theme .btn-primary,
.candy-theme .btn-secondary {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #3ac5b6 0%, #2a9d8f 40%, #21867a 100%);
    border: 3px solid #1a6e64;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow:
        0 5px 0 #155a52,
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.candy-theme .btn-primary::before,
.candy-theme .btn-secondary::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 8%;
    right: 8%;
    height: 45%;
    border-radius: 50px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.candy-theme .btn-primary:hover,
.candy-theme .btn-secondary:hover {
    background: linear-gradient(180deg, #4ad5c6 0%, #32b0a0 40%, #28968a 100%);
    box-shadow: 0 7px 0 #155a52, 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.candy-theme .btn-primary:active,
.candy-theme .btn-secondary:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #155a52, 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.candy-theme .btn-reference {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #5a7fa5 0%, #476a8a 40%, #3a5872 100%);
    border: 3px solid #2f4a60;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow:
        0 5px 0 #253c4f,
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.candy-theme .btn-reference::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 8%;
    right: 8%;
    height: 45%;
    border-radius: 50px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.candy-theme .btn-reference:hover {
    background: linear-gradient(180deg, #6a8fb5 0%, #567a9a 40%, #456882 100%);
    box-shadow: 0 7px 0 #253c4f, 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.candy-theme .btn-reference:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #253c4f, 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.candy-theme .btn-modal-primary {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #f7b840 0%, #e8961a 40%, #cc7a08 100%);
    border: 3px solid #a86200;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow:
        0 5px 0 #8a5000,
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.candy-theme .btn-modal-primary::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 8%;
    right: 8%;
    height: 45%;
    border-radius: 50px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.candy-theme .btn-modal-primary:hover {
    background: linear-gradient(180deg, #fcc84e 0%, #f0a428 40%, #d88a14 100%);
    box-shadow: 0 7px 0 #8a5000, 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.candy-theme .btn-modal-primary:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #8a5000, 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.candy-theme .btn-modal-secondary {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #5a7fa5 0%, #476a8a 40%, #3a5872 100%);
    border: 3px solid #2f4a60;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow:
        0 5px 0 #253c4f,
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.candy-theme .btn-modal-secondary::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 8%;
    right: 8%;
    height: 45%;
    border-radius: 50px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.candy-theme .btn-modal-secondary:hover:not(:disabled) {
    background: linear-gradient(180deg, #6a8fb5 0%, #567a9a 40%, #456882 100%);
    box-shadow: 0 7px 0 #253c4f, 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.candy-theme .btn-modal-outline,
.candy-theme .btn-danger {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #6b7b8d 0%, #556575 40%, #475562 100%);
    border: 3px solid #3a4854;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color: #fff;
    box-shadow:
        0 5px 0 #2e3a44,
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.candy-theme .btn-modal-outline::before,
.candy-theme .btn-danger::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 8%;
    right: 8%;
    height: 45%;
    border-radius: 50px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.candy-theme .btn-modal-outline:hover,
.candy-theme .btn-danger:hover {
    background: linear-gradient(180deg, #7b8b9d 0%, #657585 40%, #576572 100%);
    box-shadow: 0 7px 0 #2e3a44, 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.candy-theme .btn-modal-outline:active,
.candy-theme .btn-danger:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #2e3a44, 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
/* ── Gold currency UI ──────────────────────────────────────────────────────── */

/* Reusable SVG gold icon sizing */
.gold-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Timer row: clock + gold balance side by side ── */
.sidebar-stat--timer {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
/* Timer takes all remaining space; min-width:0 prevents flex blowout */
.sidebar-stat--timer #timer {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

/* Clock icon + sweep ring wrapper */
.clock-ring-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

/* SVG ring — sits around the clock icon, centred via negative inset */
.clock-sweep-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 40px;
    height: 40px;
    pointer-events: none;
    transform: rotate(-90deg); /* start sweep from 12 o'clock */
}

/* Dim track circle */
.clock-sweep-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 2.5;
}

/* Animated fill arc */
.clock-sweep-fill {
    fill: none;
    stroke: var(--accent, #00d4aa);
    stroke-width: 2.5;
    stroke-linecap: round;
    /* dasharray/offset set by TimerDisplay JS */
    transition: stroke-dashoffset 1s linear;
}

/* Individual digit spans */
.timer-digits {
    display: inline-flex;
    align-items: baseline;
}

.timer-digit {
    display: inline-block;
    min-width: 0.58em;
    text-align: center;
    transform-origin: center;
}

.timer-sep {
    margin: 0 1px;
    opacity: 0.7;
}

/* Digit flip keyframe — scaleY pinches to 0 at midpoint, value swaps there */
@keyframes td-flip {
    0%   { transform: scaleY(1);    opacity: 1;   }
    40%  { transform: scaleY(0.05); opacity: 0.3; }
    60%  { transform: scaleY(0.05); opacity: 0.3; }
    100% { transform: scaleY(1);    opacity: 1;   }
}

.timer-digit.td-flip {
    animation: td-flip 0.15s ease-in-out;
}

/* ── Gold balance badge (inline in status bar) ── */
.gold-badge {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    outline: none;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, transform 0.1s;
    /* Fixed intrinsic size — never grows or shrinks with content */
    flex: 0 0 auto;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    box-shadow: none;
}
.gold-badge:focus-visible {
    outline: 2px solid rgba(255, 215, 0, 0.6);
    outline-offset: 2px;
}
.gold-badge:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: scale(1.03);
}
.gold-badge:active { transform: scale(0.97); }
.gold-badge-amount {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-gold);
    font-variant-numeric: tabular-nums;
    min-width: 2ch;
    text-align: right;
}

/* ── Floating earn popup (during win celebration) ── */
/* ── Flying gold piece (snap → balance badge) ── */
.gold-fly-piece {
    position: fixed;
    z-index: 9010;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 6px rgba(255, 200, 0, 0.85));
}

/* ── Mid-game snap gold pop (small, at snap location) ── */
.snap-gold-pop {
    position: fixed;
    z-index: 9010;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 6px 10px;
    background: rgba(10, 6, 0, 0.82);
    border: 1.5px solid rgba(255, 200, 50, 0.6);
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--color-gold);
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.gold-earn-popup {
    position: fixed;
    left: 50%;
    bottom: 26%;
    z-index: 10002;
    transform: translateX(-50%);
    pointer-events: none;
    text-align: center;
}
.gold-earn-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.gold-earn-num {
    font-family: 'Lilita One', cursive;
    font-size: 60px;
    color: var(--color-gold);
    text-shadow:
        -2px  0   0 #000,
         2px  0   0 #000,
         0   -2px 0 #000,
         0    2px 0 #000,
         5px  5px 0 rgba(0,0,0,0.85),
         0    0  22px rgba(255,225,80,0.75);
}
.gold-earn-sub {
    font-size: 13px;
    color: rgba(255, 215, 100, 0.9);
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.02em;
}

/* ── Win modal gold row ── */
.win-gold-earned {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
}
.win-gold-earned.hidden { display: none; }
.win-gold-amount {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-gold);
}

/* ── Win modal: Piece Pick rewards ── */
.win-pp-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.win-pp-section.hidden { display: none; }
.win-pp-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 2px;
}
.win-pp-label.hidden { display: none; }
#winPuzzleRewardLabel {
    margin-top: 8px;
    margin-bottom: -2px;
}
.win-pp-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

/* ── Achievements modal ── */
.achievements-content {
    width: min(480px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior-y: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.achievements-content::-webkit-scrollbar { width: 4px; }
.achievements-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.achievements-body { padding: 8px 0; }
.ach-summary {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    margin-bottom: 12px;
}
.ach-section { margin-bottom: 16px; }
.ach-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    padding: 0 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 6px;
}
.ach-section-icon { font-size: 1rem; }
.ach-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    margin-bottom: 4px;
    transition: background 0.15s;
}
.ach-card.ach-earned { background: rgba(255,215,0,0.08); }
.ach-card-left { flex: 1; min-width: 0; }
.ach-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
}
.ach-earned .ach-card-title { color: var(--color-gold); }
.ach-card-desc {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
    margin-top: 1px;
}
.ach-progress {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}
.ach-progress-fill {
    height: 100%;
    background: var(--color-gold);
    border-radius: 2px;
    transition: width 0.3s;
}
.ach-progress-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
    margin-top: 2px;
    display: block;
}
.ach-card-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.ach-check {
    font-size: 1.1rem;
    color: var(--color-success);
}
.ach-reward-amt {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-gold);
}

/* ── Achievement toast ── */
.achievement-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    z-index: 10002;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 14px;
    background: rgba(30,30,30,0.95);
    border: 1px solid rgba(255,215,0,0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    pointer-events: none;
    transition: transform 0.35s ease;
    max-width: 92vw;
}
.achievement-toast.ach-toast-visible {
    transform: translateX(-50%) translateY(0);
}
.ach-toast-icon { font-size: 1.4rem; flex-shrink: 0; }
.ach-toast-text { display: flex; flex-direction: column; min-width: 0; }
.ach-toast-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ach-toast-desc {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ach-toast-reward {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-gold);
    flex-shrink: 0;
}

/* ── Stats modal ── */
.stats-content {
    width: min(480px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior-y: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.stats-content::-webkit-scrollbar { width: 4px; }
.stats-content::-webkit-scrollbar-track { background: transparent; }
.stats-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.stats-body {
    padding: 8px 0 0;
}
.stats-section {
    margin-bottom: 20px;
}
.stats-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
}
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stats-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 12px;
    text-align: center;
}
.stats-card-icon {
    font-size: 1.3rem;
    margin-bottom: 4px;
}
.stats-card-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 2px;
}
.stats-card-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}
.stats-diff-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stats-diff-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 0.85rem;
}
.stats-diff-label {
    font-weight: 700;
    min-width: 60px;
}
.stats-diff-count {
    flex: 1;
    color: rgba(255, 255, 255, 0.6);
}
.stats-diff-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
}

/* ── Daily Reward ── */
.daily-reward-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: var(--overlay-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: revealFadeIn 0.3s ease;
}
.daily-reward-card {
    position: relative;
    background:
        radial-gradient(ellipse at 20% 0%, var(--glow-a) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, var(--glow-b) 0%, transparent 60%),
        linear-gradient(160deg, var(--bg-mid), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 36px 32px 32px;
    width: min(520px, 92vw);
    text-align: center;
    animation: revealScaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.daily-reward-header {
    margin-bottom: 28px;
}
.daily-reward-title {
    font-family: 'Lilita One', sans-serif;
    font-size: 2rem;
    color: #fff;
    margin-bottom: 6px;
}
.daily-reward-streak {
    font-size: 0.9rem;
    color: rgba(255, 215, 0, 0.7);
    font-weight: 600;
}
.daily-reward-strip {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.daily-reward-day {
    flex: 1 1 0;
    min-width: 48px;
    padding: 14px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.2s;
}
.daily-reward-day.current {
    border-color: rgba(255, 215, 0, 0.5);
    background: rgba(255, 215, 0, 0.08);
}
.daily-reward-day.claimed {
    opacity: 0.35;
}
.daily-reward-day-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    text-transform: uppercase;
}
.daily-reward-day.current .daily-reward-day-label {
    color: rgba(255, 215, 0, 0.8);
}
.daily-reward-day-amount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}
.daily-reward-day-bonus {
    font-size: 0.65rem;
    color: var(--color-success-text, #66bb6a);
    font-weight: 600;
    margin-top: 2px;
}
.daily-reward-claim {
    padding: 16px 36px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(180deg, #f0b840 0%, #d4881e 100%);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(224, 138, 16, 0.35);
}
.daily-reward-claim:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(224, 138, 16, 0.5);
}
.daily-reward-claim.claimed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
    color: rgba(255, 215, 0, 0.9);
    font-size: 1.2rem;
}
.daily-reward-claim-counter {
    font-weight: 800;
}
.daily-reward-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1.4rem;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    transition: color 0.15s;
    opacity: 0;
    animation: rewardSlideIn 0.3s ease forwards;
}
.daily-reward-close:hover {
    color: rgba(255, 255, 255, 0.7);
}
.daily-reward-item-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 215, 0, 0.9);
    margin-bottom: 14px;
    animation: rewardSlideIn 0.35s ease forwards;
}
.daily-reward-item-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ── Gold Shop modal ── */
.shop-content {
    width: min(480px, 94vw);
    max-height: 88vh;
    overflow-y: hidden;
    overscroll-behavior-y: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
    /* inherits base modal padding: 28px 32px */
}
.shop-content::-webkit-scrollbar { width: 4px; }
.shop-content::-webkit-scrollbar-track { background: transparent; }
.shop-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }
.shop-header-balance {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 17px;
    color: var(--color-gold);
    min-width: 60px;
    justify-content: flex-end;
}
.shop-balance-amount {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
}
.shop-items-list {
    padding: 20px 0 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.shop-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    transition: background 0.15s, border-color 0.15s;
}
.shop-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}
.shop-item-locked {
    opacity: 0.35;
    pointer-events: none;
}
.shop-item-locked .shop-item-icon {
    filter: grayscale(1);
}
.shop-item-lock {
    position: absolute;
    top: -4px;
    right: -6px;
    font-size: 0.75rem;
}
.shop-item-unlock-req {
    font-style: italic;
}
.shop-item-icon {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}
.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text, #e0e0e0);
    margin-bottom: 5px;
}
.shop-item-desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.46);
    line-height: 1.5;
}
.shop-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.shop-icon-wrap {
    position: relative;
    flex-shrink: 0;
}
.shop-item-count {
    position: absolute;
    top: -2px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 10px;
    padding: 0 5px;
}
.shop-count-bump {
    animation: shopCountBump 0.4s ease-out;
}
@keyframes shopCountBump {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.5); color: #5f5; }
    100% { transform: scale(1); }
}
.shop-item-price {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-gold);
    font-weight: 700;
    font-size: 1rem;
}
.shop-buy-btn {
    font-size: 0.85rem;
    padding: 8px 18px;
    border-radius: 12px;
    background: var(--accent, #5b9cf5);
    color: rgba(0, 0, 0, 0.75);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s, filter 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.shop-buy-btn:not(:disabled):hover { filter: brightness(1.15); }
.shop-buy-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: rgba(255,255,255,0.15);
}

/* ── Episode gold-unlock button ── */
/* ══════════════════════════════════════════════════════════════════════
   Living Journal — Journey Book (illustrated picture-book scroll)
   ══════════════════════════════════════════════════════════════════════ */

/* ── Journey Shelf (book selection) ─────────────────────────────── */

.jshelf-content {
    max-width: 680px;
    width: 92vw;
    padding: 44px 48px 52px;
}

.jshelf-header {
    text-align: center;
    margin-bottom: 36px;
}

.jshelf-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.88);
    margin-bottom: 6px;
}

.jshelf-sub {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.36);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.jshelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 24px;
}

.jshelf-book {
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.jshelf-book:hover {
    transform: translateY(-5px) scale(1.025);
    box-shadow: 6px 16px 36px rgba(0, 0, 0, 0.65);
    border-color: rgba(232, 184, 75, 0.35);
}

.jshelf-book-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
}

.jshelf-book-info {
    padding: 12px 14px 16px;
    display: flex;
    flex-direction: column;
}

.jshelf-book-text {
    flex: 1;
    min-height: 5.2rem;
}

.jshelf-book-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.35;
    min-height: calc(0.82rem * 1.35 * 2);
    margin-bottom: 4px;
}

.jshelf-book-tagline {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.38);
    line-height: 1.45;
    margin-bottom: 0;
}

.jshelf-book-progress-track {
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.jshelf-book-progress-fill {
    height: 100%;
    background: var(--accent-color, #e8b84b);
    border-radius: 2px;
    transition: width 0.4s;
}

.jshelf-book--complete .jshelf-book-progress-fill {
    background: var(--color-success-light);
}

.jshelf-book-progress-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.32);
}

/* Modal shell — two-panel layout */
.jb-content {
    max-width: 780px;
    width: 94vw;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.jb-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: 90vh;
    max-height: 90vh;
}

/* ── Left index panel ──────────────────────────────────────────────── */

.jb-index {
    width: 168px;
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
    padding: 28px 14px 28px 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(0, 0, 0, 0.22);
}
.jb-index::-webkit-scrollbar { width: 4px; }
.jb-index::-webkit-scrollbar-track { background: transparent; }
.jb-index::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

.jb-index-title {
    font-size: 0.68rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.jb-index-item {
    padding: 9px 8px;
    margin-bottom: 6px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s;
}

.jb-index-item:hover:not(.jb-index-item--locked) {
    background: rgba(255, 255, 255, 0.07);
}

.jb-index-item--locked {
    opacity: 0.35;
    cursor: default;
}

.jb-index-item--completed .jb-index-ep-num {
    color: var(--color-success-light);
}

.jb-index-ep-num {
    font-size: 0.65rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
    margin-bottom: 4px;
}

.jb-index-ep-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.68);
    line-height: 1.3;
}

/* Thin episode progress bar */
.jb-ep-progress {
    height: 2px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.jb-ep-progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.jb-index-item--completed .jb-ep-progress-fill {
    background: rgba(74, 222, 128, 0.35);
}

/* ── Right scrollable book ─────────────────────────────────────────── */

.jb-scroll-area {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
    padding: 40px 52px 80px;
    min-width: 0;
}
.jb-scroll-area::-webkit-scrollbar { width: 4px; }
.jb-scroll-area::-webkit-scrollbar-track { background: transparent; }
.jb-scroll-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* Book title block */
.jb-header {
    text-align: center;
    margin-bottom: 36px;
    padding-bottom: 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.jb-header h2 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    font-family: 'Cinzel Decorative', serif;
    line-height: 1.25;
    color: var(--accent-color, #e8b84b);
}

.jb-tagline {
    margin: 0;
    font-style: italic;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.6);
}

.jb-body {
    /* purely a container */
}

/* Premise text — styled like a book's opening page */
.jb-premise {
    font-family: 'Poppins', sans-serif;
    font-size: 0.96rem;
    line-height: 1.88;
    color: rgba(255, 255, 255, 0.85);
    margin: 0 0 52px;
    padding: 22px 26px;
    border-left: 3px solid var(--accent-color, #e8b84b);
    background: rgba(232, 184, 75, 0.06);
    border-radius: 0 8px 8px 0;
    text-align: left;
}

/* ── Episode section ───────────────────────────────────────────────── */

.jb-episode {
    margin-bottom: 56px;
}

/* Hidden until unlocked — slides in when parent re-renders */
.jb-episode--hidden {
    display: none;
}

/* Inline episode arc / journey ending */
.jb-episode-arc-block {
    margin-top: 52px;
    padding: 32px 28px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.jb-arc-deco {
    font-size: 0.72rem;
    letter-spacing: 4px;
    color: var(--accent-color, #e8b84b);
    opacity: 0.5;
    margin-bottom: 18px;
}

.jb-arc-text {
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.85);
    font-style: normal;
    margin: 0;
    text-align: left;
}

.jb-arc-text::before {
    content: '\201C';
    font-size: 2.4rem;
    line-height: 0;
    vertical-align: -0.5rem;
    margin-right: 4px;
    color: var(--accent-color, #e8b84b);
    opacity: 0.6;
    font-family: Georgia, 'Times New Roman', serif;
}
.jb-arc-text::after {
    content: '\201D';
    font-size: 2.4rem;
    line-height: 0;
    vertical-align: -0.5rem;
    margin-left: 4px;
    color: var(--accent-color, #e8b84b);
    opacity: 0.6;
    font-family: Georgia, 'Times New Roman', serif;
}

.jb-episode-arc-block--ending .jb-arc-deco {
    opacity: 0.8;
    font-size: 1rem;
    letter-spacing: 2px;
}

/* Chapter heading */
.jb-chapter-heading {
    text-align: center;
    margin-bottom: 36px;
    padding: 0 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.jb-chapter-label {
    font-size: 0.6rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent-color, #e8b84b);
    opacity: 0.65;
    margin-bottom: 8px;
}

.jb-chapter-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.35rem;
    color: #fff;
    line-height: 1.3;
    margin: 0;
}

/* ── Puzzle entry (one per puzzle — book spread) ───────────────────── */

.jb-puzzle-entry {
    margin-bottom: 52px;
}

/* Subtle rule between entries */
.jb-puzzle-entry + .jb-puzzle-entry {
    padding-top: 44px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Story beat prose */
.jb-prose {
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.85);
    margin: 0 0 52px;
    text-align: left;
}

/* Illustration plate */
.jb-illustration {
    margin: 0 auto;
    max-width: 75%;
    position: relative;
    cursor: pointer;
}

.jb-illustration img {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
    transition: box-shadow 0.2s;
}

.jb-illustration figcaption {
    font-family: 'Poppins', sans-serif;
    font-size: 0.72rem;
    font-style: italic;
    color: rgba(255, 255, 255, 0.42);
    text-align: center;
    margin-top: 10px;
    letter-spacing: 0.3px;
}

/* Active: clickable, no border */
.jb-puzzle-entry--active .jb-illustration img {
    cursor: pointer;
}

.jb-puzzle-entry--active .jb-illustration:hover img {
    box-shadow: 0 14px 48px rgba(0, 0, 0, 0.65);
}

/* Hover button — centered on the illustration, appears on mouse-over */
.jb-hover-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    background: rgba(10, 7, 2, 0.82);
    color: var(--accent-color, #e8b84b);
    border: 1px solid rgba(232, 184, 75, 0.4);
    border-radius: 99px;
    padding: 10px 28px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    white-space: nowrap;
    pointer-events: none;
    backdrop-filter: blur(6px);
}

.jb-illustration:hover .jb-hover-btn {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}


.jb-puzzle-entry--complete .jb-illustration img {
    cursor: pointer;
    opacity: 0.88;
}

.jb-puzzle-entry--complete .jb-illustration:hover img {
    opacity: 1;
}

/* Gold unlock button on locked placeholders */
.jb-unlock-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(10, 7, 2, 0.78);
    color: rgba(232, 184, 75, 0.9);
    border: 1px solid rgba(232, 184, 75, 0.28);
    border-radius: 99px;
    padding: 10px 22px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}

.jb-locked-placeholder:hover .jb-unlock-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.jb-unlock-btn:hover {
    background: rgba(30, 20, 5, 0.92);
    color: var(--accent-color, #e8b84b);
    border-color: rgba(232, 184, 75, 0.55);
    transform: translate(-50%, -50%) scale(1);
}

.jb-unlock-btn--poor {
    color: rgba(232, 184, 75, 0.4);
    border-color: rgba(232, 184, 75, 0.12);
    cursor: default;
}

.jb-unlock-btn--poor:hover {
    background: rgba(10, 7, 2, 0.78);
    color: rgba(232, 184, 75, 0.4);
    border-color: rgba(232, 184, 75, 0.12);
}

/* Locked: unprinted page placeholder */
.jb-puzzle-entry--locked .jb-illustration {
    cursor: default;
}

.jb-locked-placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    position: relative;
    background:
        repeating-linear-gradient(
            -45deg,
            rgba(255, 255, 255, 0.018) 0px,
            rgba(255, 255, 255, 0.018) 1px,
            transparent 1px,
            transparent 10px
        ),
        linear-gradient(160deg,
            rgba(255, 255, 255, 0.025) 0%,
            rgba(255, 255, 255, 0.045) 100%
        );
    border: 1px solid rgba(255, 255, 255, 0.07);
}

/* ── Story Card Overlay ──────────────────────────────────────────────── */

.jb-story-card {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--overlay-heavy);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: jbFadeIn 0.25s ease;
}

.jb-story-card.hidden {
    display: none;
}

@keyframes jbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.jb-story-card-inner {
    max-width: 460px;
    width: 92vw;
    background: linear-gradient(150deg, var(--modal-bg-start, #2c3e50), var(--modal-bg-end, #1a252f));
    border-radius: 16px;
    padding: 30px 32px 34px;
    text-align: center;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
    animation: jbSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes jbSlideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.jb-story-card-label {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1rem;
    letter-spacing: 0.5px;
    color: var(--accent-color, #e8b84b);
    margin-bottom: 16px;
    line-height: 1.4;
}

.jb-story-card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    display: block;
}

.jb-story-card-image.hidden {
    display: none;
}

.jb-story-card-text {
    font-family: 'Poppins', sans-serif;
    font-size: 0.92rem;
    line-height: 1.72;
    color: rgba(255, 255, 255, 0.88);
    margin: 0 0 26px;
    font-style: normal;
    text-align: left;
}

/* Responsive */
@media (max-width: 600px) {
    .jb-index {
        display: none;  /* hide index on small screens */
    }

    .jb-scroll-area {
        padding: 28px 22px 60px;
    }

    .jb-header h2 {
        font-size: 1.2rem;
    }

    .jb-chapter-title {
        font-size: 1.1rem;
    }

    .jb-story-card-inner {
        padding: 28px 24px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Shared puzzle polaroid cards (used by JourneyTome)
   ══════════════════════════════════════════════════════════════════════ */

.jb-card {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 6px 16px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
    position: relative;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    color: #fff;
    user-select: none;
}

.jb-card:hover:not(.jb-card--next-locked) {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}

.jb-card--next-locked {
    cursor: default;
    opacity: 0.7;
}

.jb-card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    border-radius: 2px;
    margin-bottom: 6px;
}

.jb-card--next-locked .jb-card-image {
    filter: blur(10px) brightness(0.6);
}

.jb-card-title {
    font-size: 0.62rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.85);
    padding: 0 2px;
    min-height: 1.5em;
}

.jb-card--next-locked .jb-card-title {
    color: rgba(255, 255, 255, 0.35);
}

.jb-card-check {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: var(--color-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.jb-card-mystery {
    position: absolute;
    inset: 8px 8px 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

/* ══════════════════════════════════════════════════════════════════════
   Journey Tome — The Book (two-page spread)
   ══════════════════════════════════════════════════════════════════════ */

.jt-content {
    max-width: 900px;
    width: 96vw;
    max-height: 88vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Close button floats above the spread */
.jt-content .modal-dismiss {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
}

/* ── The two-page spread ─────────────────────────────────────────────── */

.jt-book {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Left page: table of contents */
.jt-page--left {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 28px 18px 18px;
    background: rgba(0, 0, 0, 0.12);
}

.jt-book-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-color, #e8b84b);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 20px;
    padding-right: 20px; /* avoid overlap with close btn */
}

.jt-chapters {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.jt-chapters::-webkit-scrollbar { width: 4px; }
.jt-chapters::-webkit-scrollbar-track { background: transparent; }
.jt-chapters::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

.jt-chapter {
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
    border-left: 3px solid transparent;
}

.jt-chapter:hover:not(.jt-chapter--active) {
    background: rgba(255, 255, 255, 0.06);
}

.jt-chapter--active {
    background: rgba(232, 184, 75, 0.12);
    border-left-color: var(--accent-color, #e8b84b);
}

.jt-chapter--locked {
    opacity: 0.35;
}

.jt-chapter-num {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted, rgba(255,255,255,0.4));
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.jt-chapter-lock {
    font-size: 0.65rem;
}

.jt-chapter-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    line-height: 1.3;
    margin-bottom: 6px;
}

/* Progress dots */
.jt-chapter-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.jt-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    transition: background 0.2s;
}

.jt-dot--done {
    background: var(--color-success);
}

.jt-dot--active {
    background: var(--accent-color, #e8b84b);
}

/* Progress footer */
.jt-progress-footer {
    font-size: 0.68rem;
    color: var(--text-muted, rgba(255,255,255,0.4));
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 8px;
}

/* ── Spine ───────────────────────────────────────────────────────────── */

.jt-spine {
    width: 1px;
    flex-shrink: 0;
    background: linear-gradient(to bottom,
        transparent 0%,
        rgba(255,255,255,0.14) 20%,
        rgba(255,255,255,0.14) 80%,
        transparent 100%);
}

/* ── Right page: episode detail ──────────────────────────────────────── */

.jt-page--right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 22px 26px 20px;
    overflow: hidden;
}

/* Nav row */
.jt-ep-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.jt-nav-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary, #fff);
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.4;
    transition: background 0.12s;
    font-family: inherit;
}

.jt-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
}

.jt-nav-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.jt-ep-counter {
    font-size: 0.72rem;
    color: var(--text-muted, rgba(255,255,255,0.45));
    letter-spacing: 0.5px;
}

/* Episode content (animated) */
.jt-ep-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
    transition: opacity 0.15s;
}
.jt-ep-content::-webkit-scrollbar { width: 4px; }
.jt-ep-content::-webkit-scrollbar-track { background: transparent; }
.jt-ep-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

.jt-ep-content.jt-flip {
    opacity: 0;
}

.jt-ep-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-color, #e8b84b);
    margin: 0 0 14px;
    line-height: 1.3;
}

.jt-ep-arc {
    font-family: 'Poppins', sans-serif;
    font-size: 0.86rem;
    color: rgba(255, 255, 255, 0.78);
    font-style: normal;
    line-height: 1.68;
    margin: 0 0 14px;
    padding: 0 6px;
    text-align: left;
}

.jt-ep-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
}

/* Puzzle grid (reuses jb-card classes for the polaroid cards) */
.jt-puzzles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.jt-lock-msg {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-muted, rgba(255,255,255,0.4));
    padding: 20px 0 10px;
    margin: 0;
}

/* ── Responsive: stack on narrow screens ─────────────────────────────── */

@media (max-width: 620px) {
    .jt-book {
        flex-direction: column;
    }

    .jt-page--left {
        width: 100%;
        max-height: 160px;
        padding: 44px 16px 12px;
    }

    .jt-chapters {
        display: flex;
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .jt-chapter {
        flex-shrink: 0;
        min-width: 110px;
        margin-bottom: 0;
    }

    .jt-spine {
        width: 100%;
        height: 1px;
        background: linear-gradient(to right,
            transparent 0%,
            rgba(255,255,255,0.12) 20%,
            rgba(255,255,255,0.12) 80%,
            transparent 100%);
    }

    .jt-page--right {
        padding: 16px;
    }

    .jt-puzzles {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Challenge card overlay ──────────────────────────────────────────────── */
.challenge-card-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--overlay-heavy);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: revealFadeIn 0.35s ease;
}
.challenge-card {
    width: min(420px, 92vw);
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(160deg, var(--bg-mid), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: revealScaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.challenge-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}
.challenge-card-info {
    padding: 20px 24px 8px;
    text-align: center;
}
.challenge-card-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 215, 0, 0.75);
    margin-bottom: 8px;
}
.challenge-card-title {
    font-family: 'Lilita One', sans-serif;
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 6px;
}
.challenge-card-meta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 12px;
}
.challenge-card-time {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 4px;
}
.challenge-card-prompt {
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(255, 215, 0, 0.9);
    margin-bottom: 4px;
}
.challenge-card-actions {
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.challenge-card-accept {
    width: 100%;
}
.challenge-card-browse {
    width: 100%;
}

/* Challenge result in win modal */
.challenge-result {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}
.challenge-result.hidden {
    display: none;
}
.challenge-result-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.challenge-result-title.beat {
    color: var(--color-success-text, #66bb6a);
}
.challenge-result-title.missed {
    color: rgba(255, 200, 100, 0.9);
}
.challenge-result-times {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
}
.challenge-result-teaser {
    margin-top: 10px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

/* Share toast */
.share-toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    padding: 10px 20px;
    border-radius: 10px;
    background: rgba(20, 20, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    animation: rewardSlideIn 0.3s ease forwards;
}


/* ── Star rating (gold jigsaw pieces) ────────────────────────────────────── */
.star-rating {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.star-icon {
    display: inline-flex;
    transition: transform 0.2s ease;
}
.star-active {
    color: #ffd439;
    filter: drop-shadow(0 1px 3px rgba(255, 180, 0, 0.5));
}
.star-empty {
    color: rgba(255, 255, 255, 0.12);
}
/* Star reveal animation on win */
.star-icon.star-reveal {
    animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
}
@keyframes starPop {
    0%   { opacity: 0; transform: scale(0) rotate(-30deg); }
    60%  { opacity: 1; transform: scale(1.3) rotate(10deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
/* Stars on puzzle cards in collections */
.journey-puzzle-stars {
    display: flex;
    justify-content: center;
    gap: 1px;
    margin-top: 2px;
}
/* Stars on win modal */
.win-star-rating {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 8px 0 4px;
    gap: 6px;
}
.win-star-rating .star-rating {
    gap: 8px;
}
.win-star-rating.hidden {
    display: none;
}
.win-star-sub {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: 6px;
}
.win-star-bonus {
    font-size: 0.82rem;
    font-weight: 700;
    color: rgba(255, 215, 0, 0.85);
}
.win-star-upgrade {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-success-text, #66bb6a);
}
.win-star-hint {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.35);
}
/* 3-star sparkle burst */
.three-star-sparkle .star-active {
    animation: starShimmer 1.5s ease-in-out infinite;
}
.three-star-sparkle .star-active:nth-child(2) {
    animation-delay: 0.2s;
}
.three-star-sparkle .star-active:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes starShimmer {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.4)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 20px rgba(255, 180, 0, 0.4)); transform: scale(1.1); }
}

.journey-theme-card-stars {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
}

/* ── Speed combo indicator ───────────────────────────────────────────────── */
.speed-combo-indicator {
    position: fixed;
    z-index: 9000;
    transform: translateX(-50%);
    pointer-events: none;
    text-align: center;
    padding: 8px 16px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    animation: speedComboIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.speed-combo-text {
    font-family: 'Lilita One', sans-serif;
    font-size: 1.2rem;
    color: rgba(255, 215, 0, 0.95);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
    margin-bottom: 2px;
}
.speed-combo-bonus {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
}
.speed-combo-bar {
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 auto;
    overflow: hidden;
}
.speed-combo-bar-fill {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.9), rgba(255, 140, 0, 0.9));
    animation: speedComboDrain 5s linear forwards;
}
@keyframes speedComboIn {
    from { opacity: 0; transform: translateX(-50%) scale(0.5) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}
@keyframes speedComboDrain {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ── Daily puzzle modal ──────────────────────────────────────────────────── */
.daily-puzzle-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--overlay-heavy);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: revealFadeIn 0.35s ease;
}
.daily-puzzle-card {
    width: min(420px, 92vw);
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(160deg, var(--bg-mid), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: revealScaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.daily-puzzle-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}
.daily-puzzle-info {
    padding: 20px 24px 8px;
    text-align: center;
}
.daily-puzzle-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 215, 0, 0.75);
    margin-bottom: 8px;
}
.daily-puzzle-title {
    font-family: 'Lilita One', sans-serif;
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 6px;
}
.daily-puzzle-meta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 12px;
}
.daily-puzzle-times {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    margin-bottom: 4px;
}
.daily-puzzle-actions {
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.daily-puzzle-actions .btn-modal-primary,
.daily-puzzle-actions .btn-modal-secondary {
    width: 100%;
}

/* ── Piece Pick (mini puzzle reward) ─────────────────────────────────────── */
.pp-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: revealFadeIn 0.35s ease;
}
.pp-container {
    text-align: center;
    animation: revealScaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    max-width: 90vw;
    position: relative;
}
.pp-title {
    font-family: 'Lilita One', sans-serif;
    font-size: 2rem;
    color: #fff;
    margin-bottom: 6px;
}
.pp-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 20px;
    min-height: 20px;
}
.pp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 200px;
    height: 200px;
    margin: 0 auto;
    overflow: visible;
}
.pp-cell {
    position: relative;
    cursor: pointer;
    perspective: 500px;
    overflow: visible;
}
.pp-cell:not(.pp-flipped):not(.pp-dimmed):hover {
    transform: scale(1.04);
    transition: transform 0.15s;
}
.pp-cell.pp-flipped { pointer-events: none; }
.pp-cell.pp-dimmed { opacity: 0.2; pointer-events: none; }
.pp-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}
.pp-flipped .pp-card {
    transform: rotateY(180deg);
}
.pp-card-front,
.pp-card-back {
    position: absolute;
    inset: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pp-card-front {
    background: rgba(30, 30, 50, 0.95);
    border-radius: 8px;
}
.pp-card-back {
    transform: rotateY(180deg);
    background-size: 200% 200%;
    background-color: rgba(40, 40, 60, 1);
    border-radius: 8px;
}
.pp-piece-q {
    font-size: 1.6rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.3);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.pp-fly-reward {
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255, 215, 0, 0.95);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.pp-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    min-height: 200px;
}
.pp-rewards-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 28px;
}
.pp-reward-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 215, 0, 0.9);
}
.pp-tag-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}
.pp-flip-prompt {
    display: flex;
    flex-direction: row;
    gap: 10px;
    animation: rewardSlideIn 0.3s ease forwards;
}
.pp-flip-btn,
.pp-skip-btn {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.pp-flip-btn:hover,
.pp-skip-btn:hover {
    background: rgba(255, 255, 255, 0.17);
}
.pp-collect {
    padding: 12px 40px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.pp-collect:hover {
    background: rgba(255, 255, 255, 0.17);
}
/* Hide mobile-only elements on desktop */
.mobile-menu-btn,
.mobile-menu-panel,
.mobile-item-btn,
.mobile-item-panel,
.mobile-item-backdrop,
.mobile-settings-panel,
.mobile-settings-backdrop {
    display: none;
}

/* ── Sign-in prompt modal ────────────────────────────────────────────────── */

.signup-prompt-content {
    max-width: 360px;
    text-align: left;
}

.signup-prompt-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
    text-align: center;
}

.signup-prompt-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 8px;
    text-align: center;
}

.signup-prompt-sub {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 18px;
    text-align: center;
    line-height: 1.4;
}

.signup-prompt-benefits {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.signup-prompt-benefits li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    font-weight: 500;
}

.signup-benefit-check {
    color: var(--color-success);
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.signup-prompt-btn {
    width: 100%;
    margin-bottom: 10px;
}

.signup-prompt-later {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 6px;
    text-align: center;
    transition: opacity 0.15s;
}

.signup-prompt-later:hover {
    opacity: 0.8;
}

/* ── Daily Leaderboard ──────────────────────────────────────────────────── */

.lb-content {
    max-width: 440px;
    width: 90%;
    padding: 28px 32px;
}

.lb-title {
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.lb-subtitle {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.55;
    margin-bottom: 16px;
}

.lb-body {
    max-height: 60vh;
    overflow-y: auto;
}

.lb-loading,
.lb-empty {
    text-align: center;
    padding: 32px 0;
    opacity: 0.6;
    font-weight: 500;
}

.lb-summary {
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 14px;
    color: var(--color-success-text, #2e7d32);
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lb-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    transition: background 0.15s;
}

.lb-header {
    font-size: 0.8rem;
    opacity: 0.5;
    padding: 6px 12px;
}

.lb-header .lb-rank {
    font-size: 0.8rem;
}

.lb-row:nth-child(odd) {
    background: rgba(0, 0, 0, 0.03);
}

.lb-row-self {
    background: rgba(var(--accent-rgb, 100, 100, 200), 0.12) !important;
    font-weight: 600;
}

.lb-rank {
    width: 36px;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1.4rem;
    text-align: center;
}

.lb-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-time {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    margin-left: 12px;
}

.lb-separator {
    text-align: center;
    padding: 4px 0;
    opacity: 0.35;
    font-weight: 700;
    letter-spacing: 4px;
}

.lb-signin-note {
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.5;
    margin-top: 16px;
    font-weight: 500;
}

/* Leaderboard action buttons (shared style for Close + Edit Nickname) */
.lb-nickname-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
}

/* Nickname edit modal */
.lb-nickname-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-modal, rgba(0, 0, 0, 0.5));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.lb-nickname-card {
    max-width: 440px;
    width: 90%;
    text-align: center;
}

.lb-nickname-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.lb-nickname-sub {
    font-size: 0.9rem;
    opacity: 0.55;
    margin-bottom: 18px;
    font-weight: 500;
}

.lb-nickname-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 18px;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    transition: border-color 0.2s;
}

.lb-nickname-input:focus {
    border-color: var(--accent, #4a90d9);
}

.lb-nickname-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}


