* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}
body { background: #000; overflow: hidden; font-family: 'Press Start 2P', cursive; cursor: crosshair; -webkit-tap-highlight-color: transparent; }
canvas { display: block; touch-action: none; }

/* SVG Icon System */
.svg-icon { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; line-height: 1; }
.svg-icon svg { display: block; }
.rs-stat-icon .svg-icon { display: flex; align-items: center; justify-content: center; }
.inv-icon .svg-icon { display: flex; align-items: center; justify-content: center; }

/* HUD */
#ui { position: absolute; top: calc(10px + var(--safe-top)); left: 50%; transform: translateX(-50%); pointer-events: none; z-index: 10; }
.hud-panel { background: rgba(0,0,30,0.8); border: 1px solid rgba(120,160,255,0.2); border-radius: 14px; padding: 8px 22px; backdrop-filter: blur(10px); display: flex; align-items: center; gap: 18px; box-shadow: 0 2px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04); }
.hud-score-section { text-align: center; }
.hud-score-label { font-size: 7px; color: rgba(255,255,255,0.5); letter-spacing: 2px; text-align: center; margin-bottom: 2px; }
.hud-score-val { font-size: 24px; font-weight: bold; color: #ffd700; text-shadow: 0 0 10px rgba(255,200,50,0.4); text-align: center; }
.hud-combo-row { text-align: center; display: none; margin-top: 2px; }
.hud-combo-row.active { display: block; animation: comboFlash 0.3s ease; }
@keyframes comboFlash { 0%{transform:scale(1.15);} 100%{transform:scale(1);} }
.hud-combo-val { font-size: 13px; font-weight: bold; color: #ff6b6b; text-shadow: 0 0 6px rgba(255,107,107,0.4); }
.hud-v-divider { width: 1px; height: 32px; background: rgba(120,160,255,0.15); flex-shrink: 0; }
.hud-divider { display: none; }
.hud-stats-row { display: flex; align-items: center; gap: 16px; }
.hud-stat-item { text-align: center; }
.hud-stat-label { font-size: 7px; color: rgba(255,255,255,0.5); letter-spacing: 1.5px; display: block; margin-bottom: 2px; }
.hud-stat-val { font-size: 13px; font-weight: bold; display: block; text-shadow: 0 0 6px rgba(0,0,0,0.5); }

/* In-Game Buttons */
#gameButtons { position: absolute; top: calc(15px + var(--safe-top)); right: calc(220px + var(--safe-right)); z-index: 10; display: flex; gap: 8px; align-items: center; }
.hud-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; font-family: 'Press Start 2P', cursive; font-size: 10px; font-weight: normal; padding: 6px 14px; border-radius: 20px; cursor: pointer; transition: all 0.2s; backdrop-filter: blur(4px); letter-spacing: 0.5px; }
.hud-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.4); transform: scale(1.05); }
.hud-btn svg { vertical-align: -2px; margin-right: 2px; }

/* HUD dropdown menu */
.hud-menu { display:none; position:absolute; top:100%; right:0; margin-top:8px; background:rgba(10,10,30,0.95); border:1px solid rgba(255,255,255,0.15); border-radius:10px; padding:6px; backdrop-filter:blur(12px); grid-template-columns:1fr 1fr; gap:3px; min-width:220px; z-index:200; box-shadow:0 8px 32px rgba(0,0,0,0.5); }
.hud-menu-item { display:flex; align-items:center; gap:6px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.08); color:#fff; font-family:'Press Start 2P', cursive; font-size:7px; padding:8px 10px; border-radius:6px; cursor:pointer; transition:all 0.2s; white-space:nowrap; }
.hud-menu-item:hover { background:rgba(255,255,255,0.15); border-color:rgba(255,255,255,0.25); transform:scale(1.03); }
.hud-menu-toggle { position:relative; }

/* Controls & Legend */
#controls { position: absolute; bottom: calc(15px + var(--safe-bottom)); right: calc(15px + var(--safe-right)); color: rgba(255,255,255,0.35); pointer-events: none; z-index: 10; font-size: 8px; text-align: right; line-height: 2.2; }
#legend { position: absolute; bottom: calc(15px + var(--safe-bottom)); left: calc(15px + var(--safe-left)); color: #fff; pointer-events: none; z-index: 10; font-size: 8px; line-height: 2.2; opacity: 0.5; }
.leg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
.leg-diamond { display: inline-block; width: 10px; height: 10px; transform: rotate(45deg); margin-right: 3px; vertical-align: middle; }

