:root {
  --ol: #3d2817;
  --bg: #4a3222;
  --panel: #fff6e5;
  --panel-2: #ffe7c2;
  --muted: #9a7b5c;
  --green: #6ad04e;
  --green-dk: #3f9a2c;
  --orange: #ffa53c;
  --orange-dk: #d0731c;
  --red: #ff5a6e;
  --red-dk: #b8323f;
  --blue: #4aa8ff;
  --gold: #ffd23f;
  --grey: #d8cbbb;
  --grey-dk: #a8977f;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% 0, #6b4a33, #2e1f15 70%);
  color: var(--ol);
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

img { -webkit-user-drag: none; }

.num, .title, .btn, #tabs span {
  font-family: 'Lilita One', 'Fredoka', system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: .3px;
}

/* White text with a thick brown outline, mobile-game style */
.outlined, .num, .title, .btn, #tabs span {
  color: #fff;
  text-shadow:
    -2px -2px 0 var(--ol), 2px -2px 0 var(--ol), -2px 2px 0 var(--ol), 2px 2px 0 var(--ol),
    0 -2px 0 var(--ol), 0 2px 0 var(--ol), -2px 0 0 var(--ol), 2px 0 0 var(--ol), 0 4px 0 var(--ol);
}

#phone {
  position: relative;
  height: 100dvh;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 60px #0008;
  padding-top: env(safe-area-inset-top);
}

/* ---------- HUD ---------- */

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px 6px;
  background: linear-gradient(#5d4030, var(--bg));
  border-bottom: 3px solid var(--ol);
}

.res {
  display: flex;
  align-items: center;
  height: 34px;
  min-width: 96px;
  padding: 0 12px 0 0;
  background: #2b1d13;
  border: 3px solid var(--ol);
  border-radius: 999px;
  box-shadow: inset 0 3px 0 #0006;
}
.res img { width: 42px; height: 42px; margin: -6px 4px -6px -10px; filter: drop-shadow(0 2px 0 #0006); }
.res .num { font-size: 19px; flex: 1; text-align: right; }

.stage { text-align: center; min-width: 0; line-height: 1.05; }
.stage .title { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#room { font-size: 13px; color: #ffe7c2; margin-top: 2px; }
#waves { display: flex; gap: 4px; justify-content: center; margin-top: 4px; }
#waves i {
  width: 18px; height: 8px; border-radius: 4px;
  background: #2b1d13; border: 2px solid var(--ol);
}
#waves i.done { background: var(--green); }
#waves i.now { background: var(--gold); }
#waves i.boss { width: 26px; }
#waves i.boss.now { background: var(--red); }

/* ---------- game ---------- */

#game-area {
  position: relative;
  flex: none;
  /* as wide as the phone allows: the height left after the HUD, quest, tabs and a 140px panel */
  width: min(100%, calc((100dvh - 360px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.9));
  aspect-ratio: 9 / 10;
  margin: 0 auto;
  border-bottom: 3px solid var(--ol);
}
#game, #game canvas { width: 100%; height: 100%; display: block; }

#boss-bar {
  position: absolute;
  top: 10px; left: 112px; right: 10px;
  height: 32px;
  background: #2b1d13;
  border: 3px solid var(--ol);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 4px 0 #0005;
}
#boss-bar[hidden] { display: none; }
#boss-bar .fill {
  position: absolute; inset: 0;
  background: linear-gradient(var(--red), var(--red-dk));
  transform-origin: left;
}
#boss-bar span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 16px; }

#fight-boss {
  position: absolute;
  top: 62px; left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  padding: 8px 18px;
  animation: pulse 1s ease-in-out infinite;
}
#fight-boss[hidden] { display: none; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.06); } }

