:root {
  --bg:       #060d18;
  --bg2:      #0a1525;
  --panel:    rgba(6, 13, 24, .72);
  --line:     rgba(255,255,255,.10);
  --text:     #e8f4ff;
  --muted:    rgba(232,244,255,.60);
  --accent:   #22d3c8;
  --accent2:  #3b82f6;
  --gold:     #f8c94a;
  --crystal:  #22f5d8;
}

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

:root { --vh: 1vh; }

html, body, #game-root {
  width: 100%;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#world {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  outline: 0; display: block;
}

.hidden { display: none !important; }

/* ── GLASS utility ─────────────────────────────────── */
.glass {
  background: linear-gradient(160deg, rgba(10,22,40,.82), rgba(4,10,20,.65));
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.glass-pill {
  background: rgba(4,10,20,.54);
  border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(16px);
}

/* ── SPLASH BACKGROUND ─────────────────────────────── */
.splash {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 20;
  padding: 20px;
}

.splash-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34,211,200,.12) 0%, transparent 65%),
              radial-gradient(ellipse 60% 50% at 80% 80%, rgba(59,130,246,.09) 0%, transparent 50%),
              var(--bg);
  overflow: hidden;
}

/* Ambient glow orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  animation: orbFloat 8s ease-in-out infinite;
}
.orb-1 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(34,211,200,.14), transparent 70%);
  top: -120px; left: 50%; transform: translateX(-50%);
  animation-delay: 0s;
}
.orb-2 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(59,130,246,.12), transparent 70%);
  bottom: 10%; right: 8%;
  animation-delay: 3s;
}
.orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(248,201,74,.08), transparent 70%);
  top: 30%; left: 5%;
  animation-delay: 5.5s;
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) translateX(-50%); }
  50%       { transform: translateY(-24px) translateX(-50%); }
}
.orb-2 { animation-name: orbFloat2; }
.orb-3 { animation-name: orbFloat3; }
@keyframes orbFloat2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(10px,-18px)} }
@keyframes orbFloat3 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-8px,14px)} }

/* Grid lines */
.grid-lines {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(34,211,200,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34,211,200,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
}

/* Crystal cluster (decorative) */
.crystal-cluster {
  position: absolute;
  right: 12%; top: 50%;
  transform: translateY(-50%);
  width: 160px; height: 220px;
  opacity: .55;
}
.crystal {
  position: absolute;
  bottom: 0;
  border-radius: 2px 2px 0 0;
  animation: crystalPulse 3s ease-in-out infinite;
}
.c1 { left:60px; width:22px; height:110px; background: linear-gradient(to top,#0e6b64,#22f5d8,#a0fff5); animation-delay:0s; }
.c2 { left:82px; width:18px; height:140px; background: linear-gradient(to top,#0d5f5a,#1ee8d2,#c0fffa); animation-delay:.4s; }
.c3 { left:40px; width:16px; height:85px;  background: linear-gradient(to top,#0a4d48,#18c4b0,#80fff5); animation-delay:.8s; }
.c4 { left:100px;width:14px; height:96px;  background: linear-gradient(to top,#0a4d48,#18c4b0,#80fff5); animation-delay:1.2s; }
.c5 { left:24px; width:12px; height:62px;  background: linear-gradient(to top,#094540,#14a89a,#70f0e8); animation-delay:1.6s; }
@keyframes crystalPulse {
  0%,100% { filter: brightness(1) drop-shadow(0 0 6px rgba(34,245,216,.3)); }
  50%      { filter: brightness(1.25) drop-shadow(0 0 18px rgba(34,245,216,.7)); }
}
@media (max-width: 700px) { .crystal-cluster { display: none; } }

/* ── SPLASH CARD ───────────────────────────────────── */
.splash-card {
  position: relative;
  width: min(520px, 94vw);
  border: 1px solid rgba(34,211,200,.20);
  border-radius: 32px;
  padding: 44px 38px 36px;
  background: linear-gradient(155deg, rgba(8,18,34,.96) 0%, rgba(10,28,50,.88) 100%);
  box-shadow: 0 0 0 1px rgba(34,211,200,.06), 0 42px 100px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06);
  animation: cardIn .55s cubic-bezier(.22,1,.36,1) both;
}
.splash-card h1 { font-size: clamp(32px, 6vw, 48px); letter-spacing: .08em; text-align: center; margin-bottom: 6px; color: #f1f8ff; }
.splash-tag { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .35em; text-transform: uppercase; margin-bottom: 24px; }
@keyframes cardIn {
  from { opacity:0; transform: translateY(28px) scale(.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.brand-glyph {
  font-size: 28px;
  color: var(--crystal);
  filter: drop-shadow(0 0 14px rgba(34,245,216,.6));
  text-align: center;
  animation: glyphPulse 2.5s ease-in-out infinite;
}
@keyframes glyphPulse {
  0%,100% { filter: drop-shadow(0 0 10px rgba(34,245,216,.5)); }
  50%      { filter: drop-shadow(0 0 24px rgba(34,245,216,.9)); }
}

.brand-title {
  text-align: center;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: .16em;
  background: linear-gradient(135deg, #e0f8ff 0%, #22d3c8 45%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 6px 0 0;
  line-height: 1;
}

.brand-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .08em;
  margin: 8px 0 24px;
}

.form-group { margin-bottom: 14px; }
.input-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(232,244,255,.48);
  margin-bottom: 7px;
}

input[type="text"], input:not([type="color"]) {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
input:not([type="color"]):focus {
  border-color: rgba(34,211,200,.5);
  background: rgba(255,255,255,.09);
}

.color-row input[type="color"] {
  width: 46px; height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  padding: 6px;
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  margin-top: 6px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #22d3c8 0%, #3b82f6 100%);
  color: white;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(34,211,200,.28);
  transition: transform .15s, box-shadow .15s;
}
.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(34,211,200,.40);
}
.primary-btn:active { transform: translateY(0); }

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
  list-style: none;
  justify-content: center;
}
.feature-pills li {
  font-size: 11px;
  color: rgba(34,211,200,.7);
  border: 1px solid rgba(34,211,200,.2);
  border-radius: 99px;
  padding: 4px 12px;
  background: rgba(34,211,200,.05);
}

/* ── HUD ───────────────────────────────────────────── */
.hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  transform: scale(var(--tc-ui-scale, 1.0));
  transform-origin: top left;
  width: calc(100% / var(--tc-ui-scale, 1.0)) !important;
  height: calc(100% / var(--tc-ui-scale, 1.0)) !important;
}
body.panel-open .hud { pointer-events: auto; }

/* Top bar */
.topbar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px; right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.identity {
  display: flex; align-items: center; gap: 9px;
  border-radius: 18px; padding: 9px 14px;
}
.tc-glyph {
  font-size: 18px;
  color: var(--crystal);
  filter: drop-shadow(0 0 8px rgba(34,245,216,.5));
  flex-shrink: 0;
}
.id-info strong { display:block; font-size:13px; letter-spacing:.04em; }
.id-info small  { color: var(--muted); font-size:11px; }

.topbar-right { display: flex; gap: 8px; align-items: center; }
.stats-pill {
  border-radius: 99px;
  padding: 8px 14px;
  display: flex; align-items: center; gap: 5px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wallet-pill.hidden { display: none !important; }
.cp-dot  { font-size:11px; color: var(--crystal); }
.cp-label{ color: var(--muted); font-size:11px; }

/* Crosshair */
.crosshair {
  position: absolute; left:50%; top:50%;
  width:20px; height:20px;
  transform: translate(-50%,-50%);
}
.crosshair::before, .crosshair::after {
  content:""; position:absolute;
  background: rgba(255,255,255,.78);
  border-radius: 99px;
}
.crosshair::before { width:20px; height:2px; top:9px; left:0; }
.crosshair::after  { height:20px; width:2px; left:9px; top:0; }

/* Panels */
.left-panel {
  position: absolute; top: 82px; left: 14px;
  width: 230px; border-radius: 22px; padding: 15px;
}
.panel-title {
  color: var(--gold);
  font-size: 11px; letter-spacing:.14em;
  text-transform: uppercase; margin-bottom:10px;
}
.quest {
  font-size: 12px;
  padding: 8px 10px 8px 26px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-bottom: 3px;
}
.quest:hover {
  background: rgba(0, 242, 254, 0.03);
  color: #fff;
}
.quest::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
}
.quest.done {
  color: #00ff87 !important;
  text-shadow: 0 0 8px rgba(0, 255, 135, 0.15);
}
.quest.done::before {
  content: "";
  background: #00ff87 !important;
  border-color: #00ff87 !important;
  box-shadow: 0 0 8px #00ff87, 0 0 15px rgba(0, 255, 135, 0.4);
}
.quest span {
  float: right;
  font-variant-numeric: tabular-nums;
  opacity: .8;
  font-family: monospace;
}

.system-panel {
  position: absolute; top: 82px; right: 14px;
  width: 238px; border-radius: 22px; padding: 15px;
  pointer-events: auto;
}

/* Inventory panel */
.inventory-panel {
  position: absolute; top: 82px; right: 14px;
  width: 268px; max-height: calc(100vh - 110px); overflow-y: auto;
  border-radius: 22px; padding: 14px 15px 12px;
  pointer-events: auto;
}
.inv-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.inv-wallet {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
  background: rgba(34,211,200,.10); border: 1px solid rgba(34,211,200,.22);
  padding: 3px 8px; border-radius: 999px;
}
.inv-section { margin-top: 10px; }
.inv-section h4 {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 6px;
}
.inv-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.inv-item {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; min-width: 50px;
}
.inv-item b { font-size: 14px; color: var(--text); margin-top: 2px; }
.inv-item.edible {
  cursor: pointer;
  border-color: rgba(255,184,107,.40);
  background: rgba(255,184,107,.06);
}
.inv-item.edible:hover {
  background: rgba(255,184,107,.18);
  transform: translateY(-2px);
}
.inv-tools { display: flex; flex-direction: column; gap: 6px; }
.tool-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 7px 9px; cursor: pointer;
  transition: all .15s;
}
.tool-row.equipped { border-color: var(--accent); background: rgba(34,211,200,.07); }
.tool-row .tool-icon { font-size: 18px; line-height: 1; }
.tool-row .tool-info { flex: 1; min-width: 0; }
.tool-row .tool-name { font-size: 12px; font-weight: 600; color: var(--text); }
.tool-row .tool-meta { font-size: 10px; color: var(--muted); }
.tool-row .dur {
  width: 60px; height: 5px; background: rgba(255,255,255,.08);
  border-radius: 3px; overflow: hidden;
}
.tool-row .dur > span {
  display: block; height: 100%; background: var(--accent);
  border-radius: 3px; transition: width .25s;
}
.tool-row.broken .dur > span { background: #ff5a4a; }

/* Armor slots */
.inv-armor-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.armor-slot {
  background: rgba(255,255,255,.04);
  border: 1px dashed rgba(255,255,255,.10);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.armor-slot.equipped {
  background: rgba(34,211,200,.07);
  border-color: rgba(34,211,200,.30);
  border-style: solid;
  color: var(--text);
  cursor: pointer;
}
.armor-slot.equipped .a-icon { font-size: 18px; display: block; margin-bottom: 2px; }
.armor-slot.equipped .a-label { font-size: 10px; font-weight: 700; }
.armor-slot.equipped .a-dur {
  width: 100%; height: 3px; background: rgba(255,255,255,.10);
  border-radius: 2px; margin-top: 4px; overflow: hidden;
}
.armor-slot.equipped .a-dur > span {
  display: block; height: 100%; background: var(--accent);
}
.inv-armor-owned {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px;
}
.armor-own {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px; padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.armor-own:hover { background: rgba(34,211,200,.10); border-color: var(--accent); }
.inv-wallet-info {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px; padding: 8px 10px; font-size: 11px; color: var(--muted);
  line-height: 1.5;
}
.inv-wallet-info b { color: var(--text); }

/* AI badge */
.ai-badge {
  font-size: 11px; padding: 6px 10px; border-radius: 8px;
  background: rgba(255,90,74,.06);
  border: 1px solid rgba(255,90,74,.30);
  color: rgba(255,160,150,.85);
  font-variant-numeric: tabular-nums;
}
.ai-badge.on {
  background: rgba(110,200,140,.06);
  border-color: rgba(110,200,140,.30);
  color: rgba(160,230,180,.95);
}

/* Craft */
.inv-craft { display: flex; flex-direction: column; gap: 6px; }
.craft-row {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 7px 9px;
}
.craft-row.avail { border-color: rgba(34,211,200,.32); }
.craft-head {
  display: flex; align-items: center; gap: 8px;
}
.craft-head > div { flex: 1; min-width: 0; }
.craft-btn {
  font-size: 10px; letter-spacing: .12em; font-weight: 700;
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid rgba(34,211,200,.40);
  background: rgba(34,211,200,.10);
  color: var(--accent); cursor: pointer;
}
.craft-btn:disabled {
  border-color: rgba(255,255,255,.10);
  background: rgba(255,255,255,.02);
  color: var(--muted); cursor: not-allowed;
}
.craft-btn:hover:not(:disabled) {
  background: rgba(34,211,200,.18);
  transform: translateY(-1px);
}
.craft-reqs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.craft-reqs .req {
  font-size: 10px; padding: 3px 6px; border-radius: 6px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  display: inline-flex; align-items: center; gap: 3px;
}
.craft-reqs .req.short { border-color: rgba(255,90,74,.30); color: rgba(255,160,150,.85); }
.craft-reqs .req.ok    { border-color: rgba(110,200,140,.30); color: rgba(160,230,180,.95); }
.craft-reqs .req b { font-weight: 700; }

.panel-hint { font-size: 10px; color: var(--muted); margin-top: 10px; text-align: right; letter-spacing: .06em; }

/* Mob HP bar */
.mob-hp {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50px);
  pointer-events: none;
  background: rgba(4,12,22,.78); border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(8px); border-radius: 10px; padding: 5px 10px;
  text-align: center; min-width: 140px;
}
.mob-hp-name {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text); font-weight: 700; margin-bottom: 4px;
}
.mob-hp-bar {
  height: 6px; background: rgba(255,255,255,.10);
  border-radius: 3px; overflow: hidden;
}
.mob-hp-fill {
  height: 100%; background: linear-gradient(90deg, #ff5a4a, #f8c94a);
  width: 100%; transition: width .15s;
}

/* Tier pill */
.icon-btn {
  cursor: pointer; font-size: 14px;
  padding: 6px 9px; min-width: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(4,10,20,.54);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.10);
  transition: all .12s;
  pointer-events: auto;
  touch-action: manipulation;
}
.icon-btn:hover { background: rgba(34,211,200,.10); }
.icon-btn.muted { opacity: 0.55; background: rgba(180,80,80,.10); }

.tier-dot { color: var(--gold); margin-right: 2px; }
#tierPill[data-tier="iron"] .tier-dot     { color: #b8c3d1; }
#tierPill[data-tier="gold"] .tier-dot     { color: #f8c94a; }
#tierPill[data-tier="advanced"] .tier-dot { color: #ffb86b; }
#tierPill[data-tier="diamond"] .tier-dot  { color: #88e0ff; text-shadow: 0 0 8px rgba(136,224,255,.45); }

/* Reward toast (rare/queue events) */
.reward-toast {
  position: absolute;
  left: 50%; top: 60px;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(34,211,200,.18), rgba(4,12,22,.92));
  border: 1px solid rgba(34,211,200,.40);
  border-radius: 14px; padding: 11px 18px;
  pointer-events: none; font-size: 13px;
  letter-spacing: .04em; min-width: 220px;
  box-shadow: 0 12px 36px rgba(34,211,200,.20);
  text-align: center;
}
.reward-toast.hidden { display: none; }
.reward-toast b { color: var(--accent); }
.reward-toast small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; letter-spacing: .12em; }

/* Splash wallet input hint */
.input-label .hint { color: var(--muted); font-weight: 400; }

/* Wallet connect button + status */
.connect-wallet-btn {
  width: 100%; margin-top: 8px;
  background: linear-gradient(135deg, rgba(248,158,40,.15), rgba(238,114,49,.10));
  border: 1px solid rgba(248,158,40,.40);
  color: #ffb86b;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
}
.connect-wallet-btn:hover {
  background: linear-gradient(135deg, rgba(248,158,40,.25), rgba(238,114,49,.18));
  transform: translateY(-1px);
}
.connect-wallet-btn:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
.wallet-status {
  font-size: 11px; letter-spacing: .04em;
  padding: 8px 10px; margin-top: 8px;
  border-radius: 8px;
  background: rgba(110,200,140,.08);
  border: 1px solid rgba(110,200,140,.30);
  color: rgba(160,230,180,.95);
  font-family: ui-monospace, monospace;
  word-break: break-all;
}
.wallet-status.error {
  background: rgba(255,90,74,.08);
  border-color: rgba(255,90,74,.30);
  color: rgba(255,160,150,.95);
}

/* Passive XYZ + clock pill (under topbar) */
.pos-hud {
  position: absolute;
  left: 50%; top: 64px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 14px;
  font-size: 11px; letter-spacing: .08em;
  color: var(--text); font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 3;
}
.pos-sep { color: rgba(255,255,255,.18); }
#biomeText { color: var(--accent); font-weight: 600; }
#clockText { color: var(--gold); font-weight: 700; }

/* Crosshair color states */
.crosshair[data-mode="hostile"]::before,
.crosshair[data-mode="hostile"]::after { background: rgba(255,90,74,.95); }
.crosshair[data-mode="passive"]::before,
.crosshair[data-mode="passive"]::after { background: rgba(140,220,160,.95); }
.crosshair[data-mode="block"]::before,
.crosshair[data-mode="block"]::after   { background: rgba(248,201,74,.95); }

/* Leaderboard panel */
.leaderboard-panel {
  position: absolute; left: 14px; top: 82px;
  width: 280px; max-height: calc(100vh - 110px); overflow-y: auto;
  border-radius: 22px; padding: 14px 15px 12px;
  pointer-events: auto;
}
.lb-tabs { display: flex; gap: 4px; margin: 8px 0 10px; }
.lb-tab {
  flex: 1; padding: 5px 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: var(--muted); font-size: 11px; font-weight: 600;
  cursor: pointer; letter-spacing: .08em;
}
.lb-tab.active {
  background: rgba(34,211,200,.12);
  border-color: var(--accent);
  color: var(--accent);
}
.lb-list { display: flex; flex-direction: column; gap: 5px; }
.lb-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px; padding: 6px 9px; font-size: 12px;
}
.lb-row.self {
  background: rgba(34,211,200,.10);
  border-color: rgba(34,211,200,.32);
}
.lb-rank { width: 22px; font-weight: 700; color: var(--gold); font-size: 11px; }
.lb-name { flex: 1; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tier {
  font-size: 9px; letter-spacing: .12em;
  background: rgba(248,201,74,.10); color: var(--gold);
  padding: 2px 6px; border-radius: 6px; font-weight: 700;
}
.lb-tier[data-tier="diamond"] { background: rgba(136,224,255,.12); color: #88e0ff; }
.lb-tier[data-tier="iron"]    { background: rgba(184,195,209,.10); color: #b8c3d1; }
.lb-tier[data-tier="advanced"]{ background: rgba(255,184,107,.10); color: #ffb86b; }
.lb-tier[data-tier="basic"]   { background: rgba(255,255,255,.04); color: var(--muted); }
.lb-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; }

/* Tutorial overlay */
.tutorial {
  position: fixed; inset: 0;
  background: rgba(6,8,14,.78);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  z-index: 25;
  padding: 20px;
}
.tutorial-card {
  max-width: 440px; width: 100%;
  border-radius: 22px; padding: 28px 32px;
  text-align: center;
}
.tutorial-card h2 {
  font-size: 22px; letter-spacing: .12em;
  margin-bottom: 16px; color: var(--accent);
}
.tut-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin-bottom: 14px;
  text-align: left;
}
.tut-row {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px; padding: 6px 10px; font-size: 12px;
  color: var(--muted);
}
.tut-row b { color: var(--text); margin-right: 6px; font-weight: 700; }
.tut-tips {
  background: rgba(34,211,200,.05);
  border: 1px solid rgba(34,211,200,.18);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
  text-align: left; font-size: 12px; line-height: 1.55;
  color: var(--muted);
}
.tut-tips p { margin-bottom: 5px; }
.tut-tips p:last-child { margin-bottom: 0; }
.tut-tips b { color: var(--accent); }

@media (max-width: 800px), (pointer: coarse) {
  .pos-hud { font-size: 10px; padding: 4px 10px; top: 56px; }
  .leaderboard-panel { width: 88vw; left: 6vw; top: 60px; max-width: 320px; }
  .tut-grid { grid-template-columns: 1fr; }
}

/* ── Trader / Shop ──────────────────────────────────────── */
.trader-hint {
  position: absolute;
  left: 50%; bottom: 130px;
  transform: translateX(-50%);
  background: rgba(4,12,22,.88);
  border: 1px solid rgba(248,201,74,.40);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  letter-spacing: .04em;
  pointer-events: none;
  z-index: 8;
  box-shadow: 0 8px 24px rgba(248,201,74,.15);
}
.trader-hint b {
  color: var(--gold); font-weight: 800;
  background: rgba(248,201,74,.15);
  padding: 2px 7px; border-radius: 6px;
  margin-right: 6px;
}
.shop-panel {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 480px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px); overflow-y: auto;
  border-radius: 22px; padding: 18px 22px;
  pointer-events: auto;
  z-index: 12;
}
.shop-tabs { display: flex; gap: 6px; margin: 8px 0 12px; }
.shop-tab {
  flex: 1; padding: 8px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: .12em; cursor: pointer; text-transform: uppercase;
}
.shop-tab.active {
  background: rgba(248,201,74,.10);
  border-color: var(--gold); color: var(--gold);
}
.shop-list { display: flex; flex-direction: column; gap: 6px; }
.shop-list.hidden { display: none; }
.shop-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 12px; padding: 8px 10px;
}
.shop-row.avail { border-color: rgba(248,201,74,.32); }
.shop-icon { font-size: 22px; line-height: 1; }
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 13px; color: var(--text); font-weight: 700; }
.shop-meta { font-size: 10px; color: var(--muted); margin-top: 1px; }
.shop-price {
  font-size: 12px; font-weight: 700; color: var(--gold);
  background: rgba(248,201,74,.10);
  padding: 4px 8px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.shop-row .qty {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.04);
  border-radius: 8px; padding: 2px 4px;
}
.shop-row .qty button {
  width: 22px; height: 22px;
  border: 0; border-radius: 5px;
  background: rgba(255,255,255,.06);
  color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 700;
}
.shop-row .qty input {
  width: 36px; text-align: center;
  background: transparent; border: 0;
  color: var(--text); font-weight: 700;
  font-size: 12px;
}
.shop-bar {
  text-align: center; margin-top: 10px;
  padding: 8px;
  background: rgba(34,211,200,.05);
  border: 1px solid rgba(34,211,200,.20);
  border-radius: 10px;
  font-size: 12px; color: var(--muted);
}
.shop-bar b { color: var(--accent); font-weight: 800; font-size: 14px; margin-left: 4px; }
.shop-btn {
  font-size: 11px; padding: 6px 12px;
  background: rgba(34,211,200,.10);
  border: 1px solid var(--accent);
  color: var(--accent); border-radius: 8px;
  cursor: pointer; font-weight: 700; letter-spacing: .08em;
}
.shop-btn:disabled {
  background: rgba(255,255,255,.02);
  border-color: rgba(255,255,255,.08);
  color: var(--muted); cursor: not-allowed;
}

/* Stamina bar (left of HP bar at bottom) */
.stamina-bar {
  position: absolute;
  left: 50%;
  bottom: max(98px, calc(env(safe-area-inset-bottom) + 28px));
  transform: translateX(-50%);
  width: 132px; height: 5px;
  background: rgba(255,255,255,.08);
  border-radius: 3px; overflow: hidden;
  pointer-events: none;
}
.stamina-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #f8c94a, #65d088);
  transition: width .08s linear;
}
.stamina-bar.low .stamina-fill {
  background: linear-gradient(90deg, #ff5a4a, #f8c94a);
}

@media (pointer: coarse), (max-width: 800px) {
  .stamina-bar { bottom: calc(env(safe-area-inset-bottom) + 124px); width: 100px; }
  .shop-panel  { width: 92vw; padding: 14px 16px; }
}

/* ── Settings panel ─────────────────────────────────────── */
.settings-panel {
  position: absolute; right: 14px; top: 82px;
  width: 320px; max-height: calc(100vh - 110px); overflow-y: auto;
  border-radius: 22px; padding: 14px 15px 12px;
  pointer-events: auto;
  z-index: 1100;
}
.pause-panel {
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 28px));
}
.pause-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pause-grid .craft-btn {
  min-height: 38px;
  justify-content: center;
}
@media (max-width: 520px) {
  .pause-grid { grid-template-columns: 1fr; }
}
.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid rgba(255,255,255,.04);
}
.setting-row:first-child { border-top: 0; }
.setting-row label { color: var(--text); font-weight: 600; }
.setting-row label small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.setting-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
}
.setting-row .setting-val {
  font-size: 11px; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right; min-width: 44px;
  grid-column: 2;
  grid-row: 1;
}
.setting-row input[type="checkbox"] {
  width: 36px; height: 20px;
  appearance: none;
  background: rgba(255,255,255,.10);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background .15s;
}
.setting-row input[type="checkbox"]::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #cfd6df;
  transition: left .15s;
}
.setting-row input[type="checkbox"]:checked {
  background: rgba(34,211,200,.50);
}
.setting-row input[type="checkbox"]:checked::after {
  left: 18px; background: var(--accent);
}
.setting-row select {
  font-size: 11px; padding: 4px 8px; border-radius: 6px;
  background: rgba(4,10,20,.50);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.10);
}
.setting-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.setting-actions .craft-btn { font-size: 10px; }

/* Achievements list */
.ach-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ach-badge {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 8px;
  padding: 7px 5px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  opacity: 0.45;
}
.ach-badge.unlocked {
  opacity: 1;
  background: rgba(248,201,74,.06);
  border-color: rgba(248,201,74,.30);
}
.ach-badge.unlocked .ach-icon { color: var(--gold); }
.ach-icon { font-size: 18px; margin-bottom: 3px; }
.ach-label { font-weight: 700; color: var(--text); }
.ach-hint  { font-size: 9px; line-height: 1.3; margin-top: 2px; }
.ach-cp { color: var(--accent); font-weight: 700; font-size: 9px; margin-top: 2px; }

@media (max-width: 800px), (pointer: coarse) {
  .settings-panel { width: 88vw; right: 6vw; max-width: 320px; }
  .ach-list { grid-template-columns: 1fr 1fr; }
}

/* Player HP + Hunger (bottom center above hotbar) */
.player-hp {
  position: absolute;
  left: 50%;
  bottom: max(70px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 12px; border-radius: 14px;
  pointer-events: none; font-size: 11px; letter-spacing: .06em;
  z-index: 4;
}
.hp-row {
  display: flex; align-items: center; gap: 8px;
}
.player-hp-icon { color: #ff5a4a; font-size: 14px; min-width: 16px; }
.player-hp-icon.hungry { color: #ffb86b; font-size: 13px; }
.player-hp-bar {
  width: 132px; height: 7px;
  background: rgba(255,255,255,.10);
  border-radius: 4px; overflow: hidden;
}
.player-hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff5a4a, #f8c94a 70%, #65d088);
  transition: width .25s;
}
.player-hunger-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #c87838, #ffb86b 70%, #ffd8a0);
  transition: width .25s;
}
.player-xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6ea356, #aaf08e 70%, #c8ffc6);
  transition: width .25s;
}
.player-breath-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #1d6fa5, #4ba6ff 70%, #9be3ff);
  transition: width .25s;
}
/* Compass widget */
.compass {
  width: 64px; height: 64px;
  position: relative;
  border-radius: 50%;
  display: grid; place-items: center;
}
.compass-dial {
  position: absolute; inset: 6px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  transition: transform .15s linear;
}
.compass-dial .cardinal {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  color: rgba(220,235,255,.85);
  letter-spacing: .05em;
}
.compass-dial .n { top: 2px;   left: 50%; transform: translateX(-50%); color:#ff7a6b; }
.compass-dial .s { bottom: 2px;left: 50%; transform: translateX(-50%); }
.compass-dial .e { right: 2px; top: 50%;  transform: translateY(-50%); }
.compass-dial .w { left: 2px;  top: 50%;  transform: translateY(-50%); }
.compass-needle {
  position: absolute;
  left: 50%; top: 50%;
  width: 2px; height: 18px;
  margin-left: -1px;
  margin-top: -18px;
  transform-origin: 1px 18px;
  border-radius: 1px;
}
.compass-needle.north { background: #ff7a6b; }
.compass-needle.spawn { background: #f8c94a; transition: transform .25s ease; }
#playerHpText, #playerHungerText, #xpLabel { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 56px; text-align: right; font-size: 11px; text-shadow: 0 1px 2px rgba(0,0,0,.85); }
.player-hp-icon, .player-hp-icon.hungry { text-shadow: 0 1px 2px rgba(0,0,0,.7); }

/* Damage vignette */
.damage-vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(255,40,40,.55) 100%);
  opacity: 0;
  transition: opacity .12s ease-out;
  z-index: 12;
}
.damage-vignette.show { opacity: 1; }

/* Death screen */
.death-screen {
  position: fixed; inset: 0;
  background: rgba(8,6,10,.72);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  z-index: 50;
  pointer-events: auto;
}
.death-screen #respawnBtn { pointer-events: auto; touch-action: manipulation; cursor: pointer; }
.death-card {
  background: linear-gradient(160deg, rgba(40,12,18,.90), rgba(8,4,8,.92));
  border: 1px solid rgba(255,90,90,.30);
  border-radius: 22px; padding: 32px 38px;
  text-align: center; min-width: 280px;
  box-shadow: 0 24px 80px rgba(255,80,80,.25);
}
.death-glyph { font-size: 48px; color: #ff5a4a; margin-bottom: 10px; }
.death-card h2 { font-size: 24px; letter-spacing: .08em; margin-bottom: 8px; color: var(--text); }
.death-card p { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.death-card .primary-btn { width: 100%; }

/* Mobile player HP — moved to top-left so the joystick/hotbar no longer clip it.
   Uses `body .player-hp` + !important to beat the later global `.player-hp { bottom:96px !important }` (style.css ~2665). */
@media (pointer: coarse), (max-width: 800px) {
  body .player-hp {
    top: 120px !important; left: 8px !important; right: auto !important; bottom: auto !important;
    transform: none !important;
    align-items: flex-start !important;
    padding: 8px 11px !important;
    gap: 4px !important;
    max-width: 168px !important;
  }
  body .player-hp-bar { width: 84px !important; }
  /* The verbose "Lv 1 — 0/80 XP" string blows the panel wide; drop it on mobile (bar still shown). */
  body .player-hp #xpLabel { display: none !important; }
  body .player-hp .hp-row > span:last-child { font-size: 10px !important; }
}

/* Mobile splash: ekran boyutunu aşma, klavye yüzünden de uçma */
@media (pointer: coarse), (max-width: 800px) {
  .splash { padding: 12px; }
  .splash-card {
    max-width: 92vw;
    max-height: calc(var(--vh, 1vh) * 100 - 24px);
    overflow-y: auto;
    padding: 20px 22px;
  }
  .brand-title { font-size: 28px !important; }
  .brand-tagline { font-size: 12px !important; margin-bottom: 14px !important; }
  .primary-btn {
    height: 54px;
    font-size: 16px;
    -webkit-tap-highlight-color: rgba(34,211,200,.40);
    touch-action: manipulation;
  }
  input[type="text"], input#playerName, input#walletCode {
    font-size: 16px;             /* iOS zoom-in trigger 16px altında olur */
  }
  .feature-pills { display: none; }   /* küçük ekranda yer kaplamasın */
}
.row {
  display:flex; justify-content:space-between; gap:12px;
  padding:8px 0; border-top:1px solid rgba(255,255,255,.07);
  color:var(--muted); font-size:12.5px;
}
.row b { color:var(--text); font-variant-numeric:tabular-nums; }

/* Claim badge */
.claim-badge {
  position: absolute; left:50%; top: 72px;
  transform: translateX(-50%);
  border-radius: 99px; padding: 8px 18px;
  font-size: 12px; color: var(--accent);
  border-color: rgba(34,211,200,.25);
  white-space: nowrap;
  pointer-events: none;
}

/* Chat wrapper container aligning logs and input dynamically */
.chat-wrapper {
  position: absolute;
  left: 14px;
  bottom: 82px;
  width: 320px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.chat {
  width: 100%;
  max-height: 180px;
  overflow-y: auto;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 12px;
  pointer-events: auto;
}
.chat .msg  { margin: 4px 0; color: rgba(232,244,255,.82); text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.chat .sys  { color: #ffac1c; font-weight: 700; text-shadow: 0 0 8px rgba(255,172,28,0.25); }

.chat-form {
  width: 100%;
  pointer-events: auto;
}
.chat-form input {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(0, 242, 254, 0.22) !important;
  background: rgba(8, 14, 28, 0.85) !important;
  color: white;
  padding: 0 14px;
  font-size: 13px;
  outline: none;
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.05) !important;
  backdrop-filter: blur(12px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-form input:focus {
  border-color: #00f2fe !important;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.25), inset 0 0 8px rgba(0, 242, 254, 0.05) !important;
  background: rgba(10, 16, 32, 0.95) !important;
}

/* Minimap */
.minimap {
  position:absolute; right:14px; bottom:24px;
  width:142px; height:142px; border-radius:20px; opacity:.94;
}

/* Toast */
.toast {
  position:absolute; left:50%; top: 80px;
  transform:translateX(-50%);
  padding:11px 20px; border-radius:99px;
  background:rgba(4,10,20,.8);
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter:blur(16px);
  font-size:13px;
  white-space:nowrap;
}

/* Palette */
.palette {
  position:absolute; left:50%; bottom: max(14px, env(safe-area-inset-bottom));
  transform:translateX(-50%);
  display:flex; gap:7px; padding:9px;
  border-radius:22px; pointer-events:auto;
}
.slot {
  width:46px; height:46px; border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  display:grid; place-items:end;
  padding:3px;
  background-repeat:no-repeat;
  background-color:#1a2738;
  color:white; cursor:pointer;
  image-rendering: pixelated;
}
.slot.active { outline:2px solid var(--accent); transform:translateY(-3px); box-shadow:0 6px 18px rgba(34,211,200,.32); }
.slot-empty {
  font-size: 11px; color: var(--muted); letter-spacing: .04em;
  padding: 10px 16px; background: rgba(255,255,255,.04);
  border: 1px dashed rgba(255,255,255,.15); border-radius: 12px;
}
.slot-key {
  font-size:9px; font-weight:700; opacity:.8;
  background:rgba(0,0,0,.55); padding:1px 4px; border-radius:4px;
  text-shadow:0 1px 1px rgba(0,0,0,.6);
}

/* Mobile controls (hidden on desktop) */
.mobile-controls { display:none; }

/* ── MOBILE ─────────────────────────────────────────── */
@media (max-width: 800px), (pointer: coarse) {
  .left-panel { display: none; }
  .system-panel, .inventory-panel { width: 88vw; max-width: 320px; right: 6vw; top: 60px; }
  .chat-wrapper { display: none !important; }
  .minimap { right:8px; top:72px; bottom:auto; width:90px; height:90px; border-radius:14px; }
  .topbar  { left:8px; right:8px; gap:6px; }
  .identity { padding:7px 10px; }
  .id-info strong { font-size:12px; }
  /* Thin the top-right cluster on phones so pills don't overlap/clip.
     Diagnostics (ping, online count) drop; tier/CP/compass/mute/settings stay. */
  .topbar-right { gap:5px; }
  .topbar-right .stats-pill { padding:6px 9px; }
  .topbar-right .economy-pill .cp-label { display:none; }
  .topbar-right .wallet-pill { display:none !important; }
  #pingPill, #onlinePill { display:none; }
  #tierLabel { display:none; }
  /* The compass is a 64px circular dial that inflates the whole topbar height,
     pushing the clock/pos strip into the pills and colliding with the minimap.
     The minimap already shows orientation (N arrow + spawn marker), so drop it. */
  #compass { display:none; }
  /* Keep the clock/pos/biome strip clearly below the topbar (identity pill is
     two-line, ~69px tall) and left of the minimap. */
  .pos-hud { top: 90px; font-size:10px; padding:5px 11px; }
  .palette { bottom: max(8px, env(safe-area-inset-bottom)); gap:5px; padding:7px; }
  .slot    { width:34px; height:34px; border-radius:11px; font-size:8px; }
  .mobile-controls { display:block; pointer-events:auto; position:absolute; inset:0; }

  .joy {
    position:absolute; left:16px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 72px);
    width:112px; height:112px; border-radius:50%;
    background:rgba(255,255,255,.07);
    border:1px solid rgba(255,255,255,.13);
    backdrop-filter:blur(10px);
  }
  .knob {
    position:absolute; width:46px; height:46px; border-radius:50%;
    left:33px; top:33px;
    background:rgba(34,211,200,.32);
    border:1px solid rgba(255,255,255,.2);
  }
  .look-zone {
    position:absolute; right:0; top:76px;
    width:56vw; height:calc(100vh - 152px);
  }
  /* Right-thumb control cluster: squircle icon buttons hugging the bottom-right,
     primary "Kır" nearest the thumb (column-reverse), mirroring the joystick. */
  .action-stack {
    position:absolute; right:12px;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 96px);
    display:flex; flex-direction:column-reverse; gap:9px;
    pointer-events: auto;
  }
  .action-stack button {
    width:58px; height:58px;
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px;
    border:1px solid rgba(255,255,255,.16);
    border-radius:18px;
    background:rgba(6,12,22,.62);
    color:#eaf6ff;
    backdrop-filter:blur(14px);
    box-shadow:0 8px 22px rgba(0,0,0,.45);
    cursor:pointer;
    touch-action: manipulation;          /* iOS double-tap zoom kapatır */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .action-stack .act-ico { width:23px; height:23px; display:block; }
  .action-stack .act-lbl { font-size:9px; font-weight:700; letter-spacing:.03em; opacity:.92; }
  .action-stack .act-primary {
    width:66px; height:66px; border-radius:21px;
    border-color:rgba(34,211,200,.55);
    background:rgba(34,211,200,.16);
    box-shadow:0 8px 24px rgba(0,0,0,.5), 0 0 16px rgba(34,211,200,.22);
  }
  .action-stack .act-primary .act-ico { width:27px; height:27px; }
  .action-stack button:active {
    background:rgba(34,211,200,.32);
    transform: scale(0.93);
  }
  .claim-badge { top: 68px; font-size:11px; }
}

@media (max-width:800px) and (orientation:portrait), (pointer:coarse) and (orientation:portrait) {
  .palette {
    max-width: 62vw;
    overflow-x: auto !important;
    scrollbar-width: none !important;
  }
  .palette::-webkit-scrollbar {
    display: none !important;
  }
  .slot    { width:30px; height:30px; font-size:7px; }
  .joy     { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 80px); width:104px; height:104px; }
  .knob    { left:29px; top:29px; }
  .action-stack {
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 88px);
  }
}

@media (pointer: coarse) and (orientation: landscape) {
  .topbar {
    top: max(6px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    padding: 6px 10px !important;
  }
  .identity { padding: 6px 9px; }
  .id-info small { display: none; }
  #tierPill, #onlinePill, #pingPill, #compass { display: none !important; }
  .pos-hud {
    top: 58px;
    left: max(8px, env(safe-area-inset-left));
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .minimap {
    top: 58px;
    right: max(8px, env(safe-area-inset-right));
    width: 82px;
    height: 82px;
  }
  .palette {
    bottom: max(6px, env(safe-area-inset-bottom));
    max-width: min(48vw, 410px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .palette::-webkit-scrollbar { display: none; }
  .slot { width: 32px; height: 32px; border-radius: 10px; }
  .joy {
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 118px;
    height: 118px;
  }
  .knob { left: 36px; top: 36px; }
  .look-zone {
    top: 56px;
    right: 0;
    width: 62vw;
    height: calc(100vh - 70px);
  }
  .action-stack {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 68px);
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-auto-rows: 52px;
    gap: 7px;
  }
  .action-stack button,
  .action-stack .act-primary {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }
  .action-stack .act-lbl { display: none; }
  .core-guide {
    display: none !important;
  }
  .player-hp {
    left: 50% !important;
    transform: translateX(-50%) scale(.88);
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + 44px) !important;
  }
  .inventory-modal,
  .settings-panel,
  .shop-panel,
  .leaderboard-panel,
  .inventory-panel,
  #systemPanel,
  #marketPanel,
  #guidePanel {
    max-height: calc(100vh - 24px) !important;
    top: 12px !important;
  }
}

/* ── BREAK PROGRESS RING ────────────────────────────────── */
.break-ring {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, calc(-50% + 36px));
  width: 52px; height: 52px;
  pointer-events: none;
  z-index: 10;
}
#breakArc {
  stroke: var(--accent);
  stroke-dasharray: 125.6;
  stroke-dashoffset: 125.6;
  transform: rotate(-90deg);
  transform-origin: 24px 24px;
  transition: stroke-dashoffset .04s linear;
}

/* ── GAME STATE SYSTEM ───────────────────────────────────
   body.in-game is added by joinRealm() — controls what
   is visible before vs after entering the game.           */
body:not(.in-game) .hud            { display: none !important; }
body:not(.in-game) .mobile-controls { display: none !important; }
body.in-game .splash               { display: none !important; }

/* ── Phase E: UI polish (key hints, tooltip, weather, boss, daily quest) ── */
.key-hints {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 84px;
  display: flex; gap: 8px;
  align-items: center;
  background: rgba(6,12,22,.55);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .04em;
  backdrop-filter: blur(10px);
  pointer-events: none;
  z-index: 4;
}
.key-hints kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
}
.key-hints span { margin-right: 8px; }
/* Declutter: the controls cheatsheet fades out after a while (a learning aid,
   not permanent HUD). Hover brings it back. */
.key-hints { animation: keyHintsFade .6s ease 18s forwards; }
.key-hints:hover { opacity: 1 !important; animation: none !important; }
@keyframes keyHintsFade { to { opacity: 0; } }
@media (pointer:coarse), (max-width:800px) { .key-hints { display: none; } }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(10,18,30,.96);
  border: 1px solid rgba(34,211,200,.32);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  max-width: 220px;
  z-index: 80;
  box-shadow: 0 12px 32px rgba(0,0,0,.4);
}
.tooltip small { display:block; color: var(--muted); margin-top:4px; font-size:10px; }

