:root {
    /* Lo-Fi Dusk Theme (New Default) */
    --desk-bg: linear-gradient(160deg, #2c3e50 0%, #34495e 35%, #5d4157 70%, #a8caba 100%);
    
    /* Palette & UI Colors (Less Pink, More Muted/Premium) */
    --primary-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #81ecec 100%);
    --secondary-gradient: linear-gradient(135deg, #74b9ff 0%, #81ecec 100%);

    --bg-body: #1e272e;
    --bg-card: rgba(255, 255, 255, 0.95);
    --text-primary: #2f3542;
    --text-secondary: #57606f;
    --accent-purple: #6c5ce7;
    --accent-blue: #00d2d3;
    --accent-orange: #ff9f43;
    --accent-pink: #ef5777; /* Kept as a subtle accent */

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.2);

    --border-radius: 20px;
    --border-radius-sm: 12px;
    --transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --palette-width: 320px;
}

/* ========================
   THEMES
======================== */
body[data-theme="lofi-dusk"] {
    --desk-bg: linear-gradient(160deg, #2c3e50 0%, #34495e 35%, #5d4157 70%, #a8caba 100%);
    --bg-body: #1e272e;
}

body[data-theme="night"] {
    --desk-bg: linear-gradient(160deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --bg-body: #050505;
    --bg-card: rgba(25, 25, 40, 0.95);
    --text-primary: #d1d8e0;
    --text-secondary: #778ca3;
    --accent-purple: #9c88ff;
}

body[data-theme="city-pop"] {
    --desk-bg: linear-gradient(160deg, #45aaf2 0%, #2d98da 35%, #eb3b5a 75%, #fa8231 100%);
    --bg-body: #2d98da;
    --primary-gradient: linear-gradient(135deg, #00d2d3 0%, #54a0ff 100%);
    --bg-card: rgba(255, 255, 255, 0.95);
}

body[data-theme="forest"] {
    --desk-bg: linear-gradient(160deg, #1e3799 0%, #3c6382 35%, #079992 70%);
    --bg-body: #0c2461;
    --primary-gradient: linear-gradient(135deg, #009432 0%, #006266 100%);
}

/* ========================
   RESET & BASE
======================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', 'Outfit', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.6s ease, color 0.4s ease;
    position: relative;
    overflow-x: hidden;
}

/* Global Lo-Fi Noise Overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.03;
    background: url('https://grainy-gradients.vercel.app/noise.svg');
    filter: contrast(150%) brightness(100%);
}

/* ========================
   TOAST
======================== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 183, 213, 0.35);
    border-radius: var(--border-radius-sm);
    padding: 0.85rem 1.3rem;
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    max-width: 300px;
}

.toast.success { border-left: 3px solid #7bed9f; }
.toast.error   { border-left: 3px solid #ff6b9d; }
.toast.info    { border-left: 3px solid #a8d8ea; }

.toast.out {
    animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(40px) scale(0.95); }
}

/* ========================
   CONTAINER
======================== */
.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================
   HEADER
======================== */
.header {
    text-align: center;
    padding: 1.5rem 0 1.2rem;
    animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.2rem;
    color: var(--accent-purple);
    text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-logo {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.theme-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 1.2rem;
}

.theme-btn {
    background: var(--bg-card);
    border: 1.5px solid rgba(0,0,0,0.05);
    padding: 0.45rem 0.9rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.theme-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-purple);
}

.theme-btn.active {
    background: var(--accent-purple);
    color: white;
    border-color: var(--accent-purple);
}

/* ========================
   PLACED ITEM IMPROVEMENTS
======================== */
.placed-item.is-note {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%236c5ce7' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E") 0 24, pointer;
}

.placed-item.is-note:hover::before {
    content: "클릭해서 메모 쓰기";
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.placed-item:hover {
    filter: brightness(1.05) drop-shadow(0 0 12px rgba(108, 92, 231, 0.4));
    transform: scale(1.05);
}

/* ========================
   MOBILE TABS (hidden on desktop)
======================== */
.mobile-tabs {
    display: none;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 0.4rem;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 213, 0.2);
    gap: 0.3rem;
}

.tab-btn {
    flex: 1;
    padding: 0.7rem;
    border: none;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* ========================
   MAIN LAYOUT
======================== */
.main-content {
    display: grid;
    grid-template-columns: var(--palette-width) 1fr;
    gap: 1.5rem;
    flex: 1;
    animation: fadeIn 0.5s ease-out 0.1s both;
}

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

/* ========================
   PALETTE
======================== */
.palette {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 1.2rem;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid rgba(255, 183, 213, 0.25);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 600px; /* 고정형에 가까운 콤팩트한 높이로 조정 */
    position: sticky;
    top: 2rem;
    transition: background 0.4s, border-color 0.4s;
}

.palette-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.palette-title i {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Category tabs inside palette */
.category-tabs {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.cat-tab {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border: 1.5px solid rgba(255, 183, 213, 0.3);
    border-radius: 50px;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.cat-tab i { font-size: 0.75rem; }
.cat-tab span { display: inline; }

.cat-tab:hover {
    border-color: var(--accent-pink);
    color: var(--text-primary);
    background: rgba(255, 183, 213, 0.1);
}

.cat-tab.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(255, 183, 213, 0.4);
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: max-content;
    gap: 0.6rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    align-content: start;
    padding-right: 2px; /* for scrollbar */
}

.items-grid::-webkit-scrollbar { width: 6px; }
.items-grid::-webkit-scrollbar-track { background: transparent; }
.items-grid::-webkit-scrollbar-thumb {
    background: var(--accent-pink);
    border-radius: 10px;
    opacity: 0.5;
}

.item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-sm);
    padding: 0.6rem 0.3rem;
    text-align: center;
    cursor: grab;
    transition: var(--transition);
    border: 1.5px solid rgba(255, 183, 213, 0.2);
    user-select: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.item:active { cursor: grabbing; }

.item-image-wrap {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}

.item-label {
    font-size: 0.65rem;
    color: #2c1e3d; /* Clear dark purple for better contrast */
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
    line-height: 1.2;
}

.item:hover {
    transform: translateY(-4px) scale(1.04);
    border-color: var(--accent-pink);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 6px 20px rgba(255, 183, 213, 0.4);
}

.item:hover .item-image-wrap {
    transform: scale(1.15) rotate(5deg);
}

.item.dragging { opacity: 0.4; }

/* Palette hint */
.palette-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 183, 213, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* ========================
   DESK AREA
======================== */
.desk-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.desk-container {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid rgba(255, 183, 213, 0.25);
    flex: 1;
}

.desk-surface {
    background: var(--desk-bg);
    border-radius: var(--border-radius-sm);
    min-height: 520px;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 20px rgba(0, 0, 0, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.5);
    transition: background 0.6s ease;
}

/* Subtle texture dots on desk */
.desk-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 15% 25%, rgba(255,255,255,0.35) 0%, transparent 3%),
        radial-gradient(circle at 65% 70%, rgba(255,255,255,0.25) 0%, transparent 2.5%),
        radial-gradient(circle at 85% 15%, rgba(255,255,255,0.3) 0%, transparent 3%),
        radial-gradient(circle at 35% 60%, rgba(255,255,255,0.2) 0%, transparent 2%),
        radial-gradient(circle at 50% 90%, rgba(255,255,255,0.3) 0%, transparent 2.5%);
    animation: twinkle 4s ease-in-out infinite;
    pointer-events: none;
    border-radius: var(--border-radius-sm);
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1; }
}

/* Desk hint */
.desk-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    transition: opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.desk-hint.hidden { opacity: 0; }

.hint-icon {
    font-size: 2.5rem;
    animation: float 3s ease-in-out infinite;
}

.desk-hint p {
    font-size: 1rem;
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.hint-small {
    font-size: 0.8rem !important;
    opacity: 0.7;
}

/* ========================
   PLACED ITEMS
======================== */
.placed-item {
    position: absolute;
    cursor: move;
    user-select: none;
    animation: placeIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    touch-action: none;
    transition: filter 0.2s, box-shadow 0.2s;
}

.placed-item img {
    width: var(--item-size, 72px);
    height: var(--item-size, 72px);
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
    pointer-events: none;
    transition: filter 0.3s, transform 0.3s;
    user-select: none;
}

.placed-item:hover img {
    filter: drop-shadow(0 8px 20px rgba(0,0,0,0.2));
    transform: scale(1.05) rotate(3deg);
}

.placed-item.selected {
    z-index: 100;
}

.placed-item.selected img {
    filter: drop-shadow(0 0 12px rgba(255,183,213,0.9)) drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

@keyframes placeIn {
    0%   { opacity: 0; transform: scale(0.3) rotate(-20deg); }
    60%  { transform: scale(1.15) rotate(5deg); }
    80%  { transform: scale(0.95) rotate(-2deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.placed-item.removing {
    animation: placeOut 0.3s ease-in forwards;
}

@keyframes placeOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0) rotate(20deg); }
}

/* Hover glow pulse */
.placed-item::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 12px;
    background: transparent;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    pointer-events: none;
}

.placed-item.selected::after {
    border-color: rgba(255, 183, 213, 0.8);
}

/* ========================
   ITEM TOOLKIT (floating)
======================== */
.item-toolkit {
    position: fixed;
    display: none;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1.5px solid var(--accent-purple);
    border-radius: 50px;
    padding: 0.4rem 0.6rem;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    animation: toolkitIn 0.2s ease-out;
}

.item-toolkit.visible { display: flex; }

@keyframes toolkitIn {
    from { opacity: 0; transform: scale(0.8) translateY(4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.toolkit-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 183, 213, 0.15);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: var(--transition);
}

.toolkit-btn:hover {
    background: var(--accent-pink);
    color: white;
    transform: scale(1.1);
}

.toolkit-btn.danger:hover {
    background: #ff6b9d;
}

/* ========================
   CONTROLS
======================== */
.controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    flex: 1;
    justify-content: center;
    min-width: 100px;
}

.btn i { font-size: 0.9rem; }

.btn-save {
    background: linear-gradient(135deg, #C9A0DC, #A8D8EA);
    color: white;
}

.btn-random {
    background: linear-gradient(135deg, #FFDAB9, #FFB7D5);
    color: white;
}

.btn-clear {
    background: rgba(255, 107, 157, 0.12);
    color: #ff6b9d;
    border: 1.5px solid rgba(255, 107, 157, 0.25);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.btn-clear:hover {
    background: #ff6b9d;
    color: white;
    border-color: transparent;
}

.btn:active { transform: translateY(0); }

/* ========================
   STATS
======================== */
.stats {
    display: flex;
    gap: 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 213, 0.2);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.stat-label i {
    font-size: 0.75rem;
    color: var(--accent-purple);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-left: auto;
}

.stat-time {
    font-size: 0.82rem;
    font-weight: 500;
    -webkit-text-fill-color: var(--text-secondary);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

/* ========================
   DRAG OVER HIGHLIGHT
======================== */
.desk-surface.drag-over {
    box-shadow: inset 0 0 0 3px rgba(255, 183, 213, 0.6), inset 0 2px 20px rgba(0,0,0,0.06);
}

/* ========================
   MUSIC WIDGET (Lofi BGM)
======================== */
.music-widget {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 2500;
}

.music-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid rgba(255, 183, 213, 0.5);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    z-index: 2;
}

.music-fab:hover,
.music-fab.active {
    transform: scale(1.05);
    border-color: var(--accent-purple);
    background: rgba(201, 160, 220, 0.1);
}

.music-fab.playing {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(201, 160, 220, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(201, 160, 220, 0); }
    100% { box-shadow: 0 0 0 0 rgba(201, 160, 220, 0); }
}

.music-fab-icon {
    font-size: 1.5rem;
    transition: transform 0.3s;
}

.music-fab.playing .music-fab-icon {
    animation: wiggle 2s infinite;
}

.music-panel {
    position: absolute;
    bottom: 75px;
    left: 0;
    width: 320px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid rgba(255, 183, 213, 0.3);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: var(--transition);
    transform-origin: bottom left;
}

.music-panel.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}


.music-panel-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.vinyl {
    width: 50px;
    height: 50px;
    background: #111;
    border-radius: 50%;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 4px rgba(255,255,255,0.2);
}

.vinyl.spinning {
    animation: spin 3s linear infinite;
}

.vinyl.loading {
    animation: pulseFade 1.5s ease-in-out infinite;
}

@keyframes pulseFade {
    0%, 100% { opacity: 0.4; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1); }
}

.vinyl-inner {
    width: 20px;
    height: 20px;
    background: var(--accent-pink);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vinyl-dot {
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.music-meta {
    flex: 1;
}

.music-track {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.music-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.music-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
}

.music-controls-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0,0,0,0.03);
    padding: 0.6rem;
    border-radius: 50px;
}

.music-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.music-next-btn {
    background: none;
    border: none;
    color: var(--accent-purple);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.3rem;
    transition: transform 0.2s;
}

.music-next-btn:hover { transform: scale(1.2); }

.music-vol-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.music-vol-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(201, 160, 220, 0.3);
    border-radius: 2px;
    outline: none;
}

.music-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
}

.ambient-mixer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--accent-purple);
    opacity: 0.6;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.ambient-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

.ambient-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.ambient-row span {
    font-size: 1.1rem;
    cursor: default;
    width: 24px;
    text-align: center;
}

.ambient-slider {
    flex: 1;
}

/* ========================
   TIMER WIDGET (POMODORO)
======================== */
.timer-widget {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    z-index: 2500;
}

.mobile-drawer-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0.5rem;
}

.timer-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--accent-purple);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.timer-fab:hover { transform: scale(1.1); }

.timer-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    width: 250px;
    border-radius: 20px;
    padding: 1.2rem;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid var(--accent-purple);
    position: absolute;
    bottom: 60px;
    right: 0;
    transform-origin: bottom right;
    transform: scale(0.9) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.timer-panel.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.timer-display-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    background: rgba(201, 160, 220, 0.1);
    padding: 1rem;
    border-radius: 15px;
}

.timer-time {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--accent-purple);
    letter-spacing: -1px;
}

.timer-controls { display: flex; gap: 0.5rem; }

.timer-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: white;
    color: var(--accent-purple);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.timer-btn:hover { background: var(--accent-purple); color: white; transform: scale(1.1); }

.timer-setting {
    background: rgba(0,0,0,0.02);
    padding: 0.8rem;
    border-radius: 12px;
}

.timer-set-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    text-transform: uppercase;
}

