/* ============================================================
   Wicklings — "moonlit ink" theme.
   Deep ink-blue night panels, moonlight text, lantern-gold +
   bottle-green accents, film grain + vignette for atmosphere.
   ============================================================ */
:root {
  --bg: #11141d;
  --panel: #1a1f2c;
  --panel-2: #232a3c;
  --well: #131722;          /* recessed surfaces: bars, logs, viewports */
  --line: #313a52;          /* card / control borders */
  --line-soft: #262e42;     /* hairline dividers */
  --text: #e9ecf4;
  --muted: #98a0b8;
  --accent: #e8a33d;        /* candle amber */
  --accent-deep: #c97a2b;   /* ember */
  --accent-2: #58b08a;      /* bottle-glass green */
  --good: #7cc46f;
  --bad: #d9604c;
  --warn: #e3b341;
  --radius: 14px;
  --content-max: 1140px;    /* desktop: cap + center the main content column */
  --display: 'Grenze Gotisch', 'Palatino Linotype', 'Book Antiqua', serif;
  --body-font: 'Alegreya Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  /* faint lantern glow top-left, bottle-green haze bottom-right, over ink */
  background:
    radial-gradient(55% 40% at 16% 0%, rgba(232,163,61,.08), transparent 70%),
    radial-gradient(50% 38% at 88% 100%, rgba(88,176,138,.06), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body-font);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
/* film grain + vignette over everything (incl. modals) — pure atmosphere */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 100; pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 45%, transparent 60%, rgba(0,0,0,.38) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
::selection { background: rgba(232,163,61,.35); }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .4px; }