#skills {
  position: absolute;
  right: 10px; bottom: 10px;
  display: grid;
  justify-items: center;
  gap: 8px;
}
.skill-btn {
  position: relative;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 4px solid var(--ol);
  background: radial-gradient(circle at 35% 30%, #fff1a8, #ffd23f 60%, #e0a800);
  box-shadow: 0 4px 0 var(--ol);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}
.skill-btn[data-skill="treats"] { background: radial-gradient(circle at 35% 30%, #d6ffd0, #6ee05a 60%, #34a83a); }
.skill-btn.bark-btn {
  width: 76px; height: 76px;
  background: radial-gradient(circle at 35% 30%, #ffd08a, var(--orange) 60%, var(--orange-dk));
  box-shadow: 0 5px 0 var(--ol);
}
.skill-btn img { width: 60%; height: 60%; margin-top: -10px; }
.skill-btn span { position: absolute; bottom: 5px; font-size: 12px; }
.skill-btn.bark-btn span { bottom: 7px; font-size: 14px; }
.skill-btn .cd {
  position: absolute; inset: 0;
  background: #000a;
  transform-origin: bottom;
  transform: scaleY(0);
}
.skill-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ol); }
.skill-btn.cooling { filter: grayscale(.6); }
.skill-btn.locked { filter: grayscale(1) brightness(.8); }
.skill-btn.active { animation: skill-glow .4s ease-in-out infinite alternate; }
@keyframes skill-glow { to { box-shadow: 0 4px 0 var(--ol), 0 0 18px 6px #ffd23f; } }

/* ---------- panel ---------- */

#panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 10px 14px;
  display: grid;
  align-content: start;
  gap: 8px;
  background:
    repeating-linear-gradient(45deg, #ffffff08 0 14px, transparent 14px 28px),
    #6b4a33;
}

.stats {
  display: flex;
  justify-content: space-around;
  gap: 6px;
  background: #2b1d13;
  border: 3px solid var(--ol);
  border-radius: 14px;
  padding: 6px 8px;
}
.stats div { text-align: center; line-height: 1.1; }
.stats small { display: block; color: #d9bf9c; font-size: 11px; }
.stats .num { font-size: 17px; }

.card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 3px solid var(--ol);
  border-radius: 16px;
  padding: 8px 10px;
  box-shadow: 0 4px 0 #0005, inset 0 -4px 0 var(--panel-2);
}
.card .icon {
  width: 54px; height: 54px; flex: none;
  background: var(--panel-2);
  border: 3px solid var(--ol);
  border-radius: 12px;
  display: grid; place-items: center;
}
.card .icon img { width: 46px; height: 46px; object-fit: contain; }
.card .info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.card .info b { font-size: 16px; }
.card .info .lv {
  display: inline-block; margin-left: 4px;
  background: var(--ol); color: #fff; border-radius: 6px; padding: 0 6px; font-size: 12px;
}
.card .info span { font-size: 12.5px; color: var(--muted); }
.card .info em { font-style: normal; color: var(--green-dk); }
.card.owned { filter: saturate(.85); }

.btn {
  font-size: 16px;
  border: 3px solid var(--ol);
  border-radius: 14px;
  padding: 8px 12px;
  background: linear-gradient(#8de56f, var(--green) 55%, var(--green-dk));
  box-shadow: 0 4px 0 var(--ol);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.btn img { width: 24px; height: 24px; margin: -4px 0; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ol); }
.btn:disabled { background: linear-gradient(var(--grey), var(--grey-dk)); cursor: not-allowed; }
.btn.orange { background: linear-gradient(#ffc779, var(--orange) 55%, var(--orange-dk)); }
.btn.red { background: linear-gradient(#ff8a99, var(--red) 55%, var(--red-dk)); }
.btn.blue { background: linear-gradient(#8ccaff, var(--blue) 55%, #2f7fd0); }
.btn.big { font-size: 20px; padding: 12px; width: 100%; }
.btn.link { background: none; border: 0; box-shadow: none; color: #d9bf9c; text-shadow: none; font-family: 'Fredoka', sans-serif; font-size: 13px; text-decoration: underline; }
.card .btn { min-width: 92px; flex: none; }

/* toys */
.slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  background: #2b1d13;
  border: 3px solid var(--ol);
  border-radius: 16px;
}
.slot {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 3px solid var(--ol);
  background: #4a3222;
  box-shadow: inset 0 4px 0 #0006;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  padding: 0;
}
.slot.filled { background: linear-gradient(var(--panel), var(--panel-2)); box-shadow: 0 3px 0 #0006; }
.slot img { width: 78%; height: 78%; }
.slot .tier {
  position: absolute; top: -6px; left: -6px;
  min-width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--blue);
  border: 2px solid var(--ol);
  font-size: 13px; line-height: 18px;
  text-align: center;
}
.slot.t3 { background: linear-gradient(#e8f6ff, #bfe3ff); }
.slot.t5 { background: linear-gradient(#f5ebff, #d7c1ff); }
.slot.t7 { background: linear-gradient(#fff8d6, #ffe07a); }
.slot.x1 { background: linear-gradient(#ddfff4, #8fe8c8); }
.slot.x2 { background: linear-gradient(#ffe3f3, #ff9ccf); }
.slot.x3 { background: linear-gradient(#ffe6c9, #ff8a4c); }
.slot.x4 { background: linear-gradient(135deg, #b9a4ff, #7fd3ff 50%, #ffb3e6); }
.slot.selected { outline: 4px solid var(--gold); outline-offset: 1px; transform: scale(1.05); }
.slot.match { animation: wiggle .5s ease-in-out infinite; }
.slot.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }
@keyframes wiggle { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }

.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

.hint { margin: 0; font-size: 12px; color: #e8d2b4; text-align: center; }

.collection {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: var(--panel);
  border: 3px solid var(--ol);
  border-radius: 16px;
  padding: 8px;
}
.collection div { text-align: center; font-size: 10px; color: var(--muted); line-height: 1.1; }
.collection img { width: 100%; max-width: 44px; aspect-ratio: 1; }
.collection .locked img { filter: brightness(0) opacity(.25); }
.collection .more { display: grid; place-items: center; font-size: 14px; color: #fff; border: 2px dashed #ffffff33; border-radius: 10px; }
.collection-title { font-size: 12px; font-weight: 900; color: #fff; margin: 2px 0 -4px 4px; text-shadow: 0 2px 0 var(--ol); }

/* toys: each tier is a blaster + melee weapon pair */
.slot { position: relative; }
.slot .twin {
  position: absolute; right: 2px; top: 2px;
  width: 42%; height: 42%;
  background: #fff8; border: 2px solid var(--ol); border-radius: 50%;
  display: grid; place-items: center;
}
.slot .twin img { width: 82%; height: 82%; }
.gear-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gear {
  display: flex; gap: 6px; align-items: center;
  border: 3px solid var(--ol); border-radius: 14px; padding: 6px;
  box-shadow: 0 3px 0 #0006;
}
.gear.ranged { background: linear-gradient(#e8f6ff, #bfe3ff); }
.gear.melee { background: linear-gradient(#ffe9e0, #ffc6b3); }
.gear-art { width: 48px; height: 48px; flex: none; }
.gear-art img { width: 100%; height: 100%; }
.gear-info { display: flex; flex-direction: column; min-width: 0; color: var(--ol); line-height: 1.1; }
.gear-info small { font-size: 10px; font-weight: 800; opacity: .7; }
.gear-info b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gear-info .holders { display: flex; gap: 2px; margin-top: 2px; }
.gear-info .holders img { width: 22px; height: 22px; }
.gear-info .holders small { font-size: 10px; }

/* rebirth */
.hero {
  text-align: center;
  background: linear-gradient(#fff6e5, #ffe7c2);
  border: 3px solid var(--ol);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 4px 0 #0005;
}
.hero img { width: 84px; height: 84px; }
.hero .num { font-size: 34px; display: block; margin-top: -6px; }
.hero p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- tabs ---------- */

#tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(#5d4030, #3a271b);
  border-top: 3px solid var(--ol);
}
#tabs button {
  position: relative;
  border: 3px solid var(--ol);
  border-radius: 14px;
  background: linear-gradient(#8a6a50, #6b4a33);
  box-shadow: 0 4px 0 var(--ol);
  padding: 4px 0 2px;
  cursor: pointer;
  display: grid;
  justify-items: center;
}
#tabs img { width: 34px; height: 34px; }
#tabs span { font-size: 13px; margin-top: -2px; }
#tabs button.active {
  background: linear-gradient(#ffc779, var(--orange) 60%, var(--orange-dk));
  transform: translateY(-4px);
  box-shadow: 0 8px 0 var(--ol);
}
#tabs button .dot {
  position: absolute; top: -6px; right: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--ol);
}

/* ---------- toast & modal ---------- */

#toast {
  position: fixed;
  left: 50%; top: calc(env(safe-area-inset-top) + 130px);
  transform: translate(-50%, -30px);
  opacity: 0;
  width: max-content;
  max-width: min(400px, calc(100% - 32px));
  background: #2b1d13ee;
  border: 3px solid var(--ol);
  color: #fff;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 14px;
  text-align: center;
  transition: transform .25s ease, opacity .25s ease;
  z-index: 10;
  pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

#modal {
  position: fixed; inset: 0;
  background: #1a100acc;
  display: grid; place-items: center;
  padding: 16px;
  z-index: 20;
}
#modal[hidden] { display: none; }
#modal .box {
  background: linear-gradient(#fff6e5, #ffe7c2);
  border: 4px solid var(--ol);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--ol);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  display: grid;
  gap: 10px;
  animation: pop .3s ease;
}
#modal h2 { margin: 0; font-size: 26px; }
#modal p { margin: 0; color: var(--muted); }
#modal .big-img { width: 96px; height: 96px; margin: 0 auto; }

/* ---------- polish: mute, quest, buy mode, coin bump ---------- */

.icon-btn {
  position: absolute;
  left: 10px; top: 10px;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 3px solid var(--ol);
  background: #2b1d13cc;
  box-shadow: 0 3px 0 var(--ol);
  padding: 4px;
  cursor: pointer;
}
.icon-btn img { width: 100%; height: 100%; }
.music-btn { left: 60px; color: #ffd23f; font-size: 26px; font-weight: 900; line-height: 1; padding: 0; }
.music-btn.off { color: #8a7a6a; text-decoration: line-through; }
.speed-btn { left: 60px; color: #8a7a6a; font-size: 18px; font-weight: 900; line-height: 1; padding: 0; }
.speed-btn.on { color: #ffd23f; background: #6b3fa0cc; }

#fight-boss img { width: 30px; height: 30px; margin: -6px 2px -6px -6px; }

#quest {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(#fff6e5, #ffe7c2);
  border-bottom: 3px solid var(--ol);
}
#quest > img { width: 36px; height: 36px; flex: none; }
.q-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
#q-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-bar {
  position: relative;
  height: 18px;
  background: #2b1d13;
  border: 2px solid var(--ol);
  border-radius: 999px;
  overflow: hidden;
}
.q-bar i {
  position: absolute; inset: 0;
  background: linear-gradient(#ffe27a, var(--gold) 60%, #e0a800);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .2s ease;
}
.q-bar span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 14px; }
#q-claim { flex: none; padding: 6px 10px; font-size: 15px; min-width: 84px; min-height: 44px; }
#q-claim:not(:disabled) { animation: nudge 1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: scale(1.08); } }

.buy-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.buy-mode button { padding: 6px; font-size: 15px; background: linear-gradient(#8a6a50, #6b4a33); }
.buy-mode button.on { background: linear-gradient(#8ccaff, var(--blue) 55%, #2f7fd0); }
.card .btn small { font-size: 12px; margin-left: 2px; opacity: .9; }

.res.bump img { animation: bump .25s ease; }
@keyframes bump { 50% { transform: scale(1.3) rotate(-10deg); } }

/* auto-walk toggle, bottom-left of the arena */
.auto-btn {
  position: absolute;
  left: 10px; bottom: 10px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 3px solid var(--ol);
  background: linear-gradient(#8de56f, var(--green) 55%, var(--green-dk));
  box-shadow: 0 3px 0 var(--ol);
  cursor: pointer;
}
.auto-btn .num { font-size: 16px; }
.auto-btn.off { background: linear-gradient(var(--grey), var(--grey-dk)); }
.auto-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ol); }

/* ---------- stage progress, gems ---------- */

#stage-bar {
  position: relative;
  width: 140px;
  height: 16px;
  margin: 4px auto 0;
  background: #2b1d13;
  border: 2px solid var(--ol);
  border-radius: 999px;
  overflow: hidden;
}
#stage-bar i {
  position: absolute; inset: 0;
  background: linear-gradient(#8de56f, var(--green));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .3s ease;
}
#stage-bar.boss i { background: linear-gradient(#ff8a99, var(--red)); }
#stage-bar span { position: relative; display: block; text-align: center; font-size: 11px; line-height: 12px; }

.res-col { display: grid; gap: 4px; }
.res.small { height: 26px; min-width: 78px; padding-right: 9px; }
.res.small img { width: 30px; height: 30px; margin: -4px 2px -4px -8px; }
.res.small .num { font-size: 15px; }

/* ---------- side menu (Home, Dig) ---------- */

#side-menu {
  position: absolute;
  left: 10px; top: 62px;
  display: grid;
  gap: 8px;
}
#side-menu button {
  width: 58px;
  padding: 4px 0 2px;
  border-radius: 12px;
  border: 3px solid var(--ol);
  background: linear-gradient(#ffc779, var(--orange) 60%, var(--orange-dk));
  box-shadow: 0 3px 0 var(--ol);
  display: grid;
  justify-items: center;
  cursor: pointer;
}
#side-menu img { width: 34px; height: 34px; }
#side-menu .num { font-size: 12px; margin-top: -2px; }
#side-menu button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ol); }
/* the Shop sits alone at the top right, purple so it reads as the premium corner */
#shop-btn {
  position: absolute; right: 10px; top: 10px;
  width: 58px; padding: 4px 0 2px;
  border-radius: 12px; border: 3px solid var(--ol);
  background: linear-gradient(#c79bff, #8a55d8 60%, #5e33a3);
  box-shadow: 0 3px 0 var(--ol);
  display: grid; justify-items: center; cursor: pointer;
}
#shop-btn img { width: 34px; height: 34px; }
#shop-btn .num { font-size: 12px; margin-top: -2px; color: #fff; }
#shop-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ol); }

/* ---------- sheets (full-height panels over the game) ---------- */

#sheet {
  position: absolute;
  left: 0; right: 0; top: 70px; bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: #6b4a33;
  border-top: 3px solid var(--ol);
  animation: sheet-up .2s ease;
}
#sheet[hidden] { display: none; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(#5d4030, var(--bg));
  border-bottom: 3px solid var(--ol);
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 24px; }
#sheet-close { padding: 4px 14px; font-size: 18px; min-height: 44px; min-width: 48px; }
#sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  align-content: start;
  grid-auto-rows: max-content; /* rows never squeeze below their content (the house map would cover its upgrade card) */
  gap: 8px;
}
.btn.gem { background: linear-gradient(#a8ecff, #4cc3f0 55%, #2b8fc0); }

/* ---------- dig site ---------- */

.dig-hero {
  position: relative;
  border: 3px solid var(--ol);
  border-radius: 18px;
  overflow: hidden;
  height: 340px;
  background: #6b4a33;
}
.dig-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.dig-hero .depth {
  position: absolute;
  right: 12px; top: 10px;
  font-size: 30px;
}
.dig-hero .layer {
  position: absolute;
  left: 12px; top: 12px;
  background: #2b1d13cc;
  border: 2px solid var(--ol);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
}
.strata { display: flex; height: 18px; border: 3px solid var(--ol); border-radius: 10px; overflow: hidden; position: relative; }
.strata span { flex: 1; }
.strata .marker {
  position: absolute; top: -3px; bottom: -3px;
  width: 6px; margin-left: -3px;
  background: #fff; border: 2px solid var(--ol); border-radius: 3px;
}
.meter { display: grid; gap: 3px; }
.meter small { color: #e8d2b4; font-size: 12px; }
.meter .bar { position: relative; height: 16px; background: #2b1d13; border: 2px solid var(--ol); border-radius: 999px; overflow: hidden; }
.meter .bar i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(#a8ecff, #4cc3f0); }
.meter .bar.chest i { background: linear-gradient(#ffe27a, var(--gold)); }

.btn.pop { animation: pop .25s ease; }

/* ---------- pack slots ---------- */
.pack-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; } /* room for the CAPTAIN tag */
.pack-slot {
  aspect-ratio: 1;
  border: 3px solid var(--ol);
  border-radius: 12px;
  background: linear-gradient(var(--panel), var(--panel-2));
  display: grid;
  place-items: center;
}
.pack-slot img { width: 90%; height: 90%; }
.pack-slot.locked { background: #4a3222; box-shadow: inset 0 4px 0 #0006; }
.pack-slot.locked img { width: 50%; height: 50%; opacity: .6; }
.card .info span em { color: var(--green-dk); font-style: normal; }

/* ---------- home ---------- */

.house-bar {
  display: grid; gap: 2px;
  background: var(--panel); border: 3px solid var(--ol); border-radius: 14px;
  padding: 6px 10px; color: var(--ol);
}
.house-bar b { font-size: 18px; }
.house-bar small { font-size: 11px; font-weight: 700; opacity: .75; }
.house-bar .bar { height: 10px; border-radius: 6px; background: #0002; overflow: hidden; }
.house-bar .bar i { display: block; height: 100%; background: linear-gradient(#ffe07a, #f0a92b); transform-origin: left; }
.home-map {
  position: relative;
  aspect-ratio: 2 / 3;
  border: 3px solid var(--ol); border-radius: 18px;
  background: #e8b277 center / cover no-repeat;
  overflow: hidden;
}
.home-spot {
  position: absolute;
  transform: translate(-50%, -80%);
  aspect-ratio: 1;
  padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 4px 0 #0003);
  transition: transform .15s, opacity .2s;
}
.home-spot img { width: 100%; height: 100%; object-fit: contain; }
.home-spot img.icon { width: 60%; height: 60%; margin: 20%; }
.home-spot.empty img { filter: brightness(0) opacity(.18); }
.home-spot.empty::before {
  content: ''; position: absolute; inset: 8%;
  border: 3px dashed #fff9; border-radius: 50%;
}
.home-spot .plus {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ol); color: var(--ol);
  font: 900 20px/20px inherit;
}
.home-spot .lv {
  position: absolute; right: -2px; bottom: 6%;
  min-width: 22px; padding: 0 5px; border-radius: 10px;
  background: #f08a24; border: 2px solid var(--ol); color: #fff;
  font-size: 13px; line-height: 17px;
}
.home-spot.picked { transform: translate(-50%, -80%) scale(1.12); filter: drop-shadow(0 0 6px #fff) drop-shadow(0 4px 0 #0003); }
.home-spot.ready::after {
  content: '✦'; position: absolute; left: 4%; top: 0;
  color: #9be7ff; font-size: 18px; text-shadow: 0 0 6px #fff;
  animation: twinkle 1.2s ease-in-out infinite;
}
.home-spot.pop { animation: home-pop .5s ease; }
.home-spot.see-through { opacity: .45; }
@keyframes home-pop { 40% { transform: translate(-50%, -80%) scale(1.3) rotate(-4deg); } }
@keyframes twinkle { 50% { opacity: .3; transform: scale(.7); } }
.home-dog {
  position: absolute; width: 17%;
  transform: translate(-50%, -85%);
  pointer-events: none;
  filter: drop-shadow(0 3px 0 #0003);
}
.home-dog.flip { transform: translate(-50%, -85%) scaleX(-1); }

/* ---------- pets & daily ---------- */

.pet-card .btns { display: grid; gap: 4px; }
.pet-card .btns .btn { padding: 4px 8px; font-size: 13px; }
.pet-card.locked .icon img { filter: brightness(0) opacity(.35); }
#side-menu button { position: relative; }
#side-menu button.alert::after {
  content: ''; position: absolute; right: -4px; top: -4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ff4d5e; border: 2px solid var(--ol);
}
.daily-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.daily-grid .day {
  position: relative;
  display: grid; justify-items: center; gap: 2px;
  padding: 6px 2px;
  background: var(--panel); border: 3px solid var(--ol); border-radius: 14px;
  color: var(--ol);
}
.daily-grid .day small { font-size: 11px; font-weight: 800; }
.daily-grid .day img { width: 40px; height: 40px; }
.daily-grid .day b { font-size: 14px; }
.daily-grid .day.big { grid-column: span 2; background: linear-gradient(#fff8d6, #ffe07a); }
.daily-grid .day.big img { width: 56px; height: 56px; }
.daily-grid .day.today { outline: 4px solid var(--gold); outline-offset: 1px; animation: wiggle 1s ease-in-out infinite; }
.daily-grid .day.done { opacity: .55; }
.daily-grid .day i {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: normal 900 34px/1 system-ui; color: #3fbf4a; text-shadow: 0 2px 0 #fff;
}

/* ---------- bone vaults ---------- */

.vault-card {
  display: grid; gap: 8px;
  background: linear-gradient(#5b5470, #3e3850);
  border: 3px solid var(--ol); border-radius: 16px;
  padding: 10px;
}
.vault-head { display: flex; gap: 8px; align-items: center; color: #fff; }
.vault-head img { width: 54px; height: 54px; flex: none; }
.vault-head b { font-size: 18px; display: block; }
.vault-head small { font-size: 11px; color: #e3dcf5; line-height: 1.2; display: block; }
.loot-toys { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 100%; }
.loot-toys img { width: 48px; height: 48px; }

/* ---------- daily bath time ---------- */

.bath-card {
  display: grid; gap: 8px;
  background: linear-gradient(#bfe9ff, #7cc8f0);
  border: 3px solid var(--ol); border-radius: 16px;
  padding: 10px; color: var(--ol);
}
.bath-card .hint { color: var(--ol); }
.bath-head { display: flex; gap: 8px; align-items: center; }
.bath-head > img { width: 64px; height: 64px; flex: none; }
.bath-head b { font-size: 18px; display: block; }
.bath-head small { font-size: 11px; line-height: 1.25; display: block; }
.bath-head small img { width: 14px; height: 14px; vertical-align: -2px; }

.buy-mode .btn { min-height: 42px; }
.pet-card .btns .btn { min-height: 38px; }

/* short screens (e.g. 360x640): a slimmer side menu so every button stays clear of AUTO */
@media (max-height: 700px) {
  #side-menu { gap: 5px; top: 58px; }
  #side-menu button { width: 50px; padding: 2px 0 1px; }
  #side-menu img { width: 28px; height: 28px; }
  #side-menu .num { font-size: 10px; }
}

/* dog pictures with a costume accessory on top (ui.dogPortrait) */
.dog-pic { position: relative; display: inline-block; line-height: 0; }
.wardrobe-picks { display: flex; flex: none; min-height: 68px; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; }
.wardrobe-pick { flex: none; width: 58px; height: 58px; border-radius: 12px; border: 3px solid var(--ol); background: #fff7ea; padding: 2px; }
.wardrobe-pick.active { background: #ffd98a; }
.wardrobe-pick .spr { width: 48px; height: 48px; }
.wardrobe-preview { display: grid; justify-items: center; gap: 2px; margin: 4px 0 8px; }
.wardrobe-preview .dog-pic > .spr { width: 150px; height: 150px; }
.wardrobe-preview { flex: none; }
.wardrobe-preview b { color: #fff3dd; font-size: 18px; }
.wardrobe-preview span { font-size: 13px; color: #e8d2b4; }
.section-title { margin: 14px 0 2px; font-size: 18px; text-align: center; }
.section-title img { width: 22px; height: 22px; vertical-align: -4px; }

/* look-before-you-buy preview (dogs, pets, suits); a price you can't pay yet stays tappable, greyed */
.btn.short, .btn.gem.short, .btn.gem:disabled { background: linear-gradient(var(--grey), var(--grey-dk)); }
.preview-sub { margin: -4px 0 4px; font-size: 14px; opacity: .8; }
.preview-stage { width: 230px; height: 190px; margin: 0 auto 6px; border-radius: 18px; border: 3px solid var(--ol);
  background: radial-gradient(circle at 50% 70%, #fff7ea, #ffd98a); display: grid; place-items: center; overflow: hidden; }
.preview-stage .dog-pic > .spr { width: 170px; height: 170px; }
/* a held weapon reaches past the dog's right side: shift the dog left so it stays in the box */
.preview-stage .dog-pic:has(.weapon) { transform: translateX(-12%); }
.preview-stage .pet-pic .spr { width: 140px; height: 140px; object-fit: contain; }
.preview-lines p { margin: 2px 0; font-size: 14px; }
.preview-short { margin: 6px 0 0; font-size: 13px; color: #ff8a8a; }

/* Starter Pack: in the Shop and as a one-time popup; a red dot on the Shop button while it's on offer */
.starter-card { display: grid; gap: 6px; padding: 10px; border-radius: 16px; border: 3px solid var(--ol);
  background: linear-gradient(#fff1c2, #ffd36b); }
.starter-card .section-title, .starter-card .hint { color: var(--ol); }
.starter-pics { display: flex; justify-content: center; align-items: end; gap: 4px; }
.starter-pics .dog-pic > .spr { width: 84px; height: 84px; }
.starter-pics > .spr { width: 56px; height: 56px; }
.starter-list { margin: 0; text-align: center; font-size: 15px; }
#shop-btn.deal::after { content: ''; position: absolute; top: -5px; right: -5px; width: 14px; height: 14px;
  border-radius: 50%; background: #ff4d5e; border: 2px solid var(--ol); }

/* the finale (beat the Cat King) */
.finale-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0; }
.finale-stats div { display: grid; padding: 6px 2px; border-radius: 12px; background: #2b1d13; border: 2px solid var(--ol); }
.finale-stats .num { font-size: 18px; color: #ffd23f; }
.finale-stats small { font-size: 11px; color: #d9bf9c !important; }
.finale-rewards { font-weight: 700; color: var(--ol) !important; }
.champion { margin: 2px 0 0; font-weight: 700; color: #b8860b; }

/* a small icon inside a line of text (e.g. the coins a gem trade gives) */
.spr.inline-icon { width: 20px; height: 20px; vertical-align: -4px; margin-right: 3px; }

/* the weapon a dog holds in its previews (placed from scene.js WEAPON_OFFSET / WEAPON_SIZE) */
.dog-pic .weapon { position: absolute; height: auto; pointer-events: none; }

/* drag to reorder: pack slots (first = captain) and toy slots */
[data-drag] { touch-action: none; user-select: none; -webkit-user-select: none; }
[data-drag].dragging { opacity: .4; }
[data-drag].drop-on { outline: 4px dashed var(--gold); outline-offset: 2px; }
.drag-ghost { position: fixed; width: 64px; height: 64px; transform: translate(-50%, -60%); pointer-events: none; z-index: 50;
  filter: drop-shadow(0 6px 6px #0006); }
.pack-slot { position: relative; }
.pack-slot.captain-slot { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), 0 3px 0 #0006; }
.pack-slot .captain { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); padding: 1px 5px; border-radius: 8px;
  background: var(--gold); border: 2px solid var(--ol); color: var(--ol); font-size: 10px; white-space: nowrap;
  text-shadow: none; z-index: 2; letter-spacing: .5px; }
.slot { position: relative; }
.slot .toss { position: absolute; bottom: -6px; right: -6px; /* the free corner: tier sits top left, the melee twin top right */ width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: #ff5a6e; border: 2px solid var(--ol); color: #fff; font-weight: 900; font-size: 16px; line-height: 1; cursor: pointer; }

/* DIG! with no charges left: greyed until the next one comes back */
.btn.dig-tap:disabled { background: linear-gradient(var(--grey), var(--grey-dk)); }

/* side menu fold: a small tab on top; folded, only the tab stays (with a red dot if Daily waits) */
#side-menu .fold { padding: 0; height: 22px; display: grid; place-items: center; }
#side-menu .fold .num { font-size: 13px; margin: 0; color: #fff3dd; }
#side-menu.folded > button:not(.fold) { display: none; }

/* Settings */
.card.setting { justify-content: space-between; }
.card.setting.stacked { display: grid; grid-template-columns: 1fr; justify-content: stretch; gap: 8px; }
.setting-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.set-toggle { display: flex; align-items: center; gap: 4px; padding: 4px 12px; min-width: 84px; justify-content: center; }
.btn.set-toggle img { width: 22px; height: 22px; margin: 0; }
.btn.set-toggle.off { background: linear-gradient(var(--grey), var(--grey-dk)); }
.btn.set-toggle.off img { filter: grayscale(1) opacity(.7); }
/* a bone track that fills gold up to the paw */
.bone-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; border-radius: 9px; margin: 6px 0 4px;
  border: 3px solid var(--ol); background: linear-gradient(90deg, var(--gold) var(--fill, 100%), #fff3dd var(--fill, 100%)); }
.bone-slider:disabled { filter: grayscale(1) opacity(.6); }
.bone-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 36px; height: 36px; border: none; cursor: pointer;
  background: url(assets/ui/ui_paw.png) center / contain no-repeat; filter: drop-shadow(0 2px 0 var(--ol)); }
.bone-slider::-moz-range-thumb { width: 36px; height: 36px; border: none; cursor: pointer; background: url(assets/ui/ui_paw.png) center / contain no-repeat; }

/* suit tiers: a glow around the dog's picture and a coloured badge */
.dog-pic.suit-t1 > .spr { filter: drop-shadow(0 0 4px #d08a4c) drop-shadow(0 0 2px #d08a4c); }
.dog-pic.suit-t2 > .spr { filter: drop-shadow(0 0 5px #e8eef5) drop-shadow(0 0 2px #9fb3c8); }
.dog-pic.suit-t3 > .spr { filter: drop-shadow(0 0 6px #ffd23f) drop-shadow(0 0 3px #ffb300); }
.dog-pic.suit-t4 > .spr { filter: drop-shadow(0 0 7px #ff6bd6) drop-shadow(0 0 4px #6be3ff); animation: suit-rainbow 3s linear infinite; }
@keyframes suit-rainbow { to { filter: drop-shadow(0 0 7px #6bff9e) drop-shadow(0 0 4px #ffd23f) hue-rotate(360deg); } }
.suit-badge { color: #fff !important; }
.suit-badge.t1 { background: #b86f35 !important; }
.suit-badge.t2 { background: #8ea3b8 !important; }
.suit-badge.t3 { background: #e0a800 !important; }
.suit-badge.t4 { background: linear-gradient(90deg, #ff6bd6, #6be3ff, #6bff9e) !important; }

/* ---------- Arena ---------- */
#arena-btn {
  position: absolute; right: 10px; top: 80px;
  width: 58px; padding: 4px 0 2px;
  border-radius: 12px; border: 3px solid var(--ol);
  background: linear-gradient(#ffe07a, #f0a92b 60%, #b8731a);
  box-shadow: 0 3px 0 var(--ol);
  display: grid; justify-items: center; cursor: pointer;
}
#arena-btn img { width: 34px; height: 34px; }
#arena-btn .num { font-size: 12px; margin-top: -2px; color: #fff; }
#arena-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ol); }
.arena-mode { display: block; font-size: 12px; font-weight: 700; color: #e8d2b4; }
.arena-mode.on { color: #6ee05a; }
.arena-me { gap: 12px; }
.arena-big { font-size: 26px; color: #fff; }
.arena-pack { justify-content: space-between; }
.arena-dogs { display: flex; gap: 2px; align-items: end; flex-wrap: wrap; }
.arena-dog .spr { width: 40px; height: 40px; }
.arena-dog.pet .spr { width: 30px; height: 30px; }
.arena-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.arena-row { gap: 8px; padding: 6px 8px; }
.arena-row.me { outline: 3px solid var(--gold); }
.arena-rank { min-width: 42px; font-size: 16px; color: #fff; }
.btn.link.inline { padding: 0 4px; font-size: 14px; }
/* profile borders: wood, bronze, silver, gold, diamond, a rainbow for #1 */
.frame { display: inline-grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 50%;
  background: #fff7ea; border: 4px solid #8a5a3c; box-shadow: 0 0 0 2px var(--ol); }
.frame .spr { width: 82%; height: 82%; object-fit: contain; }
.frame.small { width: 42px; height: 42px; border-width: 3px; }
.frame.big { width: 76px; height: 76px; border-width: 5px; }
.frame-bronze { border-color: #c27a3a; }
.frame-silver { border-color: #c9d3de; box-shadow: 0 0 0 2px var(--ol), 0 0 8px #e8eef5; }
.frame-gold { border-color: #ffd23f; box-shadow: 0 0 0 2px var(--ol), 0 0 10px #ffd23f; }
.frame-diamond { border-color: #7fe3ff; box-shadow: 0 0 0 2px var(--ol), 0 0 12px #7fe3ff; }
.frame-champion { border-color: #ff6bd6; box-shadow: 0 0 0 2px var(--ol), 0 0 14px #ff6bd6; animation: frame-rainbow 3s linear infinite; }
@keyframes frame-rainbow { to { filter: hue-rotate(360deg); } }
/* team, avatar and border pickers */
.arena-picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 40vh; overflow-y: auto; padding: 2px; }
.arena-pick { display: grid; justify-items: center; gap: 1px; padding: 4px 2px; border-radius: 10px; border: 3px solid var(--ol);
  background: #fff7ea; cursor: pointer; }
.arena-pick .spr { width: 46px; height: 46px; }
.arena-pick small { font-size: 10px; color: var(--ol); line-height: 1.1; }
.arena-pick.on { background: #ffd98a; outline: 3px solid var(--gold); }
.arena-pick.locked { opacity: .45; cursor: not-allowed; }
.arena-name { width: 100%; padding: 8px 10px; border-radius: 10px; border: 3px solid var(--ol); font: inherit; font-size: 16px; }
/* during an arena fight the yard's buttons step aside */
body.arena-fight :is(#side-menu, #skills, #auto, #shop-btn, #arena-btn, #speed, #settings-btn, #fight-boss, #boss-bar) { display: none !important; }

/* Settings > Account */
.acct-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.acct-btns .btn { flex: 1 1 auto; }
.acct-input { width: 100%; padding: 8px 10px; margin: 4px 0; border-radius: 10px; border: 3px solid var(--ol); font: inherit; font-size: 16px; }
.player-id { letter-spacing: 1px; color: var(--ol); }

/* phone held sideways: the game is portrait only, so ask to turn it upright (installed from the
   home screen, app.webmanifest locks portrait where the browser allows it) */
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  #rotate {
    position: fixed; inset: 0; z-index: 100;
    display: grid; place-content: center; justify-items: center; gap: 6px;
    background: radial-gradient(circle at 50% 30%, #6b4a33, #2e1f15 75%);
    text-align: center; color: #e8d2b4;
  }
  #rotate img { width: 96px; height: 96px; border-radius: 22px; animation: rotate-hint 2s ease-in-out infinite; }
  #rotate .title { font-size: 26px; margin: 8px 0 0; }
  #phone, #modal, #toast { visibility: hidden; }
}
@keyframes rotate-hint { 0%, 20% { transform: rotate(-90deg); } 50%, 100% { transform: rotate(0); } }
