@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ─── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
  --bg:      #06060f;
  --panel:   #0c0c1e;
  --border:  #1e1e3a;
  --border2: #2a2a4a;
  --gold:    #ffd700;
  --red:     #e05050;
  --blue:    #5090d9;
  --green:   #50c060;
  --text:    #c8c8e0;
  --dim:     #505068;
  --font:    'Press Start 2P', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  min-height: 100vh;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════════
   HOME SCREEN
══════════════════════════════════════════════════════════════════ */
#homeScreen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px 40px;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1160px;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--border2);
  padding-bottom: 16px;
}
.home-header-right { display:flex; align-items:center; gap:10px; }

.btn-hdr {
  font-family: var(--font); font-size: 7px;
  padding: 8px 12px; border: 2px solid var(--border2);
  background: var(--panel); color: var(--text);
  border-radius: 3px; cursor: pointer; letter-spacing: 1px;
  transition: filter .1s;
}
.btn-hdr:hover { filter: brightness(1.4); }
.btn-hdr.chest-btn { border-color: #604010; color: var(--gold); }

/* ─── Wallet button ─────────────────────────────────────────────── */
.btn-wallet {
  font-family: var(--font); font-size: 7px;
  padding: 8px 14px; border: 2px solid #4a1fa8;
  background: #160a2e; color: #9945ff;
  border-radius: 3px; cursor: pointer; letter-spacing: 1px;
  transition: filter .15s, border-color .15s;
  white-space: nowrap;
}
.btn-wallet:hover        { filter: brightness(1.35); border-color: #9945ff; }
.btn-wallet.connected    { border-color: #14f195; color: #14f195; background: #061a10; }
.btn-wallet.connected:hover { filter: brightness(1.2); }

.wallet-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #0e0820; border: 2px solid #9945ff; color: #c090ff;
  font-family: var(--font); font-size: 7px; padding: 10px 20px;
  border-radius: 4px; box-shadow: 0 0 18px rgba(153,69,255,.35);
  animation: slideIn .3s ease, fadeOut .4s ease 2.6s forwards;
  z-index: 2000; pointer-events: none; white-space: nowrap;
}
.chest-total {
  display: inline-block; background: var(--red);
  color: #fff; font-size: 6px; padding: 1px 5px;
  border-radius: 8px; margin-left: 4px;
}

.home-title {
  font-size: 20px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255,215,0,0.35), 2px 2px #000;
  letter-spacing: 4px;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #10100c;
  border: 2px solid #40380a;
  border-radius: 4px;
  padding: 8px 14px;
}
.wallet-icon  { font-size: 18px; }
.wallet #walletCoins { font-size: 16px; color: var(--gold); }
.wallet-label { font-size: 8px; color: #886600; }

.home-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  width: 100%;
  max-width: 1160px;
}

.section-title {
  font-size: 9px;
  color: var(--gold);
  letter-spacing: 3px;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border2);
}