.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ---------- Auth / Create ---------- */
.auth-card {
  margin: auto;
  width: min(420px, 92vw);
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.logo {
  display: block; width: min(300px, 82%); height: auto; margin: 4px auto 0;
  image-rendering: auto;
  filter: drop-shadow(0 0 28px rgba(232,163,61,.35));
}
.tagline { color: var(--muted); text-align: center; margin: 0 0 8px; }
/* small flourish under the tagline, like a chapter ornament */
.tagline::after {
  content: '— ✦ —'; display: block; margin-top: 10px;
  color: var(--accent); opacity: .5; font-size: .8rem; letter-spacing: 4px;
}
h2 { margin: 0; text-align: center; font-size: 1.8rem; }
.field-label { color: var(--muted); font-size: .85rem; margin-top: 6px; }

input {
  background: var(--well); border: 1px solid var(--line); color: var(--text);
  padding: 14px 16px; border-radius: var(--radius); font-size: 1rem; width: 100%;
  font-family: var(--body-font);
}
input::placeholder { color: #646d88; }
input:focus { outline: 2px solid var(--accent-2); border-color: transparent; }

.btn {
  background: linear-gradient(180deg, var(--panel-2), #1e2433);
  color: var(--text); border: 1px solid var(--line);
  padding: 14px 16px; border-radius: var(--radius); font-size: 1rem; font-weight: 700;
  font-family: var(--body-font);
  cursor: pointer; transition: transform .05s, filter .15s; width: 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(170deg, #f2b94e, var(--accent-deep));
  color: #2a1a05; border-color: #a3702a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 12px rgba(232,163,61,.22);
  text-shadow: none;
}
.btn.small { width: auto; padding: 10px 14px; font-size: .9rem; }
.btn.link { background: none; border: none; box-shadow: none; color: var(--muted); font-weight: 600; font-size: .9rem; padding: 6px; text-decoration: underline; }
.btn.link:hover { color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.error { background: rgba(217,96,76,.14); color: #f0907c; padding: 10px 14px; border-radius: 10px; font-size: .9rem; border: 1px solid rgba(217,96,76,.3); }
.hidden { display: none !important; }

/* ---------- Species / color pickers ---------- */
.species-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.species-card {
  background: var(--panel); border: 2px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px; text-align: center; cursor: pointer;
}
.species-card.selected { border-color: var(--accent); background: var(--panel-2); box-shadow: 0 0 18px -6px var(--accent); }
.species-card .emoji { font-size: 2rem; }
.species-card .emoji .pet-av { width: 56px; height: 56px; }
.species-card .sp-name { font-weight: 700; margin: 4px 0 2px; }
.species-card .sp-blurb { color: var(--muted); font-size: .72rem; line-height: 1.2; }

/* Roomier adopt/species picker on desktop: more columns, bigger sprites. */
@media (min-width: 900px) {
  #create-screen .auth-card { width: min(760px, 92vw); }
  .species-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
  .species-card { padding: 18px 12px; }
  .species-card .emoji .pet-av { width: 104px; height: 104px; }
  .species-card .sp-name { font-size: 1.05rem; }
  .species-card .sp-blurb { font-size: .8rem; }
}
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.swatch.selected { border-color: #f3c468; }

/* ---------- Game shell ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(180deg, #1d2331, #171c28);
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 5;
}
.pet-badge { display: flex; align-items: center; gap: 10px; }
.hud-emoji { font-size: 1.8rem; }
.hud-name { font-weight: 700; font-family: var(--display); font-size: 1.15rem; letter-spacing: .4px; }
.hud-sub { color: var(--muted); font-size: .8rem; }
.coins { font-weight: 700; }
.hud-stats { display: flex; justify-content: flex-end; }
.hud-row { display: flex; align-items: center; gap: 10px; }
.hud-stat { font-weight: 700; white-space: nowrap; background: var(--well); border: 1px solid var(--line-soft); padding: 5px 10px; border-radius: 20px; font-size: .9rem; }
.hud-stat.energy { color: #b3a6ec; display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.15; }
.hud-timer { font-size: .58rem; font-weight: 500; color: rgba(233,236,244,.5); letter-spacing: .3px; margin-left: 18px; }
.hud-timer:empty { display: none; }

.tab-content { flex: 1; overflow-y: auto; padding: 16px 16px 90px; }
.tab-content::-webkit-scrollbar { width: 10px; }
.tab-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.tab-content::-webkit-scrollbar-track { background: transparent; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: linear-gradient(180deg, #1a1f2c, #141926);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px 4px; font-size: 1.3rem; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--body-font);
}
.tab span { font-size: .66rem; }
.tab.active { color: var(--accent); text-shadow: 0 0 12px rgba(232,163,61,.5); }
.tab.active::before {
  content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* ---------- Cards / panels ---------- */
.card {
  background: linear-gradient(180deg, #1d2331, #181d2a);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 4px 14px rgba(0,0,0,.25);
}
.card h3 { margin: 0 0 12px; font-size: 1.2rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); font-size: .85rem; }

/* Pet hero */
.pet-hero { text-align: center; padding: 22px 16px; }
.pet-avatar {
  width: 110px; height: 110px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center; font-size: 3.4rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 0 0 1px var(--line);
}
.pet-hero h2 { margin: 4px 0; }

/* Stat bars — potion-bottle colors */
.bar-label { display: flex; justify-content: space-between; font-size: .8rem; margin: 10px 0 4px; }
.bar { height: 12px; background: var(--well); border-radius: 8px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.4); }
.bar > i { display: block; height: 100%; border-radius: 8px; transition: width .3s; }
.bar.hunger > i { background: linear-gradient(90deg, #c97a2b, #e3b341); }
.bar.happy > i  { background: linear-gradient(90deg, #b05574, #d4708e); }
.bar.energy > i { background: linear-gradient(90deg, #6f63c7, #9d8fe0); }
.bar.xp > i     { background: linear-gradient(90deg, #4e9651, #7cc46f); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 8px; }
.stat-grid .s-val { font-size: 1.4rem; font-weight: 600; font-family: var(--display); }
.stat-grid .s-lbl { color: var(--muted); font-size: .72rem; }

.action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }

/* List items (jobs, training, opponents, foods) */
.item { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: inset 0 1px 0 rgba(255,255,255,.03); }
.item .it-title { font-weight: 700; }
.item .it-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.item .it-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.item .foot-ctrls { display: flex; align-items: center; gap: 8px; }
.item .foot-sell { display: flex; align-items: center; gap: 8px; margin-left: auto; }
/* Quick-sell button — rounded square with the price inside; brick red,
   distinct from the amber primary button. */
.btn-sell { flex: 0 0 auto; border: none; cursor: pointer; border-radius: 10px; padding: 9px 14px;
  background: linear-gradient(170deg, #c0503e, #90342a); color: #ffe9e2; font-size: .85rem; font-weight: 700;
  font-family: var(--body-font);
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 2px 10px rgba(192,80,62,.3); transition: transform .08s ease, box-shadow .15s ease; }
.btn-sell:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 3px 14px rgba(192,80,62,.48); }
.btn-sell:active { transform: scale(.94); }
.pill { background: var(--well); color: var(--muted); border: 1px solid var(--line-soft); border-radius: 20px; padding: 3px 9px; font-size: .72rem; }

/* Toast */
.toast {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: #232a3c; color: var(--text); border: 1px solid var(--accent);
  padding: 10px 16px; border-radius: 20px;
  font-size: .88rem; z-index: 20; max-width: 90vw; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.5), 0 0 18px -6px var(--accent);
}

/* Confirmation modal */
.modal-back { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,12,.7); padding: 20px; animation: modal-fade .12s ease; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; max-width: 360px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.6);
  animation: modal-pop .14s ease; }
.modal-msg { font-size: .95rem; line-height: 1.5; margin-bottom: 18px; text-align: center; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.danger { background: linear-gradient(170deg, #c0503e, #90342a); color: #ffe9e2; border-color: #7c2d24; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Battle log */
.battle-log { background: var(--well); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; font-size: .82rem; line-height: 1.5; max-height: 50vh; overflow-y: auto; }
.battle-log div { padding: 2px 0; border-bottom: 1px solid #1b2130; }

/* Leaderboard */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.rank-num { width: 26px; text-align: center; font-weight: 700; color: var(--muted); font-family: var(--display); font-size: 1.05rem; }
.rank-row .r-name { font-weight: 600; }
.rank-row .r-sub { color: var(--muted); font-size: .75rem; }
.rank-row.rank-you { background: rgba(232,163,61,.10); border-radius: 8px; }

/* Segmented control (e.g. Arena: Opponents | Rankings) */
.seg { display: flex; gap: 6px; background: var(--well); border: 1px solid var(--line-soft); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px; border-radius: 9px; font-weight: 600; font-size: .9rem; cursor: pointer;
  font-family: var(--body-font);
}
.seg button.active { background: var(--panel-2); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }

.center { text-align: center; }
.spinner { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- Shop / gear ---------- */
.slot-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.slot-row:last-child { border-bottom: none; }
.slot-name { color: var(--muted); font-size: .85rem; text-transform: capitalize; }
.gear-bonus { color: var(--good); font-size: .8rem; font-weight: 700; vertical-align: middle; }
.pill.equipped { background: var(--good); color: #11260c; font-weight: 700; border-color: transparent; }
.swatch-sm { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; margin-right: 4px; border: 1px solid rgba(255,255,255,.25); }

/* ---------- Pet sprites ---------- */
.pet-av { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; line-height: 1; }
.pet-av .pet-sprite { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block; }
.pet-av .av-emoji { font-size: 1em; }
.pet-av.av-sm { width: 30px; height: 30px; font-size: 1.2rem; }
.pet-av.av-md { width: 46px; height: 46px; font-size: 1.6rem; }
.pet-av.av-lg { width: 100%; height: 100%; font-size: 3rem; }
.pet-av.av-bg { width: 76px; height: 76px; font-size: 3rem; }
.hud-emoji .pet-av { width: 46px; height: 46px; font-size: 1.5rem; }  /* top-bar pet a touch bigger */

/* Daily Spin card */
.daily-card { display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(135deg, rgba(232,163,61,.12), rgba(88,176,138,.08)), linear-gradient(180deg, #1d2331, #181d2a); }
.spin-title { font-weight: 600; text-align: center; font-family: var(--display); font-size: 1.2rem; }
.spin-viewport { position: relative; overflow: hidden; border-radius: 10px; background: var(--well); height: 70px; margin-top: 10px; box-shadow: inset 0 0 0 1px var(--line); }
.spin-pointer { position: absolute; left: 50%; top: -1px; transform: translateX(-50%); z-index: 2; color: var(--accent); font-size: 1rem; text-shadow: 0 0 6px var(--accent); }
.spin-viewport::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 64px; transform: translateX(-50%); box-shadow: 0 0 0 2px rgba(232,163,61,.5) inset; border-radius: 6px; pointer-events: none; z-index: 1; }
.spin-strip { display: flex; height: 100%; will-change: transform; }
.spin-cell { flex: 0 0 64px; width: 64px; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; border-right: 1px solid var(--line-soft); }
.spin-cell.win { background: rgba(232,163,61,.16); }
.spin-swatch { display: inline-block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); }

/* Bottles card */
.bottle-card-spike { box-shadow: 0 0 0 2px var(--warn) inset; }
.bottle-spike { color: var(--warn); font-weight: 800; }
.scav-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scav-spot { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); cursor: pointer; }
.scav-spot:active { transform: scale(.95); }
.scav-spot.done { background: var(--well); color: var(--good); cursor: default; font-size: 1.1rem; }
.scav-total { text-align: center; margin-top: 10px; font-size: 1.05rem; }
.alms-reward { display: flex; justify-content: center; margin: 4px 0 6px; }
.sg-speed { margin: .3rem 0 0; font-size: .8rem; font-weight: 600; color: var(--accent); letter-spacing: .2px; }

/* 📋 Contracts + Street Rep (Pet tab) */
.contracts-card .rep-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 12px; }
.rep-name { font-weight: 600; letter-spacing: .5px; font-family: var(--display); font-size: 1.1rem; color: #f3c468; }
.rep-bar { height: 8px; background: var(--well); border-radius: 6px; overflow: hidden; margin: 6px 0 14px; }
.rep-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); transition: width .4s ease; }
.contract-list { display: flex; flex-direction: column; gap: 10px; }
.contract { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; }
.contract.ready { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.contract.claimed { opacity: .6; }
.ct-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ct-label { font-size: .9rem; font-weight: 600; }
.ct-bar { height: 6px; background: var(--well); border-radius: 5px; overflow: hidden; margin: 8px 0 4px; }
.ct-bar > i { display: block; height: 100%; background: var(--accent-2); transition: width .4s ease; }
.ct-reward { font-size: .74rem; }
.pill.ok { background: rgba(124,196,111,.15); color: var(--good); border-color: rgba(124,196,111,.3); }
.pill.bad { background: rgba(217,96,76,.15); color: var(--bad); border-color: rgba(217,96,76,.3); }
.coin-up { color: var(--good); font-weight: 700; }
.coin-down { color: var(--bad); font-weight: 700; }
.bh-coins { font-size: .82rem; margin-top: 3px; }

/* 🔥 Daily Feast streak (Pet tab) — a 7-pip weekly cycle of food rewards */
.streak-card .streak-pips { display: flex; gap: 6px; margin-top: 12px; }
.streak-pip { flex: 1; aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 10px; background: var(--well); border: 1px solid var(--line-soft);
  filter: grayscale(.8); opacity: .45;
  transition: transform .12s ease, box-shadow .15s ease; }
.streak-day { font-size: .6rem; font-weight: 700; line-height: 1; color: var(--muted); white-space: nowrap; letter-spacing: .2px; }
.streak-food { font-size: 1.05rem; line-height: 1; }
.streak-food .pet-av { width: 26px; height: 26px; }
/* Bigger food sprites in the wide desktop pips (mobile stays compact). */
@media (min-width: 900px) {
  .streak-food .pet-av { width: 64px; height: 64px; }
  .streak-food { font-size: 2.6rem; } /* keep the rare emoji fallback in scale */
}
.streak-pip.done .streak-day, .streak-pip.today .streak-day { color: var(--text); }
.streak-pip.milestone { border-radius: 50%; } /* the day-7 payoff reads as a coin/medal */
.streak-pip.done { filter: none; opacity: 1; border-color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(88,176,138,.4); }
.streak-pip.today { filter: none; opacity: 1; --pa: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 14px -3px var(--accent); animation: pin-pulse 1.6s ease-in-out infinite; }

/* 🧭 Explore hub — an actual city map: pins at coordinates joined by a route */
.explore-map {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  aspect-ratio: 4 / 3.5; border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  /* faint street grid + lantern-light district glows over a dark base */
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(233,236,244,.03) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(233,236,244,.03) 31px 32px),
    radial-gradient(circle at 22% 18%, rgba(232,163,61,.16), transparent 55%),
    radial-gradient(circle at 85% 88%, rgba(88,176,138,.13), transparent 50%),
    #0e111a;
  box-shadow: inset 0 0 70px rgba(0,0,0,.55);
}
.map-tag { position: absolute; top: 10px; left: 12px; z-index: 3; font-size: .66rem; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
  background: rgba(5,8,14,.5); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; }
.compass { position: absolute; top: 10px; right: 12px; z-index: 3; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(5,8,14,.5); display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .85rem; }
.compass-n { position: absolute; top: 1px; font-size: .48rem; font-weight: 800; color: var(--accent); }

/* roads + dashed route drawn across the map */
.map-route { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.map-roads line { stroke: rgba(233,236,244,.05); stroke-width: 3.5; stroke-linecap: round; }
.route-line { fill: none; stroke: rgba(232,163,61,.45); stroke-width: .7; stroke-dasharray: 2.4 2.2; stroke-linecap: round; }

/* map pins (place markers) positioned at their map coords */
.map-pin { position: absolute; transform: translate(-50%, -62%); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer; color: var(--text); --pa: var(--accent);
  font-family: var(--body-font); }
.pin-marker { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; background: radial-gradient(circle at 50% 38%, var(--panel-2), var(--well));
  border: 2px solid var(--pa); box-shadow: 0 0 16px -3px var(--pa);
  transition: transform .1s ease, box-shadow .15s ease; }
.map-pin:hover .pin-marker { transform: translateY(-2px); box-shadow: 0 0 24px -1px var(--pa); }
.map-pin:active .pin-marker { transform: scale(.9); }
.pin-name { font-size: .72rem; font-weight: 700; white-space: nowrap;
  background: rgba(5,8,14,.6); padding: 1px 8px; border-radius: 10px; }
.pin-badge { position: absolute; top: -3px; right: 6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--good); color: #11260c; font-size: .72rem; font-weight: 900; line-height: 18px; text-align: center;
  box-shadow: 0 0 12px -1px var(--good); }
.map-pin.ready .pin-marker { animation: pin-pulse 1.6s ease-in-out infinite; }
@keyframes pin-pulse { 0%,100% { box-shadow: 0 0 14px -3px var(--pa); } 50% { box-shadow: 0 0 22px 1px var(--pa); } }

.place-head { display: flex; align-items: center; gap: 12px; }
.place-head h3 { margin: 0; font-size: 1.5rem; }
.place-head .back-btn { flex: 0 0 auto; }
/* place artwork (128px pixel-art sprites; scale at integer multiples only) —
   framed like a little painting */
.place-art { display: block; width: min(220px, 60vw); height: auto; aspect-ratio: 1 / 1;
  image-rendering: pixelated; margin: 0 auto 6px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--well);
  box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.place-art-wrap { margin-bottom: 8px; } /* standalone art between cards: match the 14px card rhythm */
@media (min-width: 900px) { .place-art { width: 256px; height: 256px; } }

/* 🏦 Bank */
.bank-bal { display: flex; justify-content: space-between; gap: 12px; }
.bank-num { font-size: 1.7rem; font-weight: 600; margin-top: 2px; font-family: var(--display); }

/* 🎲 The Crooked Coin — skill games. Result banner (reused from the old den). */
.den-banner { font-weight: 700; font-size: .95rem; animation: den-pop .25s ease; }
.den-banner.den-win { box-shadow: 0 0 0 1px var(--good) inset; color: var(--good); }
.den-banner.den-lose { box-shadow: 0 0 0 1px var(--bad) inset; color: var(--bad); }
@keyframes den-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sg-arena { margin-top: 6px; }

/* Timing track — a marker sweeps 0↔1; stop it in the gold zone (bullseye = core). */
.sg-track { position: relative; flex: 1; height: 26px; border-radius: 8px; background: var(--well);
  border: 1px solid var(--line); overflow: hidden; box-shadow: inset 0 1px 4px rgba(0,0,0,.45); }
.sg-zone { position: absolute; top: 0; bottom: 0; background: rgba(232,163,61,.28);
  border-left: 1px solid rgba(232,163,61,.6); border-right: 1px solid rgba(232,163,61,.6); }
.sg-core { position: absolute; top: 0; bottom: 0; background: rgba(232,163,61,.85); }
.sg-marker { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1.5px;
  background: var(--text); border-radius: 2px; box-shadow: 0 0 8px rgba(255,255,255,.7); }

/* Lockpick — a stack of pin tracks, each with its own Set button. */
.sg-pin-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sg-pin-row.set .sg-track { box-shadow: inset 0 0 0 1px var(--accent-2); }
.sg-pin-row.set .sg-marker { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

/* Shells — cups slide between slots; the bead shows only during the reveal. */
.sg-cups { position: relative; height: 84px; margin: 8px 0 2px; }
.sg-cup { position: absolute; top: 0; height: 84px;
  width: calc((100% - (var(--cups) - 1) * 10px) / var(--cups));
  left: calc(var(--slot) * (100% + 10px) / var(--cups));
  display: flex; align-items: center; justify-content: center; font-size: 2.6rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; cursor: default;
  transition: left var(--swap, .42s) cubic-bezier(.5,.05,.3,1), box-shadow .15s, transform .1s; }
.sg-cup .sg-cup-body { line-height: 1; }
.sg-cup .sg-bead { position: absolute; bottom: 8px; font-size: .9rem; opacity: 0; transition: opacity .2s; }
.sg-cups.reveal .sg-cup.has-bead { box-shadow: 0 0 0 2px var(--accent) inset; }
.sg-cups.reveal .sg-cup.has-bead .sg-bead { opacity: 1; }
.sg-cup.pickable { cursor: pointer; }
.sg-cup.pickable:hover { box-shadow: 0 0 0 2px var(--accent-2) inset; transform: translateY(-3px); }

/* 🎪 The Hexfair — free real-time arcade games (Bottle Rain, …). */
.fair-card { display: flex; flex-direction: column; gap: 10px; }
.fair-card-head { display: flex; align-items: center; gap: 12px; }
.fair-emoji { font-size: 2rem; line-height: 1; }
.fair-name { font-weight: 700; font-size: 1.05rem; font-family: var(--display); }
.fair-meta { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--muted); }
.fair-stage { display: flex; flex-direction: column; align-items: center; }
.fair-hud { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 360px;
  font-weight: 700; font-size: .95rem; margin-bottom: 6px; gap: 8px; }
.fair-hud .br-combo { color: var(--accent); }
.fair-canvas { width: 100%; max-width: 360px; height: auto; border-radius: 12px;
  border: 1px solid var(--line); box-shadow: inset 0 1px 6px rgba(0,0,0,.5); touch-action: none; cursor: pointer; }

/* Recycling Center — stock-ticker price chart */
.stock-card { background: var(--well); }
.stock-head { display: flex; align-items: flex-start; justify-content: space-between; }
.stock-label { font-size: .72rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.stock-price { font-size: 1.9rem; font-weight: 600; line-height: 1.1; margin-top: 2px; font-family: var(--display); }
.stock-change { font-size: .9rem; font-weight: 700; white-space: nowrap; padding-top: 4px; }
/* aspect-ratio matches the SVG viewBox (320x130) so it scales uniformly and the
   line never stretches, whatever the container width. */
.stock-svg { display: block; width: 100%; aspect-ratio: 320 / 130; height: auto; margin: 10px 0 4px; overflow: visible; }
.stock-foot { display: flex; justify-content: space-between; font-size: .72rem; border-top: 1px solid var(--line-soft); padding-top: 8px; }
/* On wide screens, keep the Recycling Center and Bottle Yard as focused widgets
   instead of stretching across the whole content area. */
@media (min-width: 900px) {
  .stock-card, .recy-card, .bottle-card, .place-art-wrap { max-width: 560px; }
  .scav-grid { max-width: 340px; }
}

/* ---------- Pet switcher (Pet tab) ---------- */
.switcher-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.switcher-head .slot-name { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.pet-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.pet-chip {
  flex: 0 0 auto; width: 78px; background: var(--panel); border: 2px solid var(--line-soft);
  border-radius: 14px; padding: 10px 6px; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--body-font);
}
.pet-chip:disabled { cursor: default; }
.pet-chip.active { border-color: var(--accent); background: var(--panel-2); box-shadow: 0 0 14px -6px var(--accent); }
.pet-chip-av { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.pet-chip-name { font-size: .72rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-chip-lv { font-size: .62rem; color: var(--muted); }
.pet-chip.empty { border: 2px dashed var(--line); background: none; cursor: default; }
.pet-chip.empty .pet-chip-av { color: var(--muted); border: none; }

/* Market price input */
.price-input { width: 96px; padding: 8px 10px; font-size: .85rem; }

/* ---------- Animated battle ---------- */
.battle-arena { display: flex; align-items: center; justify-content: space-around; gap: 8px; padding: 8px 0; }
.fighter-panel { flex: 1; text-align: center; position: relative; }
.fighter-emoji { font-size: 3rem; line-height: 1; }
.battle-arena .pet-av, .encounter-av .pet-av { width: 120px; height: 120px; }
@media (min-width: 900px) { .battle-arena .pet-av, .encounter-av .pet-av { width: 168px; height: 168px; } }
.vs-badge { font-weight: 600; color: var(--accent); font-size: 1.4rem; font-family: var(--display); text-shadow: 0 0 14px rgba(232,163,61,.4); }
.hp-bar { height: 14px; background: var(--well); border-radius: 8px; overflow: hidden; margin-top: 8px; box-shadow: inset 0 1px 3px rgba(0,0,0,.4); }
.hp-bar > i { display: block; height: 100%; background: var(--good); border-radius: 8px; transition: width .4s ease; }
.hp-bar.low > i { background: var(--bad); }
.dmg-float {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  font-weight: 800; font-size: 1.2rem; color: #fff; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.6); animation: floatUp 1s forwards;
}
.dmg-float.crit { color: #ff7a64; font-size: 1.9rem; }
.dmg-float.dodge { color: var(--muted); font-size: 1rem; }
@keyframes floatUp { to { opacity: 0; transform: translate(-50%, -28px); } }
.shake { animation: shake .3s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
#battle-log { max-height: 34vh; min-height: 60px; }
#battle-log .crit-line { color: #ff7a64; font-weight: 700; }

/* ---------- Turnstile (captcha) ---------- */
.captcha-row { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.captcha-row .muted { font-size: .8rem; text-align: center; }
#captcha-box { min-height: 70px; }

/* ---------- Responsive content grids ----------
   1 column on phones, auto multi-column as width allows. */
.card-grid, .grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: start;
  margin-bottom: 14px;
}
.grid { gap: 12px; margin-bottom: 14px; }
.card-grid .card, .grid .item { margin-bottom: 0; }
/* When a section header follows a grid (e.g. the Shop's slot groups), keep them apart. */
/* Page title: the prominent header at the top of each tab — a chapter heading. */
.page-head {
  background: linear-gradient(135deg, rgba(232,163,61,.12), rgba(88,176,138,.05));
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.page-head h3 { font-size: 1.8rem; margin: 0; letter-spacing: .5px; color: #f3c468; }
.page-head .muted { margin: 6px 0 0; }

/* Sub-section labels: small, light dividers that sit clearly below the title. */
.section-head {
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 2px 2px 6px;
  margin: 4px 0 12px;
}
.section-head h3 {
  font-size: .82rem; margin: 0; font-weight: 700;
  font-family: var(--body-font);
  text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted);
}
.grid + .section-head { margin-top: 18px; }
.narrow { max-width: 680px; margin: 0 auto; }
.btn-logout { margin-top: 16px; }

/* ---------- Desktop / laptop layout ----------
   Swap the bottom tab bar for a left sidebar and let content breathe. */
@media (min-width: 900px) {
  #game-screen.active {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "side top" "side main";
    width: 100%;
    height: 100dvh;
  }
  /* Topbar content aligns with the centered main column (same side inset). */
  .topbar {
    grid-area: top;
    border-bottom: 1px solid var(--line-soft);
    padding: 14px max(28px, calc((100% - var(--content-max)) / 2));
  }
  /* Center + cap the content so cards don't stretch edge-to-edge on big screens.
     A single centered grid column does this without touching the markup. */
  .tab-content {
    grid-area: main;
    min-height: 0;          /* allow the scroll area to shrink inside the grid */
    display: grid;
    grid-template-columns: minmax(0, var(--content-max));
    justify-content: center;
    align-content: start;
    padding: 28px 28px 56px;
  }
  .tabbar {
    grid-area: side;
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 16px 14px;
    border-top: none;
    border-right: 1px solid var(--line-soft);
    background: linear-gradient(180deg, #1b212f, #12161f);
  }
  .tabbar::before {
    content: "";
    display: block;
    height: 172px;
    margin: 2px 0 14px;
    /* logo art over a warm lantern halo glowing from behind it */
    background:
      url("/sprites/UI/logo_big.png") center / contain no-repeat,
      radial-gradient(62% 52% at 50% 40%, rgba(232,163,61,.30), rgba(201,122,43,.12) 54%, transparent 72%);
  }
  .tabbar .tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    font-size: 1.2rem;
    padding: 11px 14px;
    border-radius: 10px;
    transition: background .15s ease, color .15s ease;
  }
  .tabbar .tab span { font-size: .95rem; font-weight: 600; }
  .tabbar .tab:hover { color: var(--text); background: rgba(255,255,255,.035); }
  .tabbar .tab.active {
    color: var(--accent);
    background: var(--panel-2);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  /* Gold left-accent rail on the active tab (replaces the mobile top bar). */
  .tabbar .tab.active::before {
    content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; right: auto;
    width: 3px; height: auto; border-radius: 0 3px 3px 0;
    background: var(--accent); box-shadow: 0 0 10px rgba(232,163,61,.6);
  }
  .btn-logout { max-width: 260px; }
  .auth-card { width: 440px; }
}

/* Roomier columns on big monitors (now that we span the full width). */
@media (min-width: 1280px) {
  .card-grid, .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
