/**
 * combine.css - Dad's Workshop game styles
 */

/* === Custom Properties === */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-panel: rgba(22, 33, 62, 0.85);
    --accent-amber: #ff9f43;
    --accent-orange: #ffa502;
    --accent-green: #2ed573;
    --text-primary: #f5f5f5;
    --text-secondary: #aaa;
    --text-muted: #666;
    --border-accent: rgba(255, 165, 0, 0.3);
    --border-glow: rgba(255, 165, 0, 0.5);
    --tile-size: 72px;
    --panel-width: 300px;
    --combine-radius-sm: 8px;
    --combine-radius-md: 12px;
    --combine-radius-lg: 16px;
}

/* === Base / Body with Wood Grain Texture === */
*::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--bg-primary);
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(139, 90, 43, 0.03) 40px,
            rgba(139, 90, 43, 0.03) 41px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 80px,
            rgba(139, 90, 43, 0.02) 80px,
            rgba(139, 90, 43, 0.02) 81px
        );
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* === Header === */
.header {
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border-accent);
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    padding: 0;
    font-weight: normal;
    border-radius: 0;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-family: inherit;
    transition: color 0.2s ease;
}
.back-btn:hover { color: var(--accent-amber); background: none; }

.header h1 {
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 20px;
    color: var(--accent-amber);
    text-shadow:
        0 0 10px rgba(255, 165, 0, 0.3),
        2px 2px 0 rgba(0, 0, 0, 0.3);
    margin: 0;
}

.trophy-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--combine-radius-sm);
    transition: transform 0.2s ease;
}
.trophy-btn:hover { transform: scale(1.15); }

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

/* === Permanent Oracle Button === */
.oracle-button {
    background: linear-gradient(135deg, #2a1040 0%, #1a0830 100%);
    border: 2px solid #9966cc;
    border-radius: 8px;
    color: #e8d0ff;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    transition: all 0.3s ease;
    min-height: 44px;
}
.oracle-button:hover {
    border-color: #cc99ff;
    box-shadow: 0 0 15px rgba(153, 102, 204, 0.5);
}
.oracle-button.available {
    animation: oracle-btn-pulse 2s ease-in-out infinite;
}
.oracle-button.used {
    opacity: 0.5;
    cursor: default;
    animation: none;
}
.oracle-button.mastered {
    opacity: 0.4;
    border-color: #666;
    cursor: default;
    animation: none;
}
@keyframes oracle-btn-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(153, 102, 204, 0.3); }
    50% { box-shadow: 0 0 20px rgba(153, 102, 204, 0.6); }
}
.oracle-icon { font-size: 18px; line-height: 1; }
.oracle-label { font-size: 13px; }
.oracle-badge {
    background: #cc99ff;
    color: #1a0830;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.oracle-button.used .oracle-badge,
.oracle-button.mastered .oracle-badge {
    display: none;
}

/* === Game Layout === */
.game-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === Glassmorphism Panel === */
.panel {
    width: var(--panel-width);
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-accent);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* === Category Tabs === */
.category-tabs {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}
.cat-tab:hover {
    background: rgba(255, 165, 0, 0.1);
    border-color: var(--border-accent);
}
.cat-tab.active {
    background: rgba(255, 165, 0, 0.15);
    border-color: var(--border-glow);
    color: var(--accent-amber);
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.2);
}

/* === Search === */
.search-container {
    position: relative;
    padding: 0 8px 8px;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--border-glow); }

.search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    display: none;
}
.search-clear:hover { color: var(--text-secondary); }

/* === Element Grid === */
.element-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr));
    align-content: start;
    gap: 8px;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: none;
}
.element-grid::-webkit-scrollbar { display: none; }

/* === Element Tiles === */
.element-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: var(--tile-size);
    border-radius: var(--combine-radius-md);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    padding: 4px;
    overflow: hidden;
    min-width: 0;
}
.element-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.2);
    border-color: var(--border-accent);
}
.element-tile:active { cursor: grabbing; }
.element-tile.discovered { opacity: 1; }
.element-tile.undiscovered { opacity: 0.3; pointer-events: none; }

