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

:root {
    --flame: #FF6B2B;
    --ember: #FF9D4D;
    --gold: #FFD700;
    --dark: #0A0A0F;
    --darker: #060609;
    --surface: #12121A;
    --surface-light: #1A1A26;
    --surface-hover: #222233;
    --text: #E8E8F0;
    --text-dim: #8888A0;
    --hp-green: #44cc66;
    --hp-red: #cc4444;
    --xp-blue: #4488ff;
    --common: #9d9d9d;
    --rare: #4169E1;
    --epic: #9B30FF;
    --legendary: #FFD700;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    background: var(--darker);
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
}

/* ===== TOP BAR ===== */
#top-bar {
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 10;
}

.logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}
.logo span { color: var(--flame); }

.top-stats {
    display: flex;
    gap: 16px;
    flex: 1;
    justify-content: center;
}

.top-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    background: var(--surface-light);
    padding: 4px 12px;
    border-radius: 8px;
}

.stat-icon { font-size: 16px; }

.top-btn {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-dim);
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.top-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}
#share-btn {
    border-color: rgba(255, 107, 43, 0.35);
    color: var(--flame);
}
#share-btn:hover {
    background: rgba(255, 107, 43, 0.15);
    border-color: var(--flame);
    color: var(--ember);
}

/* ===== GAME CONTAINER ===== */
#game-container {
    display: flex;
    height: calc(100vh - 52px);
    overflow: hidden;
}

/* ===== BATTLE AREA ===== */
#battle-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

#battle-canvas {
    flex: 1;
    width: 100%;
    display: block;
    background: var(--darker);
}

#floor-progress {
    padding: 8px 16px 12px;
    background: var(--surface);
    border-top: 1px solid rgba(255,255,255,0.04);
}

#floor-progress-text {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.progress-bar-track {
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--flame), var(--ember));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ===== SIDE PANEL ===== */
#side-panel {
    width: 320px;
    background: var(--surface);
    border-left: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#panel-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--flame);
    border-bottom-color: var(--flame);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.tab-content.active { display: block; }

/* Scrollbar */
.tab-content::-webkit-scrollbar { width: 4px; }
.tab-content::-webkit-scrollbar-track { background: transparent; }
.tab-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ===== STATS TAB ===== */
.stats-section { margin-bottom: 16px; }

#hero-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.xp-bar-container { position: relative; }

.xp-bar-track {
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--xp-blue), #66aaff);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.xp-text {
    font-size: 11px;
    color: var(--text-dim);
    display: block;
    margin-top: 4px;
    text-align: right;
}

.stat-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.stat-grid.secondary {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface-light);
    border-radius: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-dim);
}

.stat-value {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

/* ===== UPGRADE SECTION ===== */
.upgrade-section {
    margin-bottom: 16px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(255,215,0,0.06), rgba(255,107,43,0.04));
    border: 1px solid rgba(255,215,0,0.12);
    border-radius: 10px;
}

.upgrade-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.upgrade-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.upgrade-btn {
    background: var(--surface-light);
    border: 1px solid rgba(255,215,0,0.15);
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.upgrade-btn:hover:not(:disabled) {
    background: rgba(255,215,0,0.12);
    border-color: rgba(255,215,0,0.3);
    transform: translateY(-1px);
}

.upgrade-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.upgrade-btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* ===== EQUIPMENT TAB ===== */
.equip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 280px;
    margin: 0 auto;
}

.equip-slot {
    background: var(--surface-light);
    border: 2px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 80px;
    padding: 6px 4px;
}
.equip-slot:not(.has-item) {
    aspect-ratio: 1;
}

.equip-slot:hover {
    border-color: rgba(255,107,43,0.3);
    background: var(--surface-hover);
}

.equip-slot.has-item { border-width: 2px; }
.equip-slot.rarity-common { border-color: var(--common); }
.equip-slot.rarity-rare { border-color: var(--rare); }
.equip-slot.rarity-epic { border-color: var(--epic); }
.equip-slot.rarity-legendary {
    border-color: var(--legendary);
    box-shadow: 0 0 12px rgba(255,215,0,0.15);
}

.slot-icon {
    font-size: 24px;
    margin-bottom: 2px;
    opacity: 0.4;
}

.equip-slot.has-item .slot-icon { opacity: 1; }

.slot-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.equip-item-name {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ===== INVENTORY TAB ===== */
.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

#inv-count {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}

.small-btn {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-dim);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.2s;
}
.small-btn:hover { background: var(--surface-hover); color: var(--text); }

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.inv-slot {
    aspect-ratio: 1;
    background: var(--surface-light);
    border: 2px solid rgba(255,255,255,0.04);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    font-size: 20px;
}

.inv-slot:hover {
    border-color: rgba(255,107,43,0.3);
    transform: scale(1.05);
}

.inv-slot.rarity-common { border-color: rgba(157,157,157,0.4); }
.inv-slot.rarity-rare { border-color: rgba(65,105,225,0.5); }
.inv-slot.rarity-epic { border-color: rgba(155,48,255,0.5); }
.inv-slot.rarity-legendary {
    border-color: rgba(255,215,0,0.6);
    box-shadow: 0 0 8px rgba(255,215,0,0.15);
    animation: legendary-glow 2s ease-in-out infinite;
}

@keyframes legendary-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,0.15); }
    50% { box-shadow: 0 0 16px rgba(255,215,0,0.3); }
}

.inv-slot .equipped-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--hp-green);
    border-radius: 50%;
}

/* ===== LOOT POPUP ===== */
.loot-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.loot-popup.hidden { display: none; }

.loot-popup-inner {
    background: var(--surface);
    border: 2px solid var(--flame);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    min-width: 280px;
    max-width: 340px;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.loot-rarity-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.loot-item-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
}

.loot-item-stats {
    text-align: left;
    margin-bottom: 20px;
}

.loot-stat {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
    color: var(--text-dim);
}

.loot-stat-value {
    color: var(--hp-green);
    font-weight: 600;
    font-family: var(--font-display);
}

.loot-stat-value.negative { color: var(--hp-red); }

.loot-actions {
    display: flex;
    gap: 8px;
}

/* ===== BUTTONS ===== */
/* Eliminate 300ms tap delay on touch devices for ALL interactive elements */
button, .tab, .inv-slot, .equip-slot, .gem-pack, .spend-item, .top-btn, .upgrade-btn, .small-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--flame), var(--ember));
    color: white;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-sell {
    background: rgba(204,68,68,0.15);
    color: #ff6666;
    border: 1px solid rgba(204,68,68,0.2);
}
.btn-sell:hover { background: rgba(204,68,68,0.25); }

.btn-full { width: 100%; }