/* Rain overlay — cinematic sky-drop canvas */
.rain-overlay {
  position: fixed; inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.rain-overlay.show { opacity: 1; }

/* Boss banner */
.boss-banner {
  position: fixed;
  top: 80px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: rgba(28,8,12,.92);
  border: 1px solid rgba(255,90,90,.40);
  border-radius: 14px;
  padding: 10px 18px;
  z-index: 30;
  box-shadow: 0 0 0 1px rgba(255,90,90,.10), 0 20px 60px rgba(160,30,30,.30);
  animation: bossPulse 2s ease-in-out infinite;
}
@keyframes bossPulse {
  0%,100% { box-shadow: 0 0 0 1px rgba(255,90,90,.10), 0 20px 60px rgba(160,30,30,.30); }
  50%      { box-shadow: 0 0 0 1px rgba(255,90,90,.30), 0 24px 80px rgba(220,40,40,.50); }
}
.boss-glyph { font-size: 24px; color: #ff7a6b; }
.boss-info { display: flex; flex-direction: column; gap: 5px; min-width: 240px; }
.boss-info strong { font-size: 14px; color: #ffd0c0; letter-spacing: .08em; }
.boss-hp-bar { width: 240px; height: 8px; background: rgba(255,255,255,.10); border-radius: 4px; overflow: hidden; }
.boss-hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff3030, #ff7a4a 70%, #ffb060);
  transition: width .25s;
}

/* Daily quest banner */
.daily-quest {
  position: fixed;
  top: 80px; right: 14px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  z-index: 9;
  max-width: 320px;
}
.dq-glyph { font-size: 22px; }
.dq-text { display: flex; flex-direction: column; gap: 2px; }
.dq-text strong { font-size: 11px; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; }
.dq-text div { font-size: 12px; color: var(--text); line-height: 1.35; }
.dq-close {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 4px 8px;
}
.dq-close:hover { color: #fff; }

/* Chest grid (storage UI) */
.chest-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
}
.chest-grid .chest-slot {
  aspect-ratio: 1;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  transition: background .12s;
}
.chest-grid .chest-slot:hover { background: rgba(34,211,200,.10); border-color: rgba(34,211,200,.30); }
.chest-grid .chest-slot .count {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 9px; font-weight: 700; color: #f8c94a;
  text-shadow: 1px 1px 1px rgba(0,0,0,.8);
}

/* Marketplace form */
.market-form {
  display: grid;
  grid-template-columns: 1.2fr .8fr .8fr auto;
  gap: 6px;
  align-items: center;
}
.market-form select, .market-form input {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.wallet-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.wallet-actions .wallet-amount {
  height: 34px;
  min-width: 0;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-size: 12px;
}
.wallet-actions .craft-btn {
  min-width: 0;
  padding: 7px 8px;
  font-size: 11px;
}

/* Workbench glow indicator (when nearby) */
.workbench-aura {
  position: fixed;
  bottom: 130px; left: 50%; transform: translateX(-50%);
  background: rgba(20,18,8,.85);
  border: 1px solid rgba(248,201,74,.40);
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 11px;
  color: #f8d678;
  letter-spacing: .04em;
  z-index: 6;
  pointer-events: none;
}

/* Stake bonus pill */
.stake-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px;
}
.stake-pill .stake-icon { color: #aaf08e; }

/* F3 debug overlay */
.debug-panel {
  position: fixed;
  top: 80px; left: 14px;
  background: rgba(4,8,16,.92);
  border: 1px solid rgba(34,211,200,.30);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  z-index: 30;
  pointer-events: none;
  max-width: 320px;
  line-height: 1.35;
}
.debug-panel strong { display: block; color: var(--accent); font-size: 10px; letter-spacing: .12em; margin-bottom: 6px; }
.debug-panel pre { white-space: pre; font-family: inherit; font-size: 11px; }

/* ── Phase F: UI premium polish ── */
/* Hotbar slot — daha okunaklı, item-style border */
.palette {
  padding: 8px !important;
  gap: 5px !important;
  border-radius: 14px !important;
  background: linear-gradient(180deg, rgba(8,14,22,.92), rgba(4,8,14,.88)) !important;
  border: 1px solid rgba(255,255,255,.10) !important;
  box-shadow: 0 14px 40px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06) !important;
}
.palette .slot {
  border: 1px solid rgba(255,255,255,.08) !important;
  border-radius: 9px !important;
  background-color: rgba(255,255,255,.02) !important;
  transition: transform .12s, border-color .15s, box-shadow .15s;
  position: relative;
}
.palette .slot:hover { transform: translateY(-1px); border-color: rgba(34,211,200,.30) !important; }
.palette .slot.active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px rgba(34,211,200,.28), 0 0 16px rgba(34,211,200,.25), inset 0 0 14px rgba(34,211,200,.10) !important;
  transform: translateY(-2px);
}
.palette .slot-key {
  font-weight: 800 !important;
  color: rgba(232,244,255,.55) !important;
  text-shadow: 1px 1px 0 rgba(0,0,0,.7);
}
.palette .slot-empty {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}

/* Tier pill — premium gradient (basic→gray, diamond→cyan) */
#tierPill {
  background: linear-gradient(135deg, rgba(34,211,200,.16), rgba(59,130,246,.12)) !important;
  border-color: rgba(34,211,200,.30) !important;
}
#tierPill .tier-dot { color: var(--gold); text-shadow: 0 0 6px rgba(248,201,74,.4); }

