/* --- DESIGN SYSTEM MODERNE --- */
:root {
    --bg-body: #faf8ef;
    --text-main: #776e65;
    --primary: #8f7a66;
    --accent: #edc22e;
    --gem: #9b59b6;
    --xp: #3498db;
    --danger: #e74c3c;
    --glass: rgba(255, 255, 255, 0.95);
    --shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --anim-speed: 120ms;

    --grid-bg: #bbada0;
    --cell-bg: rgba(238, 228, 218, 0.35);

    /* TILE COLORS */
    --t2-bg: #eee4da;
    --t2-txt: #776e65;
    --t4-bg: #ede0c8;
    --t4-txt: #776e65;
    --t8-bg: #f2b179;
    --t8-txt: #f9f6f2;
    --t16-bg: #f59563;
    --t16-txt: #f9f6f2;
    --t32-bg: #f67c5f;
    --t32-txt: #f9f6f2;
    --t64-bg: #f65e3b;
    --t64-txt: #f9f6f2;
    --t128-bg: #edcf72;
    --t128-txt: #f9f6f2;
    --t256-bg: #edcc61;
    --t256-txt: #f9f6f2;
    --t512-bg: #edc850;
    --t512-txt: #f9f6f2;
    --t1024-bg: #edc53f;
    --t1024-txt: #f9f6f2;
    --t2048-bg: #edc22e;
    --t2048-txt: #f9f6f2;
    --t4096-bg: #3c3a32;
    --t4096-txt: #f9f6f2;
    --t8192-bg: #9b59b6;
    --t8192-txt: #f9f6f2;
    --t16384-bg: #8e44ad;
    --t16384-txt: #f9f6f2;
    --t32768-bg: #2980b9;
    --t32768-txt: #f9f6f2;
    --t65536-bg: #3498db;
    --t65536-txt: #f9f6f2;
    --t131072-bg: #00cec9;
    --t131072-txt: #f9f6f2;
    --t262144-bg: #00b894;
    --t262144-txt: #f9f6f2;
    --t524288-bg: #2ecc71;
    --t524288-txt: #f9f6f2;
    --t1048576-bg: #27ae60;
    --t1048576-txt: #f9f6f2;
    --t2097152-bg: #f1c40f;
    --t2097152-txt: #f9f6f2;
    --t4194304-bg: #e67e22;
    --t4194304-txt: #f9f6f2;
    --t8388608-bg: #e74c3c;
    --t8388608-txt: #f9f6f2;
    --t16777216-bg: #c0392b;
    --t16777216-txt: #f9f6f2;
    --t33554432-bg: #fd79a8;
    --t33554432-txt: #f9f6f2;
    --t67108864-bg: #e84393;
    --t67108864-txt: #f9f6f2;
}

body.skin-neon {
    --bg-body: #111;
    --text-main: #fff;
    --primary: #333;
    --grid-bg: #222;
    --cell-bg: #333;
    --glass: rgba(20, 20, 20, 0.95);

    --t2-bg: #000;
    --t2-txt: #0ff;
    --t4-bg: #000;
    --t4-txt: #0f0;
    --t8-bg: #000;
    --t8-txt: #ff0;
    --t16-bg: #000;
    --t16-txt: #f0f;
    --t32-bg: #000;
    --t32-txt: #f00;
    --t64-bg: #000;
    --t64-txt: #00f;
    --t128-bg: #000;
    --t128-txt: #0ff;
    --t256-bg: #000;
    --t256-txt: #0f0;
    --t512-bg: #000;
    --t512-txt: #ff0;
    --t1024-bg: #000;
    --t1024-txt: #f0f;
    --t2048-bg: #000;
    --t2048-txt: #fff;
    --t4096-bg: #000;
    --t4096-txt: #f00;
    --t8192-bg: #000;
    --t8192-txt: #0f0;
    --t16384-bg: #000;
    --t16384-txt: #ff0;
    --t32768-bg: #000;
    --t32768-txt: #f0f;
    --t65536-bg: #000;
    --t65536-txt: #0ff;
    --t131072-bg: #000;
    --t131072-txt: #fff;
    --t262144-bg: #000;
    --t262144-txt: #f00;
    --t524288-bg: #000;
    --t524288-txt: #0f0;
    --t1048576-bg: #000;
    --t1048576-txt: #ff0;
    --t2097152-bg: #000;
    --t2097152-txt: #f0f;
    --t4194304-bg: #000;
    --t4194304-txt: #0ff;
    --t8388608-bg: #000;
    --t8388608-txt: #fff;
    --t16777216-bg: #000;
    --t16777216-txt: #f00;
    --t33554432-bg: #000;
    --t33554432-txt: #0f0;
    --t67108864-bg: #000;
    --t67108864-txt: #ff0;
}