.timer-set-btns { display: flex; gap: 0.5rem; }

.time-set-btn {
    flex: 1;
    padding: 0.4rem;
    border-radius: 8px;
    border: 1px solid rgba(201, 160, 220, 0.3);
    background: white;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.time-set-btn.active {
    background: var(--accent-purple);
    color: white;
    border-color: var(--accent-purple);
}

.timer-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.timer-title { font-weight: 700; color: var(--text-primary); font-size: 1rem; }
.timer-sub { font-size: 0.75rem; color: var(--text-secondary); }

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

.timer-display {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent-purple);
    text-align: center;
    font-variant-numeric: tabular-nums;
    margin: 1rem 0;
    text-shadow: 0 2px 10px rgba(255, 99, 72, 0.2);
}

.timer-controls-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.timer-play-btn, .timer-reset-btn {
    background: var(--accent-purple);
    color: white;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.timer-reset-btn {
    background: #f1f2f6;
    color: #2f3542;
    box-shadow: none;
}

.timer-play-btn:hover, .timer-reset-btn:hover { transform: scale(1.1); }

.timer-panel.running .timer-display {
    animation: breathe 2s infinite alternate;
}

@keyframes breathe {
    from { opacity: 0.8; text-shadow: 0 2px 10px rgba(255, 99, 72, 0.1); }
    to { opacity: 1; text-shadow: 0 2px 20px rgba(255, 99, 72, 0.5); }
}

.focus-coin-display {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    background: rgba(255, 99, 72, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    display: inline-block;
    color: var(--text-primary);
}
.focus-coin-display strong {
    color: #ff6348;
    font-size: 1rem;
}

/* ========================
   NOTE EDITOR
======================== */
.note-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.note-editor-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.note-editor {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    width: 320px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.note-editor-overlay.active .note-editor {
    transform: translateY(0);
}

.note-editor h3 { margin: 0; font-family: 'Outfit', sans-serif; color: var(--text-primary); }

#noteInput {
    width: 100%;
    height: 100px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    padding: 1rem;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.9rem;
    resize: none;
    outline: none;
}

#noteInput:focus { border-color: var(--accent-pink); }

.note-editor-btns { display: flex; gap: 0.5rem; }
.note-save-btn, .note-cancel-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.note-save-btn { background: var(--primary-gradient); color: white; }
.note-cancel-btn { background: #f1f2f6; color: var(--text-secondary); }

/* Text on placed note */
.placed-item-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    font-size: 0.7rem;
    color: #4a3a5e;
    font-weight: 600;
    pointer-events: none;
    word-break: break-all;
    line-height: 1.3;
    z-index: 5;
}

/* ========================
   MUSIC PLAYER ITEM
======================== */
.placed-item.playing .cassette-wheel-mark {
    animation: cassetteSpin 2s linear infinite;
}

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

.placed-item.playing::before {
    content: '♪';
    position: absolute;
    top: -10px;
    left: 20%;
    color: var(--accent-purple);
    font-size: 1.2rem;
    animation: noteFloat 3s ease-in infinite;
    opacity: 0;
    pointer-events: none;
}

.placed-item.playing::after {
    content: '♫';
    position: absolute;
    top: -20px;
    right: 20%;
    color: var(--accent-pink);
    font-size: 1rem;
    animation: noteFloat 3s ease-in 1.5s infinite;
    opacity: 0;
    pointer-events: none;
}

@keyframes noteFloat {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateY(-40px) translateX(10px) rotate(20deg); opacity: 0; }
}

/* ========================
   VIRTUAL WINDOW & WEATHER
======================== */
.placed-item.rainy .raindrops {
    display: block !important;
}

.placed-item.rainy .drop {
    animation: rainFall 0.8s linear infinite;
}

.drop.d2 { animation-delay: 0.2s; }
.drop.d3 { animation-delay: 0.4s; }
.drop.d4 { animation-delay: 0.1s; }

@keyframes rainFall {
    0% { transform: translateY(-5px); opacity: 0; }
    50% { opacity: 0.6; }
    100% { transform: translateY(15px); opacity: 0; }
}

/* Weather Overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, transparent 40%, rgba(0, 30, 60, 0.2) 100%);
    pointer-events: none;
    z-index: 500;
    opacity: 0;
    transition: opacity 1s ease;
}

body.is-rainy::after {
    opacity: 1;
}

/* ========================
   DAILY CHALLENGE WIDGET
======================== */
.challenge-widget {
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(255, 183, 213, 0.3);
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.challenge-inner {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    z-index: 2;
}

.challenge-emoji {
    font-size: 2rem;
}

.challenge-body {
    flex: 1;
}

.challenge-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-purple);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.challenge-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.challenge-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.challenge-right {
    text-align: right;
    min-width: 60px;
}

.challenge-count {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.challenge-track {
    height: 6px;
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
    overflow: hidden;
}

.challenge-fill {
    height: 100%;
    background: var(--primary-gradient);
    transition: width 0.4s ease;
}

.challenge-done {
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 3;
}

.challenge-widget.completed .challenge-done {
    opacity: 1;
    pointer-events: auto;
}

/* ========================
   RESULT MODAL
======================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

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

.result-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .result-wrap {
    transform: translateY(0);
}

.result-close-btn {
    position: absolute;
    top: -40px;
    right: -20px;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.result-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 183, 213, 0.4);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    width: 380px;
    min-height: 520px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    text-align: left;
    position: relative;
    font-family: 'Noto Sans KR', sans-serif;
    color: #4a3a5e; /* Fix: always dark text on white card */
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 85vh;
}

.result-card::-webkit-scrollbar { width: 6px; }
.result-card::-webkit-scrollbar-track { background: transparent; }
.result-card::-webkit-scrollbar-thumb {
    background: var(--accent-pink);
    border-radius: 10px;
    opacity: 0.5;
}

.result-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; right: -50%; bottom: -50%;
    background: radial-gradient(circle at center, rgba(201, 160, 220, 0.15) 0%, transparent 60%);
    animation: rotateBg 15s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes rotateBg { 100% { transform: rotate(360deg); } }

.rc-stamp {
    position: absolute;
    top: 25px; right: 25px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    border: 2px solid var(--accent-pink);
    color: var(--accent-pink);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transform: rotate(10deg);
    opacity: 0.8;
    z-index: 2;
}

.rc-header {
    border-bottom: 2px dashed rgba(201, 160, 220, 0.4);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 1;
}

.rc-doc-tit {
    font-size: 0.85rem;
    font-weight: 700;
    color: #6d4b8e; /* Darker purple for title */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.rc-title {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 0.8rem;
    color: #4a3a5e;
    position: relative;
    z-index: 1;
}

.rc-subtitle {
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--primary-gradient);
    color: white;
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.rc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.rc-stat {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 0.8rem;
    border: 1px solid rgba(201, 160, 220, 0.2);
}

.rc-stat span {
    display: block;
    font-family: 'Noto Sans KR', sans-serif;
    color: #6a5e72; /* Darker gray-purple for labels */
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.rc-stat strong {
    font-size: 0.95rem;
    color: #4a3a5e;
    display: block;
    line-height: 1.2;
}

.rc-desc {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.6);
    padding: 1rem;
    border-radius: 12px;
    color: #5a4e63; /* Hardcoded dark color for white background */
    position: relative;
    z-index: 1;
}

.rc-desc strong {
    color: var(--accent-purple);
}

.rc-expert {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 1.2rem;
    background: rgba(201, 160, 220, 0.1);
    border-left: 4px solid var(--accent-purple);
    border-radius: 0 12px 12px 0;
    position: relative;
    z-index: 1;
}

.rc-footer {
    margin-top: auto;
    font-size: 0.75rem;
    border-top: 1px solid rgba(201, 160, 220, 0.3);
    padding-top: 1rem;
    display: flex;
    justify-content: space-between;
    color: #8a7b96; /* Darker gray-purple for footer */
    position: relative;
    z-index: 1;
}

/* Loading Overlay */
.analysis-loading {
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-family: 'Noto Sans KR', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
    border-radius: 24px;
}

.analysis-loading.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-text {
    font-size: 0.95rem;
    line-height: 2;
    white-space: pre-wrap;
    font-weight: 600;
    color: var(--text-secondary);
}

.loading-cursor {
    display: inline-block;
    width: 6px;
    height: 1.2em;
    background: var(--accent-purple);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 4px;
}

@keyframes blink { 50% { opacity: 0; } }

.result-save-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(201, 160, 220, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: -10px; /* pull up so it overlaps card slightly */
    z-index: 5;
}

.result-save-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(201, 160, 220, 0.5);
}