/* CP pill — yumuşak parıltı */
#corePoints { font-weight: 800; }
.cp-dot { color: var(--crystal); text-shadow: 0 0 8px rgba(34,245,216,.5); }

/* Player HP/Hunger/XP bar — daha kalın, daha kontrastlı */
.player-hp { padding: 8px 12px !important; border-radius: 14px !important; }
.player-hp-bar { height: 9px !important; border-radius: 5px !important; }

/* Inventory grid — daha düzgün item kutusu */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin-top: 6px;
}
.inv-grid .inv-item {
  aspect-ratio: 1;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 14px;
  position: relative;
  cursor: pointer;
  transition: background .12s;
}
.inv-grid .inv-item:hover { background: rgba(34,211,200,.10); border-color: rgba(34,211,200,.30); }
.inv-grid .inv-item.edible { border-color: rgba(101,208,136,.32); }
.inv-grid .inv-item .count {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 9px; font-weight: 800; color: var(--gold);
  text-shadow: 1px 1px 0 rgba(0,0,0,.85);
}
.inv-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 3px;
}
.inv-tab {
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.035);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}
.inv-tab.active {
  color: var(--accent);
  border-color: rgba(34,211,200,.38);
  background: rgba(34,211,200,.10);
}
.inv-empty {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  padding: 10px;
  border: 1px dashed rgba(255,255,255,.10);
  border-radius: 10px;
}
.inv-grid .inv-item {
  color: var(--text);
  padding: 0;
}
.inv-grid .inv-item.selected {
  border-color: rgba(248,201,74,.55);
  box-shadow: 0 0 0 1px rgba(248,201,74,.25), 0 8px 20px rgba(0,0,0,.22);
}
.inv-grid .inv-item.food { border-color: rgba(101,208,136,.36); }
.inv-grid .inv-item.blocks { border-color: rgba(34,211,200,.30); }
.inv-grid .inv-item.rare { border-color: rgba(248,201,74,.40); }
.inv-icon {
  font-size: 17px;
  line-height: 1;
}
.inv-action-panel {
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(3,8,18,.34);
}
.iap-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  text-transform: capitalize;
}
.iap-title em {
  margin-left: auto;
  color: var(--gold);
  font-style: normal;
  font-weight: 900;
}
.iap-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 6px;
  margin-top: 8px;
}
.iap-actions button {
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(34,211,200,.28);
  background: rgba(34,211,200,.08);
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}
.iap-actions button:hover {
  background: rgba(34,211,200,.16);
}

