:root {
  --bg: #0d1410;
  --ink: #e9f3e6;
  --muted: #9fb39a;
  --gold: #ffd964;
  --green: #58e07a;
  --red: #ff5d5d;
  --panel: rgba(16, 26, 19, 0.92);
  --panel-edge: #2c4030;
  --accent: #7af0a0;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  background: #060a07;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud .kbtn, #hud button { pointer-events: auto; }

.hud-top {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.hud-player {
  display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 14px; padding: 8px 12px 8px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.avatar {
  width: 46px; height: 46px; border-radius: 12px;
  background: radial-gradient(circle at 35% 30%, #3a6f4f, #1d3527);
  display: grid; place-items: center; font-size: 26px;
  border: 2px solid #4f7d5e;
}
.pname { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.hpbar {
  position: relative; width: 150px; height: 14px; margin: 3px 0;
  background: #20140f; border-radius: 7px; overflow: hidden; border: 1px solid #3a2a20;
  flex-shrink: 0; min-width: 150px;
}
.hpfill { height: 100%; width: 100%; background: linear-gradient(90deg,#3ddc6e,#7af0a0); transition: width .15s; }
.hpbar span { position: absolute; inset: 0; font-size: 10px; line-height: 14px; text-align: center; color: #fff; text-shadow: 0 1px 1px #000; }
.shbar { position: relative; width: 150px; height: 9px; margin: 3px 0 2px; background: #0e2230; border-radius: 5px; overflow: hidden; border: 1px solid #1d3c4e; flex-shrink: 0; min-width: 150px; }
.shfill { height: 100%; width: 100%; background: linear-gradient(90deg,#3fb8ff,#9fe8ff); transition: width .1s; }
.shbar span { position: absolute; inset: 0; font-size: 9px; line-height: 9px; text-align: center; color: #eaf7ff; text-shadow: 0 1px 1px #000; }
.stambar { position: relative; width: 150px; height: 6px; margin: 0 0 3px; background: #181a24; border-radius: 4px; overflow: hidden; border: 1px solid #2a2e3e; flex-shrink: 0; min-width: 150px; }
.stamfill { height: 100%; width: 100%; background: linear-gradient(90deg,#4aa3ff,#9fd4ff); transition: width .08s; }
.stamfill.low { background: linear-gradient(90deg,#ff8a3a,#ffc15a); }
.power { font-size: 12px; color: var(--gold); }
.power b { color: #fff; }

.hud-timer { text-align: center; background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 14px; padding: 6px 18px; }
.hud-timer .round { font-size: 12px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.hud-timer .clock { font-size: 30px; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.hud-timer .clock.warn { color: var(--red); animation: pulse .8s infinite; }
.hud-timer .sub { font-size: 11px; color: var(--accent); }
@keyframes pulse { 50% { opacity: .45; } }

.hud-bag { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.hud-bag .bag, .hud-bag .gold {
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 10px; padding: 5px 12px; font-size: 14px; font-weight: 700;
}
.hud-bag .gold b { color: var(--gold); }
.hud-menu-btn {
  pointer-events: auto; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 12px;
  color: var(--ink); background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 10px; padding: 5px 12px; margin-top: 2px;
}
.hud-menu-btn:active { transform: scale(.96); }
.pause-card { text-align: center; }
.pause-card h2 { margin-bottom: 16px; }

.hud-objectives {
  position: absolute; top: 116px; left: 12px; display: flex; flex-direction: column; gap: 4px;
}
.obj {
  background: rgba(10,16,12,.7); border-radius: 8px; padding: 4px 10px; font-size: 12px;
  display: flex; gap: 7px; align-items: center; color: var(--muted);
}
.obj.done { color: var(--green); text-decoration: line-through; opacity: .7; }
.obj .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.obj.done .dot { background: var(--green); }

.hud-tip {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(10,16,12,.82); border: 1px solid var(--panel-edge);
  border-radius: 20px; padding: 7px 16px; font-size: 12px; color: var(--muted);
  max-width: 80vw; text-align: center;
}
.hud-tip b { color: var(--gold); }

.channel-indicator {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: rgba(10,16,12,.9); border: 1px solid var(--panel-edge);
  border-radius: 20px; padding: 6px 18px 9px; min-width: 160px; text-align: center; pointer-events: none;
}
.ch-label { font-size: 12px; color: #fff; letter-spacing: .3px; margin-bottom: 5px; }
.ch-bar-track { height: 5px; background: #1a2a1e; border-radius: 3px; overflow: hidden; }
.ch-bar-fill { height: 100%; width: 0%; border-radius: 3px; transition: none; }
.channel-indicator.heal .ch-bar-fill { background: linear-gradient(90deg,#3ddc6e,#7af0a0); }
.channel-indicator.cell .ch-bar-fill { background: linear-gradient(90deg,#3fb8ff,#9fe8ff); }

.hud-bottom { position: absolute; right: 18px; bottom: 22px; display: flex; gap: 14px; align-items: center; }
.kbtn {
  width: 58px; height: 58px; border-radius: 50%; font-size: 24px; position: relative;
  background: radial-gradient(circle at 35% 30%, #26392c, #14201a);
  border: 2px solid #3c5a44; color: #fff; cursor: pointer;
}
.kbtn.cell { background: radial-gradient(circle at 35% 30%, #1d4a63, #0e2735); border-color: #3f88a8; }
.kbtn.primary {
  width: 76px; height: 76px; font-size: 32px;
  background: radial-gradient(circle at 35% 30%, #7a3bd6, #3d1d6e);
  border-color: #b07aff;
  box-shadow: 0 0 22px rgba(150,90,255,.5);
}
.kbtn:active { transform: scale(.92); }
.kbtn span { position: absolute; bottom: -2px; right: -2px; background: var(--gold); color:#000; font-size: 11px; font-weight: 800; border-radius: 8px; padding: 0 5px; }
.kbtn:disabled { opacity: .4; filter: grayscale(1); }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(20,40,28,.6), rgba(4,8,6,.92));
  backdrop-filter: blur(2px);
}
h1 { font-size: 32px; margin-bottom: 6px; text-align: center; }
.tag { color: var(--muted); text-align: center; font-size: 13px; margin-bottom: 18px; max-width: 380px; }

.menu-card, .result-card, .howto-card, .inv-card {
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 20px; padding: 26px; width: min(440px, 94vw);
  box-shadow: 0 18px 60px rgba(0,0,0,.6);
}
.menu-card { text-align: center; }

.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 18px; }
.stat-box { background: rgba(0,0,0,.25); border-radius: 12px; padding: 8px 4px; }
.stat-box .v { font-size: 18px; font-weight: 800; }
.stat-box .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.big-btn {
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  border: 1px solid #3c5a44; border-radius: 14px; padding: 13px; color: var(--ink);
  background: linear-gradient(180deg,#22352a,#162018);
}
.big-btn:active { transform: scale(.98); }
.big-btn.play { background: linear-gradient(180deg,#33c463,#1f8a44); border-color: #58e07a; color: #06140a; font-size: 18px; }
.big-btn.ghost { background: transparent; color: var(--muted); }
.seed-line { margin-top: 16px; font-size: 12px; color: var(--muted); }
.seed-line b { color: var(--gold); }

/* ---------- Dev tuning panel ---------- */
.tune-card { width: min(560px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.tune-note { font-size: 11px; color: var(--muted); margin: -4px 0 8px; line-height: 1.35; }
.tune-note b { color: var(--accent); } .tune-note i { color: var(--gold); font-style: normal; }
.tune-tabs { display: flex; gap: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--panel-edge); }
.tune-tab { flex: 1 1 auto; background: rgba(0,0,0,.25); border: 1px solid var(--panel-edge); border-bottom: none; border-radius: 7px 7px 0 0; color: var(--muted); font-family: inherit; font-size: 12px; font-weight: 600; padding: 7px 4px; cursor: pointer; transition: background .12s, color .12s; }
.tune-tab:hover { color: var(--ink); background: rgba(0,0,0,.4); }
.tune-tab.active { color: var(--accent); background: rgba(0,0,0,.5); border-color: var(--accent); }
.tune-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 8px; }
.tune-grp { margin-top: 10px; }
.tune-grp h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 4px; padding-bottom: 3px; border-bottom: 1px solid var(--panel-edge); }
.tune-row { display: grid; grid-template-columns: 1fr 62px 76px 26px; gap: 7px; align-items: center; padding: 2px 0; font-size: 12px; }
.tune-row label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.tune-def { font-size: 11px; color: #6d7d6c; text-align: right; white-space: nowrap; overflow: hidden; }
.tune-row input { width: 100%; background: rgba(0,0,0,.3); border: 1px solid var(--panel-edge); border-radius: 6px; color: var(--ink); font-family: inherit; font-size: 12px; padding: 4px 6px; text-align: right; }
.tune-row input:focus { outline: none; border-color: var(--accent); }
.tune-row input.mod { border-color: var(--gold); color: var(--gold); font-weight: 700; }
.tune-reset { background: rgba(0,0,0,.3); border: 1px solid var(--panel-edge); border-radius: 6px; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; padding: 4px 0; }
.tune-reset:hover { color: var(--accent); border-color: var(--accent); }
.tune-tip { position: fixed; z-index: 60; background: #0c140e; border: 1px solid var(--accent); color: var(--ink);
  font-size: 11px; line-height: 1.35; padding: 5px 9px; border-radius: 8px; max-width: 280px;
  pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.6); }

.dev-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.dev-label { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: #4a5a4e; margin-bottom: 8px; }
.big-btn.danger { background: linear-gradient(180deg,#3a1a1a,#231010); border-color: #6a3030; color: #e09090; }

/* ---------- Inventory ---------- */
.inv-card { width: min(540px, 96vw); max-height: 94vh; overflow-y: auto; }
.inv-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.inv-head h2 { flex: 1; }
.inv-power { color: var(--gold); font-size: 14px; }
.inv-power b { color: #fff; font-size: 18px; }
.x { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.inv-body { display: grid; grid-template-columns: 150px 1fr; gap: 14px; }
.char-stats { display: flex; flex-direction: column; gap: 6px; }
.cstat { display: flex; justify-content: space-between; background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.cstat b { color: var(--accent); }
.blueprint-line { margin-top: 10px; font-size: 13px; }
.blueprint-line b { color: var(--gold); }
.inv-slots { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.slot {
  background: rgba(0,0,0,.28); border: 1px solid #2a3c30; border-radius: 12px;
  padding: 8px; text-align: center; cursor: pointer; position: relative; min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.slot:active { transform: scale(.97); }
.slot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(122,240,160,.3); }
.slot .ico { font-size: 26px; }
.slot .nm { font-size: 11px; font-weight: 700; }
.slot .lv { font-size: 10px; color: var(--gold); }
.slot .rar { position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 50%; }
.rar-common { background: #b9c4ba; } .rar-rare { background: #4fa3ff; }
.rar-epic { background: #c071ff; } .rar-legendary { background: #ffb23e; }
.slot-label { position: absolute; top: 4px; left: 8px; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.stash-head { margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stash-head small { color: #6d7d6c; font-weight: 400; }
.sort-btn { margin-left: auto; font-family: inherit; font-size: 11px; font-weight: 600; color: var(--accent); cursor: pointer;
  background: rgba(0,0,0,.3); border: 1px solid var(--panel-edge); border-radius: 8px; padding: 4px 9px; }
.sort-btn:active { transform: scale(.96); }
.inv-stash { margin-top: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; max-height: 168px; overflow-y: auto; overflow-x: hidden; padding: 2px; }
.sitem { position: relative; aspect-ratio: 1; background: rgba(0,0,0,.3); border: 1.5px solid #2a3c30; border-radius: 9px; display: grid; place-items: center; font-size: 19px; cursor: pointer; }
.sitem:active { transform: scale(.92); }
.sitem.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(122,240,160,.3); }
.sitem.r-common { border-color: #51604f; } .sitem.r-rare { border-color: #3a6ea8; }
.sitem.r-epic { border-color: #7c4aa8; } .sitem.r-legendary { border-color: #b07f2e; }
.sitem .slv { position: absolute; bottom: 1px; right: 3px; font-size: 8px; color: var(--gold); }
.inv-stash .empty { grid-column: 1/-1; text-align: center; color: #6d7d6c; font-size: 12px; padding: 14px; }
.det-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.det-actions .big-btn { flex: 1; min-width: 92px; padding: 9px; font-size: 13px; margin: 0; }
.det-actions .scrap { background: linear-gradient(180deg,#3a2622,#241715); border-color: #6a4030; color: #e0b09a; }
/* fixed height, no scroll: panel footprint is identical across every selection state,
   so the action buttons + stash below never shift. Content is clamped to fit. */
.inv-detail { margin-top: 14px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 11px 12px; font-size: 13px; height: 296px; overflow: hidden; }
.inv-detail .perk { color: var(--accent); }
.inv-actions { min-height: 44px; }
.up-btn { margin-top: 10px; }
/* single-line clamps + tight line-height keep the panel height deterministic */
.idc-name { font-weight: 700; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idc-name small { color: var(--muted); font-weight: 400; }
.idc-stats { margin: 5px 0; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idc-line { margin-top: 3px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Stash vs Equipped comparison ---------- */
.cmp { margin-top: 9px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.09); }
.cmp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cmp-title { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.cmp-verdict { font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 9px; letter-spacing: .3px; flex-shrink: 0; }
.cmp-verdict.up { color: #06140a; background: var(--green); }
.cmp-verdict.same { color: #1c1606; background: var(--gold); }
.cmp-verdict.down { color: #fff; background: var(--red); }
.cmp-vs { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.cmp-vs .eq-icon { font-size: 17px; flex-shrink: 0; }
.cmp-vs span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-vs b { color: var(--ink); }
.cmp-rows { display: flex; flex-direction: column; gap: 3px; }
.cmp-row { display: grid; grid-template-columns: 50px 1fr 46px; align-items: center; font-size: 12px; gap: 8px; line-height: 1.25; }
.cmp-row .lbl { color: var(--muted); }
.cmp-row .vals { color: var(--muted); font-variant-numeric: tabular-nums; }
.cmp-row .vals .arr { opacity: .45; }
.cmp-row .vals b { color: var(--ink); font-weight: 700; }
.cmp-row .vals b.pos { color: var(--green); } .cmp-row .vals b.neg { color: var(--red); }
.cmp-delta { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.cmp-delta.pos { color: var(--green); } .cmp-delta.neg { color: var(--red); } .cmp-delta.zero { color: #6d7d6c; }
/* passive profile of each item: set membership (with progress) + perk */
.cmp-pass { margin-top: 7px; padding-top: 7px; border-top: 1px dashed rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 3px; }
.cmp-pr { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: baseline; font-size: 11px; line-height: 1.3; }
.cmp-pr > span { color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-size: 10px; white-space: nowrap; }
.cmp-pr b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-pr .pk { color: var(--accent); }
.cmp-pr b.none { color: #6d7d6c; font-weight: 400; }
.cmp-power { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; padding-top: 7px; border-top: 1px dashed rgba(255,255,255,.1); font-size: 13px; }
.cmp-power span { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.cmp-power b { font-size: 18px; }
.cmp-hint { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Result ---------- */
.result-card { text-align: center; }
.result-card h2 { font-size: 28px; margin-bottom: 4px; }
#resultTitle.win { color: var(--green); } #resultTitle.lose { color: var(--red); }
#resultSub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.loot-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 14px; max-height: 180px; overflow:auto; }
.loot-chip { background: rgba(0,0,0,.3); border-radius: 10px; padding: 6px 10px; font-size: 13px; display:flex; gap:6px; align-items:center; }
.loot-chip.lost { opacity: .4; text-decoration: line-through; }
.result-totals { font-size: 15px; margin-bottom: 16px; }
.result-totals b { color: var(--gold); }

/* ---------- Howto ---------- */
.howto-card { display: flex; flex-direction: column; max-height: 90vh; }
.howto-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.howto-head h2 { flex: 1; margin: 0; }
.howto-card ul { margin: 8px 0 14px 18px; padding-right: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.howto-card li { font-size: 13px; color: var(--ink); line-height: 1.35; }
.howto-card b { color: var(--gold); }
.howto-card > .big-btn { flex-shrink: 0; }

/* ---------- Event banner ---------- */
#eventBanner {
  position: absolute; top: 19%; left: 50%; transform: translateX(-50%);
  z-index: 12; pointer-events: none; text-align: center; width: 92vw; max-width: 620px;
}
#eventBanner #eventText {
  display: inline-block; font-size: 21px; font-weight: 800; letter-spacing: .4px;
  color: #f0e6ff; text-shadow: 0 0 18px rgba(170,110,255,.9), 0 2px 4px #000;
  background: linear-gradient(180deg, rgba(40,20,60,.78), rgba(20,10,34,.78));
  border: 1px solid rgba(176,122,255,.55); border-radius: 14px; padding: 10px 22px;
  animation: bannerIn .5s ease, bannerGlow 2s ease-in-out infinite alternate;
}
#eventBanner.warn #eventText { color: #ffe0b0; border-color: rgba(255,170,90,.6); text-shadow: 0 0 18px rgba(255,150,70,.9), 0 2px 4px #000; }
#eventBanner.danger #eventText { color: #ffd0d0; border-color: rgba(255,90,90,.7); text-shadow: 0 0 20px rgba(255,70,70,.95), 0 2px 4px #000; }
@keyframes bannerIn { from { opacity: 0; transform: translateY(-12px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes bannerGlow { to { filter: brightness(1.18); } }

/* ---------- Loot reveal strip ---------- */
#lootReveal { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 11; pointer-events: none; text-align: center; }
.loot-strip-title { font-size: 13px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); text-shadow: 0 0 10px rgba(255,200,80,.7), 0 1px 2px #000; margin-bottom: 6px; }
.loot-strip { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; max-width: 94vw; }
.loot-card {
  width: 62px; min-height: 74px; border-radius: 12px; padding: 7px 4px 5px;
  background: linear-gradient(180deg, rgba(20,28,22,.95), rgba(10,16,12,.95));
  border: 1.5px solid #394d3e; display: flex; flex-direction: column; align-items: center; gap: 2px;
  opacity: 0; transform: translateY(14px) scale(.7); position: relative;
}
.loot-card.show { animation: cardPop .42s cubic-bezier(.2,1.5,.5,1) forwards; }
.loot-card .ci { font-size: 26px; line-height: 1; filter: drop-shadow(0 1px 2px #000); }
.loot-card .cn { font-size: 9px; color: #cdd9c9; line-height: 1.05; }
.loot-card .crar { font-size: 8px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.loot-card.full { opacity: .55; }
.loot-card.full::after { content: "BAG FULL"; position: absolute; bottom: 2px; left: 0; right: 0; font-size: 7px; color: #ff9d6a; }
.loot-card.r-common { border-color: #6b766a; }
.loot-card.r-rare { border-color: #4fa3ff; box-shadow: 0 0 12px rgba(79,163,255,.35); }
.loot-card.r-epic { border-color: #c071ff; box-shadow: 0 0 16px rgba(192,113,255,.45); }
.loot-card.r-legendary { border-color: #ffb23e; box-shadow: 0 0 22px rgba(255,178,62,.6); }
.loot-card.r-common .crar { color: #b9c4ba; } .loot-card.r-rare .crar { color: #4fa3ff; }
.loot-card.r-epic .crar { color: #c071ff; } .loot-card.r-legendary .crar { color: #ffb23e; }
.loot-chip.safe { border: 1px solid var(--gold); box-shadow: 0 0 10px rgba(255,217,100,.3); }

/* ===== In-raid bag panel (triage + Safe Pocket) ===== */
.hud-bag .bag { pointer-events: auto; cursor: pointer; color: var(--ink); font-family: inherit; }
.hud-bag .bag:active { transform: scale(.96); }
.inv-card.bag-card { width: min(460px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.bag-safe-row { display: flex; align-items: stretch; gap: 10px; margin-bottom: 12px; }
.bag-safe-label { font-size: 12px; font-weight: 700; color: var(--gold); display: flex; flex-direction: column; justify-content: center; }
.bag-safe-label small { color: var(--muted); font-weight: 400; font-size: 10px; }
.bag-safe-slot { flex: 1; min-height: 50px; border: 1px dashed var(--panel-edge); border-radius: 12px; background: rgba(0,0,0,.25); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; }
.bag-safe-slot.empty { color: #6d7d6c; font-size: 12px; cursor: default; }
.bag-safe-slot:not(.empty) { border-style: solid; }
.bag-safe-slot .bi { font-size: 22px; line-height: 1; }
.bag-safe-slot .bn { font-size: 10px; color: #cdd9c9; }
.bag-safe-slot.r-common { border-color: #6b766a; } .bag-safe-slot.r-rare { border-color: #4fa3ff; }
.bag-safe-slot.r-epic { border-color: #c071ff; } .bag-safe-slot.r-legendary { border-color: #ffb23e; }
.bagslot.locked { border-style: dashed; }
.bagslot .lock-badge { position: absolute; top: 2px; right: 3px; font-size: 11px; opacity: .85; }
.bag-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 7px; padding: 2px; align-content: start; }
.bag-empty { grid-column: 1/-1; text-align: center; color: #6d7d6c; font-size: 12px; padding: 24px 10px; }
.bagslot { position: relative; border: 1px solid var(--panel-edge); border-radius: 11px; background: rgba(0,0,0,.3); padding: 8px 4px 6px; text-align: center; cursor: pointer; transition: transform .08s; }
.bagslot:active { transform: scale(.95); }
.bagslot.sel { outline: 2px solid var(--accent); }
.bagslot .bi { font-size: 24px; line-height: 1; filter: drop-shadow(0 1px 2px #000); }
.bagslot .bn { font-size: 9px; color: #cdd9c9; line-height: 1.1; margin-top: 2px; height: 21px; overflow: hidden; }
.bagslot .bv { font-size: 9px; color: var(--muted); margin-top: 2px; }
.bagslot.r-common { border-color: #6b766a; } .bagslot.r-rare { border-color: #4fa3ff; }
.bagslot.r-epic { border-color: #c071ff; box-shadow: 0 0 10px rgba(192,113,255,.3); }
.bagslot.r-legendary { border-color: #ffb23e; box-shadow: 0 0 12px rgba(255,178,62,.4); }
.bagslot .pd.up { color: #7af0a0; font-weight: 700; } .bagslot .pd.dn { color: #ff8a7a; font-weight: 700; }
.bag-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; min-height: 0; }
.bag-actions .big-btn { margin: 0; padding: 10px; }
.bag-actions .big-btn.danger { background: #5a2c2c; border-color: #8a4242; }
.bag-actions > .bag-btn-row { display: flex; gap: 8px; }
.bag-actions > .bag-btn-row .big-btn { flex: 1; }
.bag-detail-scroll { max-height: 38vh; overflow-y: auto; background: rgba(0,0,0,.25); border: 1px solid var(--panel-edge); border-radius: 10px; padding: 9px 11px; }
.bag-detail-scroll .idc { margin-bottom: 8px; }
.bag-detail-scroll .cmp { margin-top: 0; }

/* ===== Container loot sheet — bottom sheet, NON-pausing (world visible above) ===== */
.loot-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; pointer-events: auto;
  background: linear-gradient(180deg, rgba(16,26,19,.97), rgba(10,16,12,.99)); border-top: 1px solid var(--accent);
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.5); padding: 10px 14px 16px;
  max-height: 42vh; display: flex; flex-direction: column; animation: sheetUp .2s ease; }
.loot-sheet.hidden { display: none; }
.ls-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ls-head #lsTitle { flex: 1; font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.ls-leave { pointer-events: auto; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 12px;
  color: var(--ink); background: #5a2c2c; border: 1px solid #8a4242; border-radius: 10px; padding: 6px 12px; }
.ls-leave:active { transform: scale(.96); }
.ls-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 7px; padding: 2px; align-content: start; }
.ls-takeall { margin: 10px 0 0; padding: 11px; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes cardPop { 0% { opacity: 0; transform: translateY(16px) scale(.6) rotate(-8deg); } 60% { opacity: 1; transform: translateY(-3px) scale(1.12) rotate(2deg); } 100% { opacity: 1; transform: none; } }
#lootReveal.fade { animation: lootFade .6s ease forwards; }
@keyframes lootFade { to { opacity: 0; } }

/* ---------- Storm / cataclysm overlay ---------- */
#stormOverlay {
  position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0;
  transition: opacity .6s;
  background:
    radial-gradient(circle at 50% 50%, transparent 30%, rgba(96,40,170,.0) 45%, rgba(96,40,170,.55) 100%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(150,90,255,.05) 0deg, transparent 8deg);
  box-shadow: inset 0 0 220px 60px rgba(120,50,200,.5);
}
#stormOverlay.on { opacity: 1; animation: stormPulse 1.6s ease-in-out infinite alternate; }
#stormOverlay.cataclysm { opacity: 1; background: radial-gradient(circle at 50% 50%, rgba(220,180,255,.95), rgba(120,40,200,.9) 40%, rgba(40,10,70,.96)); animation: flash .6s ease; }
@keyframes stormPulse { to { box-shadow: inset 0 0 280px 90px rgba(150,70,230,.66); } }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 1; } }

/* ---------- Full-screen tactical map ---------- */
#bigmap { position: absolute; inset: 0; z-index: 15; background: rgba(4,8,6,.93); backdrop-filter: blur(3px); }
#bigmapCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bigmap-head { position: absolute; top: 14px; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 14px; pointer-events: none; }
.bigmap-title { font-size: 15px; font-weight: 700; color: var(--accent); background: rgba(10,16,12,.8); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 7px 16px; }
.bigmap-head .x { position: absolute; right: 16px; top: -2px; pointer-events: auto; background: rgba(10,16,12,.8); border: 1px solid var(--panel-edge); border-radius: 10px; width: 38px; height: 38px; }
.bigmap-legend { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 11px; color: var(--muted); background: rgba(10,16,12,.8); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 7px 16px; max-width: 92vw; }
.bigmap-legend b { color: var(--ink); }
.bigmap-dev-reveal { position: absolute; bottom: 16px; right: 16px; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); background: rgba(10,16,12,.8); border: 1px solid var(--panel-edge); border-radius: 10px; padding: 5px 12px; cursor: pointer; pointer-events: auto; user-select: none; }
.bigmap-dev-reveal input { accent-color: #ffd964; cursor: pointer; }

/* floating combat text handled on canvas */
@media (max-width: 560px) {
  .hpbar { width: 110px; }
  h1 { font-size: 26px; }
  .hud-timer .clock { font-size: 24px; }
}