/* ========================
   RESPONSIVE — Tablet (≤900px)
======================== */
@media (max-width: 900px) {
    .container { padding: 1rem; }

    .main-content {
        grid-template-columns: 1fr;
    }

    .palette {
        position: static;
        max-height: none;
    }

    .items-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        max-height: 200px;
    }

    .desk-surface {
        min-height: 380px;
    }
}

/* ========================
   RESPONSIVE — Mobile (≤600px)
======================== */
@media (max-width: 600px) {
    .container { padding: 0; }
    .header { padding: 1rem; }

    .mobile-tabs {
        display: flex;
        padding: 0 1rem;
        margin-bottom: 1rem;
    }

    .palette {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 2000;
        background: var(--bg-card);
        border-radius: 30px 30px 0 0;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
        max-height: 70vh;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
        padding: 1.5rem;
        flex-direction: column;
    }

    .palette.active { transform: translateY(0); }

    .mobile-drawer-close { display: block; margin-left: auto; }

    .desk-area { display: flex; flex-direction: column; flex: 1; }
    
    .desk-surface { 
        min-height: 450px; 
        margin: 0 1rem;
        border-radius: 20px;
        box-shadow: var(--shadow-sm);
    }

    .music-widget { left: 1rem; bottom: 1rem; }
    .timer-widget { left: auto; right: 1rem; bottom: 1rem; }
}