.tile-emoji {
    font-size: 28px;
    line-height: 1.2;
    display: block;
    max-width: 100%;
    text-align: center;
    overflow: hidden;
}
.tile-name {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

/* === Progress Bar === */
.progress-container { padding: 8px; flex-shrink: 0; }

.progress-bar {
    position: relative;
    height: 24px;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(25% - 1px),
            rgba(255, 255, 255, 0.15) calc(25% - 1px),
            rgba(255, 255, 255, 0.15) 25%,
            transparent 25%,
            transparent calc(50% - 1px),
            rgba(255, 255, 255, 0.15) calc(50% - 1px),
            rgba(255, 255, 255, 0.15) 50%,
            transparent 50%,
            transparent calc(75% - 1px),
            rgba(255, 255, 255, 0.15) calc(75% - 1px),
            rgba(255, 255, 255, 0.15) 75%,
            transparent 75%
        ),
        rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-amber), var(--accent-green));
    border-radius: 12px;
    transition: width 0.5s ease;
}
.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* === Workspace === */
.workspace {
    position: relative;
    flex: 1;
    min-height: 400px;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 39px,
            rgba(100, 149, 237, 0.06) 39px,
            rgba(100, 149, 237, 0.06) 40px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 39px,
            rgba(100, 149, 237, 0.06) 39px,
            rgba(100, 149, 237, 0.06) 40px
        ),
        var(--bg-secondary);
    border: 2px dashed rgba(100, 149, 237, 0.15);
    border-radius: var(--combine-radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workspace-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}
.placeholder-icon { font-size: 48px; opacity: 0.4; }
.placeholder-text { font-size: 15px; }

.clear-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 14px;
    border-radius: var(--combine-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}
.clear-btn:hover {
    background: rgba(255, 100, 100, 0.15);
    border-color: rgba(255, 100, 100, 0.3);
    color: #ff6b6b;
}

/* === Workspace Size Toggle (mobile only) === */
.ws-size-toggle {
    display: none;
    justify-content: center;
    gap: 2px;
    padding: 4px 8px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}
.ws-size-btn {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    line-height: 1;
}
.ws-size-btn.active {
    background: rgba(255, 165, 0, 0.15);
    border-color: var(--border-glow);
    color: var(--accent-amber);
}

/* === Hint Bar === */
.hint-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(22, 33, 62, 0.9);
    border-top: 1px solid var(--border-accent);
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.hint-icon {
    font-size: 18px;
    animation: glow-pulse 2s ease-in-out infinite;
}
.hint-text { flex: 1; }

/* === Keyframe Animations (9 total) === */

@keyframes element-idle-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes tile-appear {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes progress-fill {
    from { width: 0%; }
    to { width: var(--target-width, 100%); }
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 165, 0, 0.2); }
    50% { box-shadow: 0 0 15px rgba(255, 165, 0, 0.5), 0 0 30px rgba(255, 165, 0, 0.2); }
}

@keyframes combine-shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-4px); }
    30% { transform: translateX(4px); }
    45% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
    90% { transform: translateX(2px); }
}

@keyframes merge-flash {
    0% { opacity: 0; transform: scale(0.5); }
    30% { opacity: 1; transform: scale(1.5); }
    100% { opacity: 0; transform: scale(2); }
}

@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes speech-bubble-pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes category-slide {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Utility Animation Classes === */
.idle-bob { animation: element-idle-bob 3s ease-in-out infinite; }
.new-discovery { animation: tile-appear 0.4s ease-out forwards; }
.hint-glow { animation: glow-pulse 2s ease-in-out infinite; }
.screen-shake { animation: combine-shake 200ms ease-in-out; }
.bubble-pop { animation: speech-bubble-pop 0.3s ease-out forwards; }

/* === Responsive: Tablet (768-1023px) === */
@media (max-width: 1023px) {
    :root { --panel-width: 240px; }
    .element-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* === Responsive: Mobile (<768px) === */
@media (max-width: 767px) {
    :root { --panel-width: 100%; }
    .game-layout {
        flex-direction: column;
    }
    .workspace {
        min-height: 20vh;
        order: 1;
    }
    .panel {
        width: 100%;
        height: 45vh;
        border-right: none;
        border-top: 1px solid var(--border-accent);
        order: 2;
    }
    .panel::before {
        display: none;
    }
    .ws-size-toggle {
        display: flex;
    }
    .element-tile { min-height: 56px; }
    .element-grid {
        padding-right: 4px;
    }
}

/* === Responsive: Small Mobile (<400px) === */
@media (max-width: 400px) {
    .element-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .element-tile { min-height: 56px; }
    .tile-emoji { font-size: 24px; }
    .tile-name { font-size: 9px; }
    /* Category tabs: emoji only */
    .cat-tab .tab-label { display: none; }
    .cat-tab .tab-count { display: none; }
    .cat-tab { padding: 6px 8px; font-size: 16px; }
}

/* === Effects Overlay === */
.effects-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}

/* Merge clone (temporary element for slide animation) */
.merge-clone {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,200,0,0.8), rgba(255,165,0,0.4));
    box-shadow: 0 0 20px rgba(255,200,0,0.6);
    transition: transform 300ms ease-in-out;
}