/* ===== ITEM TOOLTIP ===== */
.item-tooltip {
    position: fixed;
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 14px 16px;
    min-width: 200px;
    max-width: 260px;
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.item-tooltip.hidden { display: none; }

.tooltip-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}

.tooltip-slot {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.tooltip-stat {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 2px 0;
    color: var(--text-dim);
}

.tooltip-stat-val {
    font-weight: 600;
    font-family: var(--font-display);
    color: var(--hp-green);
}

.tooltip-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 11px;
    color: var(--text-dim);
}

/* ===== AUTH MODAL ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}
.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 32px;
    width: 340px;
    max-width: 90vw;
}

.modal-content h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-desc {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 20px;
}

#auth-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

#auth-form input {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
    outline: none;
    transition: border-color 0.2s;
}
#auth-form input:focus { border-color: var(--flame); }

.auth-toggle {
    text-align: center;
    font-size: 13px;
    color: var(--text-dim);
}
.auth-toggle a {
    color: var(--flame);
    text-decoration: none;
    font-weight: 500;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success { border-color: rgba(68,204,102,0.3); }
.toast.error { border-color: rgba(204,68,68,0.3); }
.toast.loot { border-color: rgba(255,215,0,0.3); }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ===== GEMS DISPLAY ===== */
.top-stat.gems {
    background: linear-gradient(135deg, rgba(0,191,255,0.12), rgba(138,43,226,0.08));
    border: 1px solid rgba(0,191,255,0.2);
}

.top-stat.gems .stat-icon {
    filter: drop-shadow(0 0 4px rgba(0,191,255,0.5));
}

/* ===== STORE TAB ===== */
.store-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(0,191,255,0.08), rgba(138,43,226,0.06));
    border: 1px solid rgba(0,191,255,0.15);
    border-radius: 10px;
    margin-bottom: 16px;
}

.store-balance-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 6px rgba(0,191,255,0.5));
}

#store-gems-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    color: #00BFFF;
}

.store-balance-label {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}

.store-section {
    margin-bottom: 20px;
}

.store-section-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: #00BFFF;
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

/* Gem Packs */
.gem-packs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.gem-pack {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.gem-pack:hover {
    border-color: rgba(0,191,255,0.3);
    background: var(--surface-hover);
    transform: translateY(-2px);
}

.gem-pack.popular {
    border-color: rgba(0,191,255,0.3);
    background: linear-gradient(135deg, rgba(0,191,255,0.06), rgba(138,43,226,0.04));
}

.gem-pack-badge {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #00BFFF, #8A2BE2);
    color: white;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    font-family: var(--font-display);
}

.gem-pack-amount {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    margin-bottom: 4px;
}

.gem-pack-icon {
    font-size: 18px;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 4px rgba(0,191,255,0.4));
}

.gem-pack-btn {
    background: linear-gradient(135deg, #00BFFF, #0099CC);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.gem-pack-btn:hover {
    filter: brightness(1.15);
}

/* Spend Items */
.spend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    transition: all 0.2s;
}

.spend-item:hover {
    border-color: rgba(0,191,255,0.2);
    background: var(--surface-hover);
}

.spend-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spend-item-icon {
    font-size: 22px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    flex-shrink: 0;
}

.spend-item-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.spend-item-desc {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}

.spend-item-btn {
    background: linear-gradient(135deg, rgba(0,191,255,0.15), rgba(138,43,226,0.1));
    border: 1px solid rgba(0,191,255,0.25);
    color: #00BFFF;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.spend-item-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(0,191,255,0.25), rgba(138,43,226,0.15));
    border-color: rgba(0,191,255,0.4);
    transform: translateY(-1px);
}

.spend-item-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.spend-item-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.gem-cost-icon {
    font-size: 12px;
}

/* Speed Boost Active Indicator */
.boost-active {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(255,215,0,0.08), rgba(255,107,43,0.06));
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 10px;
    margin-top: 12px;
    animation: boost-pulse 2s ease-in-out infinite;
}

.boost-active.hidden { display: none; }

.boost-icon {
    font-size: 18px;
    animation: boost-flash 1s ease-in-out infinite;
}

.boost-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    color: var(--gold);
    flex: 1;
}

.boost-timer {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--ember);
}

@keyframes boost-pulse {
    0%, 100% { border-color: rgba(255,215,0,0.2); }
    50% { border-color: rgba(255,215,0,0.4); }
}

@keyframes boost-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Toast for gems */
.toast.gems { border-color: rgba(0,191,255,0.3); }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
    }

    #battle-area {
        height: 45vh;
        min-height: 260px;
    }

    #side-panel {
        width: 100%;
        flex: 1;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.05);
    }

    .inventory-grid {
        grid-template-columns: repeat(6, 1fr);
    }

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

    .top-stats { gap: 8px; }
    .top-stat { padding: 4px 8px; font-size: 12px; }
    .stat-icon { font-size: 14px; }
}

@media (max-width: 480px) {
    #top-bar { padding: 0 10px; gap: 8px; }
    .logo { font-size: 16px; }
    .inventory-grid { grid-template-columns: repeat(5, 1fr); }
    .gem-packs-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .gem-pack-amount { font-size: 15px; }
    .gem-pack-btn { font-size: 11px; padding: 5px 8px; }
    .tab { font-size: 12px; padding: 10px 6px; }
}

/* ============================================================
   TUTORIAL OVERLAY
   ============================================================ */
#tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}

#tutorial-overlay.hidden {
    display: none;
}

#tutorial-card {
    background: #1a1a2e;
    border: 2px solid #7c3aed;
    border-radius: 16px;
    padding: 28px 24px 24px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 40px rgba(124, 58, 237, 0.4), 0 20px 60px rgba(0,0,0,0.6);
    animation: tutorialPop 0.3s ease-out;
}

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

#tutorial-step-indicator {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7c3aed;
    margin-bottom: 12px;
}

#tutorial-emoji {
    font-size: 44px;
    margin-bottom: 12px;
    line-height: 1;
}

#tutorial-title {
    font-size: 20px;
    font-weight: 700;
    color: #f0e6ff;
    margin-bottom: 10px;
    line-height: 1.2;
}

#tutorial-desc {
    font-size: 15px;
    color: #a89bc4;
    line-height: 1.6;
    margin-bottom: 14px;
}

#tutorial-highlight-label {
    font-size: 13px;
    font-weight: 600;
    color: #fbbf24;
    margin-bottom: 22px;
    letter-spacing: 0.02em;
}

#tutorial-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.tutorial-btn {
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
}

.tutorial-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

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

.tutorial-btn-skip {
    background: transparent;
    color: #6b7280;
    border: 1px solid #374151;
}

.tutorial-btn-next {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.tutorial-btn-finish {
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

.tutorial-progress-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
}

.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #374151;
    transition: background 0.2s;
}