/* Tool durability arc — sadece bar yerine progress bar */
.inv-tools .tool-card {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 6px;
}
.inv-tools .tool-card.equipped {
  border-color: rgba(34,211,200,.4);
  box-shadow: 0 0 0 1px rgba(34,211,200,.15);
}
.inv-tools .durability {
  height: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 2px;
  overflow: hidden;
}
.inv-tools .durability > div {
  height: 100%;
  background: linear-gradient(90deg, #ff5a4a 0%, #f8c94a 50%, #65d088 100%);
  transition: width .25s;
}

/* Settings inputs — daha modern */
.settings-panel select,
.settings-panel input[type="range"] {
  accent-color: var(--accent);
}

/* Ping pill colored states */
#pingPill .cp-label { font-size: 9px; opacity: .7; }

/* ── Phase G: inventory item interactions polish ── */
.inv-grid .inv-item {
  cursor: default;
  transition: background .12s, transform .1s, box-shadow .15s;
}
.inv-grid .inv-item.edible {
  cursor: pointer;
  border-color: rgba(101,208,136,.40);
  box-shadow: 0 0 0 1px rgba(101,208,136,.10);
}
.inv-grid .inv-item.edible:hover {
  background: rgba(101,208,136,.18);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(101,208,136,.40), 0 4px 12px rgba(101,208,136,.18);
}
.inv-grid .inv-item.placeable {
  cursor: pointer;
  border-color: rgba(34,211,200,.32);
}
.inv-grid .inv-item.placeable:hover {
  background: rgba(34,211,200,.14);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(34,211,200,.40), 0 4px 12px rgba(34,211,200,.18);
}

/* Inventory legend — kullanıcının hangi action'a sahip olduğunu net gösterir */
.inv-legend {
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--muted);
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.inv-legend .dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 4px; vertical-align: middle;
}
.inv-legend .food-dot { background: #65d088; }
.inv-legend .place-dot { background: var(--accent); }

/* ── Phase H: AI Director / Core Guide ── */
.core-guide {
  position: fixed;
  right: 14px;
  bottom: 200px;
  width: 280px;
  padding: 10px 12px;
  border-radius: 14px;
  z-index: 8;
  font-size: 12px;
  pointer-events: auto;
  border: 1px solid rgba(34,211,200,.22) !important;
}
.cg-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.cg-glyph {
  font-size: 16px;
  color: var(--crystal);
  text-shadow: 0 0 8px rgba(34,245,216,.5);
  animation: glyphPulse 2.8s ease-in-out infinite;
}
.cg-head strong { font-size: 11px; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; }
.cg-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px;
  padding: 2px 8px; border-radius: 6px;
}
.cg-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
.cg-body { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.cg-hint {
  background: rgba(34,211,200,.06);
  border-left: 2px solid var(--accent);
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 12px; line-height: 1.4;
  color: var(--text);
  animation: hintIn .35s cubic-bezier(.22,1,.36,1);
}
@keyframes hintIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.cg-quest {
  margin-top: 8px;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(248,201,74,.10), rgba(248,201,74,.04));
  border: 1px solid rgba(248,201,74,.28);
  border-radius: 9px;
}
.cgq-title { font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 3px; }
.cgq-desc  { font-size: 11px; color: var(--muted); margin-bottom: 4px; line-height: 1.35; }
.cgq-reward { font-size: 10px; color: #aaf08e; letter-spacing: .04em; }
.core-guide.collapsed .cg-body, .core-guide.collapsed .cg-quest { display: none; }
.core-guide.collapsed { width: auto; padding: 6px 12px; }
@media (max-width: 800px), (pointer:coarse) {
  /* Top-right under the minimap so it stops covering the action buttons */
  .core-guide {
    top: 170px; right: 8px; left: auto; bottom: auto;
    width: min(200px, 52vw);
    max-height: 104px; overflow-y: auto;
    font-size: 11px;
  }
}

/* ───────────────────────────────────────────────────────── */
/* PREMIUM 3-COLUMN INVENTORY MODAL & CHEST STYLES         */
/* ───────────────────────────────────────────────────────── */
.inventory-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 920px);
  height: auto;            /* fit content → no huge empty void below the grid */
  max-height: 86vh;
  background: rgba(15, 23, 42, 0.75) !important;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 24px !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7) !important;
  display: flex;
  flex-direction: column;
  color: #f8fafc;
  z-index: 10000;
  pointer-events: auto;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.inventory-modal.hidden {
  display: none !important;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.4);
}

