:root {
    --primary-color: #FF9F1C;
    --secondary-color: #2EC4B6;
    --accent-color: #E71D36;
    --light-color: #FDFFFC;
    --dark-color: #011627;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #87CEEB; /* Sky blue fallback */
}

canvas {
    display: block;
    touch-action: none; /* Prevent default touch actions like scrolling */
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100; /* Ensure UI is on top of canvas/everything */
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    pointer-events: auto;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}

#start-screen {
    justify-content: flex-start;
    padding: 30px 20px 40px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: center;
    text-align: center;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

#game-over-screen {
    pointer-events: auto;
}

.hidden {
    opacity: 0;
    pointer-events: none;
    display: none; /* simple hide */
}

h1 {
    font-size: 3rem; /* Reduced from 4rem */
    text-shadow: 3px 3px 0px var(--primary-color);
    margin-bottom: 10px;
    font-weight: 900;
    text-align: center;
    padding: 0 20px;
    max-width: 100%;
    box-sizing: border-box;
}

/* Optional: Make the highscore list on start screen look good */
.highscore-container {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    margin-top: 30px; /* Added spacing between start button and highscore */
    width: 100%; /* Use full available width up to max-width */
    max-width: 340px; /* Slightly wider */
    box-sizing: border-box;
}
.highscore-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
}
.highscore-container ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1.1rem;
    max-height: 150px;
    overflow-y: auto;
}
.highscore-container li {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

p {
    font-size: 1.5rem;
    margin-bottom: 30px;
    text-align: center;
    padding: 0 20px;
    max-width: 100%;
    box-sizing: border-box;
}

#settings-panel {
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.2);
    padding: 16px 18px;
    border-radius: 16px;
    width: min(520px, 90%);
    margin-bottom: 18px;
}

#settings-panel.hidden {
    display: none;
}

#settings-panel h3 {
    margin: 0 0 6px 0;
    font-size: 1.4rem;
}

.settings-hint {
    font-size: 1rem;
    margin: 0 0 10px 0;
    color: #fff2cf;
}

#words-input {
    width: 100%;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 10px 12px;
    font-size: 1rem;
    resize: vertical;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.settings-actions button {
    font-size: 1rem;
    padding: 10px 18px;
}

#settings-toggle-btn {
    background: #ff9fd2;
    box-shadow: 0 6px 0 #b85a87;
    font-size: 1.1rem;
    margin-bottom: 14px;
}

button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #1b8a7f;
    transition: transform 0.1s, box-shadow 0.1s;
    font-weight: bold;
    margin-top: 10px;
}

button:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #1b8a7f;
}

button:hover {
    background-color: #3ddbdc;
}

#score-display {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 0px));
    right: max(20px, env(safe-area-inset-right, 0px));
    font-size: 2rem;
    color: white;
    background: rgba(0,0,0,0.45);
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid rgba(255, 215, 0, 0.6);
}

.coin-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff6b3, #ffd700 55%, #c98a00 100%);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.6), 0 2px 6px rgba(0,0,0,0.3);
    border: 2px solid #b87700;
}

.coin-label {
    font-size: 1.3rem;
    color: #ffe8a3;
}

.coin-fly {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff6b3, #ffd700 55%, #c98a00 100%);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.6), 0 2px 6px rgba(0,0,0,0.3);
    border: 2px solid #b87700;
    transition: left 1.6s ease-in-out, top 1.6s ease-in-out, opacity 1.6s ease-in-out;
    pointer-events: none;
    z-index: 10;
}

.help-bubble {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fffaf0;
    border: 4px solid #ff9cc2;
    color: #111;
    font-size: 1.6rem;
    font-weight: 800;
    padding: 10px 22px;
    border-radius: 22px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 20;
}

.help-bubble::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -14px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 14px solid #fffaf0;
}

#speak-btn,
#music-toggle-btn {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 0px));
    left: max(20px, env(safe-area-inset-left, 0px));
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 110;
    transition: transform 0.2s;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#music-toggle-btn {
    left: max(80px, calc(env(safe-area-inset-left, 0px) + 60px));
}