/* Merge flash */
.merge-flash-el {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff, var(--flash-color, #ffa500));
    animation: merge-flash 400ms ease-out forwards;
    pointer-events: none;
}

/* Particles */
.effect-particle {
    position: absolute;
    font-size: 16px;
    pointer-events: none;
    animation: particle-burst var(--fall-duration, 800ms) ease-out forwards;
    animation-delay: var(--fall-delay, 0ms);
}
@keyframes particle-burst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--particle-x, 60px), var(--particle-y, -40px)) scale(0.5); opacity: 0; }
}

/* Speech bubble */
.speech-bubble {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    padding: 12px 20px;
    border-radius: 16px;
    border: 2px solid rgba(100, 100, 100, 0.3);
    font-size: 14px;
    font-weight: 500;
    max-width: 280px;
    text-align: center;
    animation: speech-bubble-enter 300ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    z-index: 60;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    pointer-events: auto;
    cursor: pointer;
}
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(255, 255, 255, 0.95);
}
.speech-bubble.near-miss {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    color: #fef3c7;
}
.speech-bubble.near-miss::after {
    border-top-color: rgba(245, 158, 11, 0.15);
}
.speech-bubble.float-away {
    transition: transform 600ms ease-in, opacity 600ms ease-in;
    transform: translateX(-50%) translateY(-40px);
    opacity: 0;
}
@keyframes speech-bubble-enter {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    60% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Result reveal */
.result-reveal {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0);
    animation: result-pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    z-index: 55;
    pointer-events: none;
}
.result-reveal .result-emoji { font-size: 36px; }
.result-reveal .result-name {
    font-size: 12px; color: #fbbf24; margin-top: 4px;
    white-space: nowrap; font-weight: 600;
}
@keyframes result-pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Toast stack */
.toast-stack {
    position: fixed;
    top: 80px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
    max-width: 300px;
}
.discovery-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(255, 165, 0, 0.4);
    border-radius: 10px;
    padding: 8px 14px;
    color: #fff;
    font-size: 13px;
    transform: translateX(120%);
    transition: transform 300ms ease-out, opacity 300ms ease-out;
    pointer-events: auto;
    cursor: pointer;
}
.discovery-toast.slide-in { transform: translateX(0); }
.discovery-toast.slide-out { transform: translateX(120%); opacity: 0; }
.toast-emoji { font-size: 24px; flex-shrink: 0; }

/* Connection lines SVG */
.connection-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
.valid-pair-line {
    stroke: rgba(255, 200, 0, 0.15);
    stroke-width: 1.5;
    stroke-dasharray: 4 4;
}

/* Dust particles (ambient) */
.dust-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
    animation: dust-drift var(--drift-duration, 18s) linear infinite;
    animation-delay: var(--drift-delay, 0s);
}
@keyframes dust-drift {
    0% { transform: translateY(0) translateX(0); opacity: 0.12; }
    25% { transform: translateY(-25vh) translateX(8px); opacity: 0.18; }
    50% { transform: translateY(-50vh) translateX(-5px); opacity: 0.12; }
    75% { transform: translateY(-75vh) translateX(10px); opacity: 0.08; }
    100% { transform: translateY(-100vh) translateX(0); opacity: 0; }
}

/* Idle wobble */
.idle-wobble {
    animation: idle-nudge 600ms ease-in-out;
}
@keyframes idle-nudge {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}

/* Milestone banner */
.milestone-banner {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    font-size: 28px;
    font-weight: 900;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5), 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
    z-index: 70;
    opacity: 0;
    animation: banner-swoop 5s ease-out forwards;
    pointer-events: auto;
    cursor: pointer;
    white-space: nowrap;
}
@keyframes banner-swoop {
    0% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(0.7); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.1); }
    15% { transform: translateX(-50%) translateY(0) scale(1); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.9); }
}

/* Confetti particle (game-specific — differs from shared confettiFall) */
.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    pointer-events: none;
    animation: confetti-drop var(--confetti-duration, 2s) ease-in forwards;
    animation-delay: var(--confetti-delay, 0s);
}
@keyframes confetti-drop {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(var(--confetti-distance, 400px)) rotate(var(--confetti-spin, 720deg)); opacity: 0; }
}