.tutorial-dot.active {
    background: #7c3aed;
}

.tutorial-dot.done {
    background: #4c1d95;
}

/* ============================================================
   PORTAL TUTORIAL SPOTLIGHT
   Dark overlay with transparent cutout over target element
   ============================================================ */
#tutorial-spotlight {
    position: fixed;
    inset: 0;
    z-index: 998;
    pointer-events: none;
    background: transparent;
    transition: background 0.4s ease;
}

/* Dark backdrop when a target element is set */
#tutorial-spotlight.spotlight-active {
    background: rgba(0, 0, 0, 0.62);
}

/* Pulsing ring around highlighted element */
#tutorial-pulse-ring {
    position: fixed;
    z-index: 999;
    pointer-events: none;
    border: 2px solid #a855f7;
    border-radius: 8px;
    box-shadow: 0 0 12px 4px rgba(168, 85, 247, 0.5), inset 0 0 8px rgba(168, 85, 247, 0.2);
    animation: pulseRing 1.4s ease-in-out infinite;
}

@keyframes pulseRing {
    0%   { transform: scale(1);    opacity: 1; }
    50%  { transform: scale(1.04);  opacity: 0.75; }
    100% { transform: scale(1);    opacity: 1; }
}

/* Event hint text (auto-advance trigger hint) */
#tutorial-event-hint {
    font-size: 12px;
    color: #86efac;
    font-weight: 500;
    margin-bottom: 6px;
    min-height: 16px;
    animation: eventHintPulse 2s ease-in-out infinite;
}

@keyframes eventHintPulse {
    0%, 100% { opacity: 0.7; }
    50%       { opacity: 1; }
}

#tutorial-event-hint.hidden { display: none; }

/* ===== DAILY STREAK DISPLAY ===== */
.top-stat.streak {
    background: linear-gradient(135deg, rgba(255,107,0,0.15), rgba(255,69,0,0.08));
    border: 1px solid rgba(255,107,0,0.3);
    animation: streakPulse 2.5s ease-in-out infinite;
}

.top-stat.streak .stat-icon {
    filter: drop-shadow(0 0 5px rgba(255,107,0,0.7));
}

.top-stat.streak:hover {
    background: linear-gradient(135deg, rgba(255,107,0,0.25), rgba(255,69,0,0.15));
    border-color: rgba(255,107,0,0.6);
}

@keyframes streakPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,0,0); }
    50% { box-shadow: 0 0 8px 2px rgba(255,107,0,0.3); }
}

/* ===== DAILY REWARD DAY GRID ===== */
.dr-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 6px 8px;
    min-width: 44px;
    position: relative;
    transition: all 0.2s;
}

.dr-day-active {
    background: rgba(255,107,0,0.2);
    border-color: rgba(255,107,0,0.6);
    box-shadow: 0 0 8px rgba(255,107,0,0.3);
}

.dr-day-done {
    opacity: 0.5;
}

.dr-day-num {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-display);
}

.dr-day-icon {
    font-size: 16px;
    line-height: 1;
}

.dr-day-reward {
    font-size: 9px;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-weight: 600;
    white-space: nowrap;
}

.dr-day-check {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #22c55e;
    color: white;
    font-size: 9px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ===== LEADERBOARD TAB ===== */
.lb-season-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 4px;
}

.lb-season-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--ember);
    letter-spacing: 0.5px;
}

.lb-season-reset {
    font-size: 11px;
    color: var(--text-dim);
}

.lb-list {
    overflow-y: auto;
    max-height: calc(100% - 52px);
    padding: 0 4px;
}

.lb-loading {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 24px;
}

.lb-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 24px;
    line-height: 1.6;
}