#speak-btn:active,
#music-toggle-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#speak-btn.hidden,
#music-toggle-btn.hidden {
    display: none;
}

.highscore-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    pointer-events: auto;
    width: 90%;
    max-width: 380px;
    box-sizing: border-box;
    flex-wrap: wrap;
    justify-content: center;
}

#save-score-btn {
    min-width: 120px;
    min-height: 48px;
    padding: 12px 20px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

#player-name {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

input {
    padding: 10px 14px;
    font-size: 1.1rem;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    box-sizing: border-box;
}

#highscore-list {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 15px;
    width: 300px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 20px;
}

#highscore-ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

#highscore-ul li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    display: flex;
    justify-content: space-between;
}

#shop-items {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 16px 0 10px 0;
}

.shop-item {
    background: #ffb347;
    box-shadow: 0 6px 0 #c57a1a;
    font-size: 1.1rem;
}

.shop-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- SET SELECTION CARDS --- */
#set-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin-bottom: 16px;
    padding: 0 20px;
    box-sizing: border-box;
}

.set-card {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 14px;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 400px;
    text-align: center;
    pointer-events: auto;
    box-sizing: border-box;
}

.set-card:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
}

.set-card.selected {
    background: rgba(255, 159, 28, 0.3);
    border-color: #ffd700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

.set-card-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.set-card-count {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* --- SETTINGS SET MANAGEMENT --- */
#sets-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.settings-set-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px 14px;
}

.settings-set-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-set-name {
    font-weight: bold;
    font-size: 1rem;
}

.settings-set-count {
    font-size: 0.85rem;
    opacity: 0.6;
}

.settings-set-actions {
    display: flex;
    gap: 6px;
}

.set-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1rem;
    cursor: pointer;
    color: white;
    min-width: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    margin: 0;
}

.set-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.set-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.settings-btn-add {
    background: var(--secondary-color);
    width: 100%;
    padding: 12px;
    font-size: 1.05rem;
    margin-top: 4px;
    margin-bottom: 10px;
}

#set-editor {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 14px;
    margin-top: 10px;
}

#set-editor.hidden {
    display: none;
}

/* =========================================================
   WALLET / SHOP / INVENTORY / LOADOUT
   ========================================================= */

#wallet-display {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 0px));
    /* Sit to the LEFT of #score-display (which is anchored to the right edge).
       The score badge is roughly 170\u2013200px wide \u2014 give a bit of breathing room. */
    right: calc(max(20px, env(safe-area-inset-right, 0px)) + 220px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px 10px 14px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(255, 159, 28, 0.25));
    border: 2px solid rgba(255, 215, 0, 0.65);
    border-radius: 18px;
    color: #fff8d6;
    font-size: 1.4rem;
    font-weight: 800;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    z-index: 105;
    pointer-events: auto;
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.coin-icon--big {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* Hide in-game score display while any full-screen overlay is shown.
   Uses :has() (modern browsers) + JS fallback toggles .hidden too. */
#ui-container:has(.overlay:not(.hidden)) #score-display {
    display: none;
}

/* Hide the floating wallet badge while the shop overlay is open
   (the shop already shows its own wallet pill and the badge would
   cover the close button on mobile). */
#ui-container:has(#shop-screen:not(.hidden)) #wallet-display {
    display: none;
}

/* ---- Game over wallet line ---- */
.wallet-summary {
    font-size: 1.15rem;
    margin: 6px 0 22px 0;
    color: #ffe28a;
    text-shadow: 1px 1px 0 #000;
}

.game-over-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.secondary-btn {
    background: #ff9fd2 !important;
    box-shadow: 0 6px 0 #b85a87 !important;
}

/* ---- Loadout bar on start screen ---- */
#loadout-bar {
    display: flex;
    gap: 8px;
    margin: 14px 0 10px 0;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 16px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 420px;
    width: 100%;
    box-sizing: border-box;
}

.loadout-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.loadout-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.loadout-value {
    font-size: 1.4rem;
    margin-top: 2px;
}

#open-shop-btn,
#open-shop-btn-2 {
    background: linear-gradient(135deg, #ff9f1c, #ff6b35);
    box-shadow: 0 6px 0 #a0431b;
    margin-top: 6px;
}

