:root {
  --ink: #2b2233;
  --ink2: #5e5068;
  --red: #e05555;
  --red-d: #b53a3a;
  --green: #6cc46a;
  --green-d: #3f9a3e;
  --blue: #6fb8ec;
  --blue-d: #3f8ac4;
  --yellow: #f2c94c;
  --orange: #f08a3c;
  --wood: #b87a48;
  --wood-d: #8a5530;
  --berry: #7a5cff;
  --cream: #fff8ec;
  --card: rgba(255, 248, 236, 0.94);
  --shadow: 0 6px 0 rgba(43, 34, 51, 0.2), 0 14px 30px rgba(43, 34, 51, 0.22);
  --r: 20px;
  --disp: 'Lilita One', 'Fredoka', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #f4d49e; color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
body { touch-action: none; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; touch-action: none; }
#numbers { position: fixed; inset: 0; pointer-events: none; width: 100%; height: 100%; }
.labels { position: fixed; inset: 0; pointer-events: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 60, 60, 0) 55%, rgba(220, 40, 40, 0.5) 100%);
  transition: opacity 0.35s ease-out;
}
#vignette.on { opacity: 1; transition: none; }
#vignette.low { opacity: 0.55; animation: lowhp 1s ease-in-out infinite; }
@keyframes lowhp { 50% { opacity: 0.25; } }
#nightfx { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 45%, rgba(20, 10, 40, 0.45) 100%); opacity: 0; transition: opacity 1s; }
#nightfx.on { opacity: 1; }