/* Message */
#message { position: absolute; top: 45%; left: 50%; transform: translate(-50%,-50%); color: #fff; font-size: 14px; font-weight: bold; text-shadow: 0 0 8px rgba(255,200,50,0.3); pointer-events: none; opacity: 0; transition: opacity 0.3s; z-index: 10; text-align: center; }
#syncToast { position: fixed; bottom: calc(18px + var(--safe-bottom)); left: calc(18px + var(--safe-left)); background: rgba(30,40,60,0.85); color: #8fc; font-size: 13px; padding: 6px 14px; border-radius: 8px; pointer-events: none; opacity: 0; transition: opacity 0.3s; z-index: 30; font-weight: 500; letter-spacing: 0.3px; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* Notification Log */
.notif-log-feed {
    position: fixed; bottom: calc(38px + var(--safe-bottom)); right: calc(10px + var(--safe-right)); z-index: 55;
    display: flex; flex-direction: column-reverse; gap: 2px;
    pointer-events: none; max-height: 120px; overflow: hidden;
    width: 200px;
}
.notif-log-entry {
    font-size: 9px; color: #ccc; padding: 2px 6px;
    background: rgba(10,10,30,0.7); border-radius: 4px;
    border-left: 2px solid rgba(255,200,50,0.4);
    animation: notifFadeIn 0.25s ease;
    transition: opacity 0.5s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes notifFadeIn { from { opacity:0; transform:translateX(10px); } to { opacity:1; transform:translateX(0); } }
.notif-log-btn {
    position: fixed; bottom: calc(10px + var(--safe-bottom)); right: calc(10px + var(--safe-right)); z-index: 56;
    width: 26px; height: 26px; border-radius: 8px;
    background: rgba(10,10,30,0.75); border: 1.5px solid rgba(255,200,50,0.3);
    display: flex; align-items: center; justify-content: center;
    color: #fc8; cursor: pointer; transition: all 0.2s;
    backdrop-filter: blur(6px);
}
.notif-log-btn:hover { background: rgba(255,200,50,0.15); border-color: rgba(255,200,50,0.6); }
.notif-log-btn.has-new { border-color: rgba(255,200,50,0.7); box-shadow: 0 0 8px rgba(255,200,50,0.3); }
.notif-log-panel {
    position: fixed; bottom: calc(40px + var(--safe-bottom)); right: calc(10px + var(--safe-right)); z-index: 200;
    width: 220px; max-height: 250px;
    background: rgba(10,10,30,0.95); border: 1.5px solid rgba(255,200,50,0.3);
    border-radius: 10px; padding: 8px;
    backdrop-filter: blur(12px); box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.notif-log-header {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 9px; font-weight: bold; color: #fc8;
    padding-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 4px;
}
.notif-log-content {
    max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.notif-log-content::-webkit-scrollbar { width: 3px; }
.notif-log-content::-webkit-scrollbar-thumb { background: rgba(255,200,50,0.3); border-radius: 3px; }
.notif-log-item {
    font-size: 8px; color: #aaa; padding: 3px 5px;
    background: rgba(255,255,255,0.03); border-radius: 4px;
    border-left: 2px solid rgba(255,200,50,0.2);
}
.notif-log-item .notif-time { color: #666; font-size: 7px; margin-right: 4px; }

/* Overlays */
.overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 100; overflow-y: auto; }
.overlay.overlay-bg { justify-content: flex-start; padding: 30px 10px 40px; }
.overlay-bg { background: rgba(0,0,0,0.88); }

/* Start Screen */
#startScreen { background: radial-gradient(ellipse at center, #1a0a2e 0%, #000 70%); }
#startScreen h1 { font-size: 36px; color: #ffd700; text-shadow: 0 0 15px rgba(255,200,50,0.35), 0 0 30px rgba(255,100,50,0.15); margin-bottom: 8px; letter-spacing: 4px; }
#startScreen .subtitle { font-size: 12px; color: #aab; margin-bottom: 30px; }
.instructions { margin-top: 25px; color: #889; font-size: 9px; text-align: center; line-height: 2.2; }
.credit { margin-top: 20px; font-size: 8px; color: rgba(255,255,255,0.2); letter-spacing: 1px; }

/* Buttons */
.btn { font-size: 14px; padding: 12px 40px; color: #fff; border: none; border-radius: 50px; cursor: pointer; font-weight: normal; letter-spacing: 1px; text-transform: uppercase; transition: all 0.2s; margin: 6px; }
.btn:hover { transform: scale(1.08); }
.btn-yeet { background: linear-gradient(135deg, #ff6b35, #ff3366); box-shadow: 0 0 15px rgba(255,50,100,0.25); }
.btn-yeet:hover { box-shadow: 0 0 25px rgba(255,50,100,0.45); }
.btn-blue { background: linear-gradient(135deg, #35c9ff, #3366ff); box-shadow: 0 0 15px rgba(50,100,255,0.25); }
.btn-blue:hover { box-shadow: 0 0 25px rgba(50,100,255,0.45); }
.btn-green { background: linear-gradient(135deg, #35ff6b, #33cc66); box-shadow: 0 0 15px rgba(50,255,100,0.25); font-size: 11px; padding: 10px 30px; }
.btn-green:hover { box-shadow: 0 0 25px rgba(50,255,100,0.45); }
.btn-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); box-shadow: 0 0 15px rgba(120,50,255,0.25); }
.btn-purple:hover { box-shadow: 0 0 25px rgba(120,50,255,0.45); }
.btn-small { font-size: 10px; padding: 8px 20px; letter-spacing: 1px; }
.btn:disabled { opacity: 0.35; cursor: default; transform: none !important; }

/* Shop */
#shopScreen h2 { font-size: 24px; color: #ffd700; text-shadow: 0 0 10px rgba(255,200,50,0.3); margin-bottom: 5px; }
.roundComplete { font-size: 12px; color: #7bf; margin-bottom: 5px; }
.shopCoins { font-size: 14px; color: #ffd700; margin-bottom: 15px; }
.section-title { font-size: 11px; color: #aab; margin: 15px 0 8px; text-transform: uppercase; letter-spacing: 2px; }
.shop-layout { display:flex; gap:15px; max-width:950px; width:96%; margin-bottom:10px; flex:1; min-height:0; overflow:hidden; }
.shop-nav { position:sticky; top:10px; min-width:130px; max-width:140px; align-self:flex-start; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.06); border-radius:10px; padding:8px 0; flex-shrink:0; }
.shop-nav-item { display:block; width:100%; text-align:left; background:none; border:none; color:rgba(255,255,255,0.4); font-family:'Press Start 2P',cursive; font-size:7px; padding:7px 12px; cursor:pointer; transition:all 0.15s; border-left:2px solid transparent; }
.shop-nav-item:hover { color:rgba(255,255,255,0.7); background:rgba(255,255,255,0.03); }
.shop-nav-item.shop-nav-active { color:#7bf; border-left-color:#7bf; background:rgba(100,180,255,0.06); }
.shop-main { flex:1; min-width:0; overflow-y:auto; padding-right:5px; }
.shop-section { scroll-margin-top:10px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; width: 100%; margin-bottom: 10px; }
.shop-item { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 12px; text-align: center; transition: all 0.2s; }
.shop-item:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); }
.shop-item.maxed { opacity: 0.4; }
.shop-item.owned { border-color: rgba(100,255,100,0.3); }
.shop-item .name { color: #fff; font-size: 10px; font-weight: bold; margin-bottom: 3px; }
.shop-item .desc { color: #aaa; font-size: 8px; margin-bottom: 5px; min-height: 28px; }
.shop-item .level { color: #7bf; font-size: 8px; margin-bottom: 6px; }
.shop-item .cost { color: #ffd700; font-size: 9px; margin-bottom: 6px; }

/* Game Over */
#gameOver h2 { font-size: 28px; color: #ff6b6b; text-shadow: 0 0 10px rgba(255,100,100,0.3); margin-bottom: 8px; }
.finalScore { font-size: 18px; color: #ffd700; margin-bottom: 5px; }
.stats { color: #aaa; font-size: 10px; margin-bottom: 20px; line-height: 2; }

/* Crew Screen */
#crewScreen h2 { font-size: 24px; color: #a78bfa; text-shadow: 0 0 10px rgba(167,139,250,0.3); margin-bottom: 5px; }
.crew-subtitle { color: #aab; font-size: 9px; margin-bottom: 15px; }
.crew-list { display: flex; flex-wrap: wrap; gap: 12px; max-width: 650px; justify-content: center; margin-bottom: 20px; }
.crew-card { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 12px; width: 130px; text-align: center; }
.crew-card canvas { display: block; margin: 0 auto 6px; border-radius: 8px; background: rgba(0,0,30,0.5); }
.crew-card .cname { color: #fff; font-size: 9px; font-weight: bold; }
.crew-card .crew-btns { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }
.crew-card .crew-btns button { font-size: 7px; padding: 4px 8px; cursor: pointer; border: none; border-radius: 6px; color: #fff; font-weight: bold; font-family: 'Press Start 2P', cursive; }
.crew-card .crew-btns .edit-btn { background: #3b82f6; }
.crew-card .crew-btns .del-btn { background: #ef4444; }
.active-toggle { display: block; width: 90%; margin: 6px auto 0; padding: 3px 8px; font-size: 7px; font-weight: bold; border: none; border-radius: 10px; cursor: pointer; color: #fff; text-transform: uppercase; letter-spacing: 0.5px; transition: all 0.15s; font-family: 'Press Start 2P', cursive; }
.active-on { background: #27ae60; }
.active-off { background: #555; }
.active-toggle:hover { transform: scale(1.08); }
.crew-card.crew-inactive { opacity: 0.45; }
.crew-card.crew-inactive canvas { filter: grayscale(0.6); }
.shop-item.selected-galaxy { border-color: rgba(100,180,255,0.5); background: rgba(100,180,255,0.08); }

/* Galaxy Cards with Preview */
.galaxy-card { position:relative; border-radius:12px; overflow:hidden; transition:all 0.3s; border:2px solid rgba(255,255,255,0.08); }
.galaxy-card canvas { display:block; width:100%; height:120px; }
.galaxy-card .galaxy-card-info { padding:10px 12px; background:rgba(0,0,0,0.5); position:relative; z-index:1; }
.galaxy-card .name { color:#fff; font-size:10px; font-weight:bold; margin-bottom:3px; }
.galaxy-card .desc { color:#aaa; font-size:8px; margin-bottom:5px; min-height:28px; }
.galaxy-card .cost { font-size:9px; margin-bottom:6px; }
.galaxy-card .galaxy-entities { color:#778; font-size:7px; margin-bottom:5px; }
/* Locked galaxy - heavily grayed out */
.galaxy-card.galaxy-locked { filter:grayscale(0.85) brightness(0.35); border-color:rgba(255,255,255,0.05); }
.galaxy-card.galaxy-locked:hover { filter:grayscale(0.7) brightness(0.5); }
/* Affordable galaxy - can buy, highlighted */
.galaxy-card.galaxy-affordable { filter:none; border-color:rgba(255,215,0,0.5); box-shadow:0 0 12px rgba(255,215,0,0.15); }
.galaxy-card.galaxy-affordable:hover { border-color:rgba(255,215,0,0.8); box-shadow:0 0 20px rgba(255,215,0,0.3); }
.galaxy-card.galaxy-affordable .btn { opacity:1; box-shadow:0 0 10px rgba(50,255,100,0.3); }
/* Owned but not active */
.galaxy-card.galaxy-owned { filter:grayscale(0.3) brightness(0.7); border-color:rgba(100,255,100,0.2); }
.galaxy-card.galaxy-owned:hover { filter:grayscale(0.1) brightness(0.85); }
/* Currently active galaxy */
.galaxy-card.galaxy-active-card { filter:none; border-color:rgba(100,200,255,0.7); box-shadow:0 0 15px rgba(100,200,255,0.25), inset 0 0 20px rgba(100,200,255,0.05); }
.galaxy-card.galaxy-active-card:hover { box-shadow:0 0 25px rgba(100,200,255,0.4); }

/* Settings */
#settingsModal { display:none; }
#settingsModal .settings-content { background:rgba(10,0,40,0.95); border:2px solid rgba(100,150,255,0.3); border-radius:16px; padding:30px 35px; max-width:420px; width:92%; text-align:center; box-shadow:0 0 30px rgba(50,100,255,0.15); }
#settingsModal h2 { font-size:18px; color:#7bf; text-shadow:0 0 10px rgba(100,180,255,0.3); margin-bottom:20px; }
.settings-group { margin-bottom:18px; text-align:left; }
.settings-group label { color:#aab; font-size:9px; display:block; margin-bottom:6px; }
.settings-row { display:flex; align-items:center; gap:12px; margin-bottom:10px; }
.settings-row label { flex:0 0 80px; margin-bottom:0; }
.settings-row input[type="range"] { flex:1; accent-color:#7bf; height:6px; }
.settings-row .vol-value { color:#7bf; font-size:9px; min-width:30px; text-align:right; }
.mute-toggle { background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.15); color:#fff; font-family:'Press Start 2P',cursive; font-size:8px; padding:5px 12px; border-radius:8px; cursor:pointer; transition:all 0.2s; }
.mute-toggle:hover { background:rgba(255,255,255,0.15); }
.mute-toggle.muted { background:rgba(255,60,60,0.2); border-color:rgba(255,60,60,0.4); color:#f66; }

/* Music Player */
#musicPlayer { position:fixed; right:calc(10px + var(--safe-right)); top:calc(150px + var(--safe-top)); z-index:110; transition:all 0.3s ease; background:rgba(0,0,20,0.8); border:1px solid rgba(100,150,255,0.2); border-radius:10px; padding:8px 10px; min-width:190px; max-width:210px; backdrop-filter:blur(4px); }
#musicPlayer .mp-song { color:#7bf; font-size:8px; text-align:center; margin-bottom:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-height:14px; }
#musicPlayer .mp-controls { display:flex; align-items:center; justify-content:center; gap:6px; }
#musicPlayer .mp-btn { background:none; border:1px solid rgba(255,255,255,0.15); color:rgba(255,255,255,0.6); font-size:10px; width:28px; height:28px; border-radius:50%; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all 0.2s; padding:0; }
#musicPlayer .mp-btn.mp-play { width:34px; height:34px; font-size:13px; border-color:rgba(100,180,255,0.3); }
#musicPlayer .mp-btn:hover { color:#fff; border-color:rgba(255,255,255,0.4); background:rgba(255,255,255,0.08); }
#musicPlayer .mp-btn.active { color:#7bf; border-color:rgba(100,180,255,0.4); }
.mp-volume-row { display:flex; align-items:center; gap:6px; margin-top:6px; padding-top:5px; border-top:1px solid rgba(255,255,255,0.06); }
.mp-vol-icon { font-size:10px; flex-shrink:0; }
.mp-vol-slider { flex:1; accent-color:#7bf; height:4px; cursor:pointer; }

/* Music player repositioned on menu */
#musicPlayer.mp-menu-pos { top:auto; bottom:calc(15px + var(--safe-bottom)); right:calc(15px + var(--safe-right)); }

/* Crew Edit */
#crewEdit h2 { font-size: 20px; color: #a78bfa; margin-bottom: 10px; }
.crew-form { max-width: 360px; width: 90%; text-align: left; }
.crew-form label { color: #aab; font-size: 9px; display: block; margin-top: 10px; margin-bottom: 4px; }
.crew-form input[type="text"] { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 12px; width: 100%; outline: none; font-family: 'Press Start 2P', cursive; }
.crew-form input[type="text"]:focus { border-color: rgba(167,139,250,0.6); }
.color-picker { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.color-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: all 0.15s; }
.color-swatch:hover, .color-swatch.sel { border-color: #fff; transform: scale(1.15); }
.outfit-picker { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.outfit-opt { padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: 8px; color: #fff; border: 2px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06); transition: all 0.15s; }
.outfit-opt:hover, .outfit-opt.sel { border-color: #a78bfa; background: rgba(167,139,250,0.2); }
.outfit-opt.locked { opacity: 0.3; cursor: default; }
#crewPreviewWrap { margin: 15px auto; text-align: center; }
#crewPreviewCanvas { border-radius: 10px; background: rgba(0,0,30,0.6); border: 1px solid rgba(255,255,255,0.1); }

/* Custom Modal */
.modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); display:flex; align-items:center; justify-content:center; z-index:200; }
.modal-box { background:rgba(10,0,40,0.95); border:2px solid rgba(255,100,150,0.4); border-radius:16px; padding:30px 40px; text-align:center; max-width:400px; box-shadow:0 0 30px rgba(255,50,100,0.2); }
.modal-text { color:#fff; font-size:12px; margin-bottom:20px; line-height:2; }
.modal-btns { display:flex; gap:12px; justify-content:center; }

/* Zoom HUD */
#zoomHUD { position:fixed; top:calc(15px + var(--safe-top)); right:calc(15px + var(--safe-right)); display:flex; align-items:center; gap:6px; z-index:110; }
.zoom-btn { padding:6px 8px !important; min-width:auto !important; font-size:12px !important; }
#zoomLevel { color:rgba(255,255,255,0.6); font-size:9px; min-width:40px; text-align:center; }

/* Overlay Close Button */
.overlay-close-btn { position:fixed; top:calc(12px + var(--safe-top)); right:calc(12px + var(--safe-right)); background:none; border:none; color:rgba(255,255,255,0.6); font-size:32px; cursor:pointer; z-index:150; line-height:1; padding:4px 8px; transition:color 0.2s, transform 0.2s; }
.overlay-close-btn:hover { color:#fff; transform:scale(1.2); }

/* Cheat Panel */
#cheatPanel h2 { color:#5f5; text-shadow:0 0 10px rgba(50,255,50,0.3); }

/* Galaxy Quick Select - removed */

/* Wiki/Help Panel */
.wiki-content { max-width: 600px; width: 92%; margin-bottom: 20px; }
.wiki-section { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 15px 18px; margin-bottom: 12px; }
.wiki-title { font-size: 10px; color: #7bf; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 10px; }
.wiki-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.wiki-item { display: flex; align-items: center; gap: 6px; font-size: 9px; color: #ccc; }
.wiki-item span:last-child { color: #aab; margin-left: auto; }
.wiki-controls { font-size: 9px; color: #ccc; line-height: 2.4; }
.wiki-controls b { color: #fff; }
.wiki-controls.mobile-controls { display:none; }

/* Galaxy Screen */
#galaxyScreen h2 { font-size: 24px; color: #7bf; text-shadow: 0 0 10px rgba(100,180,255,0.3); margin-bottom: 5px; }
.galaxy-subtitle { color: #aab; font-size: 9px; margin-bottom: 15px; }

/* Round Summary */
.round-summary-round { font-size: 13px; color: #7bf; margin-bottom: 12px; }
.round-summary-tabs { display: flex; gap: 0; margin-bottom: 15px; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
.rs-tab { flex: 1; background: rgba(255,255,255,0.04); border: none; color: rgba(255,255,255,0.4); font-family: 'Press Start 2P', cursive; font-size: 9px; padding: 10px 16px; cursor: pointer; transition: all 0.2s; letter-spacing: 0.5px; }
.rs-tab:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.08); }
.rs-tab.rs-tab-active { color: #ffd700; background: rgba(255,215,0,0.1); }
.round-summary-content { max-width: 500px; width: 94%; max-height: 55vh; overflow-y: auto; margin-bottom: 15px; }
.rs-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rs-stat-card { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: #ddd; }
.rs-stat-icon { font-size: 18px; flex-shrink: 0; width: 30px; text-align: center; }
.rs-stat-info { flex: 1; }
.rs-stat-label { font-size: 7px; color: rgba(255,255,255,0.4); letter-spacing: 1px; display: block; margin-bottom: 2px; }
.rs-stat-value { font-size: 14px; color: #fff; font-weight: bold; display: block; }
.rs-stat-delta { font-size: 9px; color: #5f5; font-weight: bold; margin-left: 5px; }
.rs-stat-card.rs-highlight { border-color: rgba(255,215,0,0.3); background: rgba(255,215,0,0.06); }
.rs-stat-card.rs-highlight .rs-stat-value { color: #ffd700; }

/* Collection Grid */
.collection-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(100px,1fr)); gap:8px; max-width:820px; width:92%; margin-bottom:10px; }
.coll-item { background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:10px; padding:8px 6px; text-align:center; transition:all 0.2s; position:relative; }
.coll-item:hover { background:rgba(255,255,255,0.08); border-color:rgba(255,255,255,0.18); }
.coll-item.coll-owned { border-color:rgba(100,255,100,0.25); }
.coll-item.coll-locked { opacity:0.35; filter:grayscale(0.5); }
.coll-item canvas { display:block; margin:0 auto 4px; border-radius:6px; background:rgba(0,0,30,0.4); }
.coll-item .coll-name { font-size:7px; color:#ccc; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.coll-item .coll-type { font-size:6px; color:rgba(255,255,255,0.25); margin-top:1px; letter-spacing:0.5px; }
.coll-item .coll-status { font-size:6px; margin-top:3px; font-weight:bold; }
.coll-label { width:100%; text-align:center; font-size:10px; font-weight:bold; text-transform:uppercase; letter-spacing:1px; grid-column:1/-1; margin:6px 0 2px; padding-bottom:4px; border-bottom:1px solid rgba(255,255,255,0.06); }

/* Auth Modal */
.auth-box { position:relative; background:rgba(10,0,40,0.95); border:2px solid rgba(50,200,100,0.3); border-radius:16px; padding:25px 30px; max-width:380px; width:92%; text-align:center; box-shadow:0 0 30px rgba(50,200,100,0.15); }
.auth-tabs { display:flex; gap:0; margin-bottom:12px; border-radius:8px; overflow:hidden; border:1px solid rgba(255,255,255,0.1); }
.auth-tab { flex:1; background:rgba(255,255,255,0.04); border:none; color:rgba(255,255,255,0.4); font-family:'Press Start 2P',cursive; font-size:8px; padding:8px 10px; cursor:pointer; transition:all 0.2s; }
.auth-tab:hover { color:rgba(255,255,255,0.7); background:rgba(255,255,255,0.08); }
.auth-tab.auth-tab-active { color:#5f5; background:rgba(50,200,100,0.1); }
.auth-field { text-align:left; margin-bottom:8px; }
.auth-field label { display:block; font-size:7px; color:rgba(255,255,255,0.4); margin-bottom:3px; letter-spacing:1px; }
.auth-field input { width:100%; background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.15); color:#fff; padding:8px 12px; border-radius:8px; font-size:11px; outline:none; font-family:'Press Start 2P',cursive; }
.auth-field input:focus { border-color:rgba(50,200,100,0.5); }
.auth-field input::placeholder { color:rgba(255,255,255,0.2); font-size:8px; }

/* ===================== MOBILE RESPONSIVE ===================== */
@media (max-width: 768px) {
    /* Prevent browser gestures on the game */
    body { cursor: default; overscroll-behavior: none; }

    /* Hide legend & controls hints on mobile */
    #legend, #controls { display:none !important; }

    /* Music player: hide during gameplay, keep on menu */
    #musicPlayer { display:none !important; }
    #musicPlayer.mp-menu-pos { display:block !important; right:calc(10px + var(--safe-right)); bottom:calc(10px + var(--safe-bottom)); min-width:160px; max-width:180px; }

    /* HUD - compact */
    #ui { top:calc(4px + var(--safe-top)); }
    .hud-panel { padding:4px 10px; gap:8px; border-radius:10px; }
    .hud-score-val { font-size:14px; }
    .hud-stat-val { font-size:9px; }
    .hud-stat-label, .hud-score-label { font-size:5px; letter-spacing:1px; }
    .hud-v-divider { height:20px; }
    .hud-stats-row { gap:8px; }
    .hud-combo-val { font-size:10px; }

    /* Game buttons - move below HUD, larger touch targets */
    #gameButtons { top:auto; bottom:calc(8px + var(--safe-bottom)); right:calc(8px + var(--safe-right)); gap:4px; z-index:15; }
    .hud-btn { font-size:7px; padding:8px 10px; border-radius:14px; min-width:36px; min-height:36px; display:flex; align-items:center; justify-content:center; }
    .hud-menu { min-width:180px; grid-template-columns:1fr 1fr; bottom:100%; top:auto; margin-bottom:8px; margin-top:0; }
    .hud-menu-item { font-size:7px; padding:10px 8px; min-height:40px; }

    /* Zoom HUD — top right, larger buttons */
    #zoomHUD { top:calc(6px + var(--safe-top)); right:calc(6px + var(--safe-right)); gap:3px; }
    .zoom-btn { padding:6px 8px !important; font-size:10px !important; min-width:32px; min-height:32px; }
    #zoomLevel { font-size:7px; min-width:30px; }

    /* Start screen */
    #startScreen h1 { font-size:18px; letter-spacing:2px; }
    #startScreen .subtitle { font-size:8px; margin-bottom:16px; }
    .instructions { font-size:6px; line-height:2; }
    .btn { font-size:10px; padding:12px 24px; min-height:44px; }
    .btn-small { font-size:8px; padding:8px 14px; min-height:36px; }

    /* Overlays - full screen on mobile with safe padding */
    .overlay.overlay-bg { padding:10px 6px 20px; }
    .overlay-close-btn { font-size:30px; top:calc(6px + var(--safe-top)); right:calc(6px + var(--safe-right)); width:40px; height:40px; display:flex; align-items:center; justify-content:center; }

    /* Shop */
    #shopScreen h2 { font-size:16px; }
    .shop-layout { flex-direction:column; gap:8px; }
    .shop-nav { max-width:100%; min-width:0; display:flex; flex-wrap:wrap; gap:2px; padding:4px; position:static; }
    .shop-nav-item { display:inline-block; width:auto; font-size:6px; padding:6px 10px; border-left:none; border-bottom:2px solid transparent; text-align:center; min-height:32px; }
    .shop-nav-item.shop-nav-active { border-left-color:transparent; border-bottom-color:#7bf; }
    .shop-main { max-height:60vh; overflow-y:auto; -webkit-overflow-scrolling:touch; }
    .shop-grid { grid-template-columns:repeat(auto-fit, minmax(130px, 1fr)); gap:6px; }
    .shop-item { padding:8px; border-radius:8px; }
    .shop-item .name { font-size:8px; }
    .shop-item .desc { font-size:6px; min-height:18px; }
    .shop-item .cost { font-size:8px; }
    .shopCoins { font-size:11px; }
    .roundComplete { font-size:10px; }

    /* Galaxy cards */
    .galaxy-card canvas { height:90px; }
    .galaxy-card .name { font-size:8px; }
    .galaxy-card .desc { font-size:6px; min-height:18px; }
    .galaxy-card .galaxy-entities { font-size:6px; }

    /* Crew */
    .crew-list { gap:8px; }
    .crew-card { width:100px; padding:8px; }
    .crew-card .cname { font-size:7px; }

    /* Round summary */
    .rs-stats-grid { grid-template-columns:1fr 1fr; }
    .rs-stat-icon { font-size:14px; width:24px; }
    .rs-stat-value { font-size:11px; }
    .rs-stat-label { font-size:6px; }

    /* Collection grid */
    #collectionScreen { overflow-y:auto; padding-bottom:calc(30px + var(--safe-bottom)); }
    #collectiblesGrid { width:100%; max-width:100%; }
    .collection-grid { grid-template-columns:repeat(3, minmax(0, 1fr)); gap:5px; width:100%; max-width:100%; }
    .coll-item { padding:5px 4px; }
    .coll-item canvas { width:48px; height:48px; }
    .coll-item .coll-name { font-size:6px; }

    /* Crew edit */
    .crew-form { width:95%; }
    .color-swatch { width:28px; height:28px; }

    /* Settings */
    #settingsModal .settings-content { padding:20px 14px; max-width:95vw; }

    /* Auth */
    .auth-box { padding:18px 14px; width:95%; }

    /* Wiki */
    .wiki-grid { grid-template-columns:1fr; }
    .wiki-section { padding:10px 12px; }
    .wiki-content { max-width:100%; }
    .wiki-controls.desktop-controls { display:none; }
    .wiki-controls.mobile-controls { display:block; }

    /* Modal */
    .modal-box { padding:20px 18px; max-width:90vw; }

    /* Side buttons: bottom bar on mobile */
    .inv-btn { 
        position:fixed; left:calc(8px + var(--safe-left)); bottom:calc(8px + var(--safe-bottom)); top:auto;
        transform:none; width:40px; height:40px; font-size:16px; border-radius:12px; z-index:60;
    }
    .inv-btn:hover { transform:scale(1.05); }
    .pet-overview-btn { 
        position:fixed; left:calc(54px + var(--safe-left)); bottom:calc(8px + var(--safe-bottom)); top:auto;
        transform:none; width:40px; height:40px; z-index:60;
    }
    .pet-overview-btn:hover { transform:scale(1.05); }
    .res-toggle-btn { 
        position:fixed; left:calc(100px + var(--safe-left)); bottom:calc(8px + var(--safe-bottom)); top:auto;
        transform:none; width:40px; height:40px; z-index:60;
    }
    .res-toggle-btn:hover { transform:scale(1.05); }

    /* Resource HUD & gain feed - reposition for mobile */
    .res-hud-panel { 
        left:calc(8px + var(--safe-left)); top:auto; bottom:calc(56px + var(--safe-bottom));
        transform:none; max-width:200px;
    }
    .res-gain-feed { left:calc(8px + var(--safe-left)); top:auto; bottom:calc(110px + var(--safe-bottom)); }
    .pet-overview-panel { 
        left:0; right:0; top:auto; bottom:calc(56px + var(--safe-bottom));
        transform:none; max-width:100vw; width:100%;
        max-height:50vh; border-radius:12px 12px 0 0;
    }

    /* Inventory grid */
    .inv-category-grid { grid-template-columns:1fr 1fr; gap:8px; }
    .inv-item { padding:8px; }
    .inv-icon { font-size:22px; }
    .inv-name { font-size:8px; }
    .inv-tooltip { 
        position:fixed; left:50%; right:auto; top:auto; bottom:calc(10px + var(--safe-bottom));
        transform:translateX(-50%); width:85vw; max-width:300px;
        padding:14px; border-radius:12px;
    }
    @keyframes tooltipSlide { from { opacity:0; transform:translateX(-50%) translateY(20px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

    /* Pet bars in inventory */
    .inv-pet-item { padding:8px; }
    .pet-bar { height:7px; }

    /* Collection sections */
    .coll-section { margin-bottom:14px; }
    .coll-section-header { font-size:10px; padding:6px 10px; }
    .coll-section-count { font-size:8px; }

    /* Pet care screen */
    .pet-care-status { flex-direction:column; gap:8px; align-items:center; }
    .pet-care-emoji { font-size:40px; }
    .pet-care-bars { width:100%; }
    .pet-bar-row { font-size:9px; }
    .pet-bar-bg-lg { height:12px; }
    .pet-care-actions { flex-wrap:wrap; gap:6px; justify-content:center; }
    .pet-care-actions button { font-size:9px; padding:8px 12px; min-height:36px; }

    /* Pet outfit grid */
    .pet-outfit-grid { grid-template-columns:repeat(3, 1fr); gap:6px; }
    .pet-outfit-item { padding:6px; font-size:9px; }

    /* Farm */
    #farmCanvas { width:100%; max-width:100%; height:auto; max-height:45vh; }
    .farm-pet-list { gap:4px; }
    .farm-pet-tag { font-size:8px; padding:3px 8px; }

    /* Shop items & pet outfits */
    .shop-item-icon { font-size:20px; }
    .shop-item-name { font-size:8px; }

    /* Crafting */
    .craft-layout { flex-direction:column; align-items:center; }
    .craft-palette { max-width:100%; min-width:0; display:flex; flex-wrap:wrap; gap:4px; justify-content:center; }
    .craft-cell { width:42px; height:42px; }
    .craft-recipes { max-height:150px; }
    .craft-recipe-card { padding:4px 6px; }

    /* Notification log */
    .notif-log-feed { width:160px; top:calc(56px + var(--safe-top)); bottom:auto; right:calc(8px + var(--safe-right)); max-height:80px; }
    .notif-log-entry { font-size:7px; }
    .notif-log-btn { top:calc(28px + var(--safe-top)); bottom:auto; right:calc(8px + var(--safe-right)); }
    .notif-log-panel { top:calc(56px + var(--safe-top)); bottom:auto; right:calc(8px + var(--safe-right)); width:200px; max-height:200px; }

    /* Pet warning portraits - bottom left above side buttons */
    #petWarnPortraits { bottom:56px !important; top:auto !important; left:8px !important; flex-direction:row !important; }
}

/* Extra small screens */
@media (max-width: 480px) {
    #startScreen h1 { font-size:14px; letter-spacing:1px; }
    #startScreen .subtitle { font-size:7px; }
    .instructions { font-size:5.5px; line-height:1.8; }
    .btn { font-size:8px; padding:8px 16px; min-height:40px; }
    .btn-small { font-size:7px; padding:6px 10px; min-height:32px; }

    /* HUD extra compact */
    .hud-panel { padding:3px 6px; gap:6px; }
    .hud-score-val { font-size:12px; }
    .hud-stat-val { font-size:8px; }
    .hud-stat-label, .hud-score-label { font-size:4.5px; }
    .hud-v-divider { height:16px; }
    .hud-stats-row { gap:5px; }
    .hud-combo-val { font-size:8px; }

    /* Game buttons stacked vertically on very small screens */
    #gameButtons { gap:3px; flex-direction:column; }
    .hud-btn { font-size:6px; padding:6px 8px; min-width:32px; min-height:32px; }
    .hud-menu { grid-template-columns:1fr; min-width:140px; }
    .hud-menu-item { font-size:5px; padding:8px 6px; min-height:36px; }

    /* Zoom */
    .zoom-btn { padding:4px 6px !important; font-size:9px !important; min-width:28px; min-height:28px; }

    /* Shop */
    .shop-grid { grid-template-columns:1fr 1fr; gap:4px; }
    .shop-item { padding:6px; }
    .shop-item .name { font-size:7px; }
    .shop-item .desc { font-size:5.5px; }
    .shopCoins { font-size:9px; }

    /* Collection */
    .collection-grid { grid-template-columns:repeat(auto-fill, minmax(60px, 1fr)); gap:3px; }
    .coll-item .coll-name { font-size:5px; }

    /* Side buttons - bottom bar smaller */
    .inv-btn { width:34px; height:34px; font-size:14px; border-radius:10px; }
    .pet-overview-btn { width:34px; height:34px; left:48px; }
    .res-toggle-btn { width:34px; height:34px; left:88px; }
    .res-hud-panel { bottom:48px; max-width:170px; font-size:8px; }
    .res-gain-feed { bottom:95px; }
    .pet-overview-panel { bottom:48px; max-height:45vh; }
    #petWarnPortraits { bottom:48px !important; }

    /* Inventory */
    .inv-category-grid { grid-template-columns:1fr; }
    .inv-tooltip { width:80vw; }

    /* Farm */
    #farmCanvas { width:100%; height:40vh; min-height:160px; }

    /* Pets */
    .pet-care-actions { flex-wrap:wrap; }
    .pet-care-actions button { font-size:8px; padding:6px 10px; min-height:32px; }
    .pet-care-emoji { font-size:32px; }
    .pet-outfit-grid { grid-template-columns:repeat(2, 1fr); }

    /* Crafting */
    .craft-cell { width:34px; height:34px; }
    .craft-palette { flex-direction:row; flex-wrap:wrap; }
    .craft-res { font-size:8px; padding:3px 4px; }
    .craft-recipes { max-height:120px; }

    /* Overlays */
    .overlay-close-btn { font-size:26px; width:36px; height:36px; }

    /* Crew */
    .crew-card { width:85px; padding:6px; }
    .crew-card .cname { font-size:6px; }

    /* Notification log */
    .notif-log-feed { width:140px; max-height:60px; font-size:6px; }
    .notif-log-panel { width:180px; max-height:180px; }

    /* Wiki */
    .wiki-section h3 { font-size:10px; }
    .wiki-section p, .wiki-section li { font-size:7px; }
}

/* Landscape orientation on mobile - maximize horizontal space */
@media (max-width: 768px) and (orientation: landscape) {
    .overlay.overlay-bg { padding:6px 4px 10px; }
    .overlay-close-btn { top:4px; right:4px; }
    #farmCanvas { height:60vh; }
    .pet-overview-panel { max-height:40vh; }
    .res-hud-panel { max-height:35vh; overflow-y:auto; }
    .hud-panel { padding:2px 8px; }
    .hud-score-val { font-size:12px; }
    .hud-v-divider { height:14px; }
    #gameButtons { bottom:4px; right:4px; }
    .inv-btn, .pet-overview-btn, .res-toggle-btn { bottom:4px; width:32px; height:32px; }
    .pet-overview-btn { left:46px; }
    .res-toggle-btn { left:84px; }
}

/* =========================== */
/* INVENTORY BUTTON            */
/* =========================== */
.inv-btn {
    position:absolute;
    left:10px;
    top:calc(50% - 34px);
    transform:translateY(-50%);
    width:40px;height:40px;
    background:rgba(10,10,30,0.75);
    border:2px solid rgba(240,192,64,0.5);
    border-radius:12px;
    display:flex;align-items:center;justify-content:center;
    font-size:20px;
    color:#f0c040;
    cursor:pointer;
    z-index:60;
    backdrop-filter:blur(8px);
    transition:all 0.2s;
    box-shadow:0 2px 10px rgba(0,0,0,0.4);
}
.inv-btn:hover {
    background:rgba(240,192,64,0.2);
    border-color:rgba(240,192,64,0.8);
    transform:translateY(-50%) scale(1.1);
}

/* =========================== */
/* RESOURCE TOGGLE BUTTON      */
/* =========================== */
.pet-overview-btn {
    position:absolute;
    left:10px;
    top:50%;
    transform:translateY(-50%);
    width:40px;height:40px;
    background:rgba(10,10,30,0.75);
    border:2px solid rgba(255,136,170,0.4);
    border-radius:12px;
    display:flex;align-items:center;justify-content:center;
    color:#f7a;
    cursor:pointer;
    z-index:60;
    backdrop-filter:blur(8px);
    transition:all 0.2s;
    box-shadow:0 2px 8px rgba(0,0,0,0.3);
}
.pet-overview-btn:hover {
    background:rgba(255,136,170,0.15);
    border-color:rgba(255,136,170,0.7);
    transform:translateY(-50%) scale(1.1);
}
.pet-overview-panel {
    position:absolute;
    left:56px;
    top:50%;
    transform:translateY(-50%);
    z-index:61;
    background:rgba(10,10,30,0.92);
    border:1px solid rgba(255,136,170,0.25);
    border-radius:10px;
    padding:8px;
    backdrop-filter:blur(10px);
    max-height:60vh;
    overflow-y:auto;
    min-width:200px;
    max-width:260px;
    box-shadow:0 4px 20px rgba(0,0,0,0.5);
}
.pet-ov-row {
    display:flex;
    align-items:center;
    gap:6px;
    padding:4px 6px;
    border-radius:6px;
    cursor:pointer;
    transition:all 0.2s;
    border-bottom:1px solid rgba(255,255,255,0.04);
    position:relative;
}
.pet-ov-row:last-child { border-bottom:none; }
.pet-ov-row:hover {
    background:rgba(255,136,170,0.1);
}
.pet-ov-mini-bars {
    display:flex;
    gap:3px;
    align-items:center;
    flex:1;
    min-width:0;
}
.pet-ov-mini-bar {
    flex:1;
    height:5px;
    background:rgba(255,255,255,0.08);
    border-radius:3px;
    overflow:hidden;
    min-width:20px;
}
.pet-ov-mini-fill {
    height:100%;
    border-radius:3px;
    transition:width 0.3s;
}
.pet-ov-expanded {
    position:absolute;
    left:100%;
    top:0;
    margin-left:6px;
    background:rgba(15,15,35,0.95);
    border:1px solid rgba(255,136,170,0.3);
    border-radius:10px;
    padding:10px;
    min-width:180px;
    z-index:62;
    box-shadow:0 4px 16px rgba(0,0,0,0.5);
    pointer-events:none;
    white-space:nowrap;
}
.res-toggle-btn {
    position:absolute;
    left:10px;
    top:calc(50% + 34px);
    transform:translateY(-50%);
    width:40px;height:40px;
    background:rgba(10,10,30,0.75);
    border:2px solid rgba(100,180,255,0.4);
    border-radius:12px;
    display:flex;align-items:center;justify-content:center;
    color:#6ab4ff;
    cursor:pointer;
    z-index:60;
    backdrop-filter:blur(8px);
    transition:all 0.2s;
    box-shadow:0 2px 8px rgba(0,0,0,0.3);
}
.res-toggle-btn:hover {
    background:rgba(100,180,255,0.15);
    border-color:rgba(100,180,255,0.7);
    transform:translateY(-50%) scale(1.1);
}
.res-btn-active {
    background:rgba(100,180,255,0.2);
    border-color:rgba(100,180,255,0.8);
    color:#adf;
}

/* =========================== */
/* RESOURCE HUD PANEL          */
/* =========================== */
.res-hud-panel {
    position:absolute;
    left:10px;
    top:calc(50% + 60px);
    display:flex;
    flex-direction:column;
    gap:3px;
    z-index:59;
    background:rgba(10,10,30,0.8);
    border:1px solid rgba(100,180,255,0.2);
    border-radius:8px;
    padding:6px;
    backdrop-filter:blur(8px);
    max-height:40vh;
    overflow-y:auto;
}
.res-hud-item {
    display:flex;
    align-items:center;
    gap:4px;
    padding:2px 6px;
    border-radius:4px;
    cursor:default;
    transition:background 0.15s;
    white-space:nowrap;
}
.res-hud-item:hover {
    background:rgba(255,255,255,0.08);
}
.res-hud-item span {
    font-size:10px;
    font-weight:bold;
    color:#ccc;
    min-width:16px;
}
.res-panel-full {
    position:fixed;
    left:50%;
    top:50%;
    transform:translate(-50%,-50%);
    width:92vw;
    max-width:360px;
    max-height:70vh;
    background:rgba(10,10,30,0.95);
    border:1px solid rgba(100,180,255,0.35);
    border-radius:14px;
    padding:10px 12px 12px;
    z-index:200;
    overflow-y:auto;
}
.res-panel-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    font-size:9px;
    letter-spacing:2px;
    color:#7bf;
    margin-bottom:8px;
}
.res-panel-close {
    background:none;
    border:none;
    color:#aaa;
    font-size:18px;
    cursor:pointer;
}
.res-panel-full .res-hud-item {
    padding:6px 8px;
    gap:8px;
}
.res-panel-full .res-hud-icon {
    width:18px;
    display:flex;
    align-items:center;
    justify-content:center;
}
.res-panel-full .res-name {
    font-size:9px;
    color:#ddd;
    flex:1;
}
.res-panel-full .res-count {
    font-size:9px;
    color:#9cf;
}

/* =========================== */
/* RESOURCE GAIN FEED          */
/* =========================== */
.res-gain-feed {
    position:absolute;
    left:56px;
    top:calc(50% - 80px);
    display:flex;
    flex-direction:column-reverse;
    gap:2px;
    z-index:58;
    pointer-events:none;
    max-height:200px;
    overflow:hidden;
}
.res-gain-entry {
    display:flex;
    align-items:center;
    gap:4px;
    padding:2px 8px;
    background:rgba(10,10,30,0.7);
    border-radius:6px;
    border-left:2px solid rgba(255,200,0,0.5);
    opacity:0;
    transform:translateY(10px);
    transition:opacity 0.3s ease, transform 0.4s ease;
    white-space:nowrap;
}
.res-gain-entry span {
    font-size:10px;
    font-weight:bold;
}
.res-gain-show {
    opacity:1;
    transform:translateY(0);
}
.res-gain-fade {
    opacity:0 !important;
    transform:translateY(-15px) !important;
    transition:opacity 2s ease, transform 2s ease !important;
}

/* =========================== */
/* INVENTORY SCREEN            */
/* =========================== */
.inv-grid {
    display:flex;
    flex-direction:column;
    gap:14px;
    max-width:820px;
    width:90%;
    margin:10px auto;
}
.inv-category {
    background:rgba(255,255,255,0.03);
    border:1px solid rgba(255,255,255,0.06);
    border-radius:12px;
    padding:10px;
    overflow:hidden;
}
.inv-category-header {
    font-size:10px;
    font-weight:bold;
    color:#aaa;
    text-transform:uppercase;
    letter-spacing:1px;
    padding:4px 6px 8px;
    border-bottom:1px solid rgba(255,255,255,0.08);
    margin-bottom:8px;
    display:flex;
    align-items:center;
    gap:6px;
}
.inv-category-grid {
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(200px,1fr));
    gap:8px;
}
.inv-item {
    background:rgba(255,255,255,0.06);
    border:1px solid rgba(255,255,255,0.1);
    border-radius:10px;
    padding:10px;
    display:flex;
    align-items:center;
    gap:10px;
    transition:all 0.2s;
}
.inv-item:hover {
    background:rgba(255,255,255,0.1);
    border-color:rgba(255,255,255,0.2);
}
.inv-icon { font-size:28px; }
.inv-name { font-size:10px; color:#ddd; flex:1; }
.inv-count { font-size:11px; color:#7bf; font-weight:bold; }
.inv-pet-item {
    flex-wrap:wrap;
    border-color:rgba(255,136,170,0.3);
}
.inv-pet-bars {
    width:100%;
    display:flex;flex-direction:column;gap:4px;
    margin-top:4px;
}
.pet-bar {
    display:flex;align-items:center;gap:5px;
    font-size:10px;
}
.pet-bar-bg {
    flex:1;height:8px;
    background:rgba(255,255,255,0.1);
    border-radius:4px;overflow:hidden;
}
.pet-bar-fill {
    height:100%;border-radius:4px;
    transition:width 0.3s;
}
.pet-hunger-bar { background:linear-gradient(90deg,#e67300,#fa5); }
.pet-happy-bar { background:linear-gradient(90deg,#55f,#5ff); }
.pet-health-bar { background:linear-gradient(90deg,#c22,#f55); }
.inv-pet-btns {
    width:100%;display:flex;gap:6px;margin-top:6px;justify-content:flex-end;
}
.inv-item.inv-clickable { cursor:pointer; }
.inv-item.inv-clickable:hover { background:rgba(255,255,255,0.12); border-color:rgba(255,255,255,0.25); }
.inv-item.inv-selected { background:rgba(100,200,255,0.15); border-color:rgba(100,200,255,0.4); }
.inv-tooltip {
    position:fixed; right:20px; top:50%; transform:translateY(-50%);
    width:220px; background:rgba(15,15,35,0.95); border:1px solid rgba(255,255,255,0.2);
    border-radius:14px; padding:20px; z-index:200;
    backdrop-filter:blur(12px); box-shadow:0 4px 30px rgba(0,0,0,0.6);
    display:flex; flex-direction:column; align-items:center; gap:10px;
    animation:tooltipSlide 0.2s ease;
}
@keyframes tooltipSlide { from { opacity:0; transform:translateY(-50%) translateX(20px); } to { opacity:1; transform:translateY(-50%) translateX(0); } }
@keyframes petWarnIn { from { opacity:0; transform:translateY(-50%) translateX(-15px); } to { opacity:1; transform:translateY(-50%) translateX(0); } }
.inv-tooltip-icon { width:64px; height:64px; display:flex; align-items:center; justify-content:center;
    background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.1); border-radius:12px; }
.inv-tooltip-name { font-size:13px; font-weight:bold; color:#fff; text-align:center; }
.inv-tooltip-desc { font-size:9px; color:#aaa; text-align:center; line-height:1.4; }
.inv-tooltip-count { font-size:10px; color:#7bf; font-weight:bold; }
.inv-tooltip-use {
    width:100%; padding:8px; border:none; border-radius:8px;
    background:linear-gradient(135deg,#2ecc71,#27ae60); color:#fff;
    font-size:11px; font-weight:bold; cursor:pointer; letter-spacing:1px;
    transition:all 0.2s;
}
.inv-tooltip-use:hover { background:linear-gradient(135deg,#27ae60,#1e8449); transform:scale(1.03); }
.inv-tooltip-use:disabled { background:rgba(255,255,255,0.1); color:#666; cursor:not-allowed; transform:none; }
.inv-tooltip-close {
    position:absolute; top:6px; right:8px; background:none; border:none;
    color:#888; font-size:16px; cursor:pointer; line-height:1;
}
.inv-tooltip-close:hover { color:#fff; }

/* =========================== */
/* COLLECTION SECTIONS         */
/* =========================== */
.coll-section {
    width:90%;max-width:820px;margin:8px auto;
}
.coll-section-header {
    font-size:11px;
    font-weight:bold;
    color:#7bf;
    padding:8px 0 4px;
    border-bottom:1px solid rgba(100,180,255,0.2);
    margin-bottom:6px;
    display:flex;
    align-items:center;
    gap:4px;
}
.coll-section-count {
    font-size:9px;
    color:#888;
    font-weight:normal;
    margin-left:auto;
}

/* =========================== */
/* PET CARE SCREEN             */
/* =========================== */
.pet-care-status {
    display:flex;align-items:center;gap:20px;
    padding:15px;margin:10px 0;
    background:rgba(255,255,255,0.05);
    border-radius:12px;
    max-width:500px;width:90%;
}
.pet-care-emoji { font-size:40px; }
.pet-care-bars { flex:1;display:flex;flex-direction:column;gap:8px; }
.pet-bar-row {
    display:flex;align-items:center;gap:8px;
    font-size:9px;color:#aaa;
}
.pet-bar-bg-lg {
    flex:1;height:14px;
    background:rgba(255,255,255,0.1);
    border-radius:7px;overflow:hidden;
}
.pet-bar-bg-lg .pet-bar-fill {
    height:100%;border-radius:7px;
}
.pet-care-actions {
    display:flex;gap:8px;
    flex-wrap:wrap;
    justify-content:center;
    margin:10px 0;
}
.pet-outfit-section { max-width:500px;width:90%;margin:0 auto; }
.pet-outfit-grid {
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:8px;
    margin-top:8px;
}
.pet-outfit-item {
    background:rgba(255,255,255,0.06);
    border:1px solid rgba(255,255,255,0.12);
    border-radius:8px;
    padding:8px 4px;
    text-align:center;
    font-size:20px;
    cursor:pointer;
    transition:all 0.2s;
}
.pet-outfit-item:hover {
    background:rgba(255,255,255,0.12);
    border-color:rgba(255,255,255,0.25);
}
.pet-outfit-item span { font-size:8px;color:#aaa;display:block;margin-top:2px; }
.pet-outfit-equipped {
    border-color:rgba(80,255,80,0.5);
    background:rgba(80,255,80,0.1);
}
.pet-outfit-locked {
    opacity:0.3;cursor:default;
}

/* =========================== */
/* FARM VIEW                   */
/* =========================== */
#farmCanvas {
    border:2px solid rgba(80,255,80,0.3);
    border-radius:12px;
    max-width:700px;width:90%;
    image-rendering:pixelated;
    touch-action:none;
}
.farm-controls {
    max-width:700px;width:90%;margin:8px auto 0;
}
.farm-pet-list {
    display:flex;flex-wrap:wrap;gap:6px;
    justify-content:center;
}
.farm-pet-tag {
    background:rgba(255,255,255,0.08);
    border:1px solid rgba(255,255,255,0.15);
    border-radius:6px;
    padding:3px 8px;
    font-size:9px;
    color:#ccc;
}

/* =========================== */
/* SHOP ITEMS                  */
/* =========================== */
.shop-item-icon { margin-bottom:4px; }
.shop-item-name { font-size:10px;font-weight:bold;color:#ddd; }
.shop-card { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 12px; text-align: center; transition: all 0.2s; }
.shop-card:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); }

/* =========================== */
/* CRAFTING SYSTEM             */
/* =========================== */
.craft-layout {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    max-width: 700px;
    margin: 0 auto;
}
.craft-palette {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 8px;
    min-width: 100px;
    max-width: 140px;
}
.craft-palette-title {
    font-size: 9px;
    font-weight: bold;
    color: #aaa;
    margin-bottom: 6px;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}
.craft-res {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 9px;
    color: #ccc;
    transition: all 0.15s;
    border: 1px solid transparent;
}
.craft-res:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}
.craft-res[draggable="true"] {
    cursor: grab;
}
.craft-res[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.6;
}
.craft-res-selected {
    background: rgba(255,153,0,0.2) !important;
    border-color: rgba(255,153,0,0.5) !important;
    color: #f90;
}
.craft-grid-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: row;
}
.craft-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(255,153,0,0.3);
    border-radius: 8px;
    padding: 4px;
}
.craft-cell {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.craft-cell:hover {
    background: rgba(255,153,0,0.15);
    border-color: rgba(255,153,0,0.4);
}
.craft-cell-filled {
    cursor: pointer;
    background: rgba(255,255,255,0.08);
}
.craft-cell-filled:hover {
    background: rgba(255,80,80,0.2);
    border-color: rgba(255,80,80,0.5);
}
.craft-cell-droptarget {
    border-color: rgba(255,153,0,0.4);
    box-shadow: inset 0 0 6px rgba(255,153,0,0.15);
}
.craft-cell-dragover {
    background: rgba(255,200,0,0.25) !important;
    border-color: rgba(255,200,0,0.7) !important;
    transform: scale(1.05);
}
.craft-result {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-direction: column;
    min-width: 70px;
}
.craft-arrow {
    font-size: 20px;
    color: #f90;
    font-weight: bold;
}
.craft-result-item {
    text-align: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    min-width: 60px;
}
.craft-recipes {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 200px;
    overflow-y: auto;
}
.craft-recipe-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 3px 0;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    transition: all 0.15s;
}
.craft-recipe-card:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
}
.craft-recipe-available {
    border-color: rgba(80,255,80,0.3);
    background: rgba(80,255,80,0.05);
}
.craft-recipe-available:hover {
    border-color: rgba(80,255,80,0.5);
    background: rgba(80,255,80,0.1);
}

/* Smelter UI */
.smelter-layout {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    padding: 16px 0;
    flex-wrap: wrap;
}
.smelter-slot {
    text-align: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 16px 20px;
    min-width: 80px;
}
.smelter-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,153,0,0.3);
    border-radius: 8px;
    margin: 0 auto;
}
.smelter-arrow {
    text-align: center;
    padding: 8px;
}

/* Station tabs */
.station-tabs {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.station-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px 6px 0 0;
    background: rgba(255,255,255,0.03);
    color: #888;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
}
.station-tab:hover {
    background: rgba(255,255,255,0.08);
    color: #ccc;
}
.station-tab-active {
    background: rgba(255,153,0,0.12);
    color: #f90;
    border-bottom: 2px solid #f90;
    border-color: rgba(255,153,0,0.3);
    border-bottom-color: #f90;
}

@keyframes petWarnPulse {
    0%,100% { box-shadow:0 0 6px rgba(255,0,0,0.3); }
    50% { box-shadow:0 0 14px rgba(255,0,0,0.7); }
}