.modal-header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-header-wallet {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-content {
  flex: 1;
  min-height: 0;   /* allow inner grid to scroll instead of stretching the modal */
  display: flex;
  overflow: hidden;
}

/* Sidebar Columns */
.modal-sidebar {
  width: 160px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.2);
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.category-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #f8fafc;
}

.category-btn.active {
  background: rgba(34, 211, 200, 0.12);
  border-color: rgba(34, 211, 200, 0.25);
  color: var(--accent);
}

/* Item Grids */
.modal-grid-container {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}

.item-slot {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  position: relative;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.item-slot:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.item-slot.selected {
  background: rgba(34, 211, 200, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.item-slot .slot-count {
  position: absolute;
  bottom: 4px;
  right: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1;
}

.item-slot .durability-bar {
  position: absolute;
  bottom: 4px;
  left: 6px;
  right: 6px;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.item-slot .durability-bar-fill {
  height: 100%;
  background: #10b981;
  border-radius: 2px;
  transition: width 0.15s ease;
}

/* Rarity highlights */
.item-slot.rare {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.04);
}
.item-slot.rare:hover {
  border-color: rgba(168, 85, 247, 0.8);
  background: rgba(168, 85, 247, 0.08);
}
.item-slot.rare.selected {
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
  border-color: #a855f7;
}

/* Detail actions panel */
.modal-details {
  width: 250px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.2);
}

.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  text-align: center;
  font-size: 12px;
  gap: 8px;
}

.detail-empty-icon {
  font-size: 28px;
  opacity: 0.4;
}

.detail-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.detail-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-icon-box {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.detail-info {
  flex: 1;
}

.detail-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.detail-rarity {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  width: fit-content;
}

.detail-rarity.rare {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.15);
}

.detail-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.stat-label {
  color: #64748b;
}

.stat-value {
  color: #e2e8f0;
  font-weight: 600;
}

.detail-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-btn {
  width: 100%;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.action-btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #0f172a;
}

.action-btn.primary:hover {
  background: #1ebbb1;
  box-shadow: 0 4px 12px rgba(34, 211, 200, 0.25);
}

.hotbar-binder {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.binder-slot {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.binder-slot:hover {
  background: rgba(34, 211, 200, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ───────────────────────────────────────────────────────── */
/* HUD ACTIVE 9-SLOT HOTBAR STYLE UPDATES                    */
/* ───────────────────────────────────────────────────────── */
.palette .slot {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
  position: relative !important;
  background-image: none !important; /* overrides legacy atlas background */
}

.palette .slot .slot-icon {
  pointer-events: none;
}

.palette .slot .slot-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 0px 3px;
  border-radius: 4px;
  line-height: 1.1;
  pointer-events: none;
}

.palette .slot .slot-durability {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
  overflow: hidden;
  pointer-events: none;
}

.palette .slot .slot-durability-fill {
  height: 100%;
  background: #10b981;
  border-radius: 1px;
}

/* ── Panel backdrop (mobile tap-outside-to-close) ── */
.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  touch-action: none;
}
body.panel-open .panel-backdrop { pointer-events: none; }
.panel-backdrop.hidden { display: none; }

/* ── Modal close button ── */
.modal-close-btn {
  display: none;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: auto;
}
@media (pointer: coarse), (max-width: 768px) {
  .modal-close-btn { display: inline-flex; align-items: center; }
  /* Panel z-index above backdrop */
  .inventory-modal, .settings-panel, .shop-panel, .leaderboard-panel,
  .inventory-panel, #chestPanel, #systemPanel, #chatForm, #marketPanel {
    z-index: 1100;
    /* Prevent horizontal overflow on mobile */
    max-width: min(100vw, 100%);
    /* Safe area inset */
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
  }
}

/* Body scroll lock when panel open */
body.panel-open {
  overflow: hidden;
  touch-action: none;
}

/* ───────────────────────────────────────────────────────────
   RTL LAYOUT SUPPORT
   ─────────────────────────────────────────────────────────── */
html[dir="rtl"] {
  text-align: right;
}
html[dir="rtl"] input, 
html[dir="rtl"] select, 
html[dir="rtl"] textarea {
  text-align: right;
  direction: rtl;
}
html[dir="rtl"] .setting-row {
  flex-direction: row-reverse;
}
html[dir="rtl"] .inv-section h4 {
  text-align: right;
}
html[dir="rtl"] .toast-container {
  left: 20px !important;
  right: auto !important;
}
html[dir="rtl"] .settings-panel {
  left: 20px !important;
  right: auto !important;
}
html[dir="rtl"] .hotbar-container {
  direction: ltr; /* Keeps hotbar slots numerically ordered standard (1-9) */
}

/* ───────────────────────────────────────────────────────────
   COREWILDS PREMIUM GLASSMORPHISM OVERHAUL
   ─────────────────────────────────────────────────────────── */
/* ── Modal panels: OPAQUE & crisp. The old semi-transparent + blur(20px) let
   the 3D world bleed through, so the trader/oracle screens looked blurry. These
   are now solid dark so content is sharp and readable. ── */
.inventory-modal,
.settings-panel,
.shop-panel,
.leaderboard-panel,
.inventory-panel,
#chestPanel,
#systemPanel,
#marketPanel,
#guidePanel {
  background: #0c1322 !important;
  backdrop-filter: blur(3px) !important;
  -webkit-backdrop-filter: blur(3px) !important;
  border: 1px solid rgba(120, 170, 230, 0.30) !important;
  border-radius: 18px !important;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.88) !important;
  color: #eaf2ff !important;
  z-index: 1000 !important;
}

