@font-face {
  font-family: Nunito;
  src: url('fonts/nunito.ttf') format('truetype');
  font-weight: 200 1000;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; font: 14px system-ui, sans-serif; }
#settings { background: #181c22; color: #f5f7fa; min-height: 100vh; padding: 20px; }
h1 { font-size: 22px; margin: 0 0 12px; }
label { display: grid; gap: 4px; margin-bottom: 8px; }
input, select, button { border: 1px solid #596374; border-radius: 6px; padding: 6px 8px; font: inherit; background: #282f39; color: inherit; }
.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
#status { color: #99daff; min-height: 1.2em; margin: 10px 0; }
#hud { -webkit-app-region: drag; width: 360px; height: 197px; background: rgb(16 17 22 / var(--hud-backing, .30)); color: white; position: absolute; inset: 0 auto auto 0; border: 1px solid #8886; transform: scale(var(--hud-scale, 1)); transform-origin: top left; }
.hud-window { overflow: hidden; }
#hud.unusual { background: rgb(189 31 10 / var(--hud-backing, .30)); border-color: #ffd34a; }
#seller, #room, #item, #stats, #buyRow, #estimate, #next { position: absolute; overflow: hidden; text-overflow: ellipsis; }
#seller { top: 8px; left: 12px; width: 215px; font-size: 19px; white-space: nowrap; }
#hud.seller-right #seller { left: auto; right: 8px; text-align: right; }
#room { top: 34px; left: 12px; font-weight: 800; font-size: 24px; }
hr { position: absolute; top: 64px; left: 12px; width: 215px; border: 0; border-top: 1px solid #fff5; }
#itemIcon { position: absolute; top: 83px; left: 12px; width: 54px; height: 71px; object-fit: contain; image-rendering: pixelated; }
#item, #stats, #buyRow, #estimate { left: 76px; width: 157px; }
#item { top: 78px; font-weight: 750; white-space: nowrap; }
#stats { top: 99px; height: 29px; color: #b2efb5; font-size: 11px; }
.unusual #stats { color: #fff093; }
#buyRow { top: 129px; display: flex; gap: 5px; align-items: center; font-weight: 700; }
#coin { width: 15px; height: 15px; object-fit: contain; }
#estimate { top: 150px; font-size: 12px; font-weight: 650; white-space: nowrap; }
#profit { color: #91fc9a; }
#next { bottom: 6px; left: 12px; right: 10px; font-size: 11px; color: #a5e1ff; white-space: nowrap; }
#map { position: absolute; top: 42px; right: 8px; width: 112px; height: 94px; display: grid; align-items: center; background: rgb(255 246 229 / var(--map-backing, .15)); border-radius: 6px; overflow: hidden; }
#channelBadge { position: absolute; top: 142px; right: 8px; min-width: 58px; height: 21px; padding: 0 7px; display: grid; place-items: center; border: 1px solid #65bded; border-radius: 4px; background: #174965; color: #c5efff; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
#plot { position: relative; width: 100%; }
#mapImage { position: absolute; width: 100%; height: auto; left: 0; }
#pin { position: absolute; width: 10px; height: 13px; transform: translate(-50%, -100%); }
#grid { -webkit-app-region: drag; color: white; height: 100vh; display: grid; grid-template-rows: 26px minmax(0, 1fr); }
#handle { height: 26px; padding: 4px 8px; background: #111d; }
#cells {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  column-gap: calc((100vw - 16px) * 1.5 / 552);
  row-gap: calc((100vh - 34px) * 2 / 108);
  margin: 4px 8px;
}
#cells span { display: grid; place-items: center; border: 1px solid #0b0b0b; border-radius: 3px; font-size: 10px; color: white; background: #1717179c; }
#cells span.target { background: #ffd82fcb; color: #191919; }
#grid.locked #handle, #grid.locked #cells span:not(.target) { visibility: hidden; }
#grid.locked #cells span.target { border: 0; color: transparent; }
#settings #join { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
#settings #join label { margin: 0; }
#settings #join .buttons { flex-wrap: nowrap; }
#settings > label { display: inline-flex; align-items: center; margin-right: 8px; margin-bottom: 0; }
#settings > .buttons { display: inline-flex; }
#settings h2 { margin: 0 0 8px; font-size: 17px; }
#feed { margin-top: 18px; }
#emptyFeed { color: #aebad0; }
#dealCards { display: grid; gap: 8px; }
.deal-card { width: 100%; display: grid; grid-template-columns: minmax(132px, 1.9fr) minmax(0, 3fr) minmax(87px, 1.15fr) minmax(74px, 1fr); align-items: center; gap: 8px; min-height: 85px; text-align: left; padding: 10px; background: #242c38; color: #fff; cursor: pointer; font-size: 12px; }
.deal-card:hover, .deal-card:focus-visible { background: #313e50; }
.deal-card[aria-pressed="true"] { outline: 2px solid #8cd4ff; outline-offset: -2px; }
.deal-card.unusual { border-color: #f59d57; }
.deal-identity { display: flex; align-items: center; gap: 7px; min-width: 0; }
.deal-identity > span { min-width: 0; }
.card-item-meta { display: flex; align-items: center; gap: 6px; }
.card-item-type { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card-cheap { color: #a33620; background: #fde6d6; padding: 1px 5px; border-radius: 4px; flex: none; font-weight: 750; }
.card-icon { width: 33px; height: 36px; object-fit: contain; image-rendering: pixelated; flex: none; }
.deal-card strong, .deal-card small:not(.card-item-meta), .card-metric > span, .card-location > span { display: block; overflow-wrap: anywhere; }
.deal-card small { font-size: 10px; color: #bcc9db; }
.card-metric > span { color: #b3c5dd; font-size: 10px; }
.card-metrics { min-width: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; column-gap: 8px; }
.card-metrics .card-rule { grid-column: 1 / -1; margin-block-start: 8px; font-size: 10px; }
.card-metric strong.card-money { display: flex; align-items: center; gap: 4px; }
.card-money span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meso { width: 16px; height: 16px; flex: none; object-fit: contain; image-rendering: pixelated; }
.card-profit strong, .card-profit [data-value="profitPercent"] { color: #9bf5a4; }
.card-location { line-height: 1.35; }
.card-location strong { color: #a8ddfb; }
.card-map { display: grid; align-items: center; height: 55px; padding: 0 3px; background: #fff6e5; border-radius: 5px; overflow: hidden; }
.card-plot { display: block; position: relative; width: 100%; }
.card-plot img { position: absolute; width: 100%; height: auto; left: 0; }
.card-plot svg { position: absolute; width: 9px; height: 12px; transform: translate(-50%, -100%); }

@media (max-width: 760px) {
  html:not(.browser-room) #settings { padding: 16px; }
  html:not(.browser-room) .deal-card {
    grid-template-columns: minmax(0, 1fr) minmax(88px, .44fr) clamp(78px, 19vw, 118px);
    gap: 10px 12px;
    padding: 10px 12px;
  }
  html:not(.browser-room) .deal-identity { grid-column: 1; grid-row: 1; gap: 8px; }
  html:not(.browser-room) .deal-identity strong { font-size: 14px; line-height: 1.15; }
  html:not(.browser-room) .card-icon { width: 41px; height: 43px; }
  html:not(.browser-room) .card-location { grid-column: 2; grid-row: 1; min-width: 0; }
  html:not(.browser-room) .card-location strong { white-space: nowrap; }
  html:not(.browser-room) .card-map { grid-column: 3; grid-row: 1; height: 58px; }
  html:not(.browser-room) .card-metrics {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr) minmax(0, 1fr) minmax(0, 1.18fr);
    column-gap: 10px;
    border-top: 1px solid #526174;
    padding-top: 8px;
  }
  html:not(.browser-room) .card-metric strong { font-size: 14px; line-height: 1.35; }
  html:not(.browser-room) .card-metric > span { font-weight: 650; }
  html:not(.browser-room) .card-metrics .card-rule { color: #aebbd0; margin-block-start: 6px; }
}

.browser-room {
  --room-paper: #fffcf2;
  --room-ink: #322a20;
  --room-muted: #676054;
  --room-line: #c6b698;
  --room-teal: #27574d;
  --room-profit: #217043;
  --room-chip: #e5efe4;
}
.browser-room body {
  min-height: 100vh;
  font-family: Nunito, system-ui, sans-serif;
  background: linear-gradient(160deg, #d7e9dc 0, #edf3e8 320px, #f4f1e5 680px);
  color: var(--room-ink);
}
.browser-room #join, .browser-room .desktop-only { display: none !important; }
.browser-room #settings {
  position: relative;
  max-width: 1280px;
  margin: auto;
  padding: 24px clamp(14px, 2vw, 28px) 36px;
  color: var(--room-ink);
  background: none;
}
.browser-room #settings h1 {
  margin: 0;
  padding-right: min(40%, 200px);
  color: var(--room-teal);
  font: 850 clamp(26px, 3vw, 36px)/1.12 Nunito, system-ui, sans-serif;
  letter-spacing: -.045em;
}
.browser-room #status {
  position: absolute;
  right: clamp(14px, 2vw, 28px);
  top: 27px;
  max-width: 42%;
  margin: 0;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid #89a898;
  background: var(--room-chip);
  color: var(--room-teal);
  font-size: 12px;
  font-weight: 700;
}
.browser-room #feed { margin-top: 21px; }
.browser-room #feed h2 { margin-bottom: 10px; color: #504a39; font-size: 15px; }
.browser-room #emptyFeed {
  color: var(--room-muted);
  padding: 20px;
  border: 1px solid var(--room-line);
  border-radius: 10px;
  background: var(--room-paper);
}
.browser-room #dealCards { gap: 10px; }
.browser-room .deal-card {
  --feed-columns: minmax(0, 24fr) minmax(0, 46.25fr) minmax(0, 13.5fr) minmax(0, 16.25fr);
  grid-template-columns: var(--feed-columns);
  gap: clamp(10px, 1.1vw, 14px);
  min-height: 116px;
  background: var(--room-paper);
  color: var(--room-ink);
  padding: 8px clamp(11px, 1.35vw, 18px);
  border: 1px solid var(--room-line);
  border-inline-start: 4px solid #6b9a83;
  border-radius: 12px;
  font-size: 14px;
}
.browser-room .deal-card:hover { background: #fff8e8; border-color: #7d967a; }
.browser-room .deal-card:focus-visible,
.browser-room .deal-card[aria-pressed="true"] {
  outline: 2px solid var(--room-teal);
  outline-offset: -2px;
}
.browser-room .deal-card.unusual {
  border-inline-start-color: #ac4c26;
  background: #fff5e4;
}
.browser-room .deal-identity { gap: clamp(8px, 1vw, 15px); }
.browser-room .deal-identity strong {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.browser-room .card-icon {
  width: clamp(48px, 6.2vw, 76px);
  height: clamp(48px, 6.2vw, 76px);
  padding: 6px;
  border: 1px solid #d9ccb2;
  border-radius: 9px;
  background: #f4ecda;
}
.browser-room .deal-card small { color: var(--room-muted); font-size: 11px; font-weight: 700; line-height: 1.3; }
.browser-room .deal-card [data-value="itemStats"] { color: var(--room-teal); font-size: 12px; font-weight: 800; }
.browser-room .deal-card .card-rule { font-size: 10px; font-weight: 600; }
.browser-room .card-metrics {
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr);
  grid-template-rows: 1fr auto;
  align-self: stretch;
  column-gap: clamp(6px, 1vw, 13px);
  margin-block: 8px;
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--room-line);
}
.browser-room .card-metric > span {
  color: var(--room-muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em;
  line-height: 1.2;
}
.browser-room .card-metric strong { font-size: clamp(12px, 1.35vw, 16px); font-weight: 900; line-height: 1.3; }
.browser-room .card-profit strong { font-size: clamp(13px, 1.4vw, 17px); }
.browser-room .card-meso { width: 18px; height: 18px; }
.browser-room .card-profit strong, .browser-room .card-profit [data-value="profitPercent"] { color: var(--room-profit); font-weight: 900; }
.browser-room .card-rule, .browser-room .card-metric small, .browser-room .card-metric > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.browser-room .card-location small:not(:empty)::before { content: '•'; color: var(--room-profit); margin-inline-end: 5px; }
.browser-room .card-location {
  padding-inline-start: 10px;
  border-inline-start: 1px solid #ded5c0;
}
.browser-room .card-location strong { color: var(--room-teal); font-size: 15px; font-weight: 900; }
.browser-room .card-location > span { font-weight: 800; }
.browser-room .card-map {
  height: 98px;
  padding-inline: 8px;
  border: 1px solid #dfd1b6;
  border-radius: 8px;
  background: #f8efdb;
}
@media (max-width: 880px) {
  .browser-room .deal-card {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 12px;
    padding-block: 12px;
  }
  .browser-room .deal-identity { grid-column: span 2; }
  .browser-room .card-metrics { grid-column: 1 / -1; grid-row: 2; margin-block: 0; padding-inline-start: 0; border-inline-start: 0; }
  .browser-room .card-location { grid-column: 3; grid-row: 1; padding-inline-start: 6px; }
  .browser-room .card-map { grid-column: 4; grid-row: 1; height: 56px; }
}
@media (max-width: 440px) {
  .browser-room .deal-card { column-gap: 6px; padding-inline: 7px; }
  .browser-room .deal-identity { gap: 6px; }
  .browser-room .card-icon { width: 34px; height: 34px; padding: 3px; }
  .browser-room .card-location strong { font-size: 11px; }
  .browser-room .card-map { padding-inline: 4px; }
}


.browser-room .feed-heading { display: flex; align-items: baseline; justify-content: space-between; }
.browser-room #ledgerView { color: var(--room-teal); font-weight: 650; font-size: 12px; }
.browser-room .deal-card { font-variant-numeric: tabular-nums; }
.ledger-room body { background: #e9e6da; }
.ledger-room #settings {
  width: 1240px;
  max-width: none;
  padding-inline: 20px;
}
.ledger-room #dealCards { gap: 10px; }
.ledger-room .deal-card {
  grid-template-columns: var(--feed-columns);
  column-gap: 13px;
  height: 116px;
  padding: 8px 18px;
  background: #fffcf4;
}
.ledger-room .deal-identity, .ledger-room .card-location, .ledger-room .card-map { grid-area: auto; }
.ledger-room .card-metrics { grid-area: auto; margin-block: 8px; padding-inline-start: 12px; border-inline-start: 1px solid var(--room-line); }
.ledger-room .card-map { height: 98px; }
.ledger-room .card-icon { width: 76px; height: 76px; }
.ledger-room .card-metric strong { font-size: 16px; }
.ledger-room .card-profit strong { font-size: 17px; }
.ledger-room .card-location strong { font-size: 15px; }
.ledger-room .card-metric strong, .ledger-room .card-location strong { white-space: nowrap; }
.ledger-room .card-icon[hidden] { display: block !important; visibility: hidden; }

.browser-room .feed-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.browser-room #nightMode {
  border: 1px solid var(--room-line);
  border-radius: 20px;
  background: var(--room-paper);
  color: var(--room-teal);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.browser-room #nightMode[aria-pressed="true"] { background: var(--room-chip); }

.browser-room.night-room {
  color-scheme: dark;
  --room-paper: #212925;
  --room-ink: #f4f2e7;
  --room-muted: #c0c9bd;
  --room-line: #5b6c61;
  --room-teal: #a3d9c0;
  --room-profit: #9fe8ad;
  --room-chip: #2f4338;
}
.night-room body { background: #151c18; }
.night-room #settings h2 { color: var(--room-ink); }
.night-room #status { border-color: var(--room-line); }
.night-room .deal-card { background: var(--room-paper); border-inline-start-color: #76a994; }
.night-room .deal-card:hover { background: #2a3530; border-color: #82a896; }
.night-room .deal-card.unusual { background: #392d25; border-inline-start-color: #eeae68; }
.night-room .card-icon { border-color: #4c5e53; background: #2e3c34; }
.night-room .card-location { border-inline-start-color: #4a5b52; }
.night-room .card-map { border-color: #746858; background: #3a332b; }
.ledger-room .feed-heading { height: 28px; }

#next { display: flex; align-items: center; gap: 6px; min-height: 16px; }
#nextIcon { width: 16px; height: 16px; object-fit: contain; image-rendering: pixelated; flex: none; }
#nextText { overflow: hidden; text-overflow: ellipsis; }

.shortcut-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
#shortcutStatus { color: #99daff; }
#dealDelay { width: 105px; }
.grid-fit-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.grid-fit-controls label { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.grid-fit-controls input { width: 72px; }
#hudOpacity, #hudScale { width: 125px; }
#hudOpacityValue, #hudScaleValue { min-width: 4ch; }
#hud.release-flash #next { color: #ffe093; font-weight: 800; }

.slot-count { color: #b2efb5; font-weight: 700; }
.slot-count.numeric-slots, .night-room .slot-count.numeric-slots { color: #ff9d93; }
.browser-room .slot-count { color: var(--room-profit); }
.browser-room .slot-count.numeric-slots { color: #9d271e; }
.browser-room.night-room .slot-count.numeric-slots { color: #ff9d93; }

.negative-stat { color: #ff9d93; font-weight: 700; }
.browser-room .negative-stat { color: #9d271e; }
.browser-room.night-room .negative-stat { color: #ff9d93; }
