/* Maple Tracker — "Light Fantasy" page styles.
   Order: tokens, base, scenery, components, page sections, responsive.
   Scenery art lives in assets/kit (generated sprites with the white background removed); item and NPC sprites come from maplestory.io. */

/* ===================== Tokens ===================== */
:root {
  color-scheme: light;

  /* Sky */
  --sky: #bdeaff;
  --sky-pale: #eaf8ff;
  --cloud: #f8fcff;
  --ice: #eaf4ff;

  /* Cards */
  --card: #ffffff;
  --card-soft: #f5f9ff;
  --line: #d1e2f5;
  --line-hover: #91c7f6;

  /* Text */
  --text: #142d59;
  --text-2: #58729d;
  --muted: #8297b5;

  /* Accents */
  --blue: #238cff;
  --yellow: #ffcc59;
  --green: #34b96a;
  --red: #ef565d;
  --orange: #ffaa45;

  /* Shape, depth, motion */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(20, 45, 89, .06), 0 8px 24px rgba(35, 100, 180, .1);
  --shadow-hover: 0 2px 4px rgba(20, 45, 89, .07), 0 12px 30px rgba(35, 100, 180, .16);
  --ring: 0 0 0 3px rgba(35, 140, 255, .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t: .2s;

  --font: "Nunito", system-ui, "Segoe UI", sans-serif;
  --font-logo: "Pixelify Sans", var(--font);

  /* Names read by the shared price card (also used by the overlay) and the chart */
  --border: var(--line);
  --ok: var(--green);
  --err: var(--red);
  --accent: var(--blue);
  --chart-line: var(--blue);
  --chart-grid: #e6eef8;
}

/* ===================== Base ===================== */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--sky-pale); }
body { margin: 0; min-height: 100vh; color: var(--text); font: 600 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: var(--blue); text-underline-offset: 2px; }
img { image-rendering: auto; }
.pixel { image-rendering: pixelated; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.wrap { position: relative; z-index: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 0 24px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ===================== Scenery (behind the whole page) =====================
   Sky on top, three repeating strips (mountains, forest, grass ledge) under the header, props on the
   top and the sides, and a meadow along the bottom of the page. Art: assets/kit. */
body { position: relative; padding-bottom: 10px; } /* padding, not a child margin: a margin would stick out below the scenery */.world { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(#5db5f3 0, #8fd0fa 120px, #c4e9ff 230px, #e3f5ff 360px, var(--sky-pale) 520px, #eef9ff 80%, #dff3e6 100%); }
.world img { position: absolute; display: block; user-select: none; }
.world .mob { image-rendering: pixelated; }
.band { position: absolute; left: 0; right: 0; background-repeat: repeat-x; background-position: left bottom; }
.band-mountains { top: 46px; height: 132px; opacity: .78; filter: saturate(.85); background-image: url(assets/kit/strip-mountains.png); background-size: auto 132px; }
/* Grass ledges only in the top corners; their inner end fades out. */
.ledge { position: absolute; height: 38px; background: url(assets/kit/strip-ground.png) left top / auto 38px repeat-x;
  -webkit-mask-image: linear-gradient(90deg, #000 70%, transparent); mask-image: linear-gradient(90deg, #000 70%, transparent); }
.ledge-right { -webkit-mask-image: linear-gradient(270deg, #000 70%, transparent); mask-image: linear-gradient(270deg, #000 70%, transparent); }
.side { position: absolute; }
.side img { position: relative; }
.side .mob { position: absolute; }
.meadow { position: absolute; left: 0; right: 0; bottom: 0; height: 150px; }
.meadow img { bottom: 34px; }
.meadow::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: url(assets/kit/strip-ground.png) left top / auto 44px repeat-x; }
.cloud { opacity: .95; }
.drift { animation: drift 26s ease-in-out infinite alternate; }
.drift.slow { animation-duration: 38s; }
@keyframes drift { to { transform: translateX(40px); } }
.float { animation: bob 7s ease-in-out infinite alternate; }
.float.slow { animation-duration: 10s; }
@keyframes bob { to { transform: translateY(-8px); } }
/* Side islands and the corner trees need a wide page margin; on narrower screens only a cut sliver would show. */
@media (max-width: 1700px) { .world .side, .world .wide-only { display: none; } }

/* ===================== Components ===================== */

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; height: 44px; padding: 0 18px;
  font: 800 14px/1 var(--font); white-space: nowrap; cursor: pointer; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 2px 6px rgba(20, 45, 89, .08);
  transition: background var(--t), border-color var(--t), box-shadow var(--t), transform var(--t), filter var(--t); }
.btn:hover:not(:disabled) { border-color: var(--line-hover); box-shadow: 0 4px 12px rgba(35, 100, 180, .16); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 3px rgba(20, 45, 89, .12); }
.btn:focus-visible { box-shadow: var(--ring); }
.btn:disabled { cursor: not-allowed; color: #a9b8cd; background: #f1f5fa; border-color: #e1e9f3; box-shadow: none; }
.btn:disabled img { opacity: .45; filter: grayscale(1); }
.btn img { image-rendering: pixelated; flex: none; }
.btn-gold { color: #3b2a05; border-color: #e7a93a; background: linear-gradient(#ffe08c, #ffcc59 55%, #ffb63e);
  box-shadow: inset 0 1px 0 #fff4cf, 0 3px 10px rgba(255, 170, 69, .35); }
.btn-gold:hover:not(:disabled) { border-color: #d99620; filter: brightness(1.04); box-shadow: inset 0 1px 0 #fff4cf, 0 6px 16px rgba(255, 170, 69, .45); }
.btn-blue { color: #fff; border-color: #1b7be6; background: linear-gradient(#4aa6ff, var(--blue) 60%, #1b7ef0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 10px rgba(35, 140, 255, .3); }
.btn-blue:hover:not(:disabled) { border-color: #146bd0; filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 16px rgba(35, 140, 255, .4); }
.btn-danger { color: var(--red); border-color: #f5b7ba; }
.btn-danger:hover:not(:disabled) { border-color: var(--red); background: #fff6f6; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn[aria-pressed="true"] { box-shadow: var(--ring); }

/* --- Inputs & selects --- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input, .select { height: 42px; width: 100%; padding: 0 14px; font: 700 15px var(--font); color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; font-variant-numeric: tabular-nums;
  transition: border-color var(--t), box-shadow var(--t); }
.input:hover, .select:hover { border-color: var(--line-hover); }
.input:focus-visible, .select:focus-visible { border-color: var(--blue); box-shadow: var(--ring); }
.select { appearance: none; cursor: pointer; padding-right: 34px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='14' viewBox='0 0 12 14' fill='none' stroke='%2358729d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 5 3-3 3 3M3 9l3 3 3-3'/%3E%3C/svg%3E") right 12px center no-repeat; }

/* --- Tooltips (any element with data-tip; only laid out while shown) --- */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); display: none; position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 20;
  width: max-content; max-width: 240px; padding: 8px 11px; border-radius: 9px; pointer-events: none;
  background: var(--text); color: #fff; font: 600 12px/1.4 var(--font); box-shadow: 0 8px 20px rgba(20, 45, 89, .25); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; animation: rise var(--t) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

/* --- Card --- */
.card { position: relative; min-width: 0; display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  transition: border-color var(--t), box-shadow var(--t); }
.card:hover { border-color: #b9d6f3; box-shadow: var(--shadow-hover); }
.card-head { position: relative; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 16px 20px 12px;
  border-radius: var(--r-lg) var(--r-lg) 0 0; overflow: hidden;
  background: linear-gradient(90deg, #fff 30%, rgba(234, 246, 255, .9)); }
.card-head > :not(.scene) { position: relative; z-index: 1; }
.card-ico { flex: none; width: 46px; height: 46px; display: grid; place-items: center; }
.card-ico img { image-rendering: pixelated; }
/* The title block keeps clear of the corner vignette; long subtitles wrap instead of running under it. */
.card-title { min-width: 0; }
.card-head:has(.scene) .card-title { flex: 1; }
.card-head:has(.scene) .card-title h2 { white-space: nowrap; }
.card-head:has(.scene) .card-title p { max-width: 57%; } /* wraps before the opaque part of the vignette */
.card-title h2 { font: 900 21px/1.15 var(--font); color: var(--text); letter-spacing: -.005em; }
.card-title p { margin-top: 3px; font-size: 13px; font-weight: 700; color: var(--text-2); text-shadow: 0 0 3px #fff, 0 0 6px #fff; }
/* Little landscape in the corner of each card header, fading into the card. */
.scene { position: absolute; right: 0; bottom: 0; height: 100%; width: 46%; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%); mask-image: linear-gradient(90deg, transparent, #000 40%); }
.scene::before { content: ""; position: absolute; inset: 0; background: linear-gradient(#cdebff, #eef8ff 80%); }
/* The vignette's ground ledge sits on the card header's bottom edge; its empty left part fades out. */
.scene img { position: absolute; right: -4px; bottom: -10px; height: 92px; width: auto; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 20px 20px; }

/* --- Stat tile (icon + label + big number) --- */
.stat { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 14px 16px; border-radius: var(--r);
  background: var(--card-soft); border: 1px solid #dfeaf7; transition: border-color var(--t), background var(--t); }
.stat:hover { border-color: var(--line-hover); background: #f9fbff; }
.stat-ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; }
.stat-ico img { image-rendering: pixelated; }
.stat-text { min-width: 0; flex: 1; }
/* Labels wrap rather than clip: clipping (overflow: hidden) would also cut off their hover tooltip. */
.stat-label { display: block; font-size: 13px; font-weight: 700; line-height: 1.25; color: var(--text-2); }
.stat-value { display: block; margin-top: 2px; font: 900 25px/1.15 var(--font); font-variant-numeric: tabular-nums;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--t); }
.stat-sub { display: block; margin-top: 1px; font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.is-blue .stat-value { color: var(--blue); }
.stat.is-green .stat-value { color: var(--green); }
.stat.is-red .stat-value { color: var(--red); }
.stat.is-neg .stat-value { color: var(--red); }
/* Stacked tile (EXP card): label on top, then icon + number, then the detail line. */
.stat.stack { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "label label" "icon value" "sub sub";
  align-items: center; column-gap: 10px; row-gap: 6px; }
.stat.stack .stat-head { display: contents; }
.stat.stack .stat-head > :first-child { grid-area: icon; }
.stat.stack .stat-label { grid-area: label; text-align: center; }
.stat.stack .stat-value { grid-area: value; margin: 0; }
.stat.stack .stat-sub { grid-area: sub; }
.bump { animation: bump .7s var(--ease); }
@keyframes bump { 0% { transform: translateY(-2px); filter: brightness(1.25); } 100% { transform: none; filter: none; } }

/* EXP badge icon (the game's blue EXP tag) */
.exp-tag { display: inline-grid; place-items: center; width: 34px; height: 22px; border-radius: 4px;
  font: 900 11px/1 var(--font); color: #fff; letter-spacing: .02em; background: linear-gradient(#3f8cff, #1756c9);
  border: 2px solid #0f3c8f; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45); }

/* --- Progress (RPG EXP bar, modern) --- */
.xp { position: relative; height: 14px; border-radius: 99px; background: #e3ebf5; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(20, 45, 89, .12); }
.xp-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, #3fb7ff, #34c48a 70%, var(--green)); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08), inset 0 2px 0 rgba(255, 255, 255, .35);
  transition: width .8s var(--ease); }
.xp::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255, 255, 255, .5) calc(10% - 1px) 10%); }

/* --- Status dot --- */
.dot { width: 18px; height: 18px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, #c9d2de, #8d99aa);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
.dot.is-on { background: radial-gradient(circle at 35% 30%, #8ff0b2, var(--green)); animation: glow 2s ease-in-out infinite; }
.dot.is-paused { background: radial-gradient(circle at 35% 30%, #ffe39a, #f2b030); }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(52, 185, 106, .18); } }

/* ===================== Header ===================== */
.top { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 20px; padding-bottom: 22px; min-height: 172px; align-items: flex-start; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-leaf { image-rendering: pixelated; zoom: 3; filter: drop-shadow(0 1px 0 rgba(90, 20, 0, .35)); }
.brand-name { font: 700 52px/1 var(--font-logo); letter-spacing: .01em; color: #fff; white-space: nowrap;
  --o: #4a1d06; text-shadow: 3px 0 var(--o), -3px 0 var(--o), 0 3px var(--o), 0 -3px var(--o), 3px 3px var(--o), -3px 3px var(--o),
    3px -3px var(--o), -3px -3px var(--o), 0 6px 0 rgba(74, 29, 6, .55); }
.brand-name em { font-style: normal; color: #ffb52e; }
.brand-sub { display: block; margin-top: 8px; font-size: 15px; font-weight: 800; color: var(--text);
  text-shadow: 0 0 2px #fff, 0 0 4px #fff, 0 0 8px #fff, 0 0 12px rgba(255, 255, 255, .9); }
.brand-slime { align-self: flex-end; margin: 0 0 -6px -8px; image-rendering: pixelated; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }

/* ===================== Session bar ===================== */
.session { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .94); border: 1px solid var(--line); box-shadow: var(--shadow); }
.npc { flex: none; display: flex; flex-direction: column; align-items: center; width: 130px; }
.npc img { image-rendering: pixelated; }
.npc-sign { margin-top: -2px; padding: 3px 9px; border-radius: 4px; white-space: nowrap; font: 800 11px/1.2 var(--font); color: #fff3d6;
  background: linear-gradient(#b07a43, #8a5a2b); border: 1px solid #4f3013; box-shadow: inset 0 1px 0 rgba(255, 225, 170, .45), 0 2px 0 rgba(79, 48, 19, .35);
  text-shadow: 0 1px 0 #4f3013; }
.dialog { position: relative; flex: 1; min-width: 0; padding: 14px 18px; border-radius: 12px;
  background: linear-gradient(#fffdf6, #fff8e7); border: 1.5px solid #ecd39b; box-shadow: 0 2px 6px rgba(160, 120, 40, .1); }
.dialog::before, .dialog::after { content: ""; position: absolute; top: 50%; border-style: solid; border-color: transparent; }
.dialog::before { left: -13px; margin-top: -9px; border-width: 9px 13px 9px 0; border-right-color: #ecd39b; }
.dialog::after { left: -10px; margin-top: -7px; border-width: 7px 11px 7px 0; border-right-color: #fffaee; }
#status { font-size: 14px; font-weight: 600; color: var(--text); transition: color var(--t); }
#status b { font-weight: 900; }
#status.ok { color: #1f7a45; } #status.warn { color: #9a6400; } #status.err { color: #c0323a; }
.dialog.flash { animation: flash .7s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 5px rgba(255, 204, 89, .55); } 100% { box-shadow: 0 2px 6px rgba(160, 120, 40, .1); } }
.pill { display: flex; align-items: center; gap: 12px; flex: none; padding: 10px 16px; border-radius: 12px;
  background: #fff; border: 1px solid #dfeaf7; min-width: 168px; }
.pill b { display: block; font-size: 13.5px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.pill small { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); }
.pill .clock-time { font-size: 17px; }
.session-actions { display: flex; gap: 10px; flex: none; }

/* ===================== Dashboard ===================== */
.dashboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.span-all { grid-column: 1 / -1; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* Experience: next level */
.level { padding: 14px 16px 12px; border-radius: var(--r); background: var(--card-soft); border: 1px solid #dfeaf7; display: grid; gap: 8px; }
.level-row { display: flex; align-items: center; gap: 12px; }
.level-row .lv { flex: 1; min-width: 0; }
.level-row .lv small { display: block; font-size: 13px; font-weight: 800; color: var(--text); }
.level-row .lv b { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; color: var(--text); }
.level-row .lv b .arrow { color: var(--muted); }
.level-pct { font: 900 17px var(--font); color: var(--text); font-variant-numeric: tabular-nums; }
.level-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Potions */
.pots { display: grid; gap: 10px; }
.pot { display: grid; grid-template-columns: auto minmax(0, 1fr) 48px 92px 66px; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--r); background: var(--card-soft); border: 1px solid #dfeaf7;
  transition: border-color var(--t), background var(--t); }
.pot:hover { border-color: var(--line-hover); background: #f9fbff; }
.pot.is-top { border-color: #ffd28a; }
.slot { position: relative; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 12px;
  background: linear-gradient(#fbfdff, #e6eef8); border: 1px solid #c9d9ec; box-shadow: inset 0 1px 0 #fff, 0 2px 4px rgba(20, 45, 89, .08); }
.slot img { image-rendering: pixelated; zoom: 1.5; }
/* Quickslot key as a small tag on the slot corner, clear of the icon. */
.slot .key { position: absolute; left: -7px; top: -7px; z-index: 1; padding: 2px 6px; border-radius: 6px; font: 900 10.5px/1.2 var(--font);
  color: #fff; background: var(--text); box-shadow: 0 1px 3px rgba(20, 45, 89, .3); letter-spacing: .02em; }
.slot.is-empty img { filter: grayscale(1); opacity: .45; }
.pot-name b { display: block; font-size: 15.5px; font-weight: 900; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pot-name small { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pot-name small.left { font-size: 11.5px; color: var(--muted); }
.pot-col { display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.pot-col b { font-size: 16px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; line-height: 42px; }
.pot-col .total { color: var(--green); }
.pot-col .input { height: 42px; padding: 0 12px; }
.top-tag { margin-left: 6px; padding: 1px 7px; border-radius: 99px; font-size: 10.5px; font-weight: 800; color: #9a5a00; background: #fff1d6; border: 1px solid #ffd28a; vertical-align: 2px; }
.pots-hint { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Price checker */
.card-price .card-body { align-items: center; }
#priceBody { width: 100%; max-width: 420px; }

/* Chart */
.chart-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 16px 20px 6px; }
.chart-head .card-title { flex: 1; min-width: 240px; }
.seg { display: inline-flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--card-soft); border: 1px solid #dfeaf7; }
.seg button { height: 34px; padding: 0 14px; font: 800 13px var(--font); color: var(--text-2); background: transparent; border: 1px solid transparent;
  border-radius: 9px; cursor: pointer; transition: background var(--t), color var(--t), border-color var(--t); }
.seg button:hover { background: #fff; border-color: var(--line); color: var(--text); }
.seg button[aria-checked="true"] { color: #fff; background: linear-gradient(#4aa6ff, var(--blue)); border-color: #1b7be6; box-shadow: 0 2px 6px rgba(35, 140, 255, .3); }
.chart-stats { display: flex; border-radius: var(--r); background: var(--card-soft); border: 1px solid #dfeaf7; }
.chart-stats > div { display: flex; align-items: center; gap: 10px; padding: 9px 18px; min-width: 128px; }
.chart-stats > div + div { border-left: 1px solid #dfeaf7; }
.chart-stats small { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.chart-stats b { display: block; font-size: 15px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; padding: 4px 20px 16px; }
#chart { display: block; width: 100%; height: 230px; }
.chart-empty { position: absolute; inset: 0 20px 30px; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; pointer-events: none; }
.chart-empty img { image-rendering: pixelated; margin-bottom: 4px; }
.chart-empty b { font-size: 15px; font-weight: 800; color: var(--text-2); }
.chart-empty span { font-size: 13px; font-weight: 600; color: var(--muted); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; padding: 8px 11px; border-radius: 10px; white-space: nowrap;
  background: var(--text); color: #cfe0f7; font-size: 12px; font-weight: 600; box-shadow: 0 8px 20px rgba(20, 45, 89, .25);
  transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity var(--t); font-variant-numeric: tabular-nums; }
.chart-tip b { display: block; color: #fff; font-size: 14px; font-weight: 900; }
.chart-tip.show { opacity: 1; }

/* Settings */
.settings { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(280px, 360px); gap: 18px 24px; align-items: end; padding: 16px 20px 20px; }
.settings .card-head { grid-column: 1 / -1; padding: 0; min-height: 0; background: none; overflow: visible; }
.set-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; grid-column: 1 / 3; }
.set-controls .field { width: 128px; }
.set-controls .btn { height: 42px; padding: 0 14px; }
.file-btn input { display: none; }
.diag { grid-column: 3; align-self: stretch; }
.diag summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; height: 100%; min-height: 64px; padding: 10px 16px;
  border-radius: var(--r); background: var(--card-soft); border: 1px solid #dfeaf7; transition: border-color var(--t); }
.diag summary:hover { border-color: var(--line-hover); }
.diag summary::-webkit-details-marker { display: none; }
.diag summary b { display: block; font-size: 14px; font-weight: 900; color: var(--text); }
.diag summary small { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.diag summary .chev { margin-left: auto; color: var(--text-2); transition: transform var(--t); }
.diag[open] summary .chev { transform: rotate(90deg); }
.diag-body { grid-column: 1 / -1; padding: 14px 16px; border-radius: var(--r); background: var(--card-soft); border: 1px solid #dfeaf7; }
.diag-body p { font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
#cropView { max-width: 100%; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#rawText { margin: 8px 0 0; max-height: 140px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--text-2); }
#rawText:empty::before { content: "Nenhuma leitura ainda."; color: var(--muted); }

/* Plain text in the sky just above the meadow, so the grass strip stays clear. */
.credits { position: relative; z-index: 2; margin: 14px auto 132px; width: fit-content; max-width: calc(100% - 32px);
  font-size: 10.5px; font-weight: 600; color: var(--muted); opacity: .85; text-align: center; text-shadow: 0 1px 0 rgba(255, 255, 255, .8); }
.credits a { color: var(--blue); }

/* Manual region picker */
#picker { display: none; position: fixed; inset: 0; z-index: 50; padding: 16px; overflow: auto; background: rgba(10, 25, 50, .8); }
#picker.open { display: block; }
#picker p { color: #fff; margin: 0 0 8px; font-weight: 700; }
#pickCanvas { max-width: 100%; cursor: crosshair; border: 1px solid #888; }

/* ===================== Responsive ===================== */
/* Cards follow their own width: narrow in three columns, wide when stacked. */
.card-exp, .card-mesos, .card-pots { container-type: inline-size; }
@container (max-width: 400px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
}
/* Slightly narrow potion card: tighter columns so the item name still fits on one row. */
@container (max-width: 470px) {
  .pot { grid-template-columns: auto minmax(0, 1fr) 38px 82px 54px; gap: 8px; }
  .pot-name b { white-space: normal; line-height: 1.2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
}
@container (max-width: 400px) {
  .pot { grid-template-columns: auto minmax(0, 1fr) 96px; grid-template-areas: "slot name name" "slot qty price" "slot total total"; row-gap: 6px; }
  .pot > .slot { grid-area: slot; align-self: start; }
  .pot > .pot-name { grid-area: name; }
  .pot > .q { grid-area: qty; } .pot > .p { grid-area: price; } .pot > .t { grid-area: total; }
  .pot-col { grid-template-columns: auto 1fr; align-items: center; }
  .pot-col b { line-height: 1.3; }
}
@container (max-width: 400px) {
  .stat { padding: 12px; gap: 10px; }
  .stat-value { font-size: 22px; }
  .scene { width: 45%; opacity: .7; }
}
@media (max-width: 1320px) {
  .settings { grid-template-columns: 1fr 1fr; }
  .set-controls { grid-column: 1 / -1; }
  .diag { grid-column: 1 / -1; }
}
@media (max-width: 1180px) {
  .brand-leaf { zoom: 2; }
  .brand-name { font-size: 40px; }
  .btn { padding: 0 14px; }
  .dashboard { grid-template-columns: 1fr 1fr; }
  .card-pots { grid-column: 1 / -1; }
  .session { flex-wrap: wrap; }
  .dialog { flex-basis: calc(100% - 150px); }
  .session-state { margin-left: 146px; }
}
@media (max-width: 900px) {
  .top { flex-direction: column; align-items: flex-start; min-height: 0; }
  .actions { justify-content: flex-start; }
  .brand-name { font-size: 42px; }
  .chart-stats { width: 100%; }
  .chart-stats > div { flex: 1; min-width: 0; padding: 9px 12px; }
}
@media (max-width: 800px) {
  .dashboard { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .brand-leaf { zoom: 2; }
  .brand-name { font-size: 34px; }
  .brand-sub { font-size: 13px; }
  .brand-slime { display: none; }
  .scene { width: 32%; opacity: .8; }
  .actions { margin-bottom: 4px; }
  .actions .btn { flex: 1 1 auto; }
  .session { padding: 12px; }
  .npc { width: 100%; flex-direction: row; gap: 10px; justify-content: flex-start; }
  .dialog { flex-basis: 100%; }
  .dialog::before, .dialog::after { display: none; }
  .session-state { margin-left: 0; }
  .pill { flex: 1 1 140px; min-width: 0; }
  .session-actions { width: 100%; }
  .session-actions .btn { flex: 1; }
  .seg { width: 100%; } .seg button { flex: 1; padding: 0 6px; }
  #chart { height: 200px; }
  .set-controls .field { width: calc(50% - 6px); }
  .set-controls .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .001s !important; }
}

.pot-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Narrow EXP card: the icon joins the label row so the number gets the full tile width. */
@container (max-width: 520px) {
  .stat.stack { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon label" "value value" "sub sub"; padding: 12px; row-gap: 4px; }
  .stat.stack .stat-label { text-align: left; white-space: normal; font-size: 12px; line-height: 1.2; }
  .stat.stack .stat-head > :first-child { transform: scale(.8); transform-origin: left center; }
}

/* Footer monsters: walk from --a to --b facing right, turn around, walk back. Sprites face left, hence the flip. */
.meadow .walker { bottom: 36px; left: var(--a); animation: stroll linear infinite; } /* left: where they stand with reduced motion */
@keyframes stroll {
  0% { left: var(--a); transform: scaleX(-1); } 49.9% { left: var(--b); transform: scaleX(-1); }
  50% { left: var(--b); transform: scaleX(1); } 100% { left: var(--a); transform: scaleX(1); }
}

/* The game's own UI buttons (UI/Basic.img BtUP, BtMin, BtDown; 12×12), shown at exactly 2× so the pixels stay square. */
.game-arrow { flex: none; width: 24px; height: 24px; margin: 0 5px; image-rendering: pixelated; }
/* Level as on the game's status bar: the "LV." plate (UI/StatusBar.img/base/backgrnd2) with the number in its dark slot. */
.lv-badge { position: relative; display: inline-block; width: 74px; height: 30px; flex: none;
  background: url(assets/icons/game-lv.png) no-repeat; image-rendering: pixelated; }
.lv-badge span { position: absolute; left: 37px; top: 0; width: 35px; line-height: 30px; text-align: center;
  font: 900 14px/30px var(--font); color: #fff; font-variant-numeric: tabular-nums; }
.level-row .lv b { gap: 10px; margin-top: 3px; }
