/* Maple Classic Tracker: an evening sky over cream "paper" panels with wooden title bars. */
:root {
  --sky-1: #241b45;
  --sky-2: #4c2f63;
  --sky-3: #9a4d6c;
  --sky-4: #e5895a;
  --on-sky: #fbefdc;
  --on-sky-soft: #e9cfb4;

  --paper: #fff8ea;
  --paper-2: #f8ead0;
  --paper-3: #f1dcb6;
  --ink: #3b2817;
  --ink-soft: #85694c;
  --wood: #84502a;
  --wood-dark: #5b3519;
  --gold: #f3bd4f;

  --accent: #ff8c2e;
  --accent-dark: #c4601a;
  --exp: #e58a12;
  --meso: #c99a0f;
  --pot: #d4473e;
  --good: #2c9a58;
  --bad: #d4473e;

  /* names used by the charts and older rules */
  --panel: var(--paper);
  --panel2: var(--paper-2);
  --line: #ead3ab;
  --text: var(--ink);
  --muted: var(--ink-soft);
  --bg: var(--sky-1);

  --radius: 16px;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--sky-1); }
body {
  margin: 0; min-height: 100vh; color: var(--on-sky); font: 600 14px/1.45 var(--font-body);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 32%, var(--sky-3) 68%, var(--sky-4) 100%) fixed;
}
a { color: var(--accent-dark); font-weight: 800; }