/* ---------- buttons, cards, inputs ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 18px; color: #fff; border: 0; border-radius: 16px; padding: 12px 22px; cursor: pointer;
  background: var(--ink2); box-shadow: 0 5px 0 rgba(43, 34, 51, 0.35); text-shadow: 0 2px 0 rgba(43, 34, 51, 0.3);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; touch-action: none;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(43, 34, 51, 0.35); }
.btn.big { font-size: 21px; padding: 13px 26px; width: 100%; font-family: var(--disp); letter-spacing: 0.5px; font-weight: 400; }
.btn.small { font-size: 15px; padding: 8px 14px; border-radius: 12px; }
.btn.red { background: linear-gradient(#f07a6a, var(--red)); box-shadow: 0 5px 0 var(--red-d); }
.btn.green { background: linear-gradient(#8fd88a, var(--green)); box-shadow: 0 5px 0 var(--green-d); }
.btn.blue { background: linear-gradient(#9ad0f8, var(--blue)); box-shadow: 0 5px 0 var(--blue-d); }
.btn.wood { background: linear-gradient(#d09060, var(--wood)); box-shadow: 0 5px 0 var(--wood-d); }
.btn.ghost { background: transparent; color: var(--ink2); box-shadow: none; text-shadow: none; text-decoration: underline; }
.btn:disabled { filter: grayscale(0.7) opacity(0.55); cursor: default; }
.card {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 3px solid #fff;
  padding: 18px; width: min(420px, calc(100vw - 32px));
}
input {
  font: inherit; font-size: 18px; color: var(--ink); font-weight: 500; border: 3px solid #eadcc8; border-radius: 14px;
  padding: 9px 14px; width: 100%; background: #fff; outline: none;
}
input:focus { border-color: var(--green); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 16px; overflow-y: auto; z-index: 5;
}
#title { justify-content: flex-start; padding-top: max(18px, env(safe-area-inset-top)); }
#title::before { content: ''; position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 40%, rgba(255, 240, 210, 0.35), rgba(43, 34, 51, 0.12)); pointer-events: none; z-index: -1; }

/* the carved garden sign */
.sign { position: relative; margin-top: 18px; animation: signin 0.8s cubic-bezier(0.3, 1.5, 0.6, 1); transform-origin: 50% -30px; }
@keyframes signin { from { transform: rotate(-8deg) translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sign .rope { position: absolute; top: -30px; width: 4px; height: 38px; background: repeating-linear-gradient(45deg, #c9a46a 0 4px, #9a7040 4px 8px); border-radius: 2px; }
.sign .rope.l { left: 18%; } .sign .rope.r { right: 18%; }
.board {
  position: relative; padding: 14px 34px 16px; border-radius: 18px 22px 16px 24px / 22px 16px 24px 18px;
  background:
    repeating-linear-gradient(176deg, rgba(0,0,0,0) 0 9px, rgba(90, 50, 20, 0.12) 9px 11px, rgba(0,0,0,0) 11px 23px),
    radial-gradient(ellipse at 30% 40%, rgba(255, 220, 160, 0.35), rgba(0,0,0,0) 60%),
    linear-gradient(#c98d55, #a86a38);
  border: 4px solid #6e4020;
  box-shadow: inset 0 3px 0 rgba(255, 230, 190, 0.4), inset 0 -5px 0 rgba(70, 35, 10, 0.35), 0 8px 0 #5a3218, 0 16px 30px rgba(43, 34, 51, 0.35);
  transform: rotate(-1.5deg);
}
.logo {
  margin: 0; line-height: 0.95; text-align: center; font-family: var(--disp); font-weight: 400;
  font-size: clamp(48px, 11vw, 88px); display: flex; align-items: baseline; justify-content: center; gap: 0.18em; white-space: nowrap;
}
.logo span {
  color: #4a2408;
  /* carved into the board: dark letters, a lit lower lip and a shadowed upper edge */
  text-shadow: 0 2px 0 rgba(255, 214, 160, 0.75), 0 -2px 0 rgba(30, 12, 2, 0.5), 0 3px 3px rgba(255, 200, 140, 0.25);
}
.logo .amp { font-size: 0.72em; color: #ffd24a; text-shadow: 0 3px 0 #8a4a10, 2px 0 0 #8a4a10, -2px 0 0 #8a4a10, 0 -2px 0 #8a4a10; }
.nail { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f0f0f0, #8a8a90 60%, #50505a); box-shadow: 0 1px 0 rgba(255,255,255,0.4); }
.n1 { left: 10px; top: 10px; } .n2 { right: 10px; top: 10px; } .n3 { left: 10px; bottom: 10px; } .n4 { right: 10px; bottom: 10px; }
.moss { position: absolute; background: radial-gradient(circle at 40% 40%, #8fd460, #4f9a3a); border-radius: 50%; }
.moss.m1 { left: -8px; bottom: -6px; width: 46px; height: 22px; box-shadow: 18px -6px 0 -4px #6fbf4a, 34px 2px 0 -6px #5aa840; }
.moss.m2 { right: 30px; top: -9px; width: 28px; height: 14px; box-shadow: 14px 3px 0 -3px #6fbf4a; }
.hat {
  position: absolute; right: -16px; top: -34px; width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent;
  border-bottom: 52px solid var(--red); transform: rotate(18deg); filter: drop-shadow(0 3px 0 #8a2a2a);
}
.hat::after { content: ''; position: absolute; left: -24px; top: 46px; width: 48px; height: 12px; border-radius: 8px; background: #fff; box-shadow: 0 2px 0 #cfc8c0; }
.tag, .hint {
  margin: 0; text-align: center; font-weight: 600; color: #fff; max-width: 440px;
  text-shadow: 0 2px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink);
}
.hint { font-size: 14px; font-weight: 500; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--ink2); margin: 0 0 5px 4px; }
.classes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cls {
  position: relative; border: 3px solid #fff; border-radius: 16px; background: linear-gradient(#fff, var(--cc2, #eee)); padding: 4px 2px 5px;
  cursor: pointer; font: inherit; color: var(--ink); box-shadow: 0 4px 0 rgba(43, 34, 51, 0.18); transition: transform 0.12s;
  display: flex; flex-direction: column; align-items: center; gap: 1px; touch-action: manipulation;
}
.cls img { width: 100%; max-width: 76px; aspect-ratio: 1; display: block; }
.cls .cn { font-size: 12.5px; font-weight: 700; line-height: 1; white-space: nowrap; }
.cls:hover { transform: translateY(-2px); }
.cls.on { border-color: var(--cc); box-shadow: 0 0 0 3px var(--cc), 0 4px 0 rgba(43, 34, 51, 0.18); transform: translateY(-2px) scale(1.04); }
.classes.mini .cls img { max-width: 44px; }
.classes.mini .cls .cn { font-size: 11px; }
.clsinfo { background: #fff; border-radius: 14px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; line-height: 1.3; min-height: 54px; box-shadow: inset 0 -3px 0 rgba(43,34,51,0.06); }
.clsinfo b { color: var(--cc); }
.clsinfo .wp { display: inline-block; margin-top: 3px; font-size: 13px; background: #fff3d8; border-radius: 99px; padding: 1px 9px; font-weight: 600; }
.or { text-align: center; margin: 12px 0 9px; color: var(--ink2); font-size: 14px; font-weight: 600; position: relative; }
.or::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed #e6d6bf; }
.or span { background: var(--cream); padding: 0 10px; position: relative; border-radius: 8px; }
.joinrow { display: flex; gap: 8px; }
.joinrow input { text-transform: uppercase; letter-spacing: 5px; text-align: center; font-weight: 700; width: 0; flex: 1; min-width: 0; }
.joinrow .btn { flex: none; }
.msg { min-height: 18px; margin-top: 8px; text-align: center; color: #d6456f; font-weight: 600; font-size: 15px; }
#openshed { width: 100%; margin-top: 4px; }
.coin { color: #ffd24a; text-shadow: 0 1px 0 #a07a10; }
#openshed b { background: rgba(0,0,0,0.18); border-radius: 99px; padding: 0 9px; margin-left: 4px; }

/* the shed */
.shedcard h2, .results h2 { margin: 0; font-family: var(--disp); font-weight: 400; font-size: 36px; color: var(--wood-d); text-align: center; }
.shedcard .sub { margin: 2px 0 10px; text-align: center; color: var(--ink2); font-weight: 500; }
.wallet { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.shedlist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.upg { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: #fff; border-radius: 14px; padding: 9px 12px; align-items: center; box-shadow: 0 3px 0 rgba(43,34,51,0.08); }
.upg .un { font-weight: 700; }
.upg .ud { font-size: 13px; color: var(--ink2); }
.upg .pips { display: flex; gap: 4px; margin-top: 3px; }
.upg .pips i { width: 16px; height: 8px; border-radius: 4px; background: #eadcc8; }
.upg .pips i.on { background: linear-gradient(#ffe070, #f2b020); }
.upg .btn { grid-row: 1 / span 3; grid-column: 2; min-width: 88px; }

/* lobby */
.lobby { text-align: center; }
.lbl { font-weight: 600; color: var(--ink2); font-size: 15px; }
.code { font-family: var(--disp); font-size: 60px; letter-spacing: 10px; line-height: 1.05; margin: 2px 0 8px; padding-left: 10px; color: var(--red); text-shadow: 0 4px 0 var(--red-d); }
.plist { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 7px; text-align: left; }
.plist li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 6px 12px; font-weight: 600; font-size: 18px; box-shadow: 0 3px 0 rgba(43,34,51,0.1); animation: popin 0.3s ease-out; }
.plist img { width: 38px; height: 38px; }
.plist .cl { font-size: 13px; color: var(--ink2); font-weight: 500; }
.plist .tagx { margin-left: auto; font-size: 12px; background: var(--yellow); border-radius: 999px; padding: 2px 8px; }
.plist .you { font-size: 12px; background: #e6f4ff; border-radius: 999px; padding: 2px 8px; }
.lobby .field { text-align: left; }
.hazard { margin: 6px 0 12px; }
.hazard .hl { font-weight: 700; color: var(--ink2); font-size: 14px; }
.hbtns { display: flex; gap: 6px; justify-content: center; margin: 5px 0 4px; }
.hbtns button { width: 46px; height: 42px; border-radius: 12px; border: 3px solid #fff; font: inherit; font-weight: 700; font-size: 18px; cursor: pointer; color: #fff;
  background: linear-gradient(#b8a890, #9a8a70); box-shadow: 0 3px 0 rgba(43,34,51,0.25); touch-action: manipulation; }
.hbtns button.on { background: linear-gradient(#ffb070, var(--orange)); box-shadow: 0 0 0 3px var(--ink), 0 3px 0 rgba(43,34,51,0.25); }
.hbtns button:disabled { cursor: default; }
.hazard .hname { font-size: 14px; font-weight: 600; }
.wait { color: var(--ink2); font-weight: 600; margin: 8px 0; }
.dots i { font-style: normal; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; } .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
@keyframes popin { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#leave, #leave2 { margin-top: 6px; }

/* ---------- world labels ---------- */
.nametag {
  display: flex; flex-direction: column; align-items: center; gap: 2px; transform: translateY(-50%);
  font-weight: 700; font-size: 14px; color: #fff; white-space: nowrap;
  text-shadow: 0 2px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 -1.5px 0 var(--ink), 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.nametag .nm { border-bottom: 3px solid var(--pc); padding: 0 3px; line-height: 1.1; }
.nametag .think { display: none; font-size: 13px; animation: blink 1s infinite; }
.nametag.me { font-size: 15px; }
.nametag.down { opacity: 0.75; }
.nametag.down .hpbar { display: none; }
.hpbar { width: 44px; height: 7px; border-radius: 99px; background: rgba(43, 34, 51, 0.6); border: 2px solid #fff; overflow: hidden; }
.hpbar i { display: block; height: 100%; background: linear-gradient(#b6f28f, #5fc05a); transition: width 0.2s; }
.hpbar.low i { background: linear-gradient(#ffa0a0, #ff5a5a); }
.speech {
  background: #fff; color: var(--ink); font-weight: 700; font-size: 15px; padding: 6px 12px; border-radius: 16px; white-space: nowrap;
  border: 3px solid var(--ink); position: relative; transform: translateY(-100%); animation: speechin 0.35s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.speech::after { content: ''; position: absolute; left: 50%; bottom: -12px; margin-left: -8px; border: 8px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
@keyframes speechin { from { transform: translateY(-100%) scale(0.3); } to { transform: translateY(-100%) scale(1); } }
.podtag { display: flex; flex-direction: column; align-items: center; font-family: var(--disp); color: #fff; font-size: 16px; line-height: 1;
  text-shadow: 0 2px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 -1.5px 0 var(--ink); }
.podtag span { font-size: 30px; color: #ffe070; }
.podtag.late span { color: #ff7a6a; animation: blink 0.6s infinite; }

/* ---------- hud ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.sa-top { top: max(8px, env(safe-area-inset-top)); }
#xp {
  position: absolute; left: 12px; right: 12px; top: max(8px, env(safe-area-inset-top)); height: 16px;
  background: rgba(43, 34, 51, 0.55); border-radius: 99px; border: 3px solid #fff; overflow: visible; box-shadow: 0 3px 0 rgba(43, 34, 51, 0.2);
}
#xp .fill { height: 100%; width: 0%; background: linear-gradient(90deg, #9be870, #5fd0ff 60%, #ff8fd0); border-radius: 99px; transition: width 0.25s; }
#xp .lv {
  position: absolute; left: -6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(#ffe070, #f2b020); border: 3px solid #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--disp); font-size: 17px; color: #fff; text-shadow: 0 2px 0 #a06a10; box-shadow: 0 3px 0 rgba(43,34,51,0.25);
}
.toprow {
  position: absolute; left: 12px; right: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 26px);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.pill { background: var(--card); border-radius: 999px; padding: 4px 12px; font-weight: 700; box-shadow: 0 3px 0 rgba(43, 34, 51, 0.18); display: flex; align-items: center; gap: 6px; height: 34px; }
.pill.small { height: 30px; padding: 3px 10px; font-size: 15px; }
#hp { flex: 0 1 240px; min-width: 0; }
#hp .heart { color: #ff5a5a; font-size: 20px; }
#hp .bar { flex: 1; height: 13px; background: #f0e2d6; border-radius: 99px; overflow: hidden; min-width: 40px; }
#hp .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff9a9a, #ff5050); border-radius: 99px; transition: width 0.2s; }
#hp .num { font-size: 14px; min-width: 26px; text-align: right; }
#hp.low { animation: bitten 0.6s infinite; }
#stagepill { flex-direction: column; height: auto; padding: 4px 18px 6px; gap: 0; border-radius: 16px; min-width: 150px; }
#stagepill .sn { font-size: 13px; color: var(--ink2); line-height: 1.1; }
#stagepill .st { font-family: var(--disp); font-weight: 400; font-size: 24px; line-height: 1; letter-spacing: 1px; }
#stagepill .sbar { width: 100%; height: 5px; background: #eadcc8; border-radius: 99px; overflow: hidden; margin-top: 3px; }
#stagepill .sbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd070, #ff8a4a); }
#stagepill.pod .st { color: #d6456f; }
.res { display: flex; gap: 6px; }
.ico { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; }
.ico.berry { background: radial-gradient(circle at 35% 35%, #c0b0ff, #7a5cff 55%, #4a30c0); box-shadow: 5px -3px 0 -3px #4f9a3a; }
.ico.coin { background: radial-gradient(circle at 35% 35%, #fff3b0, #ffd24a 55%, #c09010); }
.ico.fert { width: 14px; height: 18px; border-radius: 40% 40% 45% 45%; background: linear-gradient(#9ff5e0, #3fc0a0); transform: rotate(10deg); }
#supply { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(8px, env(safe-area-inset-top)) + 90px); width: 150px; height: 24px; padding: 2px 10px; }
#supply .bar { flex: 1; height: 9px; background: #e2ece6; border-radius: 99px; overflow: hidden; }
#supply .bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #5fe0c0, #3fc0a0); transition: width 0.3s; }
#supply.full { animation: glowpulse 0.8s infinite; }
@keyframes glowpulse { 50% { box-shadow: 0 0 0 4px rgba(95, 224, 192, 0.6), 0 3px 0 rgba(43,34,51,0.18); } }
#bossbar { position: absolute; left: 50%; top: calc(max(8px, env(safe-area-inset-top)) + 122px); transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); text-align: center; }
#bossbar .name { color: #fff; font-family: var(--disp); font-size: 20px; text-shadow: 0 2px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 -1.5px 0 var(--ink); }
#bossbar .bar { height: 18px; border-radius: 99px; background: rgba(43, 34, 51, 0.6); border: 3px solid #fff; overflow: hidden; margin-top: 2px; }
#bossbar .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#c89a70, #7a5436); transition: width 0.2s; }
#swarm { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); text-align: center; animation: swarmin 0.4s cubic-bezier(0.3, 1.6, 0.6, 1); }
#swarm b { display: inline-block; font-family: var(--disp); font-weight: 400; font-size: clamp(26px, 6vw, 46px); color: #ffe070; letter-spacing: 1px; animation: swarmpulse 0.5s ease-in-out infinite alternate;
  text-shadow: 0 4px 0 #8a2a1a, 3px 0 0 #8a2a1a, -3px 0 0 #8a2a1a, 0 -3px 0 #8a2a1a, 2px 2px 0 #8a2a1a, -2px 2px 0 #8a2a1a, 0 0 30px rgba(255, 90, 60, 0.8); }
@keyframes swarmin { from { transform: translate(-50%, -50%) scale(2); opacity: 0; } }
@keyframes swarmpulse { to { transform: scale(1.08); } }
#loadout { position: absolute; left: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 72px); display: flex; flex-direction: column; gap: 6px; }
#loadout .row { display: flex; gap: 6px; flex-wrap: wrap; max-width: 240px; }
.slot { width: 44px; height: 44px; border-radius: 14px; background: var(--card); position: relative; display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 3px 0 rgba(43, 34, 51, 0.18); }
.slot svg { position: absolute; inset: -3px; width: 50px; height: 50px; transform: rotate(-90deg); }
.slot svg circle { fill: none; stroke-width: 4; }
.slot svg .bg { stroke: rgba(43,34,51,0.12); }
.slot svg .fg { stroke: #6cc46a; stroke-linecap: round; transition: stroke-dashoffset 0.08s linear; }
.slot.reload svg .fg { stroke: #f08a3c; }
.slot.reload .em { opacity: 0.5; }
.slot.gear { width: 32px; height: 32px; border-radius: 50%; font-size: 16px; }
.slot b { position: absolute; right: -5px; bottom: -5px; background: var(--ink); color: #fff; font-size: 10px; border-radius: 99px; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; padding: 0 3px; z-index: 1; }
.slot.oc b { background: linear-gradient(#ff8fd0, #c05ae0); }
.slot.new { animation: popin 0.4s ease-out; }
#side { position: absolute; right: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 72px); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#objective { background: var(--card); border-radius: 14px; padding: 6px 10px; box-shadow: 0 3px 0 rgba(43,34,51,0.18); width: 190px; font-size: 13px; font-weight: 600; }
#objective .ot::before { content: '★ '; color: #f2b020; }
#objective .ob { height: 6px; background: #eadcc8; border-radius: 99px; overflow: hidden; margin: 4px 0 2px; }
#objective .ob i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd070, #f2b020); transition: width 0.3s; }
#objective .op { font-size: 12px; color: var(--ink2); }
#objective.done { background: linear-gradient(#fff6c8, #ffe89a); }
#objective.done .op { color: #3f9a3e; font-weight: 700; }
#team { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.mate { background: var(--card); border-radius: 12px; padding: 3px 8px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 0 rgba(43, 34, 51, 0.15); max-width: 190px; }
.mate img { width: 22px; height: 22px; }
.mate .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 80px; }
.mate .b { width: 44px; height: 6px; background: #eadcc8; border-radius: 99px; overflow: hidden; flex: none; }
.mate .b i { display: block; height: 100%; background: #5fc05a; }
.mate.down { background: #ffe0e0; }
#subs {
  position: absolute; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 58px); transform: translateX(-50%); max-width: min(640px, calc(100vw - 32px));
  background: rgba(30, 24, 40, 0.78); color: #fff; border-radius: 12px; padding: 7px 14px; font-weight: 500; font-size: 15px; line-height: 1.3; text-align: center;
  animation: fadein 0.3s; border-left: 5px solid var(--yellow);
}
#subs .who { display: block; font-size: 11px; font-weight: 700; color: var(--yellow); letter-spacing: 1.5px; }
#hud.lu #subs { bottom: 240px; }
#ping { position: absolute; left: 12px; bottom: max(10px, env(safe-area-inset-bottom)); font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); }
#board { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font-family: var(--disp); font-size: 22px; color: #fff; text-shadow: 0 2px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 -1.5px 0 var(--ink); white-space: nowrap; }
.touchdot { position: fixed; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; pointer-events: none; z-index: 4;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08) 60%, rgba(255, 255, 255, 0) 72%); border: 1.5px solid rgba(255, 255, 255, 0.35); opacity: 0; transition: opacity 0.15s; }
.touchdot.anchor { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: rgba(255, 255, 255, 0.28); border: 0; }
.touchdot.on { opacity: 1; }

/* edge arrows toward the pod, supply drops, elites and the boss */
#arrows { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.arrow { position: absolute; left: 0; top: 0; width: 48px; height: 48px; margin: -24px 0 0 -24px; display: flex; align-items: center; justify-content: center; }
.arrow .tip { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 36%, var(--ac) 37% 45%, transparent 46%); filter: drop-shadow(0 2px 0 rgba(43, 34, 51, 0.3)); }
.arrow .tip::after { content: ''; position: absolute; right: -7px; top: 50%; margin-top: -10px; border-left: 15px solid var(--ac); border-top: 10px solid transparent; border-bottom: 10px solid transparent; }
.arrow .ic { position: relative; font-size: 18px; line-height: 1; }
.arrow .dist { position: absolute; top: 42px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); }
.arrow.pod { --ac: #ffcf40; } .arrow.pod .tip { animation: glowpulse 0.8s infinite; border-radius: 50%; }
.arrow.supply { --ac: #ffb347; } .arrow.elite { --ac: #ff5f5f; } .arrow.boss { --ac: #8a5a3a; } .arrow.mate { --ac: #6fb8ec; }

.corner { position: fixed; right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 8px; z-index: 20; }
.roundbtn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: 0 3px 0 rgba(43, 34, 51, 0.2); font-size: 19px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; touch-action: none; }
.roundbtn.off { opacity: 0.5; }

/* ---------- level up tray ---------- */
#levelup { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; pointer-events: none; display: flex; justify-content: center;
  padding: 0 16px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(43, 34, 51, 0), rgba(43, 34, 51, 0.3)); animation: trayin 0.3s cubic-bezier(0.3, 1.4, 0.6, 1); }
@keyframes trayin { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.lu-tray { width: min(880px, calc(100% - 110px)); display: flex; flex-direction: column; gap: 6px; }
.lu-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.lu-head h2 { margin: 0; font-family: var(--disp); font-weight: 400; font-size: 28px; color: var(--yellow); line-height: 1;
  text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink), 1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink); }
.lu-secs { background: var(--red); color: #fff; font-weight: 700; border-radius: 99px; padding: 1px 9px; font-size: 15px; box-shadow: 0 2px 0 var(--red-d); }
.lu-hint { color: #fff; font-weight: 600; font-size: 13px; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); }
.lu-timer { flex: 1; min-width: 40px; height: 7px; background: rgba(255, 255, 255, 0.55); border-radius: 99px; overflow: hidden; }
.lu-timer i { display: block; height: 100%; background: var(--yellow); width: 100%; }
.cards { display: flex; gap: 10px; pointer-events: auto; touch-action: none; }
.lcard {
  flex: 1 1 0; min-width: 0; background: var(--cream); border-radius: 18px; padding: 10px 12px 10px 10px; cursor: pointer; position: relative; border: 3px solid #fff;
  box-shadow: 0 5px 0 rgba(43, 34, 51, 0.28), 0 10px 20px rgba(43, 34, 51, 0.2); display: grid; grid-template-columns: 54px 1fr; column-gap: 10px; align-items: center; text-align: left;
  transition: transform 0.12s; animation: cardin 0.3s cubic-bezier(0.3, 1.6, 0.6, 1) both; font: inherit; color: inherit; touch-action: none;
}
.lcard:nth-child(2) { animation-delay: 0.05s; } .lcard:nth-child(3) { animation-delay: 0.1s; }
@keyframes cardin { from { transform: translateY(30px) scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.lcard:hover { transform: translateY(-4px); }
.lcard:active { transform: translateY(2px); }
.lcard .key { position: absolute; right: 8px; top: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.lcard .ic { grid-row: 1 / span 3; width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; background: radial-gradient(circle at 35% 30%, #fff, var(--cc, #ffe0ea)); box-shadow: inset 0 -4px 0 rgba(43, 34, 51, 0.1); }
.lcard .nm { font-weight: 700; font-size: 17px; line-height: 1.1; padding-right: 22px; }
.lcard .lv { display: inline-block; margin: 3px 0; font-size: 11px; font-weight: 700; color: #fff; background: var(--cc2, var(--red)); border-radius: 99px; padding: 1px 8px; }
.lcard .lv.new { background: var(--green); }
.lcard .ds { font-size: 13px; color: var(--ink2); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lcard.weapon { --cc: #ffe2c8; --cc2: #f08a3c; }
.lcard.gear { --cc: #dcecff; --cc2: #3f8ac4; }
.lcard.heal { --cc: #fff4b8; --cc2: #d0a020; }
.lcard.oc { --cc: #f4d8ff; --cc2: #b04ad0; border-color: #e8b0ff; }
.lcard.picked { transform: scale(1.04); box-shadow: 0 0 0 4px var(--yellow), 0 5px 0 rgba(43, 34, 51, 0.28); }

/* ---------- pod shop ---------- */
#shop { position: fixed; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(43, 34, 51, 0.25), rgba(43, 34, 51, 0.55)); animation: fadein 0.3s; }
.shopcard { width: min(640px, 100%); background: linear-gradient(#e8c89a, #d8b07a); border-radius: 22px; border: 4px solid #8a5530; padding: 14px; box-shadow: var(--shadow), inset 0 3px 0 rgba(255,255,255,0.35); }
.shophead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.shophead h2 { margin: 0; font-family: var(--disp); font-weight: 400; font-size: 30px; color: #5a2e10; text-shadow: 0 2px 0 rgba(255, 230, 190, 0.7); flex: 1; }
.shophead .wallet { margin: 0; background: #fff; border-radius: 99px; padding: 3px 12px; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.shoptime { font-family: var(--disp); font-size: 22px; color: #fff; background: var(--wood-d); border-radius: 12px; padding: 2px 10px; }
.items { touch-action: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 12px; pointer-events: auto; }
.item { background: var(--cream); border: 3px solid #fff; border-radius: 16px; padding: 10px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 rgba(90, 50, 20, 0.35); display: flex; flex-direction: column; gap: 3px; touch-action: none; }
.item .in { font-weight: 700; font-size: 16px; }
.item .id { font-size: 13px; color: var(--ink2); line-height: 1.2; flex: 1; }
.item .ic2 { font-size: 22px; }
.item .cost { align-self: flex-start; display: flex; align-items: center; gap: 4px; background: #ede4ff; border-radius: 99px; padding: 1px 9px; font-weight: 700; font-size: 14px; }
.item.poor { opacity: 0.55; }
.item.bought { animation: bought 0.4s; }
@keyframes bought { 40% { transform: scale(1.06); box-shadow: 0 0 0 4px var(--yellow); } }
.item:active { transform: translateY(2px); }
#shop.readyd #ready { filter: grayscale(0.6); }

/* ---------- banner, results, toasts ---------- */
#banner { position: fixed; left: 50%; top: 31%; transform: translate(-50%, -50%); z-index: 9; text-align: center; pointer-events: none; width: calc(100vw - 32px); animation: bannerin 0.5s cubic-bezier(0.3, 1.6, 0.6, 1); }
#banner.out { animation: bannerout 0.4s ease-in forwards; }
#banner .t { font-family: var(--disp); font-size: clamp(30px, 6.5vw, 58px); color: #fff; line-height: 1.05;
  text-shadow: 0 5px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink); }
#banner .s { display: inline-block; margin-top: 8px; background: var(--card); border-radius: 99px; padding: 4px 16px; font-weight: 600; font-size: 17px; box-shadow: 0 3px 0 rgba(43, 34, 51, 0.2); }
#banner .s:empty { display: none; }
@keyframes bannerin { from { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
@keyframes bannerout { to { transform: translate(-50%, -80%) scale(0.9); opacity: 0; } }
@keyframes bitten { 50% { box-shadow: 0 3px 0 rgba(43, 34, 51, 0.18), 0 0 0 4px rgba(255, 80, 80, 0.5); } }
#results { background: radial-gradient(ellipse at center, rgba(43, 34, 51, 0.3), rgba(43, 34, 51, 0.1)); }
.results { text-align: center; width: min(560px, calc(100vw - 24px)); }
.results .headline { font-size: 40px; }
.results.won .headline { color: #e09a10; }
.results.lost .headline { color: #8a6aa0; }
.results .sub { color: var(--ink2); font-weight: 600; margin: 4px 0 8px; }
.results .earned { display: inline-flex; gap: 8px; align-items: center; background: #fff6d6; border-radius: 99px; padding: 5px 14px; font-weight: 700; margin-bottom: 8px; }
.tablewrap { overflow-x: auto; }
.stats { width: 100%; border-collapse: separate; border-spacing: 0 5px; margin-bottom: 12px; font-size: 15px; }
.stats th { font-size: 12px; color: var(--ink2); font-weight: 600; text-align: right; padding: 0 6px; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats td { background: #fff; padding: 6px; text-align: right; font-weight: 600; }
.stats td:first-child { border-radius: 12px 0 0 12px; }
.stats td:last-child { border-radius: 0 12px 12px 0; }
.stats .who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.stats .who img { width: 26px; height: 26px; }
.stats .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.stats tr.me td { background: #fff6d6; }
.row2 { display: flex; justify-content: center; gap: 10px; margin-top: 8px; }
#conn, #toast { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 20px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#conn { top: calc(max(10px, env(safe-area-inset-top)) + 34px); bottom: auto; background: var(--red); }
.spin { display: inline-block; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  .lu-tray { width: 100%; }
  #levelup { padding-bottom: calc(max(12px, env(safe-area-inset-bottom)) + 52px); background: none; }
  .lu-head h2 { font-size: 22px; }
  .lu-hint { display: none; }
  .cards { gap: 6px; }
  .lcard { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 8px 6px; border-radius: 16px; row-gap: 1px; }
  .lcard .ic { grid-row: auto; width: 38px; height: 38px; font-size: 21px; }
  .lcard .key { right: 5px; top: 5px; width: 17px; height: 17px; font-size: 10px; }
  .lcard .nm { font-size: 13px; padding: 0; }
  .lcard .lv { margin: 1px 0; font-size: 10px; }
  .lcard .ds { font-size: 10.5px; line-height: 1.2; }
  .pill { height: 30px; padding: 3px 9px; }
  #hp { flex: 1 1 auto; }
  #hp .num { display: none; }
  #stagepill { min-width: 0; padding: 3px 10px 5px; }
  #stagepill .sn { font-size: 11px; }
  #stagepill .st { font-size: 19px; }
  .res { flex-direction: column; gap: 4px; }
  .pill.small { height: 26px; font-size: 13px; padding: 2px 8px; }
  #supply { top: calc(max(8px, env(safe-area-inset-top)) + 96px); width: 120px; }
  .slot { width: 34px; height: 34px; font-size: 17px; border-radius: 11px; }
  .slot svg { width: 40px; height: 40px; }
  .slot.gear { width: 25px; height: 25px; font-size: 13px; }
  #loadout { top: calc(max(8px, env(safe-area-inset-top)) + 100px); }
  #loadout .row { max-width: 160px; gap: 5px; }
  #side { top: calc(max(8px, env(safe-area-inset-top)) + 126px); }
  #objective { width: 150px; font-size: 11.5px; padding: 5px 8px; }
  .mate { font-size: 12px; padding: 2px 6px; }
  .mate .b { width: 30px; }
  .mate .n { max-width: 56px; }
  #subs { font-size: 13px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px); }
  #hud.lu #subs { bottom: 250px; }
  #bossbar { top: calc(max(8px, env(safe-area-inset-top)) + 128px); }
  .code { font-size: 50px; }
  .nametag { font-size: 12px; }
  .items { grid-template-columns: 1fr 1fr; }
  .item { padding: 8px; }
  .item .in { font-size: 14px; }
  .item .id { font-size: 11.5px; }
  .card { padding: 14px; }
  .classes { gap: 6px; }
  .cls .cn { font-size: 11px; }
  .results .headline { font-size: 30px; }
  .stats { font-size: 13px; }
  .board { padding: 10px 22px 12px; }
}
@media (max-height: 640px) and (min-width: 701px) {
  .tag { display: none; }
  .logo { font-size: 52px; }
}