.lb-row {
    display: grid;
    grid-template-columns: 28px 1fr 40px 40px;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.lb-row:hover {
    background: var(--surface-hover);
}

.lb-row.mine {
    background: rgba(255, 107, 43, 0.12);
    border-color: rgba(255, 107, 43, 0.3);
}

.lb-rank {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    color: var(--text-dim);
}

.lb-rank.rank-1 { color: #FFD700; font-size: 16px; }
.lb-rank.rank-2 { color: #C0C0C0; font-size: 15px; }
.lb-rank.rank-3 { color: #CD7F32; font-size: 15px; }

.lb-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-name.mine-name {
    color: var(--ember);
}

.lb-floor {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    color: var(--flame);
    text-align: right;
}

.lb-kills {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
}

.lb-col-headers {
    display: grid;
    grid-template-columns: 28px 1fr 40px 40px;
    gap: 6px;
    padding: 0 8px 4px;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.lb-col-headers span:nth-child(3),
.lb-col-headers span:nth-child(4) {
    text-align: right;
}

.lb-my-rank-banner {
    margin: 6px 4px 2px;
    padding: 8px 12px;
    background: rgba(255, 107, 43, 0.08);
    border: 1px solid rgba(255, 107, 43, 0.2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
}

.lb-my-rank-banner strong {
    color: var(--ember);
    font-family: var(--font-display);
}

.lb-not-ranked {
    margin: 6px 4px 2px;
    padding: 8px 12px;
    background: var(--surface-light);
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.5;
}

/* ============================================================
   MOBILE TOUCH & RESPONSIVE ENHANCEMENTS
   ============================================================ */

/* Dynamic viewport height — prevents mobile browser chrome from clipping game */
@supports (height: 100dvh) {
    html, body { height: 100dvh; }
    #game-container { height: calc(100dvh - 52px); }
}

/* ---- Touch targets & layout fixes for all mobile (≤768px) ---- */
@media (max-width: 768px) {
    /* Prevent accidental horizontal scroll */
    html { overflow-x: hidden; }

    /* ---- Minimum 44px touch targets on all interactive elements ---- */
    .tab {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .top-btn {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .upgrade-btn  { min-height: 44px; }
    .gem-pack-btn { min-height: 44px; font-size: 13px; }
    .spend-item-btn { min-height: 44px; }
    .btn          { min-height: 44px; }
    .tutorial-btn { min-height: 44px; }
    .small-btn    { min-height: 44px; padding: 0 12px; }

    /* Inventory & equip slots: bigger tap area */
    .inv-slot   { min-height: 52px; }
    .equip-slot { min-height: 72px; }

    /* Referral copy button: ensure 44px minimum */
    .referral-copy-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 12px;
    }

    /* Prestige button: full-width already, enforce min-height */
    .prestige-btn { min-height: 44px; }

    /* Prestige modal action buttons */
    .prestige-cancel-btn,
    .prestige-confirm-btn { min-height: 44px; }

    /* Leaderboard share button */
    .lb-share-btn { min-height: 44px; }

    /* Record toast buttons */
    .record-share-btn,
    .record-dismiss-btn { min-height: 44px; }

    /* Skill upgrade button */
    .skill-upgrade-btn { min-height: 44px; }

    /* Modal close button */
    .modal-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 8px;
        right: 8px;
    }

    /* ---- Gem pack cards stack vertically (task spec: "stack vertically on mobile") ---- */
    .gem-packs-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Gem packs in row layout on mobile: show amount + button inline */
    .gem-pack {
        display: flex;
        align-items: center;
        padding: 10px 16px;
        gap: 12px;
        text-align: left;
    }
    .gem-pack-amount { font-size: 20px; flex: 0 0 auto; }
    .gem-pack-icon   { font-size: 20px; flex: 0 0 auto; margin-bottom: 0; }
    .gem-pack-btn    { flex: 0 0 auto; width: auto; padding: 8px 18px; }
    /* Push badge back to correct position */
    .gem-pack-badge  { top: -8px; }

    /* ---- Loot popup: full-width on small screens ---- */
    .loot-popup-inner {
        max-width: calc(100vw - 32px);
        width: calc(100vw - 32px);
        min-width: unset;
        padding: 24px 20px;
    }
    .loot-actions { gap: 10px; }

    /* ---- Safe area bottom padding (notched phones / home bar) ---- */
    #side-panel { padding-bottom: max(env(safe-area-inset-bottom, 0px), 4px); }

    /* ---- Top bar: prevent overflow on narrower viewports ---- */
    .top-stats { overflow: hidden; flex-wrap: nowrap; }

    /* ---- Readable font sizes: nothing below 12px on mobile ---- */
    .slot-label         { font-size: 11px; }
    .xp-text            { font-size: 12px; }
    .stat-label         { font-size: 13px; }
    .stat-value         { font-size: 13px; }
    .spend-item-desc    { font-size: 12px; }
    .spend-item-name    { font-size: 14px; }
    .lb-name            { font-size: 13px; }
    .lb-floor           { font-size: 13px; }

    /* ---- Stat grid rows: slightly taller for easier reading ---- */
    .stat-row { padding: 10px 12px; }

    /* ---- Spend items: more breathing room ---- */
    .spend-item { padding: 12px; }

    /* ---- Tooltip: larger text on mobile ---- */
    .item-tooltip {
        font-size: 14px;
        min-width: 220px;
    }
    .tooltip-name { font-size: 16px; }
    .tooltip-slot { font-size: 12px; }
    .tooltip-stat { font-size: 14px; }
    .tooltip-actions { font-size: 12px; }
}

/* ---- Very small phones: 375–420px (iPhone SE, iPhone 12 mini) ---- */
@media (max-width: 420px) {
    /* De-prioritise floor & level from header — still visible in the Stats tab */
    #floor-display,
    #level-display { display: none; }

    .top-stats  { gap: 6px; }
    .top-stat   { padding: 4px 7px; font-size: 11px; }
    .stat-icon  { font-size: 13px; }
    .logo       { font-size: 14px; }
    #top-bar    { padding: 0 8px; gap: 6px; }
    .top-btn    { font-size: 16px; min-width: 40px; min-height: 40px; }

    /* 4-column inventory — each slot ~82px on 375px, comfortably tappable */
    .inventory-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }

    /* Equip grid: 3 wide (default is 3, just keep it explicit) */
    .equip-grid { grid-template-columns: repeat(3, 1fr); }

    /* Tab labels: stay readable */
    .tab { font-size: 11px; padding: 10px 4px; }

    /* Stats body text: minimum 13px */
    .stat-label { font-size: 13px; }
    .stat-value { font-size: 13px; }

    /* Tutorial card on small screens */
    #tutorial-card   { padding: 20px 16px 18px; }
    #tutorial-title  { font-size: 17px; }
    #tutorial-desc   { font-size: 14px; }
    .tutorial-btn    { padding: 10px 18px; }

    /* Special attack button on mobile: anchor to bottom-left so it doesn't overlap tabs */
    #special-attack-area {
        bottom: 44px;
        right: auto;
        left: 12px;
        transform: none;
    }

    /* Make special attack button larger on small phones for easy tapping */
    #special-attack-btn {
        width: 80px;
        height: 80px;
    }
    .special-cd-ring {
        width: 86px;
        height: 86px;
    }
    .special-btn-icon { font-size: 30px; }
}

/* ===== SPECIAL ATTACK BUTTON ===== */
#special-attack-area {
    position: absolute;
    bottom: 50px; /* above floor-progress strip */
    right: 16px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none; /* let clicks through except the button itself */
}

#special-attack-btn {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(255, 215, 0, 0.6);
    background: linear-gradient(145deg, #FF6B00, #FFD700);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    box-shadow: 0 0 24px rgba(255, 165, 0, 0.55), 0 4px 14px rgba(0,0,0,0.5);
    animation: specialPulse 1.8s ease-in-out infinite;
    overflow: visible;
    pointer-events: all;
    transition: background 0.25s, box-shadow 0.25s, border-color 0.25s, opacity 0.25s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#special-attack-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #FF8C00, #FFE566);
    box-shadow: 0 0 36px rgba(255, 200, 0, 0.75), 0 4px 14px rgba(0,0,0,0.5);
}

#special-attack-btn:active:not(:disabled) {
    transform: scale(0.93);
}

#special-attack-btn.on-cooldown {
    background: linear-gradient(145deg, #2a2a2a, #3a3a3a);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    animation: none;
    cursor: default;
}

@keyframes specialPulse {
    0%, 100% {
        box-shadow: 0 0 24px rgba(255, 165, 0, 0.55), 0 4px 14px rgba(0,0,0,0.5);
    }
    50% {
        box-shadow: 0 0 42px rgba(255, 200, 0, 0.85), 0 4px 14px rgba(0,0,0,0.5);
    }
}

.special-cd-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 78px;
    height: 78px;
    transform: rotate(-90deg);
    pointer-events: none;
}

.special-cd-track {
    fill: none;
    stroke: rgba(0, 0, 0, 0.35);
    stroke-width: 4;
}

.special-cd-fill {
    fill: none;
    stroke: rgba(180, 180, 255, 0.75);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 188.5; /* 2 * pi * 30 */
    stroke-dashoffset: 188.5; /* starts hidden (ready state) */
}

.special-btn-icon {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
}

.special-btn-label {
    font-family: var(--font-display);
    font-size: 8px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    letter-spacing: 0.8px;
    margin-top: 2px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.special-cd-text-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-align: center;
    min-height: 14px;
    pointer-events: none;
}

/* ===== SKILL UPGRADE (STORE) ===== */
.skill-upgrade-card {
    background: var(--surface-light);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 10px;
    padding: 12px;
}