/* ---- Shop overlay ---- */
#shop-screen {
    justify-content: flex-start;
    padding: 20px 16px 60px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    background: rgba(8, 12, 30, 0.85);
}

.shop-header {
    width: 100%;
    max-width: 720px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 4px 14px 4px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.4);
    margin-bottom: 14px;
}

.shop-header h2 {
    margin: 0;
    font-size: 1.6rem;
    text-shadow: 2px 2px 0 var(--primary-color);
    flex: 1;
    text-align: left;
}

.shop-wallet {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 215, 0, 0.18);
    border: 2px solid rgba(255, 215, 0, 0.55);
    padding: 6px 14px;
    border-radius: 14px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff8d6;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.3rem;
    padding: 0;
    margin: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.shop-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 14px;
    width: 100%;
    max-width: 720px;
}

.shop-tab {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 18px;
    font-size: 1rem;
    margin: 0;
    cursor: pointer;
    transition: all 0.18s;
}

.shop-tab:hover {
    background: rgba(255, 255, 255, 0.18);
}

.shop-tab.active {
    background: linear-gradient(135deg, var(--primary-color), #ff6b35);
    border-color: #ffd700;
    box-shadow: 0 4px 0 #a0431b;
    color: #fff;
}

#shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 720px;
    margin-bottom: 16px;
}

.shop-card {
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 14px 10px 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    cursor: pointer;
    pointer-events: auto;
    min-height: 170px;
    position: relative;
}

.shop-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.12);
}

.shop-card.owned {
    border-color: rgba(80, 220, 120, 0.6);
}

.shop-card.equipped {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.18);
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.4);
}

.shop-card.locked {
    opacity: 0.55;
}

.shop-card-emoji {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 6px;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
}

.shop-card-name {
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 2px;
}

.shop-card-desc {
    font-size: 0.78rem;
    opacity: 0.75;
    margin-bottom: 8px;
    min-height: 28px;
    line-height: 1.2;
}

.shop-card-action {
    margin-top: auto;
    padding: 6px 12px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

.shop-card-action.buy {
    background: #ffb347;
    color: #3a1f00;
    box-shadow: 0 3px 0 #b87a1a;
}

.shop-card-action.buy:disabled {
    background: #777;
    color: #ddd;
    box-shadow: 0 3px 0 #444;
    cursor: not-allowed;
}

.shop-card-action.equip {
    background: var(--secondary-color);
    color: #fff;
    box-shadow: 0 3px 0 #1b8a7f;
}

.shop-card-action.equipped {
    background: #ffd700;
    color: #3a1f00;
    box-shadow: 0 3px 0 #b87a1a;
}

.shop-card-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 1rem;
}

.shop-hint {
    font-size: 0.95rem;
    opacity: 0.7;
    text-align: center;
    max-width: 600px;
}

/* ---- Gadget action button (in-game) ---- */
#gadget-action-btn {
    position: absolute;
    bottom: max(28px, env(safe-area-inset-bottom, 0px));
    right: max(28px, env(safe-area-inset-right, 0px));
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 28%, #fff5b1 0%, #ffd84d 38%, #ff9f1c 75%, #d97a00 100%);
    border: 3px solid #fff;
    color: #3a1f00;
    font-size: 2.1rem;
    cursor: pointer;
    pointer-events: auto;
    z-index: 110;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.45),
        0 0 0 4px rgba(255, 200, 60, 0.25),
        inset 0 -4px 8px rgba(180, 90, 0, 0.35),
        inset 0 3px 6px rgba(255, 255, 255, 0.5);
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.08s ease, box-shadow 0.12s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    animation: gadgetPulse 2.4s ease-in-out infinite;
}

#gadget-action-btn::after {
    content: 'A';
    position: absolute;
    top: -6px;
    right: -6px;
    background: #1f6feb;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}

#gadget-action-btn:active,
#gadget-action-btn.pressed {
    transform: scale(0.9);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.4),
        inset 0 4px 8px rgba(180, 90, 0, 0.4);
    animation: none;
}

#gadget-action-btn.hidden {
    display: none;
}

