/* TREASURE EMPIRE — style.css (STEP 2)
   ---------------------------------------------------------------------------
   Mobile-first 9:16 portrait layout, dark premium mining theme.
   Max-width phone column centered on desktop; safe-area insets respected;
   tap targets >= 44px; text >= 12px; system font stack only (no external
   fonts). Canvas capped by the JS loop; no WebGL anywhere.
   --------------------------------------------------------------------------- */

:root {
  --bg: #0f1b2d;
  --bg-deep: #0a0f1a;
  --panel: #1a2c44;
  --panel-2: #22395a;
  --panel-3: #16283f;
  --gold: #f2b93b;
  --gold-soft: #ffe27a;
  --gold-deep: #c98f1a;
  --diamond: #7fd4ff;
  --ruby: #ff5a6e;
  --emerald: #5ad47a;
  --ink: #f2f7e8;
  --muted: #9db0c4;
  --danger: #ff6b5e;
  --ok: #5ad47a;
  --border: rgba(242, 185, 59, 0.22);
  --radius: 14px;
  --nav-h: 62px;
  --hud-h: 56px;
}

* { box-sizing: border-box; }

/* Author display rules (flex etc.) would otherwise override the UA
   [hidden] style — hidden must always win. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  /* STEP 5 — Telegram stable viewport height when inside Telegram
     (set as --tg-viewport-stable-height by main.js); 100dvh elsewhere. */
  min-height: var(--tg-viewport-stable-height, 100dvh);
  background: linear-gradient(180deg, #12233a 0%, var(--bg) 30%, var(--bg-deep) 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

#app[data-screen="loading"] { padding-bottom: 0; }
#app[data-screen="loading"] #hud,
#app[data-screen="loading"] #bottomNav { display: none; }

/* ---------- Banners ---------- */
.dev-banner, .offline-banner {
  padding: 8px 12px;
  font-size: 12px;
  text-align: center;
}
.dev-banner { background: #3a2f10; color: var(--gold-soft); border-bottom: 1px solid var(--border); }
.offline-banner { background: #3d1a16; color: #ffb3ab; border-bottom: 1px solid rgba(255, 107, 94, 0.4); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }

/* ---------- HUD ---------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--hud-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
  background: rgba(10, 15, 26, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.hud-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.hud-item:active { background: var(--panel-2); }
.hud-icon { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.hud-icon.coin { background: radial-gradient(circle at 35% 35%, var(--gold-soft), var(--gold) 55%, var(--gold-deep)); box-shadow: 0 0 8px rgba(242, 185, 59, 0.6); }
.hud-icon.gem { background: linear-gradient(135deg, #d8f4ff, var(--diamond) 60%, #2a7ab0); transform: rotate(45deg); border-radius: 4px; box-shadow: 0 0 8px rgba(127, 212, 255, 0.6); }
.hud-icon.bolt { background: var(--ok); clip-path: polygon(60% 0, 20% 55%, 45% 55%, 35% 100%, 85% 40%, 55% 40%); border-radius: 0; }
.hud-label { font-size: 11px; color: var(--muted); }
.hud-value { font-weight: 700; font-size: 14px; }
.hud-energy { flex: 1.4; }
.hud-energy-wrap { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-energy-top { display: flex; justify-content: space-between; }
.energy-bar { display: block; height: 7px; background: #0a1420; border-radius: 4px; overflow: hidden; }
.energy-fill { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, #3fae5a, var(--ok)); border-radius: 4px; transition: width 0.3s; }
.vip-badge {
  flex: none;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #241a08;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  border-radius: 999px;
}

/* ---------- STEP 6 — cloud-save indicator ---------- */
.save-indicator {
  flex: none;
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  white-space: nowrap;
}
.save-indicator[data-state="saving"],
.save-indicator[data-state="saved"],
.save-indicator[data-state="error"] { display: inline-flex; }
.save-indicator .save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.save-indicator[data-state="saving"] { color: var(--gold-soft); }
.save-indicator[data-state="saving"] .save-dot { background: var(--gold); animation: save-pulse 1s ease-in-out infinite; }
.save-indicator[data-state="saved"] { color: var(--ok); }
.save-indicator[data-state="saved"] .save-dot { background: var(--ok); }
.save-indicator[data-state="error"] { color: #ff6b5e; }
.save-indicator[data-state="error"] .save-dot { background: #ff6b5e; }
@keyframes save-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Screens ---------- */
#screens { flex: 1; display: flex; flex-direction: column; }
.screen { padding: 14px 14px 20px; display: flex; flex-direction: column; gap: 12px; animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.screen-head h2 { margin: 0; font-size: 21px; }
h3 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.version-line { text-align: center; color: var(--muted); font-size: 12px; }
.error-line { color: #ffb3ab; font-size: 13px; }

/* ---------- Cards / lists ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-row h3 { margin: 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.row-card.dim { opacity: 0.55; }
.row-icon { width: 44px; height: 44px; flex: none; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; background: var(--panel-2); color: var(--gold-soft); }
.row-icon.worker { background: #4a2f16; }
.row-icon.machine { background: #1f3a4a; }
.row-icon.gem-ruby { background: #4a1620; color: var(--ruby); }
.row-icon.gem-sapphire { background: #16283f; color: var(--diamond); }
.row-icon.gem-emerald { background: #123d22; color: var(--emerald); }
.row-icon.gem-topaz { background: #4a3a10; color: var(--gold-soft); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; }
.row-sub { font-size: 12px; color: var(--muted); }
.row-cost { font-size: 13px; font-weight: 700; color: var(--gold-soft); white-space: nowrap; }
.row-cost.afford-no { color: var(--danger); }
.progress-mini { height: 6px; background: #0a1420; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-mini > span { display: block; height: 100%; background: var(--gold); }
.progress-mini > span.done { background: var(--ok); }

/* ---------- Buttons ---------- */
.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: linear-gradient(135deg, #ffd94d, var(--gold)); color: #241a08; border-color: transparent; }
.btn-gold { background: linear-gradient(135deg, #ffe27a, var(--gold) 55%, var(--gold-deep)); color: #241a08; border-color: transparent; }
.btn-danger { background: #4a1a16; border-color: rgba(255, 107, 94, 0.5); color: #ffb3ab; }
.btn-small { min-height: 44px; padding: 10px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--diamond); font: inherit; font-size: 14px; text-align: left; padding: 8px 0; cursor: pointer; min-height: 44px; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--ink); font-size: 20px; cursor: pointer; }
.avatar-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--gold); background: var(--panel-2); color: var(--gold-soft); font-weight: 800; font-size: 18px; cursor: pointer; }

/* ---------- Loading ---------- */
.screen-loading { justify-content: center; align-items: center; min-height: 70dvh; text-align: center; }
.splash { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.logo-mark { position: relative; width: 96px; height: 96px; }
.logo-pick { position: absolute; inset: 8px; border-radius: 50%; border: 4px solid var(--gold); transform: rotate(45deg); border-top-color: transparent; border-right-color: transparent; }
.logo-coin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 56px; height: 56px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold-soft), var(--gold) 55%, var(--gold-deep)); color: #241a08; font-size: 28px; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 32px rgba(242, 185, 59, 0.55); }
.splash h1 { margin: 4px 0 0; font-size: 30px; letter-spacing: 0.02em; }
.tagline { color: var(--muted); margin: 0; }
.progress-track { width: 100%; max-width: 280px; height: 10px; background: #0a1420; border-radius: 5px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; width: 8%; background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-soft)); border-radius: 5px; transition: width 0.3s; }
.progress-fill.storage { background: linear-gradient(90deg, #2a7ab0, var(--diamond)); }
.progress-track.thin { height: 7px; }
.status-line { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- Dashboard ---------- */
.hero-card { padding: 0; overflow: hidden; }
.mini-canvas { width: 100%; height: 150px; display: block; }
.hero-info { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.hero-island { font-weight: 700; font-size: 17px; }
.hero-level, .hero-rate { color: var(--muted); font-size: 13px; }
.hero-rate strong { color: var(--gold-soft); }
.offline-card { border-color: rgba(127, 212, 255, 0.4); background: #16283f; }
#dashMissions .row-card { padding: 10px 12px; }

/* ---------- Mining ---------- */
.mine-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #0a0f1a; }
.mine-canvas { width: 100%; height: 340px; display: block; touch-action: manipulation; cursor: pointer; }
.tap-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(10, 15, 26, 0.75); color: var(--gold-soft); font-weight: 800; letter-spacing: 0.14em; font-size: 13px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); pointer-events: none; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.85; } 50% { opacity: 0.4; } }
.prod-strip { display: flex; flex-wrap: wrap; gap: 8px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; }
.boosts { color: var(--diamond); font-weight: 700; }
.progress-block { display: flex; flex-direction: column; gap: 6px; }
.progress-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.action-row .btn { flex: 1 1 auto; }

/* ---------- Map ---------- */
.map-canvas { width: 100%; height: 380px; display: block; border-radius: var(--radius); border: 1px solid var(--border); background: #0e2a3d; touch-action: manipulation; cursor: pointer; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.dot-locked { background: #5a5a66; }
.dot-progress { background: var(--gold); }
.dot-done { background: var(--ok); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; }
.tab { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { background: linear-gradient(135deg, #ffd94d, var(--gold)); color: #241a08; border-color: transparent; }

/* ---------- Equipment / treasure ---------- */
.loadout { display: flex; gap: 10px; }
.loadout-slot { flex: 1; background: var(--panel-3); border: 1px dashed var(--border); border-radius: 10px; padding: 10px 6px; text-align: center; font-size: 12px; }
.loadout-slot .slot-name { display: block; color: var(--muted); margin-bottom: 4px; }
.loadout-slot .slot-item { font-weight: 700; }
.chest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chest-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.chest-art { width: 52px; height: 44px; border-radius: 8px 8px 4px 4px; position: relative; }
.chest-art.wooden { background: linear-gradient(180deg, #8a5a2e, #5a3a1a); }
.chest-art.silver { background: linear-gradient(180deg, #d8dee8, #8a94a8); }
.chest-art.golden { background: linear-gradient(180deg, #ffe27a, #c98f1a); box-shadow: 0 0 16px rgba(242, 185, 59, 0.5); }
.chest-art.diamond { background: linear-gradient(180deg, #bfe9ff, #2a7ab0); box-shadow: 0 0 18px rgba(127, 212, 255, 0.6); }
.chest-art::after { content: ""; position: absolute; left: 50%; top: -4px; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 3px; background: var(--gold); }
.gem-row { display: flex; gap: 10px; flex-wrap: wrap; }
.gem-chip { flex: 1; min-width: 70px; background: var(--panel-3); border-radius: 10px; padding: 10px 6px; text-align: center; }
.gem-chip .gem-dot { display: block; width: 16px; height: 16px; margin: 0 auto 4px; transform: rotate(45deg); border-radius: 4px; }
.gem-dot.ruby { background: var(--ruby); }
.gem-dot.sapphire { background: var(--diamond); }
.gem-dot.emerald { background: var(--emerald); }
.gem-dot.topaz { background: var(--gold); }
.plain-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.reveal { background: #16283f; border: 1px solid var(--gold); border-radius: var(--radius); padding: 16px; text-align: center; }
.reveal h3 { color: var(--gold-soft); }

/* ---------- Missions / achievements ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px; text-align: center; font-size: 11px; color: var(--muted); min-height: 76px; }
.ach-card.unlocked { border-color: var(--gold); color: var(--gold-soft); background: #2a2410; }
.ach-card .ach-icon { font-size: 20px; display: block; margin-bottom: 4px; }
.streak-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.streak-day { background: var(--panel-3); border: 1px solid var(--border); border-radius: 10px; padding: 8px 2px; text-align: center; font-size: 11px; min-height: 74px; }
.streak-day.today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); animation: pulse 1.6s infinite; }
.streak-day.claimed { opacity: 0.55; }
.streak-day .day-num { display: block; font-weight: 800; margin-bottom: 4px; }

/* ---------- Leaderboard / friends ---------- */
.prize-banner { background: #2a2410; border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--gold-soft); margin: 0; }
.demo-label { font-size: 11px; color: var(--muted); margin: 0; }
.rank-card { text-align: center; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.rank-row.me { border-color: var(--gold); background: #2a2410; }
.rank-row.top1 { border-color: #ffd94d; }
.rank-row.top2 { border-color: #d8dee8; }
.rank-row.top3 { border-color: #d08a4a; }
.rank-num { width: 30px; font-weight: 800; text-align: center; }
.rank-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-gold { font-weight: 700; color: var(--gold-soft); }
.stats-row { display: flex; gap: 10px; }
.stat-box { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px; text-align: center; }
.stat-box .stat-num { display: block; font-weight: 800; font-size: 18px; }
.stat-box .stat-label { font-size: 11px; color: var(--muted); }
.ref-link { word-break: break-all; background: var(--panel-3); border-radius: 8px; padding: 10px; font-size: 13px; }

/* ---------- VIP / settings / profile ---------- */
.vip-hero { text-align: center; padding: 8px 0 0; }
.vip-crown { font-size: 44px; color: var(--gold); text-shadow: 0 0 24px rgba(242, 185, 59, 0.7); }
.vip-hero h2 { margin: 0; }
.benefit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.benefit-list li { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.benefit-list li::before { content: "✓ "; color: var(--ok); font-weight: 800; }
.price-card { text-align: center; }
.dev-box { border-style: dashed; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--gold); }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field-row { display: flex; gap: 8px; }
.field-row input, input[type="text"] { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-3); color: var(--ink); padding: 8px 12px; font: inherit; width: 100%; }
input[type="text"]:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.link-rows { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; }
.card.danger { border-color: rgba(255, 107, 94, 0.5); }
.profile-head { display: flex; gap: 14px; align-items: center; }
.avatar-big { width: 64px; height: 64px; flex: none; border-radius: 50%; background: var(--panel-2); border: 2px solid var(--gold); color: var(--gold-soft); font-size: 28px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
/* STEP 5 — real Telegram photo on the profile screen (same 64px circle
   as the initial avatar; hidden unless Telegram supplied a photo_url). */
.profile-photo { width: 64px; height: 64px; flex: none; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; background: var(--panel-2); }
.profile-username { margin: 0; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.l100-card { border-color: var(--gold); background: #2a2410; }

/* ---------- Modals / sheets / toast / nav ---------- */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(5, 8, 14, 0.78); justify-content: flex-end; padding: 0; }
.modal-sheet { background: var(--panel); border: 1px solid var(--border); border-bottom: none; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); max-width: 480px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; max-height: 88dvh; overflow-y: auto; }
.sheet { position: fixed; inset: 0; z-index: 90; background: rgba(5, 8, 14, 0.7); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); max-width: 480px; width: 100%; display: flex; flex-direction: column; gap: 10px; max-height: 80dvh; overflow-y: auto; }
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(10, 15, 26, 0.96);
  border-top: 1px solid var(--border);
  z-index: 50;
}
.nav-btn { flex: 1; background: none; border: none; color: var(--muted); font: inherit; font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; min-height: 44px; }
.nav-btn .nav-icon { font-size: 18px; }
.nav-btn.active { color: var(--gold); font-weight: 700; }
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 100;
  max-width: 90vw;
  background: #22395a;
  border: 1px solid var(--gold);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  text-align: center;
}

/* ---------- Small screens ---------- */
@media (max-width: 360px) {
  .mine-canvas { height: 300px; }
  .map-canvas { height: 320px; }
  .streak-grid { grid-template-columns: repeat(4, 1fr); }
  .hud-label { display: none; }
}
/* STEP 10 — the HUD labels also overflow at 390px (iPhone 12/13/14):
   with labels shown the flex row's min-content exceeds the viewport
   and the save indicator is pushed past the right edge (P4). Hide the
   labels up to 420px, as the 360px rule already does below it. */
@media (max-width: 420px) {
  .hud-label { display: none; }
}
@media (min-width: 481px) {
  body { background: #05080e; }
}

/* ---------- Step 3: level-up overlay + gemcutter ---------- */
.levelup-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 8, 14, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.levelup-card {
  background: var(--panel); border: 1px solid var(--gold);
  border-radius: 18px; padding: 28px 20px;
  max-width: 340px; width: 100%; text-align: center;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; gap: 10px;
}
.levelup-star { font-size: 44px; color: var(--gold); line-height: 1; }
.levelup-card h2 { color: var(--gold-soft); margin: 0; }
.gem-bank-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