/* Screen flash (milestone 100) */
.screen-flash {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 80;
    pointer-events: none;
    animation: flash-fade 300ms ease-out forwards;
}
@keyframes flash-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Completion glow */
.completion-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255, 215, 0, 0.15), transparent 70%);
    z-index: 4;
    pointer-events: none;
    animation: glow-fade 5s ease-in-out;
    transition: opacity 2s ease;
}
@keyframes glow-fade {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Panel tile wave (completion) */
.tile-wave {
    animation: tile-wave-bounce 600ms ease-out;
}
@keyframes tile-wave-bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* === Oracle Crystal === */
.oracle-crystal {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, #9b59b6, #6c3483);
    border-radius: 50%;
    opacity: 0.15;
    cursor: pointer;
    z-index: 100;
    animation: oracle-pulse 4s ease-in-out infinite;
}
@keyframes oracle-pulse {
    0%, 100% { box-shadow: 0 0 2px #9b59b6; }
    50% { box-shadow: 0 0 6px #9b59b6; }
}

/* === Oracle Overlay === */
.oracle-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 14, 46, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: oracle-fade-in 0.3s ease;
}
.oracle-panel {
    background: linear-gradient(135deg, #1a0e2e, #2d1b4e);
    border: 2px solid #d4af37;
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    max-width: 360px;
    color: #e8d5f5;
}
.oracle-crystal-ball {
    font-size: 48px;
    animation: oracle-spin 2s ease-in-out;
}
.oracle-title {
    color: #d4af37;
    margin: 16px 0 8px;
}
.oracle-recipe {
    font-size: 20px;
    margin: 16px 0;
}
.oracle-element {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}
.oracle-plus {
    margin: 0 8px;
    color: #d4af37;
}
.oracle-message {
    color: #b8a9c9;
    font-style: italic;
    margin: 16px 0;
}
.oracle-close {
    background: #d4af37;
    color: #1a0e2e;
    border: none;
    padding: 8px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 12px;
    font-family: inherit;
}
.oracle-close:hover {
    background: #e6c04a;
}
@keyframes oracle-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes oracle-spin {
    0% { transform: rotate(0deg) scale(0.5); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    .idle-bob,
    .hint-glow,
    .new-discovery,
    .screen-shake,
    .bubble-pop { animation: none !important; }

    .element-tile,
    .progress-fill,
    .cat-tab { transition: opacity 0.2s ease !important; }

    .hint-icon { animation: none !important; }

    .spring-back { transition: none !important; }

    .merge-clone { transition: none !important; }
    .merge-flash-el { animation: none !important; }
    .effect-particle { animation: none !important; display: none !important; }
    .speech-bubble { animation: none !important; transform: translateX(-50%) !important; opacity: 1 !important; }
    .result-reveal { animation: none !important; transform: scale(1) !important; }
    .discovery-toast { transition: none !important; transform: translateX(0) !important; }
    .dust-particle { display: none !important; }
    .idle-wobble { animation: none !important; }
    .milestone-banner { animation: none !important; opacity: 1 !important; transform: translateX(-50%) !important; }
    .confetti-piece { display: none !important; }
    .screen-flash { display: none !important; }
    .completion-glow { display: none !important; }
    .tile-wave { animation: none !important; }
    .element-tile.selected { transform: none !important; }
    .ticker-message { animation: none !important; transform: translateX(0) !important; }
    .fail-flash { animation: none !important; }
    .oracle-crystal { animation: none !important; }
    .oracle-overlay { animation: none !important; }
    .oracle-crystal-ball { animation: none !important; }
    .oracle-button.available { animation: none !important; }
}

/* === Category Headers === */
.category-header {
    grid-column: 1 / -1;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-amber);
    padding: 8px 4px 4px;
    border-bottom: 1px solid rgba(255, 165, 0, 0.2);
    margin-top: 8px;
}
.category-header:first-child {
    margin-top: 0;
}

/* === Letter Headings (Alphabetical All view) === */
.letter-heading {
    grid-column: 1 / -1;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-amber);
    padding: 8px 4px 4px;
    border-bottom: 1px solid rgba(255, 165, 0, 0.2);
    margin-top: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.letter-heading:first-child {
    margin-top: 0;
}

/* === Tab Counts === */
.tab-count {
    font-size: 11px;
    opacity: 0.7;
}

/* === Selected Tile (Tap-to-Select) === */
.element-tile.selected {
    border-color: var(--accent-amber);
    box-shadow: 0 0 12px rgba(255, 165, 0, 0.4), 0 0 24px rgba(255, 165, 0, 0.15);
    transform: scale(1.05);
    background: rgba(255, 165, 0, 0.12);
}

/* === Selection Bar (mobile only) === */
.selection-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 165, 0, 0.1);
    border-top: 1px solid rgba(255, 165, 0, 0.3);
    border-bottom: 1px solid rgba(255, 165, 0, 0.3);
    font-size: 13px;
    color: var(--accent-amber);
    flex-shrink: 0;
    order: 0;
}
.selection-bar.active {
    display: flex;
}
.selection-bar-emoji { font-size: 20px; }
.selection-bar-text { flex: 1; }
.selection-bar-cancel {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    font-family: inherit;
}
@media (min-width: 768px) {
    .selection-bar { display: none !important; }
}

/* === Drag Handle (mobile only) === */
.tile-drag-handle {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: -2px;
    pointer-events: auto;
}
@media (pointer: coarse) {
    .tile-drag-handle {
        display: flex;
        min-height: 44px;
    }
    .element-tile {
        position: relative;
        padding-right: 20px;
    }
}
@media (pointer: fine) {
    .tile-drag-handle { display: none; }
}

/* === Status Ticker === */
.status-ticker {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    overflow: hidden;
    z-index: 15;
    pointer-events: none;
}
.ticker-message {
    position: absolute;
    white-space: nowrap;
    font-size: 13px;
    line-height: 28px;
    padding: 0 12px;
    animation: ticker-scroll 9s linear forwards;
}
.ticker-message.near-miss {
    color: var(--accent-amber);
}
@keyframes ticker-scroll {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

/* === Fail Flash === */
.fail-flash {
    animation: fail-flash-pulse 200ms ease-out;
}
@keyframes fail-flash-pulse {
    0% { border-color: rgba(255, 100, 100, 0.8); box-shadow: 0 0 15px rgba(255, 100, 100, 0.5); }
    100% { border-color: rgba(255, 165, 0, 0.25); box-shadow: none; }
}

/* === Element Tooltip === */
.element-tooltip {
    position: fixed;
    z-index: 1000;
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 165, 0, 0.4);
    border-radius: var(--combine-radius-md);
    padding: 12px 16px;
    max-width: 220px;
    pointer-events: none;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.tooltip-emoji { font-size: 36px; text-align: center; }
.tooltip-name { font-size: 16px; font-weight: 700; color: #fff; text-align: center; margin: 4px 0; }
.tooltip-category { font-size: 12px; color: var(--accent-amber); text-align: center; margin-bottom: 6px; }
.tooltip-desc { font-size: 12px; color: #ccc; line-height: 1.4; }

/* === Workspace Elements === */
.workspace-element {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 80px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 165, 0, 0.25);
    cursor: grab;
    z-index: 10;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.workspace-element:hover {
    border-color: var(--border-glow);
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.2);
}
.ws-emoji {
    font-size: 32px;
    line-height: 1;
    display: block;
    max-width: 100%;
    text-align: center;
    overflow: hidden;
}
.ws-name {
    font-size: 10px;
    color: #ccc;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

/* === Toast Notification === */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(30, 30, 50, 0.95);
    border: 1px solid rgba(255, 165, 0, 0.4);
    border-radius: var(--combine-radius-sm);
    padding: 10px 20px;
    color: #fff;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.toast-notification.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === Drag Ghost === */
.drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 80px;
    border-radius: 14px;
    background: rgba(255, 165, 0, 0.15);
    border: 2px solid rgba(255, 165, 0, 0.6);
    box-shadow: 0 8px 32px rgba(255, 165, 0, 0.3);
    opacity: 0.9;
}
.drag-ghost .tile-emoji { font-size: 32px; line-height: 1; display: block; max-width: 100%; overflow: hidden; text-align: center; }
.drag-ghost .tile-name { font-size: 10px; color: #fff; margin-top: 2px; }

/* Combine-ready glow on overlap */
.combine-ready {
    box-shadow: 0 0 20px rgba(255, 200, 0, 0.6), 0 0 40px rgba(255, 200, 0, 0.3) !important;
    border-color: rgba(255, 200, 0, 0.8) !important;
    transition: box-shadow 0.2s, border-color 0.2s;
}

/* Spring-back elastic animation */
.spring-back {
    transition: left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* Workspace highlighted during drag */
.workspace.drop-active {
    border-color: rgba(255, 165, 0, 0.5) !important;
    background-color: rgba(255, 165, 0, 0.03);
}

/* Dimmed panel tile (source during drag) */
.panel-dimmed { opacity: 0.4 !important; }

/* Body state during drag */
body.drag-active {
    cursor: grabbing !important;
    user-select: none;
    -webkit-user-select: none;
}
body.drag-active * { cursor: grabbing !important; }

/* Focus rings */
.cat-tab:focus-visible,
.element-tile:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent-amber);
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 9999;
    background: var(--accent-amber);
    color: #000;
    padding: 8px 16px;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    font-family: inherit;
}
.skip-link:focus {
    left: 0;
}
