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

button, input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #fef9ef 0%, #fde8c8 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.screen {
    width: 100%;
    max-width: 500px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   SHARED
   ============================================================ */
.coin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd54f, #ffb300);
    color: #7b5800;
    font-size: 0.7em;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.4);
    flex-shrink: 0;
}

.coins-value {
    font-weight: 700;
    color: #ffc107;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
#home-screen {
    position: relative;
    align-items: center;
}

.home-inner {
    position: relative;
    z-index: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 20px 30px 40px;
}

.home-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    width: 100%;
}

.home-coins {
    background: rgba(0,0,0,0.06);
    color: #5a4a30;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 1em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.home-coins .coins-value {
    color: #b8860b;
}

.home-settings {
    background: rgba(0,0,0,0.06);
    border: none;
    color: #6b7b8d;
    font-size: 1.4em;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-settings:hover { background: rgba(0,0,0,0.1); }

.home-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: auto;
    padding-bottom: 20px;
}

/* Logo banner */
.home-logo {
    margin: auto 0;
    padding: 30px 0;
}

.logo-icon {
    font-size: 4em;
    line-height: 1;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.logo-banner {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 16px 40px 20px;
    border-radius: 18px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
}

.logo-word {
    font-size: 2.6em;
    font-weight: 800;
    color: #3a3a3a;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.logo-pack {
    font-size: 1.3em;
    font-weight: 700;
    color: #ff9800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 2px;
}

.btn-play {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
    background: linear-gradient(180deg, #43e97b 0%, #38c96a 100%);
    color: white;
    border: none;
    border-bottom: 5px solid #2a9d50;
    padding: 16px 60px;
    border-radius: 18px;
    font-size: 1.5em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 6px 20px rgba(56,201,106,0.35);
}
.btn-play-label { display: block; line-height: 1.2; }
.btn-play-level { display: block; font-size: 0.5em; font-weight: 600; opacity: 0.85; margin-top: 2px; }

.btn-play:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(56,201,106,0.5); }
.btn-play:active { transform: translateY(2px); border-bottom-width: 2px; box-shadow: 0 2px 8px rgba(56,201,106,0.3); }

.btn-shop {
    margin-top: 14px;
    background: transparent;
    border: 2px solid rgba(0,0,0,0.12);
    color: #7a6a50;
    padding: 10px 28px;
    border-radius: 12px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-shop:active { background: rgba(0,0,0,0.04); }

.home-dev-levels {
    margin-top: 16px;
    background: transparent;
    border: 1px solid rgba(0,0,0,0.1);
    color: rgba(0,0,0,0.35);
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.85em;
    cursor: pointer;
}
.home-dev-levels:active { background: rgba(0,0,0,0.04); }

/* ============================================================
   LEVEL MAP
   ============================================================ */
#level-map {
    background: linear-gradient(180deg, #0288d1 0%, #4fc3f7 50%, #b3e5fc 100%);
}

.map-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 12px;
    background: rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 10;
}

.map-back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.3em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.map-back-btn:hover { background: rgba(255,255,255,0.3); }

.map-title { flex: 1; color: white; font-size: 1.3em; font-weight: 700; }

.map-coins {
    background: rgba(0,0,0,0.2);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.map-scroll { flex: 1; overflow-y: auto; padding: 20px 0 40px; -webkit-overflow-scrolling: touch; }

.level-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0 20px;
    position: relative;
}

.level-path::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 50%;
    width: 2px;
    background: rgba(255,255,255,0.2);
    transform: translateX(-50%);
    z-index: 0;
}

.tier-label {
    color: rgba(255,255,255,0.9);
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 10px 20px;
    margin: 8px 0;
    background: rgba(0,0,0,0.15);
    border-radius: 20px;
    position: relative;
    z-index: 1;
}

.map-node {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 320px;
    padding: 6px 0;
    position: relative;
    z-index: 1;
}

.map-node.left { flex-direction: row; align-self: flex-start; margin-left: 10%; }
.map-node.right { flex-direction: row-reverse; align-self: flex-end; margin-right: 10%; text-align: right; }