/* ── HUD overlays sitting over live gameplay: lighter glass is fine here. ── */
#chatForm,
#chatBox,
.left-panel,
#playerHpBox,
.player-hp,
.core-guide {
  background: rgba(9, 13, 26, 0.64) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(120, 170, 230, 0.18) !important;
  border-radius: 14px !important;
}

/* Premium Voxel Item Slot Grids */
.item-slot, .slot, .chest-slot {
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), 0 2px 8px rgba(0,0,0,0.3) !important;
}

.item-slot:hover, .slot:hover, .chest-slot:hover {
  background: rgba(0, 242, 254, 0.06) !important;
  border-color: rgba(0, 242, 254, 0.35) !important;
  transform: translateY(-2px) scale(1.03) !important;
  box-shadow: 0 8px 20px rgba(0, 242, 254, 0.15) !important;
}

.item-slot.selected, .slot.active, .chest-slot.active {
  background: rgba(0, 242, 254, 0.1) !important;
  border-color: #00f2fe !important;
  box-shadow: 0 0 14px rgba(0, 242, 254, 0.3), inset 0 0 8px rgba(0, 242, 254, 0.1) !important;
  transform: translateY(-3px) scale(1.05) !important;
}

/* Glowing tech buttons & Category pills */
.category-btn, .craft-btn, .action-btn, .shop-btn {
  font-family: 'Outfit', 'Inter', system-ui, sans-serif !important;
  border-radius: 10px !important;
  text-transform: uppercase !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
  transition: all 0.2s ease !important;
}