/* ---------- the sky behind everything ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sky::before { /* stars */
  content: ''; position: absolute; inset: 0 0 40% 0; opacity: .8;
  background-image:
    radial-gradient(1.5px 1.5px at 8% 12%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 22% 28%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 37% 8%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 51% 22%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 66% 10%, #ffe9c2 50%, transparent 51%), radial-gradient(1px 1px at 78% 30%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 91% 16%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 14% 44%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 59% 40%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 85% 48%, #fff 50%, transparent 51%);
  animation: twinkle 6s ease-in-out infinite alternate;
}
.sky::after { /* rolling hills along the bottom */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 22vh; min-height: 140px;
  background:
    radial-gradient(120% 90% at 20% 100%, #3a2440 60%, transparent 61%),
    radial-gradient(90% 80% at 75% 100%, #4a2b45 60%, transparent 61%),
    radial-gradient(140% 70% at 50% 110%, #2c1c33 62%, transparent 63%);
}
.cloud { position: absolute; width: 260px; height: 70px; border-radius: 999px; background: #fff; opacity: .09; filter: blur(2px); animation: drift linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 120px; height: 100px; left: 40px; top: -45px; }
.cloud::after { width: 90px; height: 80px; left: 130px; top: -30px; }
.cloud.c1 { top: 12%; animation-duration: 140s; animation-delay: -30s; }
.cloud.c2 { top: 34%; transform: scale(.7); animation-duration: 180s; animation-delay: -110s; }
.cloud.c3 { top: 58%; transform: scale(1.2); animation-duration: 220s; animation-delay: -60s; opacity: .06; }
.fall { position: absolute; top: -40px; font-size: 18px; opacity: .55; animation: fall linear infinite; }
.fall.f1 { left: 8%; animation-duration: 19s; animation-delay: -4s; }
.fall.f2 { left: 31%; animation-duration: 24s; animation-delay: -15s; font-size: 14px; }
.fall.f3 { left: 57%; animation-duration: 21s; animation-delay: -9s; }
.fall.f4 { left: 79%; animation-duration: 27s; animation-delay: -2s; font-size: 13px; }
.fall.f5 { left: 93%; animation-duration: 23s; animation-delay: -18s; }
@keyframes drift { from { left: -320px; } to { left: 110%; } }
@keyframes fall { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(40px, 55vh) rotate(200deg); } 100% { transform: translate(-20px, 110vh) rotate(400deg); } }
@keyframes twinkle { from { opacity: .45; } to { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .cloud, .fall, .sky::before { animation: none; } .fall { display: none; } }

.topbar, nav.tabs, main, .foot { position: relative; z-index: 1; }

/* ---------- controls ---------- */
button, .btn {
  font: 800 14px/1 var(--font-body); color: var(--ink); background: var(--paper); border: 2px solid var(--paper-3);
  border-radius: 999px; padding: 9px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .08s, filter .15s, background .15s; white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(1px); }
button.primary { background: linear-gradient(180deg, #ffa24a, var(--accent)); border-color: var(--accent-dark); color: #fff; text-shadow: 0 1px 0 #b0520f; box-shadow: 0 3px 0 var(--accent-dark); }
button.primary:active { box-shadow: 0 1px 0 var(--accent-dark); }
button.ghost, .btn.ghost { background: transparent; border-color: var(--paper-3); }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--accent-dark); text-decoration: underline; box-shadow: none; }
button.small { padding: 5px 11px; font-size: 12px; }
/* Buttons sitting on the sky rather than on paper */
.topbar button:not(.primary), .topbar .btn, .session-actions button:not(.primary) { background: #2f2216cc; border-color: #8a6440; color: #f1d9b6; }
.topbar .btn.ghost { background: transparent; }
input, select {
  font: 700 14px/1.2 var(--font-body); color: var(--ink); background: #fffdf7; border: 2px solid var(--paper-3);
  border-radius: 10px; padding: 7px 10px;
}
input:focus, select:focus, button:focus-visible { outline: 3px solid #ffb877; outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; }

/* ---------- header and tabs ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 18px 28px 10px; flex-wrap: wrap; max-width: 1240px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.leaf { font-size: 34px; filter: drop-shadow(0 3px 6px #0006); animation: sway 5s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes sway { 50% { transform: rotate(-12deg); } }
.brand-name { font: 700 26px/1 var(--font-head); color: #fff; letter-spacing: .01em; }
.brand-name b { color: var(--gold); font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--on-sky-soft); margin-top: 3px; }
.source { display: flex; gap: 8px; flex-wrap: wrap; }
.right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: #2f2216cc; border: 2px solid #8a6440; color: #f1d9b6; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #b9a58c; }
.pill.ok { border-color: #3f8f5c; } .pill.ok::before { background: #5fe08d; }
.pill.warn { border-color: #b78a2c; } .pill.warn::before { background: var(--gold); }
.pill.live { background: #1f6b3e; border-color: #5fe08d; color: #eafff1; } .pill.live::before { background: #8dffb4; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.tabs { display: flex; gap: 8px; padding: 6px 28px 0; max-width: 1240px; margin: 0 auto; flex-wrap: wrap; }
.tabs button {
  flex-direction: column; gap: 3px; min-width: 84px; padding: 9px 12px 8px; border-radius: 14px; font-size: 12px;
  background: #2f2216aa; border: 2px solid #6e4e33; color: #e7cba5; box-shadow: none; position: relative;
}
.tabs button .ti { font-size: 20px; line-height: 1; filter: saturate(.8); }
.tabs button.active { background: var(--paper); border-color: var(--gold); color: var(--accent-dark); box-shadow: 0 4px 0 #c99a4a; }
.tabs button.active .ti { filter: none; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; display: grid; place-items: center; background: var(--bad); color: #fff; border: 2px solid #fff3; border-radius: 999px; padding: 0 5px; font-size: 11px; font-weight: 900; }

main { padding: 18px 28px 8px; max-width: 1240px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(6px); } }

/* ---------- paper panels with a wooden title bar ---------- */
.panel {
  background: var(--paper); color: var(--ink); border: 3px solid #e8c88e; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; min-width: 0; overflow-x: auto;
  box-shadow: 0 10px 24px #1d10224d, inset 0 0 0 2px #fffaf0;
}
.panel h2 { font: 700 13px/1.2 var(--font-head); text-transform: uppercase; letter-spacing: .08em; color: var(--wood); margin: 0 0 10px; }
.panel > h2:first-child, .panel > .panel-head:first-child {
  margin: -14px -16px 14px; padding: 10px 16px; background: linear-gradient(180deg, #93603a, var(--wood) 55%, #72411f);
  color: #fff1d8; border-bottom: 3px solid var(--wood-dark); border-radius: 12px 12px 0 0; text-shadow: 0 1px 0 #4a2a12;
}
.panel > h2:first-child::before, .panel > .panel-head:first-child h2::before { content: '🍁'; margin-right: 8px; font-size: 13px; text-shadow: none; }
.panel > .panel-head:first-child h2 { color: inherit; margin: 0; }
.panel > .panel-head:first-child button { background: #fff1d822; border-color: #f3d9b077; color: #fff1d8; text-shadow: none; box-shadow: none; }
.panel > .panel-head:first-child .muted { color: #f1d7b3; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.mt { margin-top: 14px !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }

.banner, .help, .goal, .race { position: relative; }
.banner { background: #fff1d4; color: #6b3d12; border: 3px solid var(--gold); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; box-shadow: 0 8px 18px #1d10223d; }

/* ---------- session bar ---------- */
.session { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.session-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.session-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.elapsed { font: 700 30px/1 var(--font-head); color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px #0005; min-width: 112px; }
.map-input { width: 230px; max-width: 100%; }
.job-input { width: 140px; }

/* ---------- stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.card {
  position: relative; background: var(--paper); color: var(--ink); border: 3px solid #e8c88e; border-radius: var(--radius);
  padding: 12px 14px 12px; min-width: 0; overflow: hidden; box-shadow: 0 10px 22px #1d10224d;
}
.card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--c, var(--accent)); }
.card.exp { --c: linear-gradient(90deg, #f5b631, #e58a12); }
.card.meso { --c: linear-gradient(90deg, #f4d35e, #c99a0f); }
.card.pot { --c: linear-gradient(90deg, #f07a6a, #d4473e); }
.card.net { --c: linear-gradient(90deg, #6ddc8f, #2c9a58); }
.card .label { display: flex; align-items: center; gap: 6px; color: var(--wood); font: 700 11px/1.2 var(--font-head); text-transform: uppercase; letter-spacing: .07em; margin-top: 4px; }
.card .label .ci { font-size: 15px; }
.card .value { font: 700 30px/1.15 var(--font-head); font-variant-numeric: tabular-nums; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.card .value.good { color: var(--good); }
.card .value.bad { color: var(--bad); }
.card .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.nudge { animation: nudge 1.2s ease-in-out infinite; }
.card.nudge .sub { color: var(--bad); font-weight: 800; }
@keyframes nudge { 50% { border-color: var(--bad); box-shadow: 0 0 0 4px #d4473e55, 0 10px 22px #1d10224d; } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid2 .panel, .grid3 .panel { margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; }
.stats dt, .stats dd { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.stats dd { padding-left: 16px; }
.stats dt { color: var(--muted); font-weight: 700; }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 900; }
.stats dt:last-of-type, .stats dd:last-of-type { border-bottom: 0; }

.share { margin-top: 12px; }
.share-bar { height: 12px; background: #cfeedd; border: 2px solid #a8d9bb; border-radius: 999px; overflow: hidden; }
.share-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f07a6a, var(--pot)); transition: width .4s; }
.share-text { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------- tables ---------- */
table.items { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.items th { text-align: left; color: var(--wood); font: 700 11px/1.2 var(--font-head); text-transform: uppercase; letter-spacing: .06em; padding: 8px; background: var(--paper-2); border-bottom: 2px solid var(--line); }
.items th:first-child { border-radius: 10px 0 0 10px; } .items th:last-child { border-radius: 0 10px 10px 0; }
.items td { padding: 8px; border-bottom: 1px dashed var(--line); font-weight: 700; }
.items tr:last-child td { border-bottom: 0; }
.items input.price { width: 90px; }
.items .num { text-align: right; }
.items .item-name { display: flex; align-items: center; gap: 8px; }
.items canvas, .items img { width: 30px; height: 30px; image-rendering: pixelated; border-radius: 8px; border: 2px solid var(--line); background: #fff; }
.history tr.open-row { cursor: pointer; }
.history tr.open-row:hover td { background: #fff1d4; }

.chart { width: 100%; height: 220px; display: block; }

/* ---------- what it sees ---------- */
.detect-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.detect-grid .panel { margin-bottom: 16px; }
.preview { width: 100%; display: block; background: #1d1424; border-radius: 10px; aspect-ratio: 16 / 9; border: 2px solid var(--line); }
.readings { display: grid; grid-template-columns: auto 1fr; gap: 0; align-items: center; }
.readings .k, .readings .v { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.readings .v { padding-left: 12px; }
.readings .k { color: var(--muted); font-weight: 700; }
.readings .v { font-variant-numeric: tabular-nums; font-weight: 900; }
.readings .v.miss { color: var(--muted); font-weight: 600; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot { background: var(--paper-2); border: 2px solid var(--line); border-radius: 12px; padding: 6px; text-align: center; font-size: 12px; min-width: 0; }
.slot canvas { width: 40px; height: 40px; image-rendering: pixelated; display: block; margin: 0 auto 4px; border-radius: 6px; }
.slot .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.slot .count { color: var(--muted); }
.slot button { margin-top: 4px; }
.new-item { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #fff1d4; border: 2px solid var(--gold); border-radius: 12px; padding: 10px; margin-top: 10px; }
.new-item img { image-rendering: pixelated; border-radius: 8px; }
.new-item input[name=name] { width: 160px; }
.guesses { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.new-item input[name=price] { width: 90px; }
.events { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.events li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.events li:last-child { border-bottom: 0; }

/* ---------- read helper, race, goal ---------- */
.help { display: flex; gap: 14px; align-items: flex-start; background: #fff0ec; color: var(--ink); border: 3px solid #e7897f; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; box-shadow: 0 10px 24px #1d10224d; }
.help-pic { width: 200px; max-width: 40%; aspect-ratio: 16 / 9; background: #1d1424; border-radius: 10px; flex: none; }
.help-body strong { font: 700 17px/1.2 var(--font-head); color: #a8322a; }
.help-body p { margin: 4px 0 10px; }
.help-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.race {
  display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 18px; align-items: center; color: var(--ink);
  background: linear-gradient(90deg, #fff4dc, var(--paper)); border: 3px solid var(--gold); border-radius: var(--radius);
  padding: 12px 18px; margin-bottom: 16px; box-shadow: 0 10px 24px #1d10224d;
}
.race-title { font: 700 15px/1.2 var(--font-head); color: var(--wood); }
.race-title::before { content: '🏁 '; }
.race-lead { font: 700 28px/1.2 var(--font-head); font-variant-numeric: tabular-nums; }
.race-bars { display: grid; gap: 8px; }
.race-row { display: grid; grid-template-columns: 64px 1fr 76px; gap: 10px; align-items: center; font-size: 12px; font-weight: 800; }
.race-row em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; }
.race-track { height: 14px; background: var(--paper-2); border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.race-track span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f5b631, var(--exp)); transition: width .5s; }
.race-row.ghost .race-track span { background: repeating-linear-gradient(45deg, #c9b296 0 6px, #b59a7b 6px 12px); }
.race.new-record { border-color: var(--good); box-shadow: 0 0 0 4px #2c9a5844, 0 10px 24px #1d10224d; }
.race.new-record .race-title::before { content: '🏆 '; }
.goal { background: var(--paper); color: var(--ink); border: 3px solid #e8c88e; border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; box-shadow: 0 10px 24px #1d10224d; }
.goal::before { content: '🎯'; font-size: 18px; margin-right: 4px; }
.goal b { color: var(--accent-dark); }

/* ---------- history ---------- */
.mini { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.mini td { padding: 6px 0; border-bottom: 1px dashed var(--line); font-weight: 700; }
.mini tr:last-child td { border-bottom: 0; }
.mini td.num { text-align: right; padding-left: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.tile { background: var(--paper-2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.tile .label { color: var(--wood); font: 700 11px/1.2 var(--font-head); text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font: 700 20px/1.3 var(--font-head); font-variant-numeric: tabular-nums; }
.edit-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 8px; font-weight: 800; color: var(--muted); }
.compare td:nth-child(2), .compare td:nth-child(3) { text-align: right; }
.compare .win { color: var(--good); font-weight: 900; }

/* ---------- timers and settings ---------- */
form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.boss { border-bottom: 1px dashed var(--line); padding: 10px 0; }
.boss-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.boss-head strong { font: 700 16px/1.2 var(--font-head); }
.boss-head button { margin-left: auto; }
.kills { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.settings input[name=killExp] { width: 130px; }
.settings .panel { display: grid; gap: 10px; align-content: start; }
.settings label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 800; }
.settings input[type=number] { width: 90px; }
.settings input.wide { flex: 1; min-width: 220px; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
code { background: #2f2216; color: #ffe2b3; border-radius: 10px; padding: 8px 12px; display: inline-block; user-select: all; font-weight: 700; }

/* ---------- toast and share picture ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; gap: 12px; align-items: center;
  background: linear-gradient(180deg, #93603a, var(--wood)); color: #fff1d8; border: 3px solid var(--wood-dark); padding: 10px 16px;
  border-radius: 14px; box-shadow: 0 10px 30px #0008; font-weight: 800; animation: rise .2s ease-out;
}
.toast button { background: var(--paper); color: var(--ink); }
.modal { position: fixed; inset: 0; background: #12091aa8; backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal-box { background: var(--paper); border: 3px solid var(--gold); border-radius: var(--radius); padding: 14px; max-width: 780px; width: 100%; box-shadow: 0 20px 50px #000a; }
.modal-box canvas { width: 100%; height: auto; border-radius: 10px; display: block; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.foot { color: var(--on-sky-soft); font-size: 12px; text-align: center; padding: 14px 20px 30px; max-width: 900px; margin: 0 auto; opacity: .85; }

/* ---------- stats card: pop-out window and OBS overlay ---------- */
.stat-card {
  background: var(--paper); color: var(--ink); border: 3px solid #e8c88e; border-radius: var(--radius); overflow: hidden;
  font: 700 14px/1.4 var(--font-body); max-width: 360px; box-shadow: 0 10px 24px #1d10224d;
}
.card-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: linear-gradient(180deg, #93603a, var(--wood) 55%, #72411f); color: #fff1d8; border-bottom: 3px solid var(--wood-dark); }
.card-top button { background: #fff1d822; border: 2px solid #f3d9b077; color: #fff1d8; box-shadow: none; text-shadow: none; padding: 3px 10px; }
.card-level { font: 700 16px/1 var(--font-head); color: var(--gold); }
.card-map { color: #f1d7b3; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-time { font: 700 15px/1 var(--font-head); font-variant-numeric: tabular-nums; }
.card-bar { position: relative; height: 16px; margin: 10px 12px 8px; background: #e9dcc4; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.card-bar span { display: block; height: 100%; background: linear-gradient(90deg, #c9e44b, #f5c542); }
.card-bar em { position: absolute; inset: 0; text-align: center; font: 800 10px/12px var(--font-body); color: #4a3412; font-style: normal; }
.card-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 0 12px 10px; }
.card-grid .k { color: var(--muted); }
.card-grid .v { text-align: right; font: 700 15px/1.4 var(--font-head); font-variant-numeric: tabular-nums; }
.card-race { margin: 0 12px 10px; font: 700 14px/1.3 var(--font-head); text-align: center; padding: 6px; border-radius: 10px; background: var(--paper-2); border: 2px solid var(--line); }
.card-buffs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; font-size: 12px; }
.card-buffs span { background: var(--paper-2); border: 2px solid var(--line); border-radius: 8px; padding: 2px 8px; }
.blink { animation: blink 0.8s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---------- smaller screens ---------- */
@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .detect-grid, .race, .settings { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .topbar, main, .tabs { padding-left: 16px; padding-right: 16px; }
  .cards { grid-template-columns: 1fr; }
  .right { margin-left: 0; }
  .tabs button { min-width: 0; flex: 1; padding: 8px 4px; font-size: 11px; }
  .help { flex-direction: column; } .help-pic { max-width: 100%; width: 100%; }
  .elapsed { font-size: 26px; }
}

/* ---------- loot ---------- */
.loot-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.loot-tiles .tile .value { font-size: 24px; }
.loot-tiles .tile.total { background: #fff1d4; border-color: var(--gold); }
.loot-group { border: 2px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.loot-head { display: flex; gap: 12px; align-items: center; padding: 7px 12px; background: var(--paper-2); border-bottom: 2px solid var(--line); font-family: var(--font-head); }
.loot-head b { color: var(--wood); text-transform: uppercase; letter-spacing: .06em; font-size: 13px; }
.loot-head .good { margin-left: auto; font-weight: 800; }
.loot-items { display: grid; }
.loot-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto 90px 22px; gap: 10px; align-items: center; padding: 6px 12px; border-bottom: 1px dashed var(--line); cursor: help; }
.loot-item:last-child { border-bottom: 0; }
.loot-item:hover { background: #fff1d4; }
.loot-item img, .loot-item .noicon { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; display: grid; place-items: center; background: #fff; border: 2px solid var(--line); border-radius: 8px; color: var(--muted); }
.li-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-qty { font: 700 16px/1 var(--font-head); color: var(--accent-dark); }
.li-price { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; cursor: text; }
.li-price input { width: 74px; padding: 3px 6px; text-align: right; }
.li-value { text-align: right; font: 700 15px/1 var(--font-head); }
.li-x, .w-x { flex: none; width: 20px; height: 20px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 5px; font: 700 11px/20px var(--font-body); box-shadow: none; text-shadow: none; cursor: pointer; }
.li-x:hover, .w-x:hover { color: #fff; background: #d9281e; }
.tip {
  position: fixed; left: 0; top: 0; z-index: 50; width: 260px; pointer-events: none; color: var(--ink);
  background: var(--paper); border: 3px solid var(--gold); border-radius: 12px; padding: 10px 12px; box-shadow: 0 12px 30px #0007; font-size: 13px;
}
.tip-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.tip-head img { width: 36px; height: 36px; image-rendering: pixelated; object-fit: contain; }
.tip-head b { font: 700 16px/1.2 var(--font-head); }
.tip dl { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 6px 0; }
.tip dt { color: var(--muted); }
.tip dd { margin: 0; text-align: right; font-weight: 900; }
.tip p { margin: 6px 0; color: var(--ink-soft); font-size: 12px; }
.tip-price { border-top: 1px dashed var(--line); padding-top: 6px; }
@media (max-width: 820px) { .loot-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .loot-item { grid-template-columns: 32px minmax(0, 1fr) auto 70px 22px; } .li-price { display: none; } }

/* Share button while the game is shared */
button#btnShare.live { background: linear-gradient(180deg, #4fd47f, #2c9a58); border-color: #1d6e3e; box-shadow: 0 3px 0 #1d6e3e; text-shadow: 0 1px 0 #165c33; }
button#btnShare.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #eafff1; box-shadow: 0 0 0 3px #eafff155; animation: pulse 1.4s ease-in-out infinite; }

/* Low HP: a red pulse around the edge of the page (and the pop-out) */
body.danger::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 60; box-shadow: inset 0 0 0 6px #ff3b30, inset 0 0 60px #ff3b30aa; animation: danger 0.6s ease-in-out infinite alternate; }
@keyframes danger { from { opacity: 0.35; } to { opacity: 1; } }
.pill.vitals::before { display: none; }
.pill.vitals .bad { color: #ff8a80; }

.plan { margin-top: 10px; padding: 8px 12px; background: #fff1d4; border: 2px solid var(--gold); border-radius: 10px; font-weight: 700; }

/* This map */
.map-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.map-head b { font: 700 18px/1.2 var(--font-head); }
.map-goal { background: #fff1d4; border: 2px solid var(--gold); border-radius: 10px; padding: 6px 12px; }
.mob-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.mob { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; background: var(--paper-2); border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.mob img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.mob-exp { text-align: right; display: grid; }
.mob-exp b { font: 700 18px/1 var(--font-head); color: var(--exp); }

/* ---------- the always-on-top widget ---------- */
body.pip {
  --paper: #2d2342; --paper-2: #382c52; --ink: #f6f1ff; --muted: #b3a9cc; --line: #ffffff1c; --good: #b4e34e; --bad: #ff8d9b;
  margin: 0; padding: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #33274b, #241b37); color: var(--ink); font: 700 12px/1.35 var(--font-body); font-variant-numeric: tabular-nums;
}
body.pip.danger::after { box-shadow: inset 0 0 0 3px #ff3b30, inset 0 0 10px #ff3b30aa; }
.w-head { flex: none; display: flex; align-items: center; gap: 7px; padding: 8px 10px 5px; }
.w-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #7d7396; }
.w-dot.on { background: #5fe07a; box-shadow: 0 0 6px #5fe07a; }
.w-who { flex: 1; min-width: 0; }
.w-nameline { display: flex; align-items: center; gap: 6px; }
.w-char { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 700 15px/1.2 var(--font-head); color: #fff; }
.w-level { flex: none; padding: 1px 6px; border-radius: 5px; background: var(--gold); color: #4a2d0c; font: 700 11px/1.35 var(--font-head); }
.w-map { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 11px; min-height: 15px; }
.w-time { flex: none; color: #fff; font: 700 14px/1 var(--font-head); }
.w-pause { flex: none; padding: 3px 7px; color: var(--ink); background: #ffffff14; border: 1px solid #ffffff2b; border-radius: 6px; font: 700 10px/1.2 var(--font-body); box-shadow: none; text-shadow: none; cursor: pointer; }
.w-pause:hover { background: #ffffff26; }
.w-bars { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0 10px 6px; }
.w-bar { position: relative; height: 15px; overflow: hidden; background: #1b142b; border: 1px solid #ffffff1f; border-radius: 999px; }
.w-bar span { display: block; height: 100%; border-radius: inherit; transition: width .12s linear; }
.w-bar em { position: absolute; inset: 0; color: #fff; font: 800 10px/13px var(--font-body); font-style: normal; text-align: center; text-shadow: 0 1px 2px #000; }
.w-hp span { background: linear-gradient(180deg, #ff6a5e, #d9281e); }
.w-mp span { background: linear-gradient(180deg, #57a7ff, #1f62d6); }
.w-bar.w-exp { grid-column: 1 / -1; }
.w-bar.w-exp span { background: linear-gradient(180deg, #d4ee5f, #93c426); }
.w-bar.low { border-color: #fff; animation: w-low .5s steps(2, jump-none) infinite; }
.w-hp.low { box-shadow: 0 0 8px #ff5a4d; }
.w-mp.low { box-shadow: 0 0 8px #57a7ff; }
@keyframes w-low { from { opacity: 1; } to { opacity: .25; } }
.w-tabs { flex: none; display: flex; gap: 3px; padding: 0 10px 6px; }
.w-tabs button { flex: 1; padding: 3px 4px; color: var(--muted); background: #ffffff0d; border: 1px solid transparent; border-radius: 7px; font: 600 11px/1.3 var(--font-head); box-shadow: none; text-shadow: none; cursor: pointer; }
.w-tabs button:hover { color: var(--ink); }
.w-tabs button.on { color: #fff; background: #ffffff24; border-color: #ffffff30; }
.w-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: #ffffff33 transparent; }
.w-page { display: flex; flex-wrap: wrap; }
.w-page[hidden] { display: none; }
.w-sec { flex: 1 1 100%; min-width: 0; }
.w-sec.closed { flex: 1 1 40%; } /* both collapsed: side by side on one line */
.w-sechead { display: flex; align-items: center; gap: 6px; width: calc(100% - 20px); margin: 0 10px 5px; padding: 3px 8px; color: #d4cce4; background: #ffffff0d; border: 1px solid #ffffff14; border-radius: 7px; font: 700 11px/1.3 var(--font-head); text-align: left; box-shadow: none; text-shadow: none; cursor: pointer; }
.w-sechead:hover { color: #fff; background: #ffffff1c; }
.w-sechead i { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; transition: transform .1s; }
.w-sec.closed .w-sechead i { transform: rotate(-90deg); }
.w-sec.closed:has(+ .w-sec.closed) .w-sechead { margin-right: 3px; width: calc(100% - 13px); }
.w-sec.closed + .w-sec.closed .w-sechead { margin-left: 3px; width: calc(100% - 13px); }
.w-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 0 10px 5px; }
.w-tile { min-width: 0; padding: 5px 6px; background: #ffffff0f; border: 1px solid #ffffff14; border-top: 2px solid var(--accent-line); border-radius: 8px; }
.w-tile.w-exp { --accent-line: #b4e34e; --accent-text: #b4e34e; }
.w-mesos { --accent-line: #f3bd4f; --accent-text: #f3bd4f; }
.w-next { --accent-line: #b794f6; --accent-text: #c4a8f8; }
.w-total { --accent-line: #4fd1c5; --accent-text: #6fe0d5; }
.w-potions { --accent-line: #62a8ff; --accent-text: #86bcff; }
.w-profit { --accent-line: #ff6f91; --accent-text: #ff8fa9; }
.w-label { overflow: hidden; color: #d4cce4; font: 700 9px/1.3 var(--font-body); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; text-overflow: ellipsis; }
.w-label i { margin-right: 3px; font-style: normal; }
.w-value { overflow: hidden; color: #fff; font: 700 19px/1.25 var(--font-head); white-space: nowrap; text-overflow: ellipsis; }
.w-value.bad { color: var(--bad); }
.w-sub { color: var(--accent-text); font: 700 10px/1.25 var(--font-body); }
.w-strip { display: flex; align-items: center; gap: 5px; margin: 0 10px 5px; padding: 3px 8px; background: #ffffff0f; border-radius: 7px; color: #d4cce4; font-size: 11px; }
.w-strip i { font-style: normal; }
.w-strip b { color: #fff; }
.w-strip b.good { color: var(--good); }
.w-strip b.bad { color: var(--bad); }
.w-race { margin: 0 10px 5px; padding: 6px 8px; background: #0000002b; border-radius: 8px; }
.w-racehead, .w-racefoot { display: flex; justify-content: space-between; gap: 6px; }
.w-racehead { align-items: center; margin-bottom: 4px; font-size: 11px; }
.w-racehead b { padding: 1px 7px; background: #ffffff12; border-radius: 999px; white-space: nowrap; }
.w-raceline { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.w-raceline > span { flex: none; width: 42px; }
.w-raceline.you > span { color: var(--gold); }
.w-track { position: relative; flex: 1; height: 13px; overflow: hidden; background: #1b142b; border: 1px solid #ffffff1f; border-radius: 3px; }
.w-track i { display: block; height: 100%; background: #8b8499; }
.you .w-track i { background: linear-gradient(180deg, #d4ee5f, #93c426); }
.w-track em { position: absolute; inset: 0; color: #fff; font: 800 9px/11px var(--font-body); font-style: normal; text-align: center; text-shadow: 0 1px 2px #000; }
.w-racefoot { color: var(--muted); font-size: 10px; }
.w-buffs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 5px; font-size: 11px; }
.w-buffs span { padding: 1px 7px; background: #ffffff12; border-radius: 6px; }
.w-picked { margin: 0 10px 5px; padding: 5px 7px 6px; background: #ffffff0a; border-radius: 8px; }
.w-pickedhead { margin-bottom: 4px; color: #d4cce4; font: 700 9px/1.3 var(--font-body); letter-spacing: .03em; text-transform: uppercase; }
.w-picked .w-note { padding: 0 0 2px; font-size: 11px; font-weight: 600; }
.w-iconrow { display: flex; flex-wrap: wrap; gap: 3px; }
.w-icon { position: relative; width: 32px; height: 32px; display: grid; place-items: center; background: #ffffff12; border-radius: 6px; }
.w-icon img { max-width: 26px; max-height: 26px; image-rendering: pixelated; }
.w-icon .w-noicon { color: var(--muted); font-size: 10px; }
.w-icon b { position: absolute; right: 1px; bottom: -1px; color: #fff; font: 800 10px/1.1 var(--font-body); text-shadow: -1px 0 #000, 1px 0 #000, 0 -1px #000, 0 1px #000; }
.w-sums { margin: 0 10px 5px; padding: 6px 9px; background: #ffffff0f; border-radius: 8px; }
.w-sum { display: flex; justify-content: space-between; gap: 8px; }
.w-sum span { color: var(--muted); }
.w-sum b { font: 700 13px/1.4 var(--font-head); }
.w-row { display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-bottom: 1px solid var(--line); }
.w-row img, .w-row .w-noicon { flex: none; width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; text-align: center; }
.w-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-qty, .w-val { flex: none; text-align: right; }
.w-qty { color: var(--muted); min-width: 30px; }
.w-val { min-width: 50px; }
.w-headrow { color: var(--muted); font-size: 11px; }
.w-note { margin: 0; padding: 12px 10px; color: var(--muted); }
.w-maphead { padding: 2px 10px; display: flex; flex-direction: column; }
.w-maphead b { font: 700 14px/1.3 var(--font-head); }
.w-maphead span { color: var(--muted); font-size: 11px; }
.w-goal { padding: 2px 10px 6px; border-bottom: 1px solid var(--line); }
.w-now { margin: 0 10px 6px; padding: 7px 9px 8px; background: #ffffff0f; border: 1px solid #ffffff14; border-top: 2px solid #b4e34e; border-radius: 8px; }
.w-big { font: 700 26px/1.2 var(--font-head); }
.w-big.good { color: #d6f47a; }
.w-parts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.w-part { min-width: 0; }
.w-part span { display: block; color: var(--muted); font: 700 9px/1.3 var(--font-body); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-part b { display: block; font: 700 14px/1.3 var(--font-head); }
.w-head3 { display: flex; justify-content: space-between; gap: 8px; margin: 7px 10px 2px; color: #d4cce4; font: 700 10px/1.3 var(--font-body); letter-spacing: .03em; text-transform: uppercase; }
.w-head3 span { min-width: 0; color: var(--muted); letter-spacing: 0; text-transform: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-name small { display: block; color: var(--muted); font: 600 10px/1.2 var(--font-body); overflow: hidden; text-overflow: ellipsis; }
.w-count { flex: none; font: 700 14px/1.2 var(--font-head); }
.w-foot { margin: 5px 10px 0; color: var(--muted); font: 600 10px/1.35 var(--font-body); }
.w-foot a { color: #c4a8f8; }
@media (max-width: 285px) { .w-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Quest guide */
.guide-search { width: 100%; font-size: 15px; padding: 10px 12px; margin-top: 6px; }
.guide-results { list-style: none; padding: 0; margin: 8px 0 0; max-height: 340px; overflow: auto; }
.guide-results li { padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 2px solid transparent; }
.guide-results li:hover, .guide-results li:focus { background: #fff1d4; border-color: var(--gold); outline: none; }
.guide-results .kind { font-size: 11px; font-weight: 900; text-transform: uppercase; color: var(--accent-dark); margin-right: 6px; }
.guide-results .sub { display: block; color: var(--muted); font-size: 12px; }
.guide-wants { margin: 4px 0 8px; padding-left: 20px; }
.guide-status { background: #fff1d4; border: 2px solid var(--gold); border-radius: 12px; padding: 10px 12px; font-weight: 700; }
.guide-status:empty { display: none; }
.guide-steps { padding-left: 22px; }
.guide-steps li { margin: 3px 0; }
.guide-steps li.here { font-weight: 900; color: var(--accent-dark); }
.guide-steps .portal { color: var(--muted); font-size: 12px; }
#guidePlaces tr.chosen td { background: #fff1d4; font-weight: 800; }

/* On a website: what only this PC's own server can do is hidden. */
body.hosted .local-only { display: none !important; }
.guide-helper { background: rgba(255, 196, 80, 0.12); border: 1px solid rgba(255, 196, 80, 0.4); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.guide-helper .btn { margin-left: 6px; }