.skill-level-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.skill-level-badge {
    background: linear-gradient(135deg, #FF6B00, #FFD700);
    color: #fff;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.skill-stats-text {
    font-size: 12px;
    color: var(--text-dim);
}

.skill-upgrade-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,107,0,0.15));
    border: 1px solid rgba(255, 215, 0, 0.35);
    border-radius: 8px;
    color: var(--gold);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.skill-upgrade-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(255,215,0,0.25), rgba(255,107,0,0.25));
    border-color: var(--gold);
}

.skill-upgrade-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.skill-upgrade-btn .upgrade-next-stats {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 500;
}

.skill-max-label {
    text-align: center;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--gold);
    padding: 6px 0;
}

/* ===== DEATH OVERLAY ===== */
#death-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: deathFadeIn 0.35s ease;
}

#death-overlay.hidden { display: none; }

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

#death-overlay-inner {
    background: linear-gradient(145deg, #1a0a0a, #1c1020);
    border: 2px solid rgba(255,68,68,0.4);
    border-radius: 18px;
    padding: 28px 32px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(255,68,68,0.18), 0 2px 8px rgba(0,0,0,0.5);
}

.death-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: #ff4444;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(255,68,68,0.5);
}

.death-floor {
    font-size: 15px;
    color: var(--text-dim);
    margin-bottom: 22px;
}

.death-floor strong {
    color: var(--text);
    font-weight: 700;
}

.death-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.death-share-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s, transform 0.1s;
}

.death-share-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.death-share-btn:active { transform: scale(0.96); }

.death-continue-btn {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 12px 20px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s, transform 0.1s;
}

.death-continue-btn:hover { background: var(--surface-hover); }
.death-continue-btn:active { transform: scale(0.96); }

/* ===== REWARDED AD — WATCH TO REVIVE ===== */
.death-revive-row {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.death-revive-row.hidden { display: none; }

.death-revive-btn {
    width: 100%;
    padding: 13px 20px;
    background: linear-gradient(135deg, #16a34a, #15803d);
    border: 2px solid rgba(34,197,94,0.5);
    border-radius: 10px;
    color: #fff;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.15s, transform 0.1s, box-shadow 0.2s;
    animation: revive-pulse 1.8s ease-in-out infinite;
    letter-spacing: 0.4px;
    box-shadow: 0 0 18px rgba(34,197,94,0.35);
}
.death-revive-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 0 26px rgba(34,197,94,0.5);
}
.death-revive-btn:active { transform: scale(0.97); }
.death-revive-btn:disabled {
    background: var(--surface-light);
    border-color: rgba(255,255,255,0.08);
    color: var(--text-dim);
    cursor: not-allowed;
    animation: none;
    box-shadow: none;
}
.death-revive-icon {
    font-size: 16px;
}
@keyframes revive-pulse {
    0%, 100% { box-shadow: 0 0 14px rgba(34,197,94,0.3); }
    50%       { box-shadow: 0 0 28px rgba(34,197,94,0.6); }
}

.death-revive-cd {
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-display);
    letter-spacing: 0.3px;
}
.death-revive-cd.hidden { display: none; }

/* ===== LEADERBOARD SHARE ===== */
.lb-share-row {
    padding: 12px 0 4px;
    display: flex;
    justify-content: center;
}

.lb-share-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s, transform 0.1s;
}

.lb-share-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.lb-share-btn:active { transform: scale(0.96); }

/* ===== PERSONAL BEST TOAST ===== */
#new-record-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1a2a1a, #1c2820);
    border: 2px solid #22c55e;
    border-radius: 14px;
    padding: 14px 20px;
    z-index: 7500;
    text-align: center;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 4px 24px rgba(34,197,94,0.25);
    animation: recordSlideIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

#new-record-toast.hidden { display: none; }

@keyframes recordSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.record-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 800;
    color: #22c55e;
    margin-bottom: 4px;
}

.record-subtitle {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.record-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.record-share-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    min-height: 36px;
    transition: opacity 0.15s;
}

.record-share-btn:hover { opacity: 0.88; }

.record-dismiss-btn {
    background: transparent;
    color: var(--text-dim);
    border: none;
    font-size: 11px;
    cursor: pointer;
    padding: 7px 10px;
    min-height: 36px;
}

.record-dismiss-btn:hover { color: var(--text); }
.skill-max-label.hidden { display: none; }

/* ===== REFERRAL SECTION ===== */
.referral-section {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(6,182,212,0.06), rgba(147,51,234,0.06));
    border: 1px solid rgba(6,182,212,0.2);
    border-radius: 10px;
}

.referral-section.hidden { display: none; }

.referral-header {
    margin-bottom: 8px;
}

.referral-title {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--cyan, #06b6d4);
    letter-spacing: -0.3px;
    margin-bottom: 2px;
}