.category-btn:hover, .craft-btn:hover, .action-btn:hover, .shop-btn:hover {
  background: rgba(0, 242, 254, 0.15) !important;
  border-color: rgba(0, 242, 254, 0.4) !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.25) !important;
}

.category-btn.active, .craft-btn.active, .action-btn.active, .shop-btn.active {
  background: rgba(0, 242, 254, 0.2) !important;
  border-color: #00f2fe !important;
  color: #00f2fe !important;
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.3) !important;
}

/* Scrollbar polish */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 242, 254, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 242, 254, 0.4);
}

/* ───────────────────────────────────────────────────────────
   COREWILDS RESPONSIVE MOBILE OVERRIDES (<= 768px)
   ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Inventory & Crafting Panel stacked view */
  .inventory-modal {
    width: 96vw !important;
    height: 88vh !important;
    max-height: none !important;
    border-radius: 16px !important;
  }
  
  .modal-content {
    flex-direction: column !important;
    overflow-y: auto !important;
  }
  
  .modal-sidebar {
    width: 100% !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 8px !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    scrollbar-width: none !important; /* Firefox */
  }
  .modal-sidebar::-webkit-scrollbar {
    display: none !important; /* Chrome/Safari */
  }
  
  .category-btn {
    white-space: nowrap !important;
    padding: 6px 12px !important;
    font-size: 11px !important;
  }
  
  .modal-grid-container {
    padding: 12px !important;
    flex: 1 1 auto !important;
    min-height: 180px !important;
    overflow-y: auto !important;
  }
  
  .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)) !important;
    gap: 6px !important;
  }
  
  .modal-details {
    width: 100% !important;
    border-left: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 12px !important;
    background: rgba(10, 15, 30, 0.6) !important;
    flex-shrink: 0 !important;
  }
  
  .detail-card {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
  }
  
  .detail-card > div:first-child {
    font-size: 28px !important;
    margin: 0 !important;
  }
  
  .detail-card h3 {
    font-size: 14px !important;
    text-align: left !important;
  }
  
  .detail-card p {
    font-size: 11px !important;
    text-align: left !important;
    width: 100% !important;
    margin: 2px 0 !important;
  }
  
  .detail-card > div {
    width: 100% !important;
  }

  /* Chest Storage modal stacked view */
  #chestPanel {
    width: 96vw !important;
    height: 88vh !important;
    max-height: none !important;
  }
  
  #chestPanel .modal-content {
    flex-direction: column !important;
    overflow-y: auto !important;
    gap: 12px !important;
    padding: 12px !important;
  }
  
  #chestPanel .modal-content > div {
    width: 100% !important;
  }
  
  #chestPanel .modal-content > div:nth-child(2) {
    display: none !important; /* Hide visual divider line on mobile stack */
  }
}

/* ───────────────────────────────────────────────────────────
   COREWILDS PREMIUM SLOT & ICON ROBUST SIZING OVERRIDES
   ─────────────────────────────────────────────────────────── */
.chest-slot {
  aspect-ratio: 1 / 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  position: relative !important;
  cursor: pointer !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), 0 2px 8px rgba(0,0,0,0.3) !important;
}

.chest-slot:hover {
  background: rgba(0, 242, 254, 0.06) !important;
  border-color: rgba(0, 242, 254, 0.35) !important;
  transform: translateY(-2px) scale(1.03) !important;
  box-shadow: 0 8px 20px rgba(0, 242, 254, 0.15) !important;
}

.slot-icon,
.shop-icon,
.quest-card span:first-child,
.recipe-card span:first-child {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
}

.palette .slot .slot-icon {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

@media (max-width: 768px) {
  .slot-icon,
  .shop-icon,
  .quest-card span:first-child,
  .recipe-card span:first-child {
    width: 28px !important;
    height: 28px !important;
  }
}

/* ───────────────────────────────────────────────────────────
   COREWILDS STATE-OF-THE-ART UI/UX STYLE REVAMP
   ─────────────────────────────────────────────────────────── */

/* 1. Glassmorphic HUD Indicators & Topbar */
.topbar {
  background: rgba(4, 8, 16, 0.45) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(0, 242, 254, 0.12) !important;
  border-radius: 16px !important;
  padding: 8px 16px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
}

.glass-pill {
  background: rgba(10, 16, 30, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03) !important;
  border-radius: 12px !important;
  font-family: 'Outfit', 'Inter', system-ui, sans-serif !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.glass-pill:hover {
  border-color: rgba(0, 242, 254, 0.3) !important;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.18) !important;
  background: rgba(10, 16, 30, 0.8) !important;
  transform: translateY(-1px);
}

/* 2. Premium Tactical HUD status console */
.player-hp {
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.85) 0%, rgba(4, 6, 12, 0.92) 100%) !important;
  border: 1px solid rgba(0, 242, 254, 0.22) !important;
  border-radius: 18px !important;
  padding: 12px 18px !important;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.65), 0 0 20px rgba(0, 242, 254, 0.08) !important;
  bottom: 96px !important;
  gap: 5px !important;
  transition: all 0.25s ease !important;
}

.player-hp-bar {
  width: 148px !important;
  height: 10px !important;
  background: rgba(0, 0, 0, 0.45) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-radius: 6px !important;
  overflow: hidden !important;
}

.player-hp-fill {
  background: linear-gradient(90deg, #ff2e93 0%, #ff8e53 100%) !important; /* Hot Pink to Orange */
  box-shadow: 0 0 8px rgba(255, 46, 147, 0.5) !important;
}

.player-hunger-fill {
  background: linear-gradient(90deg, #ffac1c 0%, #ffe066 100%) !important; /* Golden Amber */
  box-shadow: 0 0 8px rgba(255, 172, 28, 0.5) !important;
}

.player-xp-fill {
  background: linear-gradient(90deg, #00ff87 0%, #60efff 100%) !important; /* Neon Green-Cyan */
  box-shadow: 0 0 8px rgba(0, 255, 135, 0.5) !important;
}

.player-breath-fill {
  background: linear-gradient(90deg, #0072ff 0%, #00f2fe 100%) !important; /* Cyber-Blue */
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.5) !important;
}

/* 3. Holographic 9-Slot Hotbar */
.palette {
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.9) 0%, rgba(2, 4, 8, 0.96) 100%) !important;
  border: 1px solid rgba(0, 242, 254, 0.25) !important;
  border-radius: 20px !important;
  padding: 10px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.72), 0 0 25px rgba(0, 242, 254, 0.15) !important;
  bottom: max(14px, env(safe-area-inset-bottom)) !important;
}

.palette .slot {
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.01) !important;
  width: 48px !important;
  height: 48px !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.palette .slot:hover {
  background: rgba(0, 242, 254, 0.08) !important;
  border-color: rgba(0, 242, 254, 0.4) !important;
  transform: translateY(-4px) scale(1.06) !important;
  box-shadow: 0 8px 20px rgba(0, 242, 254, 0.25) !important;
}