.map-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: white;
    border: 3px solid rgba(255,255,255,0.6);
    color: #0288d1;
    font-size: 1.3em;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.map-node.completed .map-circle { background: #66bb6a; color: white; border-color: #43a047; }
.map-node.locked .map-circle { background: rgba(255,255,255,0.3); color: rgba(255,255,255,0.6); cursor: not-allowed; border-color: rgba(255,255,255,0.2); box-shadow: none; }
.map-node.current .map-circle { animation: currentPulse 2s ease-in-out infinite; border-color: #ffc107; box-shadow: 0 0 20px rgba(255,193,7,0.4); }

@keyframes currentPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255,193,7,0.4); }
    50% { transform: scale(1.08); box-shadow: 0 0 30px rgba(255,193,7,0.6); }
}

.map-circle:hover:not(:disabled) { transform: scale(1.1); box-shadow: 0 6px 18px rgba(0,0,0,0.2); }

.map-info { flex: 1; }
.map-name { display: block; color: white; font-weight: 600; font-size: 0.95em; text-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.map-node.locked .map-name { color: rgba(255,255,255,0.5); }
.map-done-check { display: inline-block; color: rgba(255,255,255,0.85); font-size: 1em; font-weight: 700; margin-top: 2px; }

/* ============================================================
   GAME CONTAINER
   ============================================================ */
.game-container { position: relative; }

.game-header {
    text-align: center;
    padding: 10px 14px 0;
}

.header-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    position: relative;
}

.btn-icon {
    background: rgba(0,0,0,0.04);
    border: 2px solid #e0d6c8;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-icon:hover { border-color: #0288d1; }

.level-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9em;
    font-weight: 700;
    color: #333;
    text-align: center;
    pointer-events: none;
}

.header-lives {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    background: #ffebee;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 0.85em;
    font-weight: 700;
    color: #c62828;
    flex-shrink: 0;
}

.lives-icon { color: #ef5350; }
.lives-value { font-weight: 700; }

/* ============================================================
   MOVES DISPLAY (in conveyor task area)
   ============================================================ */
.moves-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #e3f2fd;
    padding: 6px 14px;
    border-radius: 10px;
    font-weight: 700;
    color: #1565c0;
    flex-shrink: 0;
    transition: all 0.3s ease;
    border: 2px solid #bbdefb;
}

.moves-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #1976d2;
}

.moves-value {
    font-weight: 800;
    font-size: 1.15em;
    display: inline-block;
    min-width: 1.5em;
    text-align: center;
}

.moves-value.moves-pop {
    animation: scorePop 0.3s ease;
}

.moves-display.moves-warning {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffb74d;
}

.moves-display.moves-warning .moves-label {
    color: #e65100;
}

.moves-display.moves-critical {
    background: #ffebee;
    color: #c62828;
    border-color: #ef5350;
    animation: movesCriticalPulse 0.8s ease-in-out infinite;
}

.moves-display.moves-critical .moves-label {
    color: #c62828;
}

@keyframes movesCriticalPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); box-shadow: 0 0 12px rgba(229,57,53,0.3); }
}