body.skin-gold {
    --bg-body: #1a1000;
    --text-main: #ffd700;
    --primary: #3e2723;
    --grid-bg: #3e2723;
    --cell-bg: #5d4037;
    --glass: rgba(40, 30, 10, 0.95);

    --t2-bg: linear-gradient(135deg, #cd7f32, #8b4513);
    --t2-txt: #fff;
    --t4-bg: linear-gradient(135deg, #d4af37, #996515);
    --t4-txt: #fff;
    --t8-bg: linear-gradient(135deg, #e6c200, #b8860b);
    --t8-txt: #fff;
    --t16-bg: linear-gradient(135deg, #ffd700, #caa400);
    --t16-txt: #fff;
    --t32-bg: linear-gradient(135deg, #ffdf00, #d4af37);
    --t32-txt: #fff;
    --t64-bg: linear-gradient(135deg, #ffea00, #e6c200);
    --t64-txt: #fff;
    --t128-bg: linear-gradient(135deg, #fff000, #ffdf00);
    --t128-txt: #fff;
    --t256-bg: linear-gradient(135deg, #fff500, #ffea00);
    --t256-txt: #333;
    --t512-bg: linear-gradient(135deg, #fff800, #fff000);
    --t512-txt: #333;
    --t1024-bg: linear-gradient(135deg, #fffb00, #fff500);
    --t1024-txt: #333;
    --t2048-bg: linear-gradient(135deg, #ffff00, #fff800);
    --t2048-txt: #333;
    --t4096-bg: #fff;
    --t4096-txt: #000;
    --t8192-bg: linear-gradient(135deg, #e0e0e0, #999999);
    --t8192-txt: #000;
    --t16384-bg: linear-gradient(135deg, #c0c0c0, #808080);
    --t16384-txt: #000;
    --t32768-bg: linear-gradient(135deg, #e5e4e2, #b0c4de);
    --t32768-txt: #000;
    --t65536-bg: linear-gradient(135deg, #b9f2ff, #5ac8fa);
    --t65536-txt: #000;
    --t131072-bg: linear-gradient(135deg, #ff6b6b, #c0392b);
    --t131072-txt: #fff;
    --t262144-bg: linear-gradient(135deg, #2ecc71, #27ae60);
    --t262144-txt: #fff;
    --t524288-bg: linear-gradient(135deg, #3498db, #2980b9);
    --t524288-txt: #fff;
    --t1048576-bg: linear-gradient(135deg, #9b59b6, #8e44ad);
    --t1048576-txt: #fff;
    --t2097152-bg: linear-gradient(135deg, #e67e22, #d35400);
    --t2097152-txt: #fff;
    --t4194304-bg: linear-gradient(135deg, #1abc9c, #16a085);
    --t4194304-txt: #fff;
    --t8388608-bg: linear-gradient(135deg, #fd79a8, #d63031);
    --t8388608-txt: #fff;
    --t16777216-bg: linear-gradient(135deg, #55efc4, #00b894);
    --t16777216-txt: #000;
    --t33554432-bg: linear-gradient(135deg, #81ecec, #00cec9);
    --t33554432-txt: #000;
    --t67108864-bg: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    --t67108864-txt: #000;
}

body.skin-galaxy {
    --bg-body: #0f0c29;
    --text-main: #e0e0e0;
    --primary: #4b6cb7;
    --grid-bg: rgba(255, 255, 255, 0.1);
    --cell-bg: rgba(0, 0, 0, 0.3);
    --glass: rgba(15, 12, 41, 0.9);
    background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e);

    --t2-bg: rgba(255, 255, 255, 0.1);
    --t2-txt: #a0c4ff;
    --t4-bg: rgba(255, 255, 255, 0.15);
    --t4-txt: #bdb2ff;
    --t8-bg: rgba(255, 255, 255, 0.2);
    --t8-txt: #ffc6ff;
    --t16-bg: rgba(255, 255, 255, 0.25);
    --t16-txt: #fdffb6;
    --t32-bg: rgba(255, 255, 255, 0.3);
    --t32-txt: #caffbf;
    --t64-bg: rgba(255, 255, 255, 0.35);
    --t64-txt: #9bf6ff;
    --t128-bg: rgba(255, 255, 255, 0.4);
    --t128-txt: #8eecf5;
    --t256-bg: rgba(255, 255, 255, 0.45);
    --t256-txt: #ffd6a5;
    --t512-bg: rgba(255, 255, 255, 0.5);
    --t512-txt: #ffadad;
    --t1024-bg: rgba(255, 255, 255, 0.55);
    --t1024-txt: #ff99c8;
    --t2048-bg: rgba(255, 255, 255, 0.6);
    --t2048-txt: #d0f4de;
    --t4096-bg: rgba(255, 255, 255, 0.7);
    --t4096-txt: #fcf6bd;
    --t8192-bg: rgba(255, 255, 255, 0.75);
    --t8192-txt: #ffeb3b;
    --t16384-bg: rgba(255, 255, 255, 0.8);
    --t16384-txt: #ff9800;
    --t32768-bg: rgba(255, 255, 255, 0.85);
    --t32768-txt: #f44336;
    --t65536-bg: rgba(255, 255, 255, 0.9);
    --t65536-txt: #e91e63;
    --t131072-bg: rgba(255, 255, 255, 0.95);
    --t131072-txt: #9c27b0;
    --t262144-bg: #fff;
    --t262144-txt: #673ab7;
    --t524288-bg: rgba(0, 0, 0, 0.8);
    --t524288-txt: #00bcd4;
    --t1048576-bg: rgba(0, 0, 0, 0.85);
    --t1048576-txt: #4caf50;
    --t2097152-bg: rgba(0, 0, 0, 0.9);
    --t2097152-txt: #cddc39;
    --t4194304-bg: rgba(0, 0, 0, 0.95);
    --t4194304-txt: #ffc107;
    --t8388608-bg: #000;
    --t8388608-txt: #ff5722;
    --t16777216-bg: #111;
    --t16777216-txt: #fff;
    --t33554432-bg: #222;
    --t33554432-txt: #0ff;
    --t67108864-bg: #333;
    --t67108864-txt: #f0f;
}

body {
    font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: background 0.3s, color 0.3s;
}

#app-container {
    width: 100%;
    max-width: 450px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 15px;
    box-sizing: border-box;
    position: relative;
}

/* --- LOGIN SCREEN --- */
#login-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.login-card {
    background: var(--glass);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 85%;
    max-width: 350px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.logo-big {
    font-size: 60px;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
    letter-spacing: -2px;
}

.subtitle {
    color: #888;
    margin-bottom: 30px;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: bold;
}

.input-modern {
    position: relative;
    margin-bottom: 20px;
    width: 100%;
}

.input-modern input {
    width: 100%;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: var(--radius);
    font-size: 16px;
    outline: none;
    transition: border 0.2s;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.input-modern input:focus {
    border-color: var(--primary);
}

.input-modern i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #ccc;
    cursor: pointer;
    padding: 10px;
}

/* --- UI ELEMENTS --- */
.btn-modern {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
    transition: all 0.1s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
}

.btn-modern:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn-modern.secondary {
    background: #999;
    color: white;
    border: none;
}

.btn-modern.accent {
    background: var(--accent);
    color: white;
}

.btn-modern.danger {
    background: var(--danger);
    color: white;
}

.btn-modern.xp-btn {
    background: var(--xp);
    color: white;
}

.nav-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
    margin-bottom: 15px;
}

.nav-btn {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    border: none;
    background: var(--glass);
    color: var(--text-main);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.1s;
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

/* --- GAME UI --- */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.title-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.title-block h1 {
    font-size: 36px;
    margin: 0;
    line-height: 1;
    font-weight: 800;
}

.xp-container {
    margin-top: 5px;
    width: 100px;
    position: relative;
}

.xp-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: var(--xp);
    width: 0%;
    transition: width 0.5s ease-out;
}

.level-badge {
    font-size: 11px;
    color: white;
    background: var(--xp);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    position: absolute;
    right: -5px;
    top: -18px;
}

.player-name {
    font-size: 13px;
    font-weight: bold;
    color: var(--text-main);
    opacity: 0.8;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 12px;
    background: var(--glass);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.profile-icon {
    font-size: 26px;
    color: var(--primary);
}

.user-profile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.user-profile-btn:active {
    transform: scale(0.95);
}

.scores-row {
    display: flex;
    gap: 8px;
}

.stat-box {
    background: var(--grid-bg);
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    min-width: 55px;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stat-box .label {
    font-size: 10px;
    text-transform: uppercase;
    color: #eee4da;
    font-weight: bold;
    display: block;
    letter-spacing: 0.5px;
}

.stat-box .value {
    font-size: 18px;
    font-weight: bold;
    display: block;
}

.stat-box.gems {
    background: var(--gem);
    cursor: pointer;
    padding-right: 28px;
}

.stat-box.gems .info-icon {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.7;
}

.game-area {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
}

.placer-mode {
    cursor: crosshair;
}

.grid-container {
    background: var(--grid-bg);
    border-radius: 8px;
    padding: 10px;
    width: 100%;
    aspect-ratio: 1/1;
    display: grid;
    gap: 10px;
    position: relative;
    touch-action: none;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.grid-5 {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 8px;
    padding: 8px;
}

.game-container.debug-mode {
    border: 4px solid var(--danger);
    cursor: crosshair;
}

.grid-cell {
    background: var(--cell-bg);
    border-radius: 4px;
    width: 100%;
    height: 100%;
}

.tile-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.tile {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
    transition: transform var(--anim-speed) ease-in-out;
    will-change: transform;
    z-index: 10;
}

.tile-inner {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: var(--t2-bg);
    color: var(--t2-txt);
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.tile-inner.new {
    animation: appear 200ms ease;
}

.tile-inner.merged {
    animation: pop 150ms ease;
    z-index: 20;
}

@keyframes appear {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

.floating-text {
    position: absolute;
    color: var(--gem);
    font-weight: bold;
    font-size: 24px;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 50;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -150%) scale(1.5);
        opacity: 0;
    }
}

/* Tile Colors */
.tile[data-val="2"] .tile-inner {
    background: var(--t2-bg);
    color: var(--t2-txt);
}

.tile[data-val="4"] .tile-inner {
    background: var(--t4-bg);
    color: var(--t4-txt);
}

.tile[data-val="8"] .tile-inner {
    background: var(--t8-bg);
    color: var(--t8-txt);
}

.tile[data-val="16"] .tile-inner {
    background: var(--t16-bg);
    color: var(--t16-txt);
}

.tile[data-val="32"] .tile-inner {
    background: var(--t32-bg);
    color: var(--t32-txt);
}

.tile[data-val="64"] .tile-inner {
    background: var(--t64-bg);
    color: var(--t64-txt);
}

.tile[data-val="128"] .tile-inner {
    background: var(--t128-bg);
    color: var(--t128-txt);
}

.tile[data-val="256"] .tile-inner {
    background: var(--t256-bg);
    color: var(--t256-txt);
}

.tile[data-val="512"] .tile-inner {
    background: var(--t512-bg);
    color: var(--t512-txt);
}

.tile[data-val="1024"] .tile-inner {
    background: var(--t1024-bg);
    color: var(--t1024-txt);
}

.tile[data-val="2048"] .tile-inner {
    background: var(--t2048-bg);
    color: var(--t2048-txt);
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4);
}

.tile[data-val="4096"] .tile-inner {
    background: var(--t4096-bg);
    color: var(--t4096-txt);
}

.tile[data-val="8192"] .tile-inner {
    background: var(--t8192-bg);
    color: var(--t8192-txt);
}

.tile[data-val="16384"] .tile-inner {
    background: var(--t16384-bg);
    color: var(--t16384-txt);
}

.tile[data-val="32768"] .tile-inner {
    background: var(--t32768-bg);
    color: var(--t32768-txt);
}

.tile[data-val="65536"] .tile-inner {
    background: var(--t65536-bg);
    color: var(--t65536-txt);
}

.tile[data-val="131072"] .tile-inner {
    background: var(--t131072-bg);
    color: var(--t131072-txt);
}

.tile[data-val="262144"] .tile-inner {
    background: var(--t262144-bg);
    color: var(--t262144-txt);
}

.tile[data-val="524288"] .tile-inner {
    background: var(--t524288-bg);
    color: var(--t524288-txt);
}

.tile[data-val="1048576"] .tile-inner {
    background: var(--t1048576-bg);
    color: var(--t1048576-txt);
}

.tile[data-val="2097152"] .tile-inner {
    background: var(--t2097152-bg);
    color: var(--t2097152-txt);
}

.tile[data-val="4194304"] .tile-inner {
    background: var(--t4194304-bg);
    color: var(--t4194304-txt);
}

.tile[data-val="8388608"] .tile-inner {
    background: var(--t8388608-bg);
    color: var(--t8388608-txt);
}

.tile[data-val="16777216"] .tile-inner {
    background: var(--t16777216-bg);
    color: var(--t16777216-txt);
}

.tile[data-val="33554432"] .tile-inner {
    background: var(--t33554432-bg);
    color: var(--t33554432-txt);
}

.tile[data-val="67108864"] .tile-inner {
    background: var(--t67108864-bg);
    color: var(--t67108864-txt);
}



.power-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    justify-content: center;
}

.power-icon {
    background: white;
    width: 65px;
    height: 65px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    transition: transform 0.1s;
}

.power-icon:active {
    transform: scale(0.95);
}

.power-icon i {
    font-size: 22px;
    color: var(--text-main);
    margin-bottom: 3px;
}

.power-icon span {
    font-size: 10px;
    font-weight: bold;
    color: #888;
}

.power-icon .cost {
    font-size: 10px;
    background: var(--gem);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 2px;
}

.power-icon.active {
    border-color: var(--danger);
    background: #fce4e4;
}

/* STUCK INLINE UI */
.speech-bubble {
    position: relative;
    background: var(--danger);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    display: inline-block;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
    animation: popIn 0.3s ease-out;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: var(--danger) transparent transparent transparent;
    display: block;
    width: 0;
}

.power-icon.highlight-powerup {
    animation: pulsePowerup 1.5s infinite;
    border: 2px solid var(--accent);
}

@keyframes pulsePowerup {
    0% {
        box-shadow: 0 0 0 0 rgba(237, 194, 46, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(237, 194, 46, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(237, 194, 46, 0);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}



/* CUSTOM SKIN CONFIG */
.custom-tile-slot {
    background: #f0f0f0;
    border-radius: 8px;
    height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px dashed #ccc;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s, border-color 0.2s;
}

.custom-tile-slot:active {
    transform: scale(0.95);
}

.custom-tile-slot:hover {
    border-color: var(--primary);
}

.custom-tile-label {
    font-weight: bold;
    font-size: 16px;
    color: #333;
    z-index: 2;
    background: rgba(255, 255, 255, 0.7);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.custom-tile-slot[style*="background-image"] .custom-tile-label {
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

.custom-tile-icon {
    font-size: 14px;
    color: #888;
    z-index: 2;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px;
    border-radius: 50%;
}

.custom-tile-slot[style*="background-image"] .custom-tile-icon {
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

/* MODALS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

#stuck-modal.modal-overlay {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    align-items: flex-end;
    padding-bottom: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--glass);
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.2s;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    margin-bottom: 20px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 20px;
    width: 30px;
    height: 30px;
    background: #eee;
    border-radius: 50%;
    color: #888;
    cursor: pointer;
}

.score-anim {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 0 0 5px var(--accent);
    animation: floatUp 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 100;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1.5);
    }

    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1);
    }
}

/* QUESTS & ACHIEVEMENTS */
.quest-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.quest-card.completed {
    background: #f0fdf4;
    border: 1px solid #dcfce7;
}

.quest-info {
    flex-grow: 1;
    text-align: left;
}

.quest-bar {
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.quest-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.quest-reward {
    background: var(--gem);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
}

.quest-card.completed .quest-fill {
    background: #22c55e;
}

.quest-card.completed .quest-reward {
    background: #22c55e;
}

.achievement-card {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
    border-left: 4px solid #eee;
}

.achievement-card.unlocked {
    border-left-color: var(--gem);
    background: #f8f9fa;
}

.ach-icon {
    font-size: 24px;
    color: #ccc;
    width: 40px;
    text-align: center;
}

.achievement-card.unlocked .ach-icon {
    color: var(--accent);
    filter: drop-shadow(0 0 5px rgba(255, 85, 85, 0.3));
}

.ach-content {
    flex-grow: 1;
    text-align: left;
}

.ach-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
}

.ach-desc {
    font-size: 12px;
    color: #666;
}

.ach-reward {
    font-weight: bold;
    color: var(--gem);
    font-size: 13px;
}

.achievement-card.unlocked .ach-reward {
    color: #22c55e;
}

/* SHOP & ADMIN */
.shop-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 5px;
}

.shop-card {
    background: white;
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.shop-btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

.admin-panel {
    background: #f8d7da;
    border: 2px dashed #dc3545;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-title {
    color: #dc3545;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-size: 14px;
}

/* DEBUG CONSOLE */
#debug-console {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 380px;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #00ff9d;
    border-radius: 16px;
    padding: 10px 15px;
    z-index: 7000;
    box-shadow: 0 10px 30px rgba(0, 255, 157, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Courier New', monospace;
    color: #00ff9d;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#debug-console.minimized {
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    overflow: hidden;
    background: #000;
    border-color: #333;
}

.debug-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

#debug-console.minimized .debug-content {
    display: none;
}

.debug-led {
    width: 8px;
    height: 8px;
    background: #00ff9d;
    border-radius: 50%;
    box-shadow: 0 0 8px #00ff9d;
    animation: blink 2s infinite;
    flex-shrink: 0;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.debug-select {
    background: rgba(0, 255, 157, 0.1);
    color: #00ff9d;
    border: 1px solid rgba(0, 255, 157, 0.3);
    border-radius: 6px;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    flex-grow: 1;
}

.debug-select option {
    background: #000;
    color: #00ff9d;
}

.debug-btn {
    background: none;
    border: none;
    color: #ff5555;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    transition: transform 0.2s;
}

.debug-btn:hover {
    transform: scale(1.2);
    color: #ff0000;
}

.debug-toggle-btn {
    background: none;
    border: none;
    color: #00ff9d;
    font-size: 20px;
    cursor: pointer;
    display: none;
}

#debug-console.minimized .debug-toggle-btn {
    display: block;
}

.debug-minimize {
    color: #888;
    font-size: 12px;
    cursor: pointer;
    margin-right: 5px;
}

.hidden {
    display: none !important;
}

.shake {
    animation: shake 0.3s;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* PROFILE MODAL MODERNIZATION */
.profile-content {
    background: linear-gradient(145deg, var(--glass), rgba(255, 255, 255, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.profile-avatar-container {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid var(--primary);
    transition: transform 0.2s;
}

.profile-avatar-container:hover {
    transform: scale(1.05);
}

.profile-avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-container .default-avatar {
    font-size: 60px;
    color: #ccc;
}

.avatar-edit-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.profile-avatar-container:hover .avatar-edit-overlay {
    opacity: 1;
}

.level-badge-large {
    background: var(--xp);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-top: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.5), 0 2px 5px rgba(0, 0, 0, 0.02);
}

.stat-item .s-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-item .s-val {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
}

/* Leaderboard Avatars */
.lb-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    vertical-align: middle;
    border: 1px solid #ccc;
}

.lb-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.6);
    margin-bottom: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.lb-item-left {
    display: flex;
    align-items: center;
}