/* ─── Dungeon tiers ────────────────────────────────────────────── */
.dungeon-grid {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.tier-section.tier-locked { opacity: .5; }

.tier-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.tier-label    { font-size: 9px; color: #ccc; letter-spacing: 3px; }
.tier-mult     { font-size: 6px; color: var(--gold); }
.tier-lock-msg { font-size: 6px; color: var(--dim); margin-left: auto; }

.tier-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* Sprite glow per tier */
.glow-t1 { filter: drop-shadow(0 0 5px #50e050); }
.glow-t2 { filter: drop-shadow(0 0 7px #40a0ff); }
.glow-t3 { animation: glowPulse3 1.8s ease-in-out infinite; }
.glow-t4 { animation: glowPulse4 1.1s ease-in-out infinite; }
@keyframes glowPulse3 {
  0%,100% { filter: drop-shadow(0 0 6px  #c060ff); }
  50%     { filter: drop-shadow(0 0 14px #c060ff); }
}
@keyframes glowPulse4 {
  0%,100% { filter: drop-shadow(0 0 8px  #ff8030); }
  50%     { filter: drop-shadow(0 0 18px #ff8030); }
}

.dungeon-card {
  background: var(--panel);
  border: 2px solid var(--border2);
  border-radius: 4px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.dungeon-card:not(.locked):hover {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255,215,0,0.12);
}
.dungeon-card.cleared { border-color: #306030; }
.dungeon-card.locked  { opacity: .55; }

.dcard-img-wrap {
  position: relative;
  background: #080810;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 78px;
  overflow: hidden;
}
.dcard-img {
  image-rendering: pixelated;
  width: 60px;
  height: 60px;
  object-fit: contain;
}
.dcard-badge {
  position: absolute;
  top: 6px; right: 6px;
  background: #1a4020;
  color: #60e060;
  font-size: 6px;
  padding: 3px 6px;
  border: 1px solid #306030;
  border-radius: 2px;
}
.dcard-lock {
  position: absolute;
  font-size: 28px;
  opacity: .7;
}

.dcard-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dcard-name  { font-size: 6px; color: #eee; line-height: 1.7; }
.dcard-stars { font-size: 10px; color: var(--gold); letter-spacing: 2px; }
.dcard-sub   { font-size: 6px; color: var(--dim); line-height: 1.8; }
.dcard-locked-msg { font-size: 6px; color: var(--dim); margin-top: 4px; }

.btn-enter {
  font-family: var(--font);
  font-size: 7px;
  margin-top: 6px;
  padding: 8px 0;
  background: #102010;
  border: 2px solid #3a7030;
  color: #70e060;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: filter .1s;
  width: 100%;
}
.btn-enter:hover { filter: brightness(1.3); }

/* ─── Upgrade panel ────────────────────────────────────────────── */
.home-right {
  display: flex;
  flex-direction: column;
}
.upg-hint {
  font-size: 6px;
  color: var(--dim);
  margin-bottom: 12px;
  line-height: 2;
}
.upgrade-list { display: flex; flex-direction: column; gap: 8px; }

.upg-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0e0e1e;
  border: 2px solid var(--border2);
  border-radius: 4px;
  padding: 10px;
}
.upg-card.maxed { border-color: #304030; opacity: .75; }

.upg-icon { font-size: 20px; flex-shrink: 0; width: 28px; text-align: center; }
.upg-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.upg-name { font-size: 7px; color: #ddd; }
.upg-lv   { font-size: 5px; color: var(--gold); margin-left: 4px; }
.upg-desc { font-size: 5px; color: var(--dim); line-height: 1.8; }
.upg-bar {
  height: 6px;
  background: #08081a;
  border: 1px solid var(--border2);
  border-radius: 2px;
  overflow: hidden;
}
.upg-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #806000, var(--gold));
}

.btn-buy {
  font-family: var(--font);
  font-size: 7px;
  padding: 8px 10px;
  background: #102018;
  border: 2px solid #3a7030;
  color: #70e060;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter .1s;
}
.btn-buy:hover:not(:disabled) { filter: brightness(1.3); }
.btn-buy.maxed  { background:#0e1e0e; border-color:#246024; color:#406040; cursor:default; }
.btn-buy.poor   { background:#1e0e0e; border-color:#602020; color:#804040; cursor:not-allowed; }
.btn-buy:disabled { cursor: not-allowed; }

.home-footer {
  margin-top: 24px;
  font-size: 6px;
  color: var(--dim);
  text-align: center;
  line-height: 2;
}

/* ─── Token / Social bar ────────────────────────────────────────── */
.token-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.ca-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0a0a1c;
  border: 2px solid var(--border2);
  border-radius: 4px;
  padding: 7px 12px;
}
.ca-label {
  font-size: 7px;
  color: var(--gold);
  letter-spacing: 2px;
  white-space: nowrap;
}
.ca-value {
  font-size: 7px;
  color: var(--text);
  letter-spacing: 1px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ca-copy {
  font-family: var(--font);
  font-size: 9px;
  background: none;
  border: 1px solid var(--border2);
  color: var(--dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color .1s, border-color .1s;
}
.ca-copy:hover { color: var(--gold); border-color: var(--gold); }

.btn-social {
  font-family: var(--font);
  font-size: 7px;
  padding: 8px 14px;
  border-radius: 4px;
  text-decoration: none;
  letter-spacing: 1px;
  white-space: nowrap;
  transition: filter .15s;
  border: 2px solid transparent;
}
.btn-social:hover { filter: brightness(1.35); }

.btn-x {
  background: #0a0a0a;
  border-color: #333;
  color: #fff;
}
.btn-pump {
  background: #041a08;
  border-color: #1a7a30;
  color: #30e060;
}

/* ══════════════════════════════════════════════════════════════════
   GAME SCREEN
══════════════════════════════════════════════════════════════════ */
#gameScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 32px;
  min-height: 100vh;
  position: relative;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.dungeon-title { font-size: 10px; color: var(--gold); letter-spacing: 2px; }
.game-coins    { font-size: 9px;  color: var(--gold); }

/* ─── Three-column layout ──────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 190px 1fr 190px;
  gap: 14px;
  width: 100%;
  max-width: 1200px;
  align-items: start;
  min-width: 0;
}

/* ─── Side panels ──────────────────────────────────────────────── */
.side-panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 12px;
}
.panel-title {
  font-size: 9px; color: var(--gold);
  border-bottom: 1px solid var(--border2);
  padding-bottom: 8px; margin-bottom: 10px; letter-spacing: 2px;
}
.panel-hint { color: var(--dim); font-size: 6px; margin-bottom: 10px; line-height: 1.9; }

/* ─── Hero cards ───────────────────────────────────────────────── */
.hero-cards { display: flex; flex-direction: column; gap: 8px; }

.hero-card {
  display: flex; gap: 8px; align-items: center;
  background: #10102a; border: 2px solid var(--border2);
  border-radius: 3px; padding: 8px; cursor: pointer;
  transition: border-color .1s, background .1s;
}
.hero-card:hover       { border-color: var(--blue); background: #14143a; }
.hero-card.selected    { border-color: var(--gold); background: #1a1a10; box-shadow: 0 0 10px rgba(255,215,0,.2); }
.hero-card.placed      { opacity: .38; cursor: default; pointer-events: none; }

.card-sprite { width:36px; height:36px; image-rendering:pixelated; flex-shrink:0; }
.card-info   { display:flex; flex-direction:column; gap:4px; }
.card-name   { font-size:7px; color:#eee; }
.card-stat   { font-size:6px; color:var(--dim); }
.card-tag    { font-size:5px; padding:1px 4px; border-radius:2px; align-self:flex-start; }
.card-tag.ranged { background:#183018; color:var(--green); }
.card-tag.melee  { background:#301818; color:var(--red); }

/* ─── Arena ────────────────────────────────────────────────────── */
.arena-section { display:flex; flex-direction:column; align-items:center; gap:12px; min-width:0; }
.arena-wrapper {
  border: 3px solid var(--border2);
  box-shadow: 0 0 30px rgba(80,90,255,.1), inset 0 0 40px rgba(0,0,0,.6);
  max-width: 100%;
  overflow: hidden;
  line-height: 0;
}
#arena { display:block; image-rendering:pixelated; max-width:100%; height:auto; }

/* ─── Controls ─────────────────────────────────────────────────── */
.controls { display:flex; gap:10px; }

.btn {
  font-family: var(--font); font-size: 7px;
  padding: 10px 16px; border: 2px solid;
  border-radius: 3px; cursor: pointer; letter-spacing: 1px;
  transition: filter .1s, transform .08s;
}
.btn:active         { transform: scale(.96); }
.btn:disabled       { opacity: .35; cursor: not-allowed; transform: none; }
.btn:hover:not(:disabled) { filter: brightness(1.25); }

.btn-autoplace {
  width: 100%;
  margin-bottom: 10px;
  font-family: var(--font);
  font-size: 6px;
  padding: 7px 0;
  background: #101828;
  border: 2px solid #304868;
  color: #60a0d8;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: filter .1s;
}
.btn-autoplace:hover { filter: brightness(1.3); }

.btn-fight { background:#152010; border-color:#3a8030; color:#70e060; }
.btn-reset { background:#201010; border-color:#602020; color:#c05050; }
.btn-auto  { background:#181008; border-color:#604010; color:#c08030; }
.btn-auto.auto-on { background:#181408; border-color:#507020; color:#90d040; }
.btn-home  { background:#101820; border-color:#305060; color:#70a8e0; }

/* ─── Wave / enemy panel ───────────────────────────────────────── */
.wave-header { margin-bottom: 10px; }
.wave-name   { font-size:8px; color:var(--red); margin-bottom:4px; }
.wave-count  { font-size:6px; color:var(--dim); }

.enemy-list  { display:flex; flex-direction:column; gap:8px; }
.enemy-row   { display:flex; gap:8px; align-items:center; background:#120a0a; border:1px solid #2a1a1a; border-radius:3px; padding:6px; }
.enemy-icon  { width:34px; height:34px; image-rendering:pixelated; transform:scaleX(-1); flex-shrink:0; }
.enemy-desc  { display:flex; flex-direction:column; gap:4px; }
.enemy-name  { font-size:7px; color:#e0c0c0; }
.enemy-stat  { font-size:5px; color:var(--dim); }

/* ══════════════════════════════════════════════════════════════════
   RARITY
══════════════════════════════════════════════════════════════════ */
.r-common    { color:#aaa; }
.r-uncommon  { color:#50e050; text-shadow:0 0 8px #50e050; }
.r-rare      { color:#4090ff; text-shadow:0 0 12px #4090ff; }
.r-epic      { color:#c060ff; text-shadow:0 0 18px #c060ff; }
.r-legendary { color:#ff9020; text-shadow:0 0 24px #ff9020; animation:legendPulse 1.4s ease-in-out infinite; }
@keyframes legendPulse {
  0%,100% { text-shadow:0 0 16px #ff9020; }
  50%     { text-shadow:0 0 36px #ff9020, 0 0 8px #fff4; }
}

.glow-common    {}
.glow-uncommon  { box-shadow:0 0 8px  #50e050, inset 0 0 6px rgba(80,224,80,.1); border-color:#30a030 !important; }
.glow-rare      { box-shadow:0 0 12px #4090ff, inset 0 0 8px rgba(64,144,255,.1); border-color:#2060d0 !important; }
.glow-epic      { box-shadow:0 0 18px #c060ff, inset 0 0 10px rgba(192,96,255,.12); border-color:#8030d0 !important; }
.glow-legendary { box-shadow:0 0 26px #ff9020, inset 0 0 12px rgba(255,144,32,.15); border-color:#c06010 !important;
                  animation:legendBoxPulse 1.4s ease-in-out infinite; }
@keyframes legendBoxPulse {
  0%,100% { box-shadow:0 0 20px #ff9020; }
  50%     { box-shadow:0 0 40px #ff9020, 0 0 12px #fff3; }
}

/* ══════════════════════════════════════════════════════════════════
   ITEM CARD
══════════════════════════════════════════════════════════════════ */
.item-card {
  display: flex; flex-direction: column; align-items: center;
  background: #0e0e1e; border: 2px solid var(--border2);
  border-radius: 4px; padding: 8px 6px; cursor: pointer;
  transition: transform .1s, filter .1s;
  position: relative; min-width: 72px;
}
.item-card:hover { transform: scale(1.06); filter: brightness(1.2); }
.item-card .item-sprite { width:40px; height:40px; image-rendering:pixelated; }
.item-card .item-name   { font-size:5px; color:#ccc; margin-top:4px; text-align:center; }
.item-card .item-rarity { font-size:5px; margin-top:2px; }
.item-card .item-slot-tag { font-size:4px; color:var(--dim); }

/* ══════════════════════════════════════════════════════════════════
   CHEST SELECT MODAL
══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset:0; background:rgba(0,0,0,.85);
  display:flex; align-items:center; justify-content:center;
  z-index: 1000;
}
.modal-box {
  background: var(--panel); border:2px solid var(--border2);
  border-radius:6px; padding:28px; position:relative;
  max-height:90vh; overflow-y:auto;
}
.modal-title {
  font-size:12px; color:var(--gold); letter-spacing:3px;
  margin-bottom:22px; text-align:center;
}
.modal-close {
  font-family:var(--font); font-size:7px; margin-top:20px;
  padding:8px 20px; background:#200808; border:2px solid #602020;
  color:#e05050; border-radius:3px; cursor:pointer;
  display:block; margin-left:auto; margin-right:auto;
  transition:filter .1s;
}
.modal-close:hover { filter:brightness(1.3); }

.modal-chest-sel { width:820px; }
.chest-select-grid { display:flex; gap:14px; flex-wrap:wrap; justify-content:center; }

.chest-card {
  display:flex; flex-direction:column; align-items:center; gap:10px;
  background:#0e0e18; border:2px solid var(--border2); border-radius:5px;
  padding:20px 16px; min-width:130px; cursor:default;
  transition:border-color .12s;
}
.chest-card:hover { border-color:#444; }
.chest-card.empty { opacity:.35; }
.chest-card-actions { display:flex; flex-direction:column; gap:7px; width:100%; margin-top:4px; }
.btn-chest-open, .btn-chest-buy {
  font-family:var(--font); font-size:7px; padding:8px 10px; border-radius:3px;
  cursor:pointer; letter-spacing:1px; width:100%; text-align:center;
  transition:filter .1s;
}
.btn-chest-open { background:#102010; border:2px solid #3a7030; color:#70e060; }
.btn-chest-open.disabled { background:#0e0e0e; border-color:#2a2a2a; color:#444; cursor:not-allowed; }
.btn-chest-open:not(.disabled):hover { filter:brightness(1.3); }
.btn-chest-buy { background:#0e0a1e; border:2px solid #4a3070; color:#c090ff; }
.btn-chest-buy.poor { background:#0e0a0a; border-color:#3a1010; color:#603030; cursor:not-allowed; }
.btn-chest-buy:not(.poor):hover { filter:brightness(1.3); }
.chest-icon { font-size:44px; }
.chest-card-name { font-size:8px; color:#ddd; letter-spacing:1px; }
.chest-card-count { font-size:13px; color:var(--gold); }
.chest-card-pct   { font-size:6px; color:var(--dim); line-height:2.2; text-align:center; }

/* ══════════════════════════════════════════════════════════════════
   REEL MODAL
══════════════════════════════════════════════════════════════════ */
.modal-reel { width:800px; }

.reel-viewport {
  width:100%; height:110px; overflow:hidden;
  border:2px solid var(--border2); border-radius:4px;
  position:relative; background:#06060f;
}
.reel-strip {
  display:flex; gap:6px; padding:8px;
  transition: none;
  will-change: transform;
}
.reel-cursor {
  position:absolute; top:0; bottom:0;
  left:50%; transform:translateX(-50%);
  width:3px; background:var(--gold);
  box-shadow:0 0 10px var(--gold);
  pointer-events:none;
}

.reel-card {
  flex-shrink:0; width:84px; height:90px;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:4px; background:#0a0a18; border:2px solid var(--border2); border-radius:4px;
}
.reel-card img { width:42px; height:42px; image-rendering:pixelated; }
.reel-card .reel-item-name   { font-size:5px; color:#ccc; text-align:center; }
.reel-card .reel-item-rarity { font-size:5px; }

.reel-result {
  margin-top:18px; display:flex; flex-direction:column;
  align-items:center; gap:10px;
}
.reel-result-card {
  display:flex; flex-direction:column; align-items:center; gap:8px;
  background:#0e0e1e; border:2px solid var(--border2); border-radius:6px;
  padding:18px 24px; animation:popIn .4s cubic-bezier(.2,1.4,.4,1);
}
@keyframes popIn { 0%{transform:scale(0.5);opacity:0} 100%{transform:scale(1);opacity:1} }
.reel-result-card img  { width:64px; height:64px; image-rendering:pixelated; }
.reel-result-name      { font-size:10px; color:#eee; }
.reel-result-rarity    { font-size:8px; }
.reel-result-stats     { font-size:6px; color:var(--dim); text-align:center; line-height:2; }

/* ══════════════════════════════════════════════════════════════════
   INVENTORY MODAL
══════════════════════════════════════════════════════════════════ */
.modal-inventory { width:860px; }

.inv-hero-tabs {
  display:flex; gap:8px; margin-bottom:18px;
  border-bottom:1px solid var(--border2); padding-bottom:12px;
}
.inv-hero-tab {
  display:flex; flex-direction:column; align-items:center; gap:4px;
  background:#0e0e1e; border:2px solid var(--border2); border-radius:4px;
  padding:8px 12px; cursor:pointer; transition:border-color .1s, background .1s;
}
.inv-hero-tab:hover          { border-color:var(--blue); }
.inv-hero-tab.active         { border-color:var(--gold); background:#16140a; }
.inv-hero-tab img            { width:32px; height:32px; image-rendering:pixelated; }
.inv-hero-tab span           { font-size:5px; color:#ccc; }

.inv-body {
  display:grid; grid-template-columns:220px 1fr;
  gap:18px; align-items:start;
}
.inv-col-title { font-size:7px; color:var(--gold); margin-bottom:10px; letter-spacing:2px; }

.inv-slots { display:flex; flex-direction:column; gap:8px; }
.inv-slot {
  display:flex; align-items:center; gap:10px;
  background:#0a0a18; border:2px solid var(--border2); border-radius:4px;
  padding:8px; cursor:pointer; transition:border-color .1s;
  min-height:54px;
}
.inv-slot:hover      { border-color:var(--blue); }
.inv-slot.selected   { border-color:var(--gold); background:#12100a; }
.inv-slot-label      { font-size:5px; color:var(--dim); min-width:60px; }
.inv-slot-item       { display:flex; align-items:center; gap:6px; flex:1; }
.inv-slot-item img   { width:32px; height:32px; image-rendering:pixelated; flex-shrink:0; }
.inv-slot-item-info  { display:flex; flex-direction:column; gap:3px; }
.inv-slot-item-name  { font-size:6px; color:#ddd; }
.inv-slot-item-stat  { font-size:5px; color:var(--dim); }
.inv-slot-empty      { font-size:5px; color:#333; font-style:italic; }
.inv-unequip         { font-size:5px; margin-left:auto; padding:3px 6px;
                       background:#1a0808; border:1px solid #602020; color:#c05050;
                       border-radius:2px; cursor:pointer; flex-shrink:0; }
.inv-unequip:hover   { filter:brightness(1.4); }

.inv-filter-label    { font-size:6px; color:var(--blue); margin-left:6px; }
.inv-items-grid      { display:flex; flex-wrap:wrap; gap:8px; max-height:320px; overflow-y:auto; overflow-x:hidden; padding:4px 6px 6px; }
.inv-item-card       { background:#0e0e1e; border:2px solid var(--border2); border-radius:4px;
                       padding:8px 6px; cursor:pointer; display:flex; flex-direction:column;
                       align-items:center; gap:4px; transition:transform .1s, filter .1s;
                       min-width:72px; position:relative; }
.inv-item-card:hover { transform:scale(1.05); filter:brightness(1.2); }
.inv-item-card.equipped-elsewhere { opacity:.45; cursor:not-allowed; }
.inv-item-card img   { width:38px; height:38px; image-rendering:pixelated; }
.inv-item-card .i-name   { font-size:5px; color:#ccc; text-align:center; }
.inv-item-card .i-rarity { font-size:5px; }
.inv-item-card .i-stat   { font-size:4px; color:var(--dim); text-align:center; }
.inv-empty-msg { font-size:7px; color:var(--dim); padding:20px; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  (max 900px)
══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {

  body { font-size: 9px; }

  /* Home */
  .home-header { flex-wrap: wrap; gap: 10px; }
  .home-title  { font-size: 14px; }
  .home-body   { grid-template-columns: 1fr; }
  .home-right  { order: -1; }
  .tier-row    { grid-template-columns: repeat(2, 1fr); }
  .ca-value    { max-width: 180px; }

  /* Game */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .layout > .side-panel:first-child { order: 3; }   /* enemy list → bottom */
  .arena-section                    { order: 1; }
  .layout > .side-panel:last-child  { order: 2; }   /* hero panel → below canvas */

  .side-panel { padding: 8px; }

  /* Horizontal scrolling panels on tablet */
  .enemy-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .hero-cards { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .hero-card  { flex: 1 1 130px; }

  /* Controls */
  .controls { flex-wrap: wrap; gap: 6px; justify-content: center; }
  .btn      { font-size: 6px; padding: 8px 12px; }

  /* Modals */
  .modal-box            { padding: 16px; width: 96vw !important; max-width: 96vw !important; }
  .modal-title          { font-size: 9px; margin-bottom: 14px; }
  .chest-select-grid    { gap: 10px; }
  .chest-card           { min-width: 90px; padding: 12px 10px; }
  .modal-reel           { width: 96vw; }
  .modal-inventory      { width: 96vw; }
  .inv-body             { grid-template-columns: 1fr; }
  .inv-items-grid       { max-height: 220px; }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  (max 600px)
══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  body { font-size: 8px; touch-action: manipulation; }

  /* Home header stacks */
  #homeScreen         { padding: 14px 10px 28px; }
  .home-header        { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
  .home-header-right  { flex-wrap: wrap; gap: 6px; width: 100%; }
  .home-title         { font-size: 11px; letter-spacing: 2px; }
  .btn-hdr            { font-size: 6px; padding: 7px 9px; }
  .wallet #walletCoins { font-size: 12px; }
  .wallet-label       { font-size: 6px; }

  /* Token bar */
  .token-bar    { gap: 7px; }
  .ca-value     { max-width: 120px; font-size: 6px; }
  .ca-label     { font-size: 6px; }
  .btn-social   { font-size: 6px; padding: 6px 10px; }

  /* Dungeon grid */
  .section-title { font-size: 7px; }
  .tier-row      { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dcard-name    { font-size: 5px; }
  .dcard-stars   { font-size: 8px; }
  .btn-enter     { font-size: 6px; padding: 6px 0; }

  /* Upgrades */
  .upg-name  { font-size: 6px; }
  .btn-buy   { font-size: 6px; padding: 6px 8px; }

  /* Game screen */
  #gameScreen        { padding: 8px 6px 20px; overflow-x: hidden; }
  .game-header       { margin-bottom: 6px; }
  .dungeon-title     { font-size: 7px; }
  .game-coins        { font-size: 7px; }

  .layout { gap: 8px; width: 100%; overflow: hidden; }
  .layout > * { min-width: 0; }
  .arena-section { width: 100%; max-width: 100%; }
  .arena-wrapper { width: 100%; }
  #arena { width: 100% !important; height: auto !important; }
  .controls { max-width: 100%; }
  .panel-title { font-size: 7px; }
  .panel-hint  { font-size: 5px; }

  /* Hero cards horizontal strip */
  .side-panel:last-child .hero-cards {
    flex-direction: row; overflow-x: auto; flex-wrap: nowrap; gap: 6px;
  }
  .hero-card    { flex: 0 0 100px; padding: 6px; }
  .card-sprite  { width: 28px; height: 28px; }
  .card-name    { font-size: 6px; }
  .card-stat    { font-size: 5px; }

  /* Enemy list strip */
  .enemy-list   { flex-direction: row; overflow-x: auto; flex-wrap: nowrap; gap: 6px; padding-bottom: 4px; }
  .enemy-row    { flex: 0 0 auto; }
  .enemy-icon   { width: 26px; height: 26px; }
  .enemy-name   { font-size: 6px; }
  .enemy-stat   { font-size: 4px; }

  /* Controls */
  .controls     { gap: 5px; flex-wrap: wrap; justify-content: center; width: 100%; }
  .btn          { font-size: 5px; padding: 7px 9px; flex: 1 1 70px; text-align: center; }
  .btn-autoplace { font-size: 5px; }

  /* Wave info */
  .wave-name  { font-size: 6px; }
  .wave-count { font-size: 5px; }

  /* Modals full screen */
  .modal-box     { padding: 12px; border-radius: 0; width: 100vw !important; max-width: 100vw !important; max-height: 100vh; }
  .modal-title   { font-size: 8px; margin-bottom: 10px; }
  .chest-card    { min-width: 80px; padding: 10px 8px; }
  .chest-icon    { font-size: 26px; }
  .chest-card-name  { font-size: 5px; }
  .chest-card-count { font-size: 7px; }

  .reel-card     { width: 70px; height: 80px; }
  .reel-card img { width: 34px; height: 34px; }

  .inv-hero-tabs { gap: 5px; flex-wrap: wrap; }
  .inv-hero-tab  { padding: 6px 8px; }
  .inv-hero-tab img { width: 26px; height: 26px; }
  .inv-slot      { padding: 6px; min-height: 44px; }
  .inv-items-grid { max-height: 180px; }
  .inv-item-card  { min-width: 60px; padding: 6px 4px; }
  .inv-item-card img { width: 30px; height: 30px; }

  /* Chest notif */
  .chest-notif { font-size: 6px; bottom: 60px; right: 8px; padding: 8px 12px; }
}

/* ─── Battle chest popup ────────────────────────────────────────── */
.chest-popup-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 300;
  animation: chestPopIn .35s cubic-bezier(.2,1.4,.4,1) forwards;
}
.chest-popup-overlay.chest-popup-fade {
  animation: chestPopOut .5s ease forwards;
}
@keyframes chestPopIn {
  0%   { opacity:0; transform:scale(0.4); }
  100% { opacity:1; transform:scale(1); }
}
@keyframes chestPopOut {
  0%   { opacity:1; transform:scale(1); }
  100% { opacity:0; transform:scale(1.15); }
}

.chest-popup-box {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(6,6,15,0.92);
  border: 3px solid var(--gold);
  border-radius: 8px;
  padding: 28px 40px;
  box-shadow: 0 0 60px rgba(255,215,0,.35), 0 0 120px rgba(255,215,0,.15);
  overflow: hidden;
}

/* spinning rays behind the icon */
.chest-popup-rays {
  position: absolute; inset: -40px;
  background: conic-gradient(
    transparent 0deg, rgba(255,215,0,.06) 10deg, transparent 20deg,
    transparent 30deg, rgba(255,215,0,.06) 40deg, transparent 50deg,
    transparent 60deg, rgba(255,215,0,.06) 70deg, transparent 80deg,
    transparent 90deg, rgba(255,215,0,.06) 100deg, transparent 110deg,
    transparent 120deg, rgba(255,215,0,.06) 130deg, transparent 140deg,
    transparent 150deg, rgba(255,215,0,.06) 160deg, transparent 170deg,
    transparent 180deg, rgba(255,215,0,.06) 190deg, transparent 200deg,
    transparent 210deg, rgba(255,215,0,.06) 220deg, transparent 230deg,
    transparent 240deg, rgba(255,215,0,.06) 250deg, transparent 260deg,
    transparent 270deg, rgba(255,215,0,.06) 280deg, transparent 290deg,
    transparent 300deg, rgba(255,215,0,.06) 310deg, transparent 320deg,
    transparent 330deg, rgba(255,215,0,.06) 340deg, transparent 350deg
  );
  animation: rayspin 6s linear infinite;
  pointer-events: none;
}
@keyframes rayspin { to { transform: rotate(360deg); } }

.chest-popup-icon  { font-size: 72px; line-height: 1; position: relative; z-index: 1; }
.chest-popup-label {
  font-family: var(--font); font-size: 9px; color: var(--gold);
  letter-spacing: 4px; position: relative; z-index: 1;
}
.chest-popup-name  {
  font-family: var(--font); font-size: 13px;
  letter-spacing: 2px; position: relative; z-index: 1;
  text-shadow: 0 0 20px currentColor;
}

/* chest notification badge on game screen */
.chest-notif {
  position:fixed; bottom:80px; right:20px;
  background:#1a1206; border:2px solid var(--gold);
  color:var(--gold); font-size:7px; padding:10px 16px;
  border-radius:4px; box-shadow:0 0 16px rgba(255,215,0,.3);
  animation:slideIn .4s ease, fadeOut .4s ease 3s forwards;
  z-index:500; pointer-events:none;
}
@keyframes slideIn { from{transform:translateX(120%)} to{transform:translateX(0)} }
@keyframes fadeOut { to{opacity:0; transform:translateX(120%)} }