/* Timer (kept but hidden) */
.timer-container { text-align: center; margin: 6px 0; }
.timer-container.hidden { display: none; }
.timer-bar-bg { width: 100%; max-width: 300px; height: 10px; background: #e0d6c8; border-radius: 5px; margin: 0 auto; overflow: hidden; }
.timer-bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #42a5f5, #0288d1); border-radius: 5px; transition: width 0.3s linear; }
.timer-bar-fill.warning { background: #e53935; }
.timer-text { font-size: 1.2em; font-weight: bold; color: #0288d1; margin-top: 4px; }
.timer-text.warning { color: #e53935; }

/* ============================================================
   CONVEYOR QUEUE
   ============================================================ */
.conveyor-header { padding: 6px 0 2px; text-align: center; }

.conveyor-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.pack-progress {
    font-size: 0.95em;
    font-weight: 700;
    color: #333;
    display: inline-block;
    transition: all 0.2s;
    background: #f1f8e9;
    padding: 6px 14px;
    border-radius: 10px;
    border: 2px solid #c5e1a5;
}

.pack-progress.progress-pop {
    animation: scorePop 0.4s ease;
    color: #43a047;
}

.target-slots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 0;
}

.target-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 42px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9em;
    border: 2px solid #ddd;
    background: #fafafa;
    animation: cardSlideIn 0.35s ease-out;
    min-width: 110px;
    justify-content: center;
    box-sizing: border-box;
}

.target-card .target-icon { font-size: 1.2em; line-height: 1; }
.target-card .target-name { color: #333; }

/* Category-colored borders */
.target-card.animals  { border-color: #8bc34a; background: #f1f8e9; }
.target-card.food     { border-color: #e91e63; background: #fce4ec; }
.target-card.vehicles { border-color: #ff9800; background: #fff3e0; }
.target-card.weather  { border-color: #42a5f5; background: #e3f2fd; }
.target-card.colors   { border-color: #ab47bc; background: #f3e5f5; }
.target-card.body     { border-color: #ef5350; background: #ffebee; }
.target-card.home     { border-color: #26a69a; background: #e0f2f1; }
.target-card.nature   { border-color: #8d6e63; background: #efebe9; }
.target-card.sports   { border-color: #5c6bc0; background: #e8eaf6; }
.target-card.clothes  { border-color: #ff7043; background: #fbe9e7; }
.target-card.tools    { border-color: #78909c; background: #eceff1; }
.target-card.jobs     { border-color: #7e57c2; background: #ede7f6; }
.target-card.rooms    { border-color: #a1887f; background: #efebe9; }
.target-card.travel   { border-color: #29b6f6; background: #e1f5fe; }
.target-card.school   { border-color: #fdd835; background: #fffde7; }
.target-card.kitchen  { border-color: #ec407a; background: #fce4ec; }
.target-card.ocean    { border-color: #0097a7; background: #e0f7fa; }
.target-card.music    { border-color: #d81b60; background: #fce4ec; }
.target-card.flags    { border-color: #43a047; background: #e8f5e9; }
.target-card.space    { border-color: #5e35b1; background: #ede7f6; }

/* Special task cards */
.target-card.task {
    border-color: #ff9800;
    border-style: dashed;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3e0 100%);
}

.target-card.task .task-icon {
    font-size: 1.3em;
    line-height: 1;
    opacity: 0.85;
}

.target-card.task .target-name {
    color: #e65100;
    font-weight: 700;
}

/* Goal popup for completed tasks */
.goal-popup.task { background: rgba(255,152,0,0.9); }

@keyframes cardSlideIn {
    0% { opacity: 0; transform: translateX(40px) scale(0.8); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* ============================================================
   BOARD
   ============================================================ */
.board-container {
    display: flex;
    justify-content: center;
    position: relative;
    overflow: visible;
    flex: 1;
    align-items: center;
    padding: 6px 10px;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 5px;
    background: #e8dfd4;
    padding: 8px;
    border-radius: 14px;
    touch-action: none;
    user-select: none;
    width: 100%;
    max-width: 400px;
    /* Constrain height to match Word Pack proportions */
    height: min(calc(100dvh - 200px), 560px);
    max-height: 100%;
}

.tile {
    background: #fffcf7;
    border: 2px solid #e0d6c8;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: visible;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    min-height: 42px;
    padding: 4px 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .tile:hover { transform: scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
}

.tile.selected {
    border: 3px solid #ff9800;
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(255,152,0,0.35);
}

.tile .word {
    font-size: 0.9em;
    font-weight: bold;
    color: #333;
    text-align: center;
    padding: 5px;
    width: 100%;
    line-height: 1.3;
}

.tile.emoji .word {
    font-size: 2.5em;
    line-height: 1;
    overflow-wrap: break-word;
}

.tile.neutral::before  { background: transparent; }
.tile.animals::before  { background: #8bc34a; }
.tile.food::before     { background: #e91e63; }
.tile.vehicles::before { background: #ff9800; }
.tile.weather::before  { background: #42a5f5; }
.tile.colors::before   { background: #ab47bc; }
.tile.body::before     { background: #ef5350; }
.tile.home::before     { background: #26a69a; }
.tile.nature::before   { background: #8d6e63; }
.tile.sports::before   { background: #5c6bc0; }
.tile.clothes::before  { background: #ff7043; }

.tile.empty {
    background: transparent;
    border: 2px dashed #e0e0e0;
    cursor: default;
    opacity: 0.3;
}
.tile.empty:hover { transform: none; box-shadow: none; }
.tile.empty::before { display: none; }

/* ============================================================
   JUICY ANIMATIONS
   ============================================================ */

/* --- 1a. Match highlight: glow with category color, stay visible --- */
.tile.match-highlight {
    z-index: 10;
    animation: matchHighlight 0.5s ease forwards;
    border-width: 3px;
}

@keyframes matchHighlight {
    0%   { transform: scale(1); filter: brightness(1); box-shadow: none; }
    40%  { transform: scale(1.15); filter: brightness(1.4); box-shadow: 0 0 18px rgba(255,255,255,0.5); }
    100% { transform: scale(1.1); filter: brightness(1.3); box-shadow: 0 0 12px rgba(255,255,255,0.3); }
}

/* Per-category highlight colors (border + background tint) */
.tile.match-highlight.animals  { border-color: #8bc34a; background: #e8f5e9; }
.tile.match-highlight.food     { border-color: #e91e63; background: #fce4ec; }
.tile.match-highlight.vehicles { border-color: #ff9800; background: #fff3e0; }
.tile.match-highlight.weather  { border-color: #42a5f5; background: #e3f2fd; }
.tile.match-highlight.colors   { border-color: #ab47bc; background: #f3e5f5; }
.tile.match-highlight.body     { border-color: #ef5350; background: #ffebee; }
.tile.match-highlight.home     { border-color: #26a69a; background: #e0f2f1; }
.tile.match-highlight.nature   { border-color: #8d6e63; background: #efebe9; }
.tile.match-highlight.sports   { border-color: #5c6bc0; background: #e8eaf6; }
.tile.match-highlight.clothes  { border-color: #ff7043; background: #fbe9e7; }
.tile.match-highlight.tools    { border-color: #78909c; background: #eceff1; }
.tile.match-highlight.jobs     { border-color: #7e57c2; background: #ede7f6; }
.tile.match-highlight.rooms    { border-color: #a1887f; background: #efebe9; }
.tile.match-highlight.travel   { border-color: #29b6f6; background: #e1f5fe; }
.tile.match-highlight.school   { border-color: #fdd835; background: #fffde7; }
.tile.match-highlight.kitchen  { border-color: #ec407a; background: #fce4ec; }
.tile.match-highlight.ocean    { border-color: #0097a7; background: #e0f7fa; }
.tile.match-highlight.music    { border-color: #d81b60; background: #fce4ec; }
.tile.match-highlight.flags    { border-color: #43a047; background: #e8f5e9; }
.tile.match-highlight.space    { border-color: #5e35b1; background: #ede7f6; }

/* --- 1b. Match remove: shrink and fade out --- */
.tile.match-remove {
    z-index: 10;
    animation: matchRemove 0.3s ease forwards;
}

@keyframes matchRemove {
    0%   { transform: scale(1.1); opacity: 1; filter: brightness(1.3); }
    100% { transform: scale(0); opacity: 0; filter: brightness(2); }
}

/* --- 2. Tile bounce on gravity landing --- */
.tile.tile-bounce {
    animation: tileBounce 0.4s ease-out;
}

@keyframes tileBounce {
    0% { transform: translateY(-30px); opacity: 0.3; }
    50% { transform: translateY(4px); opacity: 1; }
    70% { transform: translateY(-2px); }
    100% { transform: translateY(0); opacity: 1; }
}

/* --- 3. Board shake (3 intensities) --- */
@keyframes boardShakeLight {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-2px, 1px); }
    30% { transform: translate(2px, -1px); }
    45% { transform: translate(-1px, 2px); }
    60% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, 0px); }
}

@keyframes boardShakeMedium {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-3px, 2px); }
    20% { transform: translate(4px, -2px); }
    30% { transform: translate(-4px, 3px); }
    40% { transform: translate(3px, -3px); }
    50% { transform: translate(-2px, 2px); }
    60% { transform: translate(3px, -1px); }
    70% { transform: translate(-2px, 1px); }
    80% { transform: translate(1px, -1px); }
}

@keyframes boardShakeHeavy {
    0%, 100% { transform: translate(0, 0); }
    8% { transform: translate(-5px, 3px) rotate(-0.5deg); }
    16% { transform: translate(6px, -4px) rotate(0.5deg); }
    24% { transform: translate(-6px, 4px) rotate(-0.3deg); }
    32% { transform: translate(5px, -3px) rotate(0.3deg); }
    40% { transform: translate(-4px, 3px); }
    48% { transform: translate(4px, -2px); }
    56% { transform: translate(-3px, 2px); }
    64% { transform: translate(3px, -1px); }
    72% { transform: translate(-2px, 1px); }
    80% { transform: translate(1px, -1px); }
}

#game-board.board-shake-light { animation: boardShakeLight 0.25s ease; }
#game-board.board-shake-medium { animation: boardShakeMedium 0.35s ease; }
#game-board.board-shake-heavy { animation: boardShakeHeavy 0.5s ease; }

/* --- 4. Category color flash overlay --- */
.category-flash {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 14px;
    pointer-events: none;
    z-index: 50;
    animation: categoryFlash 0.5s ease-out forwards;
}

@keyframes categoryFlash {
    0% { opacity: 0.35; }
    100% { opacity: 0; }
}

.category-flash.animals  { background: radial-gradient(circle, rgba(139,195,74,0.4) 0%, transparent 70%); }
.category-flash.food     { background: radial-gradient(circle, rgba(233,30,99,0.4) 0%, transparent 70%); }
.category-flash.vehicles { background: radial-gradient(circle, rgba(255,152,0,0.4) 0%, transparent 70%); }
.category-flash.weather  { background: radial-gradient(circle, rgba(66,165,245,0.4) 0%, transparent 70%); }
.category-flash.colors   { background: radial-gradient(circle, rgba(171,71,188,0.4) 0%, transparent 70%); }
.category-flash.body     { background: radial-gradient(circle, rgba(239,83,80,0.4) 0%, transparent 70%); }
.category-flash.home     { background: radial-gradient(circle, rgba(38,166,154,0.4) 0%, transparent 70%); }
.category-flash.nature   { background: radial-gradient(circle, rgba(141,110,99,0.4) 0%, transparent 70%); }
.category-flash.sports   { background: radial-gradient(circle, rgba(92,107,192,0.4) 0%, transparent 70%); }
.category-flash.clothes  { background: radial-gradient(circle, rgba(255,112,67,0.4) 0%, transparent 70%); }
.category-flash.tools    { background: radial-gradient(circle, rgba(120,144,156,0.4) 0%, transparent 70%); }
.category-flash.jobs     { background: radial-gradient(circle, rgba(126,87,194,0.4) 0%, transparent 70%); }
.category-flash.rooms    { background: radial-gradient(circle, rgba(161,136,127,0.4) 0%, transparent 70%); }
.category-flash.travel   { background: radial-gradient(circle, rgba(41,182,246,0.4) 0%, transparent 70%); }
.category-flash.school   { background: radial-gradient(circle, rgba(253,216,53,0.4) 0%, transparent 70%); }
.category-flash.kitchen  { background: radial-gradient(circle, rgba(236,64,122,0.4) 0%, transparent 70%); }
.category-flash.ocean    { background: radial-gradient(circle, rgba(0,151,167,0.4) 0%, transparent 70%); }
.category-flash.music    { background: radial-gradient(circle, rgba(216,27,96,0.4) 0%, transparent 70%); }
.category-flash.flags    { background: radial-gradient(circle, rgba(67,160,71,0.4) 0%, transparent 70%); }
.category-flash.space    { background: radial-gradient(circle, rgba(94,53,177,0.4) 0%, transparent 70%); }

/* --- 5. Score/moves pop --- */
@keyframes scorePop {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* --- 6. Combo text (scales with level) --- */
@keyframes comboFloat {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    30% { transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, calc(-50% - 50px)) scale(0.85); }
}

.combo-text {
    position: absolute;
    top: 45%; left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 30px rgba(255,215,0,0.6), 0 0 60px rgba(255,152,0,0.3);
    pointer-events: none;
    z-index: 102;
    animation: comboFloat 1.1s ease-out forwards;
    letter-spacing: -0.02em;
}

/* ============================================================
   PARTICLES & EFFECTS
   ============================================================ */
@keyframes particleBurst {
    0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    60% { opacity: 0.8; }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rotation)); }
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 99;
    animation: particleBurst 0.7s ease-out forwards;
}

.particle.animals  { background: #66bb6a; }
.particle.food     { background: #ec407a; }
.particle.vehicles { background: #ff9800; }
.particle.weather  { background: #42a5f5; }
.particle.colors   { background: #ab47bc; }
.particle.body     { background: #ef5350; }
.particle.home     { background: #26a69a; }
.particle.nature   { background: #8d6e63; }
.particle.sports   { background: #5c6bc0; }
.particle.clothes  { background: #ff7043; }
.particle.tools    { background: #78909c; }
.particle.jobs     { background: #7e57c2; }
.particle.rooms    { background: #a1887f; }
.particle.travel   { background: #29b6f6; }
.particle.school   { background: #fdd835; }
.particle.kitchen  { background: #ec407a; }
.particle.ocean    { background: #0097a7; }
.particle.music    { background: #d81b60; }
.particle.flags    { background: #43a047; }
.particle.space    { background: #5e35b1; }
.particle.neutral  { background: #999; }

/* Goal popup */
@keyframes popIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    40% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    55% { transform: translate(-50%, -50%) scale(0.95); }
    70% { transform: translate(-50%, -50%) scale(1.05); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

.goal-popup {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6em;
    font-weight: bold;
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 101;
    animation: popIn 1.2s ease-out forwards;
}

.goal-popup.animals  { background: rgba(102,187,106,0.9); }
.goal-popup.food     { background: rgba(236,64,122,0.9); }
.goal-popup.vehicles { background: rgba(255,152,0,0.9); }
.goal-popup.weather  { background: rgba(66,165,245,0.9); }
.goal-popup.colors   { background: rgba(171,71,188,0.9); }
.goal-popup.body     { background: rgba(239,83,80,0.9); }
.goal-popup.home     { background: rgba(38,166,154,0.9); }
.goal-popup.nature   { background: rgba(141,110,99,0.9); }
.goal-popup.sports   { background: rgba(92,107,192,0.9); }
.goal-popup.clothes  { background: rgba(255,112,67,0.9); }
.goal-popup.generic  { background: rgba(96,125,139,0.9); }
.goal-popup.tools    { background: rgba(120,144,156,0.9); }
.goal-popup.jobs     { background: rgba(126,87,194,0.9); }
.goal-popup.ocean    { background: rgba(0,151,167,0.9); }
.goal-popup.music    { background: rgba(216,27,96,0.9); }
.goal-popup.flags    { background: rgba(67,160,71,0.9); }
.goal-popup.space    { background: rgba(94,53,177,0.9); }

/* Mini confetti for bundle packed */
@keyframes miniConfettiFall {
    0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(var(--fall)) translateX(var(--drift)) rotate(var(--rot)) scale(0.3); }
}

.mini-confetti {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 100;
    animation: miniConfettiFall 1.2s ease-out forwards;
}

/* Confetti (win screen) */
@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(-10px) translateX(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(100vh) translateX(var(--drift)) rotate(var(--rot)); }
}

.confetti {
    position: fixed;
    top: -10px;
    pointer-events: none;
    z-index: 9999;
    animation: confettiFall 2s ease-in forwards;
}

/* Goal sparkles */
@keyframes sparkleBurst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.3); }
}

.sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fdd835;
    border-radius: 1px;
    transform: rotate(45deg);
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 0 6px rgba(253,216,53,0.7);
    animation: sparkleBurst 0.8s ease-out forwards;
}

/* Unlock banner sparkles */
@keyframes unlockFloat {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-30px) scale(0.3); }
}

.unlock-sparkle {
    position: absolute;
    bottom: 0;
    width: 5px;
    height: 5px;
    background: #fdd835;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(253,216,53,0.7);
    animation: unlockFloat 1.5s ease-out forwards;
}

/* Coin fly animation */
@keyframes coinFly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--ox), var(--oy)) scale(0.5); }
}

.coin-fly {
    position: fixed;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #fdd835, #f9a825);
    border-radius: 50%;
    color: #7b5800;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    animation: coinFly 0.7s ease-in forwards;
}

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

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

/* ============================================================
   DEV TOOLBAR
   ============================================================ */
.dev-toolbar {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255,152,0,0.08);
    border-top: 1px dashed rgba(255,152,0,0.3);
}

.dev-btn {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 700;
    cursor: pointer;
    border: none;
    color: white;
}

.dev-btn-win { background: #43a047; }
.dev-btn-win:active { background: #2e7d32; }
.dev-btn-lose { background: #e53935; }
.dev-btn-lose:active { background: #c62828; }

/* ============================================================
   MODALS
   ============================================================ */
.game-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.game-modal.show { display: flex; animation: fadeIn 0.3s ease; }

.modal-content {
    background: white;
    padding: 36px 28px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    min-width: 280px;
    max-width: 360px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.modal-content h2 { font-size: 2em; margin-bottom: 12px; }
.modal-content.win h2 { color: #2e7d32; }
.modal-content.lose h2 { color: #e53935; }
.modal-content.pause h2 { color: #0288d1; }
.modal-content.settings h2 { color: #333; }

.settings-options { margin-bottom: 18px; }

.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
}

.toggle-label { font-size: 0.95em; font-weight: 600; color: #555; }
.settings-toggle input { display: none; }

.toggle-slider {
    width: 46px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.settings-toggle input:checked + .toggle-slider { background: #0288d1; }
.settings-toggle input:checked + .toggle-slider::after { transform: translateX(20px); }

.dev-settings {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dev-field { display: flex; align-items: center; justify-content: space-between; }
.dev-field-label { font-size: 0.9em; font-weight: 600; color: #555; display: flex; align-items: center; gap: 4px; }

.dev-input {
    width: 80px;
    padding: 6px 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}
.dev-input:focus { border-color: #0288d1; }

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.btn-primary {
    background: #0288d1;
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 260px;
}
.btn-primary:hover { background: #0277bd; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(2,136,209,0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: white;
    color: #0288d1;
    border: 2px solid #0288d1;
    padding: 12px 28px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 260px;
}
.btn-secondary:hover { background: #e1f5fe; }
.btn-secondary.btn-danger { color: #e53935; border-color: #e53935; }
.btn-secondary.btn-danger:hover { background: #ffebee; }

.restart-life-cost {
    display: inline-block;
    background: #ffebee;
    color: #e53935;
    font-size: 0.8em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.btn-tertiary {
    background: none;
    border: none;
    color: #888;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 20px;
    transition: all 0.2s;
    text-decoration: underline;
}
.btn-tertiary:hover { color: #0288d1; }

/* Pause help */
.pause-help { max-height: 0; overflow: hidden; transition: max-height 0.3s ease, padding 0.3s ease; text-align: left; }
.pause-help.show { max-height: 300px; padding: 14px 0 0; }
.pause-help p { color: #666; font-size: 0.9em; margin-bottom: 6px; line-height: 1.4; }

/* ============================================================
   WIN / LOSE SCREENS
   ============================================================ */
.modal-content.shop h2 { color: #333; }

.shop-powerups { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

.win-unlock-banner {
    background: linear-gradient(135deg, #ffd54f, #ffb300);
    color: #5d4037;
    text-align: center;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    margin-bottom: 14px;
    border: 2px solid rgba(255,255,255,0.5);
}
.win-unlock-banner .unlock-icon { display: block; font-size: 1.6em; margin-bottom: 2px; }
.win-unlock-banner .unlock-label { display: block; font-size: 0.7em; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; opacity: 0.65; margin-bottom: 4px; }
.win-unlock-banner .unlock-name { display: block; font-size: 1.3em; }

.win-coins-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
    font-size: 1.5em;
    font-weight: 700;
}
.win-coins-amount { color: #ffc107; }

/* Ad reward button */
.btn-ad-reward {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 260px;
    background: linear-gradient(180deg, #43e97b 0%, #38c96a 100%);
    color: white;
    border: none;
    border-bottom: 4px solid #2a9d50;
    padding: 12px 20px;
    border-radius: 14px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 4px 16px rgba(56,201,106,0.4);
}
.btn-ad-reward:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(56,201,106,0.5); }
.btn-ad-reward:active { transform: translateY(2px); border-bottom-width: 2px; box-shadow: 0 2px 8px rgba(56,201,106,0.3); }
.btn-ad-reward.used { background: #bbb; border-bottom-color: #999; box-shadow: none; cursor: not-allowed; opacity: 0.5; }

.ad-play-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    font-size: 0.9em;
}
.ad-label { text-align: left; line-height: 1.2; }
.ad-amount { font-size: 0.85em; opacity: 0.9; }

.btn-ad-reward .coin-badge-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd54f, #ffb300);
    color: #7b5800;
    font-size: 0.55em;
    font-weight: 800;
    vertical-align: middle;
}

/* Mock ad overlay */
.mock-ad-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.mock-ad-content {
    background: white;
    padding: 60px 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    min-width: 260px;
}

.mock-ad-label { font-size: 2.5em; font-weight: 800; color: #bbb; letter-spacing: 4px; margin-bottom: 30px; }

.btn-ad-close {
    background: #0288d1;
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ad-close:hover { background: #0277bd; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(2,136,209,0.4); }
.btn-ad-close:active { transform: translateY(0); }

/* Lose screen */
.lose-life-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 4px 0 18px;
    animation: lifePopIn 0.4s ease-out;
}

.lose-heart-broken { font-size: 2.8em; line-height: 1; filter: drop-shadow(0 2px 6px rgba(239,83,80,0.3)); }
.lose-heart-minus { font-size: 1.5em; font-weight: 800; color: #c62828; text-shadow: 0 1px 3px rgba(0,0,0,0.15); }

@keyframes lifePopIn {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

.lose-progress { margin-bottom: 20px; }
.lose-progress-bar-bg { height: 10px; background: #eee; border-radius: 5px; overflow: hidden; margin-bottom: 8px; }
.lose-progress-bar-fill { height: 100%; background: linear-gradient(90deg, #ef5350, #e53935); border-radius: 5px; transition: width 0.4s ease; }
.lose-progress-text { font-size: 0.95em; font-weight: 600; color: #666; }

/* No lives */
.lose-no-lives { margin-top: 12px; }
.no-lives-heart { position: relative; display: inline-block; margin: 10px 0 16px; }
.no-lives-heart .big-heart { font-size: 4em; color: #ef5350; filter: drop-shadow(0 2px 6px rgba(239,83,80,0.3)); }
.no-lives-heart .heart-count { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 1.8em; font-weight: 800; color: white; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.no-lives-timer { font-size: 1em; color: #888; margin-bottom: 18px; font-weight: 600; }
.no-lives-timer span { color: #e53935; font-weight: 700; font-size: 1.1em; }

#btn-buy-lives { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#btn-buy-lives.cant-afford { background: #bbb; cursor: not-allowed; }
#btn-buy-lives.cant-afford:hover { background: #bbb; transform: none; box-shadow: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    body { padding: 0; align-items: flex-start; }
    .screen { max-width: 100%; }

    /* Home */
    .logo-word { font-size: 2.2em; }
    .logo-pack { font-size: 1.1em; }
    .logo-icon { font-size: 3.5em; }
    .btn-play { padding: 14px 50px; font-size: 1.3em; }

    /* Map */
    .map-node.left { margin-left: 5%; }
    .map-node.right { margin-right: 5%; }
    .map-circle { width: 50px; height: 50px; font-size: 1.1em; }
    .map-name { font-size: 0.85em; }

    /* Game */
    .game-container { border-radius: 0; }
    .game-header { padding: 8px 10px 0; }
    .header-compact { gap: 6px; margin-bottom: 4px; }
    .btn-icon { width: 36px; height: 36px; font-size: 1em; }
    .level-indicator { font-size: 0.8em; }

    .conveyor-stats { gap: 8px; margin-bottom: 6px; }
    .moves-display { padding: 4px 10px; font-size: 0.85em; }
    .pack-progress { font-size: 0.85em; padding: 4px 10px; }

    .target-card { padding: 0 12px; height: 36px; font-size: 0.8em; min-width: 90px; }
    .board-container { padding: 4px 8px; }

    #game-board {
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(8, 1fr);
        gap: 4px;
        padding: 6px;
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        height: min(calc(100dvh - 180px), 520px);
    }

    .tile { min-height: 36px; padding: 3px 1px; border-radius: 8px; }
    .tile .word { font-size: 0.65em; padding: 2px; }
    .tile.emoji .word { font-size: 1.8em; }

    .particle { width: 6px; height: 6px; }
    .goal-popup { font-size: 1.2em; padding: 10px 20px; }

    .modal-content { padding: 28px 20px; min-width: auto; margin: 0 15px; }
    .modal-content h2 { font-size: 1.7em; }
    .btn-primary { padding: 12px 28px; font-size: 1em; }
    .btn-secondary { padding: 10px 24px; font-size: 0.9em; }
}

/* Extra small screens */
@media (max-width: 380px) {
    .logo-word { font-size: 1.9em; }
    .logo-pack { font-size: 1em; }
    .logo-icon { font-size: 3em; }
    .btn-play { padding: 12px 40px; font-size: 1.1em; }
    .map-circle { width: 44px; height: 44px; font-size: 1em; }

    #game-board { gap: 3px; padding: 5px; }
    .tile { min-height: 32px; border-radius: 7px; }
    .tile .word { font-size: 0.6em; }
    .tile.emoji .word { font-size: 1.5em; }
}