/* ========================
   PHASE 4-B: GACHA & PETS
======================== */

/* Gacha Widget in Palette */
.gacha-widget {
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1.5px solid rgba(255, 183, 213, 0.3);
    box-shadow: var(--shadow-sm);
}

.gacha-machine {
    width: 60px;
    height: 85px;
    background: #FF8FB1;
    border-radius: 30px 30px 10px 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 4px;
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.1);
}

.gacha-glass {
    flex: 1;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 25px 25px 5px 5px;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
}

.capsule {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
}
.capsule.c1 { background: #FFB7D5; top: 10px; left: 5px; }
.capsule.c2 { background: #A8D8EA; top: 25px; right: 8px; }
.capsule.c3 { background: #C9A0DC; bottom: 8px; left: 15px; }

.gacha-body {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gacha-btn {
    width: 24px;
    height: 24px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.gacha-btn:hover { transform: rotate(90deg); }
.gacha-btn span { font-size: 0.4rem; font-weight: 800; color: #FF8FB1; }

.gacha-info { flex: 1; }
.gacha-info strong { display: block; font-size: 0.85rem; color: var(--text-primary); margin-bottom: 2px; }
.gacha-info p { font-size: 0.7rem; color: var(--text-secondary); margin: 0; }

/* Gacha Overlay */
.gacha-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 30, 61, 0.95);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
    backdrop-filter: blur(10px);
}

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

.gacha-result-capsule {
    width: 150px;
    height: 150px;
    position: relative;
    margin-bottom: 2rem;
}

.capsule-top, .capsule-bottom {
    position: absolute;
    width: 100%;
    height: 50%;
    background: #FFB7D5;
    border: 4px solid white;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.capsule-top {
    top: 0;
    border-radius: 75px 75px 0 0;
    border-bottom: none;
}

.capsule-bottom {
    bottom: 0;
    border-radius: 0 0 75px 75px;
    border-top: none;
    background: #fff;
}

.gacha-overlay.open .capsule-top { transform: translateY(-60px) rotate(-20deg); }
.gacha-overlay.open .capsule-bottom { transform: translateY(60px) rotate(20deg); }

.gacha-unlocked-item {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 80px;
    height: 80px;
    z-index: 5;
    transition: transform 0.5s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gacha-overlay.open .gacha-unlocked-item { transform: translate(-50%, -50%) scale(1.5); }
.gacha-unlocked-item img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 15px rgba(255,255,255,0.8)); }

.gacha-congrats {
    text-align: center;
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s 0.6s;
}

.gacha-overlay.open .gacha-congrats { opacity: 1; transform: translateY(0); }

.unlocked-badge {
    display: inline-block;
    background: var(--primary-gradient);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    box-shadow: 0 0 20px rgba(201, 160, 220, 0.6);
}

.gacha-confirm-btn {
    margin-top: 1.5rem;
    background: white;
    color: #4a3a5e;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Locked / Pet Items */
.item.locked {
    filter: grayscale(1) brightness(0.8);
    opacity: 0.6;
    cursor: not-allowed;
}

.item.locked::after {
    content: '🔒';
    position: absolute;
    top: 5px; right: 5px;
    font-size: 0.7rem;
}

/* Pet Behavior on Desk */
.placed-item.is-pet {
    transition: left 2.5s ease-in-out, top 2.5s ease-in-out, transform 0.3s;
    cursor: pointer;
}

.placed-item.is-pet:hover {
    transform: scale(1.1);
}

.pet-heart {
    position: absolute;
    font-size: 1.2rem;
    pointer-events: none;
    animation: petHeartPop 1s ease-out forwards;
    z-index: 100;
}

@keyframes petHeartPop {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-40px) scale(1.2); opacity: 0; }
}

/* Floating animation for special items */
.placed-item[data-rarity="special"] img {
    animation: floaty 3s ease-in-out infinite;
}

@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.gacha-btn.spinning {
    animation: gachaSpin 0.5s linear infinite;
}

@keyframes gachaSpin {
    100% { transform: rotate(360deg); }
}

/* Pet Thought Bubbles */
.pet-thought-bubble {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 100;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(180, 100, 180, 0.1);
}

.pet-thought-bubble.active {
    transform: translateX(-50%) scale(1);
    animation: bubbleFloat 2s ease-in-out infinite alternate;
}

@keyframes bubbleFloat {
    from { margin-top: 0; }
    to { margin-top: -5px; }
}

/* Eating Animation */
.placed-item.is-pet.eating img {
    animation: munch 0.3s ease-in-out infinite;
}

@keyframes munch {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1) rotate(2deg); }
}

/* Sleeping Animation */
.placed-item.is-pet.sleeping::after {
    content: 'Zzz';
    position: absolute;
    top: -15px;
    right: -5px;
    font-size: 0.8rem;
    color: #9d4edd;
    font-weight: 800;
    animation: zzzFloat 2s linear infinite;
}

@keyframes zzzFloat {
    0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translate(10px, -20px) scale(1.2); opacity: 0; }
}

/* Food disappearing animation */
.placed-item.shrinking {
    animation: shrinkAndFade 1.5s forwards;
    pointer-events: none;
}

@keyframes shrinkAndFade {
    to { transform: scale(0); opacity: 0; }
}