.palette .slot.active {
  border-color: #00f2fe !important;
  background: rgba(0, 242, 254, 0.15) !important;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.45), inset 0 0 8px rgba(0, 242, 254, 0.2) !important;
  transform: translateY(-6px) scale(1.1) !important;
}

.palette .slot-key {
  position: absolute !important;
  top: -4px !important;
  left: -4px !important;
  background: rgba(6, 10, 20, 0.95) !important;
  border: 1px solid rgba(0, 242, 254, 0.3) !important;
  color: #00f2fe !important;
  border-radius: 50% !important;
  width: 16px !important;
  height: 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 9px !important;
  font-weight: 900 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4) !important;
}

/* 4. Advanced Cybernetic Slot Grids */
.slot, .item-slot {
  border-radius: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  background: rgba(255, 255, 255, 0.01) !important;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.slot:hover, .item-slot:hover {
  background: rgba(0, 242, 254, 0.06) !important;
  border-color: rgba(0, 242, 254, 0.35) !important;
  transform: translateY(-3px) scale(1.05) !important;
  box-shadow: 0 10px 22px rgba(0, 242, 254, 0.18) !important;
}

.slot.active, .item-slot.selected {
  background: rgba(0, 242, 254, 0.12) !important;
  border-color: #00f2fe !important;
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.35), inset 0 0 10px rgba(0, 242, 254, 0.15) !important;
  transform: translateY(-4px) scale(1.08) !important;
}

.quest-card, .recipe-card {
  padding: 12px !important;
  border-radius: 14px !important;
  background: rgba(8, 12, 24, 0.4) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.quest-card:hover, .recipe-card:hover {
  background: rgba(8, 12, 24, 0.6) !important;
  border-color: rgba(0, 242, 254, 0.25) !important;
}

.quest-card.done {
  border-color: rgba(16, 185, 129, 0.3) !important;
  background: rgba(6, 78, 59, 0.12) !important;
}

/* STORAGE CHEST LAYOUT STYLING */
.chest-modal-content {
  display: flex;
  flex-direction: row;
  padding: 24px;
  gap: 24px;
  overflow-y: auto;
}
.chest-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  align-self: stretch;
}
.chest-grid {
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 8px;
}
@media (max-width: 768px) {
  .chest-modal-content {
    flex-direction: column !important;
    padding: 16px;
    gap: 16px;
  }
  .chest-divider {
    width: 100% !important;
    height: 1px !important;
    align-self: initial;
    margin: 8px 0;
  }
  .chest-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* ───────────────────────────────────────────────────────────
   COREWILDS PREMIUM INLINE STYLE SEPARATION Overhaul
   ─────────────────────────────────────────────────────────── */

.stats-dot-green {
  color: #65d088;
}

.sleep-hud {
  top: 56px !important;
  background: rgba(30, 144, 255, 0.22) !important;
  border-color: rgba(30, 144, 255, 0.4) !important;
}

.hp-icon-breath {
  color: #4ba6ff !important;
}

.hp-icon-xp {
  color: #aaf08e !important;
}

.panel-title-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.modal-footer {
  padding: 10px 24px !important;
  font-size: 11px !important;
  color: var(--muted) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  background: rgba(15, 23, 42, 0.4) !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.modal-footer-wallet-info {
  font-weight: 500 !important;
}

.btn-close-panel {
  margin-left: 4px !important;
}

.btn-bargain {
  margin-left: 10px !important;
}

.guide-dialogue-text {
  padding: 15px !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  color: #f1f5f9 !important;
  background: rgba(0, 0, 0, 0.2) !important;
  border-radius: 6px !important;
  margin: 10px !important;
  min-height: 80px !important;
}

.guide-actions-container {
  padding: 10px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
}

.chest-modal {
  max-width: 800px !important;
  height: 70vh !important;
  max-height: 520px !important;
}

.btn-chest-close {
  width: auto !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.chest-pane {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

.chest-modal-footer {
  padding: 10px 20px !important;
  font-size: 11px !important;
  color: var(--muted) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  background: rgba(15, 23, 42, 0.4) !important;
  text-align: center !important;
}

.setting-actions-row {
  margin-top: 6px !important;
}

.underwater-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(9, 58, 85, 0.35) !important;
  backdrop-filter: blur(1px) !important;
  pointer-events: none !important;
  z-index: 9999 !important;
}

/* Dynamic Details & Cards in Inventory Panel */
.detail-card {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  animation: fadeIn 0.25s ease-out !important;
  height: 100% !important;
}

.detail-card-center-icon {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin-bottom: 5px !important;
}

.detail-card-title {
  margin: 0 !important;
  text-align: center !important;
  font-size: 16px !important;
  color: #fff !important;
}

.detail-card-badge {
  text-align: center !important;
  font-size: 9px !important;
  padding: 2px 8px !important;
  border-radius: 10px !important;
  align-self: center !important;
  font-weight: 700 !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.detail-card-badge.recipe-badge {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #f59e0b !important;
}

.detail-card-qty {
  font-size: 11px !important;
  text-align: center !important;
  color: var(--muted) !important;
}

.detail-card-stats-grid {
  font-size: 11px !important;
  color: var(--muted) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  padding: 8px !important;
  border-radius: 6px !important;
}

.detail-card-stats-row {
  display: flex !important;
  justify-content: space-between !important;
}

.detail-card-stats-row b {
  color: #fff !important;
}

.detail-card-binder-container {
  margin-top: 12px !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding-top: 10px !important;
}

.detail-card-binder-title {
  font-size: 10px !important;
  text-transform: uppercase !important;
  margin: 0 0 6px 0 !important;
  color: var(--muted) !important;
  text-align: center !important;
}

.detail-card-binder-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 2px !important;
}

.detail-card-binder-btn {
  width: 26px !important;
  height: 26px !important;
  border-radius: 4px !important;
  font-size: 10px !important;
  margin: 2px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  background: rgba(15, 23, 42, 0.6) !important;
  color: #fff !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.detail-card-binder-btn.bound {
  border-color: #22d3c8 !important;
  background: rgba(34, 211, 200, 0.25) !important;
}

/* Quests and Recipes Grid Items */
.quest-card-grid-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(15, 23, 42, 0.4) !important;
  cursor: pointer !important;
}

.recipe-card-grid-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px !important;
  border-radius: 8px !important;
  background: rgba(15, 23, 42, 0.4) !important;
  cursor: pointer !important;
}

.recipe-card-grid-item.avail {
  border: 1px solid rgba(16, 185, 129, 0.55) !important;
  background: rgba(16, 185, 129, 0.12) !important;
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.18), 0 0 0 1px rgba(16,185,129,.15) !important;
}
.recipe-card-grid-item.avail .grid-item-icon { filter: drop-shadow(0 0 4px rgba(16,185,129,.4)); }

/* Not enough materials yet — dimmed so craftable recipes read at a glance */
.recipe-card-grid-item.short {
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  opacity: 0.55 !important;
}
.recipe-card-grid-item.short:hover { opacity: 0.8 !important; }

.grid-item-icon {
  margin-bottom: 5px !important;
}

.grid-item-title {
  font-size: 10px !important;
  font-weight: 600 !important;
  text-align: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  width: 100% !important;
}

.grid-item-subtitle {
  font-size: 9px !important;
  color: var(--muted) !important;
}

.equipped-badge-label {
  background: #10b981 !important;
  border: none !important;
  top: 2px !important;
  left: 2px !important;
  font-size: 8px !important;
  padding: 1px 3px !important;
  border-radius: 3px !important;
  width: auto !important;
  height: auto !important;
  color: #fff !important;
}

.grid-empty-msg {
  grid-column: 1 / -1 !important;
  text-align: center !important;
  padding: 40px !important;
  color: var(--muted) !important;
  font-size: 12px !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Accessibility + low-end device perf: stop continuous decorative animations.
   The blurred 72px ambient orbs and pulses run the compositor non-stop; cutting
   them helps users who request reduced motion and weak GPUs/mobiles. */
@media (prefers-reduced-motion: reduce) {
  .orb, .orb-1, .orb-2, .orb-3,
  .crystal,
  .brand-glyph, .cg-glyph,
  .boss-banner {
    animation: none !important;
  }
  * {
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── HUD scale system (phone → TV) ─────────────────────────
   One factor --hud-scale drives the size of every point-anchored HUD
   cluster via `zoom`, which scales both size AND offset so centering
   (left:50% + translateX) stays correct. Auto-default rises with
   viewport width; a Settings "UI Scale" control overrides it by
   setting an inline --hud-scale on :root (inline beats these rules).
   Full-width bars (.topbar) are excluded — their inner groups scale
   instead so they don't overflow horizontally. */
:root { --hud-scale: 1; }
@media (min-width: 1700px) { :root { --hud-scale: 1.25; } }
@media (min-width: 2560px) { :root { --hud-scale: 1.7; } }
@media (min-width: 3400px) { :root { --hud-scale: 2.1; } }

#hud .identity,
#hud .topbar-right,
#hud .left-panel,
#hud .palette,
#hud #playerHpBox,
#hud .key-hints,
#hud #posHud,
#hud .crosshair,
#hud #chatWrapper,
#hud #mobHp {
  zoom: var(--hud-scale);
}

/* ─── WALLET SELECT MODAL & BACKDROP STYLES ─── */
.wallet-select-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.wallet-select-backdrop.hidden {
  display: none !important;
}

.wallet-select-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 360px);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  color: #f8fafc;
  z-index: 10001;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wallet-select-modal.hidden {
  display: none !important;
}

.wallet-select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wallet-select-title {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wallet-select-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.wallet-select-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.wallet-options-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wallet-option-btn:hover {
  background: rgba(34, 211, 200, 0.1);
  border-color: rgba(34, 211, 200, 0.35);
  color: #22d3c8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 211, 200, 0.15);
}

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

.wallet-option-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