@keyframes gadgetPulse {
    0%, 100% { box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.45),
        0 0 0 4px rgba(255, 200, 60, 0.25),
        inset 0 -4px 8px rgba(180, 90, 0, 0.35),
        inset 0 3px 6px rgba(255, 255, 255, 0.5); }
    50%      { box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.5),
        0 0 0 8px rgba(255, 200, 60, 0.18),
        inset 0 -4px 8px rgba(180, 90, 0, 0.35),
        inset 0 3px 6px rgba(255, 255, 255, 0.55); }
}

/* Smaller on phones so it never crowds the play area */
@media (max-width: 600px) {
    #gadget-action-btn {
        width: 64px;
        height: 64px;
        font-size: 1.7rem;
        bottom: max(18px, env(safe-area-inset-bottom, 0px));
        right: max(16px, env(safe-area-inset-right, 0px));
    }
    #gadget-action-btn::after {
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
    }
}

/* ---- Coin pop animation when collecting ---- */
@keyframes coinPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); color: #ffe066; }
    100% { transform: scale(1); }
}

.coin-pop {
    animation: coinPop 0.35s ease;
}

/* ---- Mobile-optimised shop & loadout ---- */
@media (max-width: 600px) {
    /* Wallet badge a bit smaller so it doesn't crowd top corner */
    #wallet-display {
        font-size: 1.05rem;
        padding: 6px 12px 6px 10px;
        gap: 6px;
        top: max(10px, env(safe-area-inset-top, 0px));
        /* Sit to the LEFT of the smaller mobile score badge */
        right: calc(max(10px, env(safe-area-inset-right, 0px)) + 150px);
        border-radius: 14px;
    }
    .coin-icon--big { width: 22px; height: 22px; border-width: 2px; }

    /* Loadout bar: 3 even slots side-by-side, no overflow */
    #loadout-bar {
        gap: 6px;
        padding: 8px;
        margin: 10px 0 8px 0;
        max-width: 100%;
        flex-wrap: nowrap;
    }
    .loadout-slot {
        min-width: 0;
        flex: 1 1 0;
        padding: 6px 4px;
    }
    .loadout-label { font-size: 0.65rem; }
    .loadout-value { font-size: 1.25rem; }

    /* Shop overlay: tighter padding, room for header */
    #shop-screen {
        padding: 14px 10px 80px;
    }
    .shop-header {
        padding: 4px 0 10px 0;
        margin-bottom: 10px;
        gap: 8px;
    }
    .shop-header h2 { font-size: 1.15rem; }
    .shop-wallet {
        font-size: 1rem;
        padding: 4px 10px;
        border-radius: 12px;
    }
    .icon-btn { width: 38px; height: 38px; font-size: 1.1rem; }

    /* Tabs: scrollable row instead of wrapping */
    .shop-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        scrollbar-width: none;
        padding-bottom: 4px;
        margin-bottom: 10px;
    }
    .shop-tabs::-webkit-scrollbar { display: none; }
    .shop-tab {
        flex: 0 0 auto;
        padding: 8px 14px;
        font-size: 0.95rem;
        white-space: nowrap;
    }

    /* Grid: always 2 columns, tighter gaps */
    #shop-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .shop-card {
        padding: 10px 8px 8px 8px;
        min-height: 158px;
        border-radius: 14px;
    }
    .shop-card-emoji { font-size: 2.4rem; margin-bottom: 4px; }
    .shop-card-name { font-size: 0.92rem; }
    .shop-card-desc { font-size: 0.7rem; min-height: 30px; }
    .shop-card-action {
        padding: 6px 10px;
        font-size: 0.85rem;
        width: 100%;
    }
    .shop-hint { font-size: 0.85rem; padding: 0 10px; }

    h1 { font-size: 2.2rem; }
}

/* Very small phones: tighten further but still readable */
@media (max-width: 360px) {
    #shop-grid { gap: 8px; }
    .shop-card { min-height: 150px; padding: 8px 6px; }
    .shop-card-emoji { font-size: 2.1rem; }
    .shop-card-name { font-size: 0.85rem; }
    .loadout-value { font-size: 1.1rem; }
}