.referral-subtitle {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

.referral-subtitle strong {
    color: var(--cyan, #06b6d4);
}

.referral-link-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.referral-link-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(6,182,212,0.25);
    border-radius: 6px;
    color: var(--text, #e5e7eb);
    font-size: 11px;
    padding: 6px 8px;
    font-family: monospace;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.referral-link-input:focus {
    outline: none;
    border-color: rgba(6,182,212,0.5);
}

.referral-copy-btn {
    background: rgba(6,182,212,0.15);
    border: 1px solid rgba(6,182,212,0.3);
    border-radius: 6px;
    color: var(--cyan, #06b6d4);
    font-size: 16px;
    padding: 5px 9px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.referral-copy-btn:hover {
    background: rgba(6,182,212,0.3);
    transform: scale(1.05);
}

.referral-copy-btn:active {
    transform: scale(0.95);
}

.referral-copy-confirm {
    font-size: 11px;
    color: #4ade80;
    margin-top: 4px;
    font-weight: 600;
    transition: opacity 0.3s;
}

.referral-copy-confirm.hidden { display: none; }

.referral-stats-row {
    margin-top: 6px;
}

.referral-count-text {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

/* ===== PRESTIGE SECTION ===== */
.prestige-section {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(255,215,0,0.06), rgba(155,48,255,0.06));
    border: 1px solid rgba(255,215,0,0.15);
    border-radius: 10px;
}

.prestige-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.prestige-badge {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--gold);
    letter-spacing: -0.3px;
}

.star-shards-text {
    font-size: 12px;
    font-weight: 600;
    color: #c084fc;
    background: rgba(155,48,255,0.12);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(155,48,255,0.2);
}

.prestige-bonus-text {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.prestige-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #c084fc, #9333ea);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    box-shadow: 0 2px 12px rgba(147,51,234,0.3);
}

.prestige-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(147,51,234,0.45);
    background: linear-gradient(135deg, #d8b4fe, #a855f7);
}

.prestige-btn:active {
    transform: scale(0.97);
}

.prestige-btn.hidden { display: none; }

/* ===== PRESTIGE MODAL ===== */
.prestige-modal-content {
    text-align: center;
    padding: 28px 24px;
    max-width: 340px;
}

.prestige-modal-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.prestige-modal-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.prestige-modal-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.prestige-modal-rewards {
    background: rgba(255,215,0,0.06);
    border: 1px solid rgba(255,215,0,0.15);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    line-height: 1.6;
}

.prestige-modal-warning {
    font-size: 11px;
    color: var(--text-dim);
    background: rgba(255,68,68,0.06);
    border: 1px solid rgba(255,68,68,0.12);
    border-radius: 6px;
    padding: 7px 10px;
    margin-bottom: 16px;
    line-height: 1.4;
}

.prestige-modal-actions {
    display: flex;
    gap: 10px;
}

.prestige-cancel-btn {
    flex: 1;
    padding: 10px;
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.prestige-cancel-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.prestige-confirm-btn {
    flex: 2;
    padding: 10px;
    background: linear-gradient(135deg, #c084fc, #9333ea);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.prestige-confirm-btn:hover {
    background: linear-gradient(135deg, #d8b4fe, #a855f7);
}

.prestige-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== OFFLINE REWARD MODAL ===== */
.offline-modal-content {
    text-align: center;
    padding: 28px 24px;
    max-width: 340px;
}

.offline-modal-icon {
    font-size: 40px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 8px rgba(255,107,43,0.4));
}

.offline-modal-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--ember);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.offline-modal-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 18px;
}

.offline-stats {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 4px 0;
    margin-bottom: 18px;
    text-align: left;
}

.offline-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    font-size: 14px;
}

.offline-stat-row + .offline-stat-row {
    border-top: 1px solid rgba(255,255,255,0.04);
}

.offline-stat-label {
    color: var(--text-dim);
}

.offline-stat-value {
    font-family: var(--font-display);
    font-weight: 700;
}

.offline-stat-value.gold { color: var(--gold); }
.offline-stat-value.xp { color: var(--xp-blue); }
.offline-stat-value.monsters { color: var(--ember); }
.offline-stat-value.floors { color: var(--flame); }

.offline-stat-highlight {
    font-size: 17px;
    color: var(--gold);
    font-weight: 800;
    letter-spacing: 0.5px;
}

.offline-modal-actions {
    display: flex;
    gap: 10px;
}

.offline-2x-btn {
    flex: 1;
    padding: 10px 8px;
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 12px;
    cursor: not-allowed;
    opacity: 0.55;
    position: relative;
}

.offline-2x-btn:hover {
    opacity: 0.7;
}

/* Active state when portal SDK is available */
.offline-2x-btn.active {
    background: linear-gradient(135deg, #b45309, #d97706);
    border-color: rgba(251,191,36,0.5);
    color: #fff;
    cursor: pointer;
    opacity: 1;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 0 14px rgba(251,191,36,0.25);
}
.offline-2x-btn.active:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 0 22px rgba(251,191,36,0.45);
}
.offline-2x-btn.active:active { transform: scale(0.97); }

/* Rate-limited state: shows countdown */
.offline-2x-btn.rate-limited {
    cursor: not-allowed;
    opacity: 0.65;
    background: var(--surface-light);
    color: var(--text-dim);
    font-size: 11px;
}

.offline-collect-btn {
    flex: 2;
    padding: 10px;
    background: linear-gradient(135deg, var(--flame), var(--ember));
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.offline-collect-btn:hover {
    background: linear-gradient(135deg, var(--ember), var(--flame));
    transform: translateY(-1px);
}

/* Leaderboard prestige star badge */
.lb-prestige {
    font-size: 10px;
    color: #c084fc;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

/* ===== ACHIEVEMENTS TAB ===== */
.achievement-summary {
    background: var(--surface-light);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.achievement-summary-icon { font-size: 26px; }
.achievement-summary-text { flex: 1; }
.achievement-summary-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}
.achievement-summary-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}
.achievement-summary-gems {
    font-family: var(--font-display);
    font-weight: 700;
    color: #00BFFF;
    font-size: 16px;
    text-align: right;
}
.achievement-summary-gems-label {
    font-size: 10px;
    color: var(--text-dim);
    text-align: right;
    margin-top: 1px;
}
.achievement-category { margin-bottom: 14px; }
.achievement-category-header {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.achievement-card {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: border-color 0.2s;
}
.achievement-card.unlocked {
    border-color: rgba(255,215,0,0.35);
    background: linear-gradient(135deg, rgba(255,215,0,0.05), var(--surface-light));
}
.achievement-card.locked { opacity: 0.55; }
.achievement-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}
.achievement-card.locked .achievement-icon {
    filter: grayscale(1);
    opacity: 0.4;
}
.achievement-info { flex: 1; min-width: 0; }
.achievement-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.achievement-card.unlocked .achievement-name { color: var(--gold); }
.achievement-desc {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 1px;
}
.achievement-progress-bar {
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}
.achievement-progress-fill {
    height: 100%;
    background: var(--flame);
    border-radius: 2px;
}
.achievement-reward {
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    color: #00BFFF;
    white-space: nowrap;
    text-align: right;
}
.achievement-reward.earned { color: var(--gold); }
.achievement-check {
    font-size: 15px;
    flex-shrink: 0;
    margin-left: -2px;
}
.toast.achievement {
    border-color: rgba(255,215,0,0.5);
    background: linear-gradient(135deg, rgba(255,215,0,0.08), var(--surface));
}
@media (max-width: 520px) {
    .achievement-name { font-size: 12px; }
    .achievement-icon { font-size: 18px; width: 26px; }
}

/* ===== EQUIPMENT UPGRADE SYSTEM ===== */
.equip-level-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    background: linear-gradient(135deg, #22aa55, #18883f);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    font-family: var(--font-display);
    border-radius: 4px;
    padding: 1px 4px;
    line-height: 1.4;
    pointer-events: none;
    z-index: 2;
}

.equip-upgrade-btn {
    margin-top: 4px;
    padding: 3px 7px;
    border: none;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-display);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.equip-upgrade-gold {
    background: linear-gradient(135deg, #c8921a, #a87010);
    color: #fff;
    border: 1px solid rgba(255,200,60,0.4);
}
.equip-upgrade-gold:hover:not(.equip-upgrade-disabled) {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.equip-upgrade-gem {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: #fff;
    border: 1px solid rgba(167,100,255,0.5);
}
.equip-upgrade-gem:hover:not(.equip-upgrade-disabled) {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.equip-upgrade-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.equip-maxed-label {
    margin-top: 4px;
    font-size: 9px;
    font-weight: 800;
    color: #FFD700;
    font-family: var(--font-display);
    text-align: center;
    text-shadow: 0 0 6px rgba(255,215,0,0.7);
}

/* Upgrade flash animation */
@keyframes equip-upgrade-flash {
    0%   { box-shadow: 0 0 0 0 rgba(68,204,102,0.8); background: rgba(68,204,102,0.15); }
    40%  { box-shadow: 0 0 16px 4px rgba(68,204,102,0.5); background: rgba(68,204,102,0.25); }
    100% { box-shadow: none; background: var(--surface-light); }
}
.equip-upgrading {
    animation: equip-upgrade-flash 0.7s ease-out forwards;
}

/* Sparkle/glow for max-level items */
@keyframes equip-max-sparkle {
    0%, 100% { box-shadow: 0 0 8px 2px rgba(255,215,0,0.3); }
    50%       { box-shadow: 0 0 18px 5px rgba(255,215,0,0.6); }
}
.equip-max-level {
    animation: equip-max-sparkle 2s ease-in-out infinite;
}
.equip-max-level .slot-icon { opacity: 1; filter: drop-shadow(0 0 4px #FFD700); }

@media (max-width: 520px) {
    .equip-upgrade-btn { font-size: 9px; padding: 2px 5px; }
    .equip-level-badge { font-size: 8px; padding: 1px 3px; }
}

/* ===== SKILL TREE TAB ===== */
.st-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-light);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
}
.st-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}
.st-sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}
.st-header-right { text-align: right; }
.st-points {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    color: #44cc66;
    line-height: 1;
}
.st-points-label {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}
.st-progress-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 14px;
    padding: 0 2px;
}
.st-branch {
    margin-bottom: 16px;
}
.st-branch-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.st-branch-icon { font-size: 14px; }
.st-branch-label { flex: 1; }
.st-branch-progress {
    font-size: 10px;
    color: var(--text-dim);
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 1px 6px;
}
.st-skills {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.st-node {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: border-color 0.2s;
}
.st-node.maxed {
    border-color: rgba(255,215,0,0.35);
    background: linear-gradient(135deg, rgba(255,215,0,0.05), var(--surface-light));
}
.st-node-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}
.st-node-info { flex: 1; min-width: 0; }
.st-node-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.st-node.maxed .st-node-name { color: var(--gold); }
.st-node-desc {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
    line-height: 1.3;
}
.st-node-level {
    margin-top: 4px;
}
.st-star {
    font-size: 9px;
    color: rgba(255,255,255,0.15);
    margin-right: 2px;
}
.st-star.filled {
    color: var(--gold);
    text-shadow: 0 0 4px rgba(255,215,0,0.5);
}
.st-node-action { flex-shrink: 0; text-align: center; min-width: 52px; }
.st-allocate-btn {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    cursor: not-allowed;
    opacity: 0.45;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.st-allocate-btn.can-afford {
    background: rgba(68,204,102,0.15);
    border-color: rgba(68,204,102,0.5);
    color: #44cc66;
    cursor: pointer;
    opacity: 1;
    transition: all 0.15s;
}
.st-allocate-btn.can-afford:hover {
    background: rgba(68,204,102,0.25);
    border-color: rgba(68,204,102,0.8);
}
.st-allocate-btn.can-afford:active {
    transform: scale(0.95);
}
.st-node-maxed {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 10px;
    color: var(--gold);
    letter-spacing: 0.05em;
    padding: 3px 6px;
    background: rgba(255,215,0,0.1);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 5px;
}
.st-reset-row {
    text-align: center;
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.st-reset-btn {
    background: rgba(255,107,43,0.1);
    border: 1px solid rgba(255,107,43,0.3);
    border-radius: 8px;
    color: var(--flame);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 16px;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.st-reset-btn:hover {
    background: rgba(255,107,43,0.2);
    border-color: rgba(255,107,43,0.6);
}
.st-reset-btn:active { transform: scale(0.97); }
.st-reset-note {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 5px;
}

@keyframes st-allocate-flash {
    0%   { background: rgba(68,204,102,0.4); border-color: rgba(68,204,102,0.8); }
    100% { background: var(--surface-light); border-color: rgba(255,255,255,0.06); }
}
.st-node-allocated {
    animation: st-allocate-flash 0.6s ease-out forwards;
}

@media (max-width: 520px) {
    .st-node-name { font-size: 11px; }
    .st-node-icon { font-size: 17px; width: 24px; }
    .st-allocate-btn { font-size: 10px; padding: 3px 6px; }
}

/* ── Daily Challenges Tab ── */
.dc-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    background: var(--surface-light);
    border-radius: 10px;
    padding: 11px 13px;
    margin-bottom: 12px;
    border: 1px solid rgba(255,255,255,0.06);
}
.dc-header-left { flex: 1; }
.dc-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 3px;
}
.dc-subtitle {
    font-size: 11px;
    color: var(--text-dim);
}
.dc-countdown {
    color: var(--flame);
    font-weight: 700;
    font-family: var(--font-display);
}
.dc-header-right { text-align: right; }
.dc-gems-earned {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: #00BFFF;
}
.dc-gems-label {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Challenge cards */
.dc-card {
    background: var(--surface-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}
.dc-card.dc-completed {
    border-color: rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, rgba(255,215,0,0.05) 0%, var(--surface-light) 100%);
}
.dc-card-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.dc-card-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}
.dc-card.dc-completed .dc-card-icon {
    filter: none;
}
.dc-card-info {
    flex: 1;
    min-width: 0;
}
.dc-card-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dc-card.dc-completed .dc-card-name {
    color: var(--gold);
}
.dc-card-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.dc-diff-badge {
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 3px;
    display: inline-block;
}
.dc-card-reward {
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    color: #00BFFF;
    white-space: nowrap;
    text-align: right;
    padding-top: 1px;
}
.dc-card-reward.earned {
    color: var(--gold);
}

/* Progress bar */
.dc-progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.dc-progress-fill {
    height: 100%;
    background: var(--flame);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.dc-progress-text {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
    text-align: right;
}
.dc-complete-text {
    color: var(--gold);
    font-weight: 700;
    font-size: 11px;
    margin-top: 6px;
}

/* All-complete bonus */
.dc-bonus-card {
    background: linear-gradient(135deg, rgba(255,215,0,0.12) 0%, rgba(255,107,43,0.08) 100%);
    border: 1px solid rgba(255,215,0,0.5);
    border-radius: 10px;
    padding: 11px 14px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dc-bonus-icon { font-size: 22px; }
.dc-bonus-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: var(--gold);
}
.dc-bonus-hint {
    background: var(--surface-light);
    border: 1px dashed rgba(255,215,0,0.25);
    border-radius: 8px;
    padding: 9px 12px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
}
.dc-bonus-hint strong { color: var(--gold); }

@media (max-width: 520px) {
    .dc-card-name { font-size: 12px; }
    .dc-card-icon { font-size: 18px; width: 26px; }
    .dc-gems-earned { font-size: 14px; }
}

/* ── Combo / Kill-Streak Counter ─────────────────────────────────────────── */
.combo-counter {
    position: absolute;
    top: 10px;
    right: 14px;
    text-align: center;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.25s ease;
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.5));
}
.combo-counter.hidden { opacity: 0; }

.combo-number {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 700;
    color: #FFD700;
    line-height: 1;
    text-shadow: 0 0 14px rgba(255,215,0,0.75), 0 2px 4px rgba(0,0,0,0.7);
}
.combo-label {
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin-top: 1px;
}

/* Tier sizing — escalates with streak */
.combo-counter.tier-1 .combo-number { color: #FFD700; font-size: 34px; }
.combo-counter.tier-2 .combo-number { color: #FFB700; font-size: 40px; text-shadow: 0 0 16px rgba(255,183,0,0.8), 0 2px 4px rgba(0,0,0,0.7); }
.combo-counter.tier-3 .combo-number { color: #FF8C00; font-size: 48px; text-shadow: 0 0 20px rgba(255,140,0,0.85), 0 2px 4px rgba(0,0,0,0.7); }
.combo-counter.tier-4 .combo-number { color: #C060FF; font-size: 56px; text-shadow: 0 0 24px rgba(192,96,255,0.9), 0 2px 4px rgba(0,0,0,0.7); }
.combo-counter.tier-5 .combo-number { font-size: 62px; animation: combo-rainbow 1.0s linear infinite; }

/* Bump animation on each increment */
@keyframes combo-bump {
    0%   { transform: scale(1.0); }
    30%  { transform: scale(1.45); }
    65%  { transform: scale(1.1); }
    100% { transform: scale(1.0); }
}
.combo-bump { animation: combo-bump 0.22s ease-out; }

/* Rainbow for x100+ */
@keyframes combo-rainbow {
    0%   { color: #FF2060; text-shadow: 0 0 20px #FF2060; }
    16%  { color: #FF8C00; text-shadow: 0 0 20px #FF8C00; }
    33%  { color: #FFD700; text-shadow: 0 0 20px #FFD700; }
    50%  { color: #00FF80; text-shadow: 0 0 20px #00FF80; }
    66%  { color: #00CFFF; text-shadow: 0 0 20px #00CFFF; }
    83%  { color: #A855F7; text-shadow: 0 0 20px #A855F7; }
    100% { color: #FF2060; text-shadow: 0 0 20px #FF2060; }
}

@media (max-width: 520px) {
    .combo-counter.tier-1 .combo-number { font-size: 26px; }
    .combo-counter.tier-2 .combo-number { font-size: 30px; }
    .combo-counter.tier-3 .combo-number { font-size: 36px; }
    .combo-counter.tier-4 .combo-number { font-size: 42px; }
    .combo-counter.tier-5 .combo-number { font-size: 46px; }
}

/* ── Endless Mode ─────────────────────────────────────────────────────────── */
.endless-btn-area {
    margin: 12px 0 4px;
    padding: 14px 14px 12px;
    background: linear-gradient(135deg, rgba(255,69,0,0.12), rgba(255,107,43,0.06));
    border: 1px solid rgba(255,107,43,0.35);
    border-radius: 10px;
    text-align: center;
}
.endless-unlock-badge {
    font-size: 11px;
    color: #FF6B2B;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    text-transform: uppercase;
}
.endless-start-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #FF4500, #FF6B2B);
    color: #fff;
    font-family: var(--font-display, sans-serif);
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
    box-shadow: 0 3px 14px rgba(255,69,0,0.35);
}
.endless-start-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.endless-start-btn:active { transform: translateY(0); }
.endless-hint {
    margin-top: 7px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
}

/* ── Endless Overlays ───────────────────────────────────────────────────── */
.endless-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
    animation: fadeIn 0.25s ease;
}
.endless-overlay.hidden { display: none; }
.endless-overlay-box {
    background: var(--surface, #13131f);
    border: 2px solid #FF4500;
    border-radius: 16px;
    padding: 28px 24px 22px;
    text-align: center;
    max-width: 340px;
    width: 92%;
    animation: popIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
.endless-overlay-icon { font-size: 38px; margin-bottom: 6px; }
.endless-overlay-title {
    font-family: var(--font-display, sans-serif);
    font-size: 22px;
    font-weight: 700;
    color: var(--text, #E8E8F0);
    margin: 0 0 6px;
}
.endless-overlay-sub {
    font-size: 14px;
    color: var(--text-dim, #888);
    margin: 0 0 18px;
}
.endless-overlay-sub strong { color: #FF6B2B; }
.endless-co-ad-row { margin-bottom: 10px; }
.endless-revive-btn {
    display: block;
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-family: var(--font-display, sans-serif);
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: opacity 0.2s;
    box-shadow: 0 3px 14px rgba(34,197,94,0.35);
    animation: pulse-green 2s infinite;
}
.endless-revive-btn:hover { opacity: 0.9; }
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 3px 14px rgba(34,197,94,0.35); }
    50%       { box-shadow: 0 3px 22px rgba(34,197,94,0.60); }
}
.endless-revive-hint {
    font-size: 11px;
    color: var(--text-dim, #888);
    margin-top: 5px;
}
.endless-end-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    background: rgba(255,255,255,0.05);
    color: var(--text-dim, #888);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.endless-end-btn:hover { background: rgba(255,255,255,0.09); }

/* Run summary */
.endless-result-grid {
    background: rgba(255,107,43,0.07);
    border: 1px solid rgba(255,107,43,0.18);
    border-radius: 10px;
    padding: 14px 16px;
    margin: 14px 0 18px;
}
.endless-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.endless-result-row:last-child { border-bottom: none; }
.endless-result-label { font-size: 13px; color: var(--text-dim, #888); }
.endless-result-val { font-size: 15px; font-weight: 700; color: #FF6B2B; font-family: var(--font-display, sans-serif); }
.endless-new-best {
    background: linear-gradient(135deg, #FFD700, #FF6B2B);
    color: #000;
    font-size: 13px;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
    display: inline-block;
    letter-spacing: 0.3px;
}
.endless-new-best.hidden { display: none; }
.endless-play-again-btn {
    display: block;
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #FF4500, #FF6B2B);
    color: #fff;
    font-family: var(--font-display, sans-serif);
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    margin-bottom: 8px;
    box-shadow: 0 3px 14px rgba(255,69,0,0.35);
    transition: opacity 0.2s;
}
.endless-play-again-btn:hover { opacity: 0.9; }
.endless-story-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--text-dim, #888);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.endless-story-btn:hover { background: rgba(255,255,255,0.06); }
