:root {
  --paper: #f3ede0;
  --card: #fbf8f1;
  --ink: #1f1c17;
  --ink-2: #6b6457;
  --line: #ddd4c2;
  --must: #d4381e;
  --want: #d99a00;
  --maybe: #6f8588;
  --booth: #11524f;
  --booth-ink: #f3ede0;
  --po: #2f7d32;
  --pre: #2d5fb8;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16140f;
    --card: #211e17;
    --ink: #f1ebdd;
    --ink-2: #a39a88;
    --line: #37322a;
    --must: #ff5a3c;
    --want: #f2b52a;
    --maybe: #8fa6a9;
    --booth: #2b8a84;
    --booth-ink: #0f0e0b;
    --po: #5cc160;
    --pre: #6f9cf0;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.4 "Bricolage Grotesque", system-ui, sans-serif;
  max-width: 620px;
  margin-inline: auto;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- header ---------- */
.top { padding: 14px 16px 4px; }
.sortbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--paper);
  padding: 6px 16px 8px;
  border-bottom: 2px solid var(--ink);
}
.title-row { display: flex; align-items: center; justify-content: space-between; }
h1 {
  margin: 0;
  font-weight: 800; font-size: clamp(26px, 8vw, 34px); letter-spacing: -0.03em; line-height: 1;
}
h1 .yr { color: var(--must); }
.refresh {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--ink); background: transparent;
  display: grid; place-items: center;
}
.refresh.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { margin: 4px 0 10px; color: var(--ink-2); font-size: 13px; }
.status.warn { color: var(--must); font-weight: 600; }

.search {
  width: 100%; height: 40px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font: inherit; margin-bottom: 10px;
}
.search:focus { outline: none; border-color: var(--ink); }

/* filter chips: the chip IS the state (filled = shown) */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  --c: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 999px; border: 2px solid var(--c);
  background: transparent; color: var(--ink);
  font-weight: 600; font-size: 13.5px;
}
.chip .n { font-family: "IBM Plex Mono", monospace; font-size: 12px; opacity: .7; }
.chip[aria-pressed="true"] { background: var(--c); color: #fff; }
.chip[aria-pressed="true"] .n { opacity: .9; }
.chip[data-p="1"] { --c: var(--must); }
.chip[data-p="2"] { --c: var(--want); }
.chip[data-p="3"] { --c: var(--maybe); }
.chip[data-f="po"] { --c: var(--po); }
.chip[data-f="can"] { --c: var(--pre); }
.chip[data-p="2"][aria-pressed="true"] { color: #1f1c17; }

.sort { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.sort::-webkit-scrollbar { display: none; }
.sort button { flex: none; white-space: nowrap; }
.sort .dir { font-family: "IBM Plex Mono", monospace; }
.sort-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-right: 6px; }
.sort button {
  border: 0; background: transparent; padding: 6px 10px; border-radius: 8px;
  font-weight: 600; font-size: 14px; color: var(--ink-2);
}
.sort button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- list ---------- */
.list { padding: 6px 12px 24px; }
.group {
  display: flex; align-items: baseline; gap: 8px;
  margin: 18px 4px 8px;
  font-weight: 800; font-size: 20px; letter-spacing: -0.02em;
}
.group .n { font: 500 12px "IBM Plex Mono", monospace; color: var(--ink-2); }
.group .hint { font-weight: 400; font-size: 13px; color: var(--ink-2); letter-spacing: 0; }

.game {
  --c: var(--maybe);
  position: relative;
  display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 8px 10px 8px 8px; margin-bottom: 8px;
  border-left: 6px solid var(--c);
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer;
}
.game[data-p="1"] { --c: var(--must); }
.game[data-p="2"] { --c: var(--want); }
.thumb {
  width: 92px; aspect-ratio: 16 / 10; border-radius: 8px;
  object-fit: cover; background: var(--line); display: block;
}
.info { min-width: 0; }
.name { font-weight: 600; font-size: 16px; line-height: 1.2; }
.meta { font-size: 13px; color: var(--ink-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; align-items: center; }
.prio { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--c); }
.po {
  font: 600 11px "IBM Plex Mono", monospace; letter-spacing: .04em;
  color: var(--po); border: 1.5px solid var(--po); border-radius: 4px; padding: 0 5px;
  transform: rotate(-3deg);
}
/* pre-order badge (from the community pre-order list) */
.pre {
  font: 600 11px "IBM Plex Mono", monospace; letter-spacing: .02em; text-transform: uppercase;
  color: var(--pre); border: 1.5px solid var(--pre); border-radius: 4px; padding: 0 5px;
}
.pre.urgent { background: var(--must); border-color: var(--must); color: #fff; }
.pre.gone { color: var(--ink-2); border-color: var(--line); text-decoration: line-through; }
.pre.maybe { border-style: dashed; }
.prebox { border: 1.5px solid var(--pre); border-radius: 10px; padding: 8px 10px; margin: 6px 0 8px; }
.prebox .prehead { font: 600 11px "IBM Plex Mono", monospace; text-transform: uppercase; color: var(--pre); margin-bottom: 4px; }
.prebox .links a { border-color: var(--pre); color: var(--pre); }
.price { font: 500 12px "IBM Plex Mono", monospace; color: var(--ink-2); }
.price b { color: var(--ink); font-weight: 600; }
.price s { opacity: .7; }
.group .total { margin-left: auto; font: 600 13px "IBM Plex Mono", monospace; color: var(--ink); letter-spacing: 0; }

/* booth = a ticket stub */
.stub {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; padding: 6px 8px;
  background: var(--booth); color: var(--booth-ink);
  border-radius: 8px;
  font-family: "IBM Plex Mono", monospace;
  position: relative;
}
.stub::before, .stub::after {
  content: ""; position: absolute; left: -5px; width: 10px; height: 10px;
  background: var(--card); border-radius: 50%;
}
.stub::before { top: -5px; } .stub::after { bottom: -5px; }
.stub .hall { font-size: 10px; letter-spacing: .1em; opacity: .85; }
.stub .code { font-size: 17px; font-weight: 600; line-height: 1.1; }
.stub .more { font-size: 10px; opacity: .85; }
.stub.guess { background: transparent; color: var(--booth); border: 2px dashed var(--booth); }
.stub.guess::before, .stub.guess::after { display: none; }
.stub.none { background: transparent; color: var(--ink-2); border: 2px dashed var(--line); }
.stub.none::before, .stub.none::after { display: none; }
.stub.none .code { font-size: 12px; font-weight: 500; }

/* expanded details */
.details {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--line);
  padding: 8px 2px 2px; font-size: 14px;
}
.details p { margin: 0 0 6px; }
.details .facts { color: var(--ink-2); font-size: 13px; }
.details .note { background: var(--paper); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.details .guessnote { color: var(--booth); font-size: 13px; }
.details .links { display: flex; gap: 8px; margin-top: 8px; }
.details a {
  flex: 1; text-align: center; padding: 9px; border-radius: 10px;
  border: 2px solid var(--ink); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px;
}

/* ---------- setup (paste your share link) ---------- */
.setup { display: none; padding: 8px 16px 24px; }
.setup-mode .setup { display: block; }
.setup-mode .filters, .setup-mode .top .search, .setup-mode .sortbar,
.setup-mode .list, .setup-mode .mapview, .setup-mode .searchrow, .setup-mode .foot, .setup-mode .refresh, .setup-mode .status { display: none; }
.setup h2 { font-weight: 800; font-size: 24px; letter-spacing: -0.02em; margin: 8px 0 6px; }
.setup p, .setup li { font-size: 15px; }
.setup ol { padding-left: 20px; margin: 10px 0 14px; }
.setup li { margin-bottom: 4px; }
.setup-error { color: var(--must); font-weight: 600; font-size: 14px !important; margin: 0 0 8px; }
.setup-actions { display: flex; gap: 8px; }
.setup .primary {
  flex: 1; height: 46px; border: 0; border-radius: 12px;
  background: var(--must); color: #fff; font-weight: 800; font-size: 16px;
}
.setup .ghost { height: 46px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--line); background: transparent; font-weight: 600; }
.setup .small { font-size: 13px; color: var(--ink-2); }
.linkish { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; font-size: 13px; }

/* ---------- view switch + map ---------- */
.title-row { gap: 10px; }
.title-row h1 { flex: 1; min-width: 0; }
.searchrow { display: flex; gap: 8px; align-items: flex-start; }
.searchrow .search { flex: 1; min-width: 0; }
.searchrow .view { height: 40px; flex: none; }
.view { display: flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.view button { border: 0; background: transparent; padding: 5px 10px; font-weight: 700; font-size: 13.5px; }
.view button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.mapview { display: none; }
.map-mode .mapview { display: block; }
.map-mode .list#list, .map-mode .sortbar { display: none; }
.mapbar {
  position: sticky; top: 0; z-index: 5; background: var(--paper);
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-bottom: 2px solid var(--ink);
}
.halls { flex: 1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.halls::-webkit-scrollbar { display: none; }
.halls button {
  flex: none; border: 0; background: transparent; padding: 6px 10px; border-radius: 8px;
  font-weight: 700; font-size: 14px; color: var(--ink-2); white-space: nowrap;
}
.halls button .n { font: 500 11px "IBM Plex Mono", monospace; }
.halls button[aria-pressed="true"] { background: var(--booth); color: var(--booth-ink); }
.zoom { display: flex; gap: 4px; }
.zoom button {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink);
  background: transparent; font-size: 18px; font-weight: 700; line-height: 1;
}
.mapwrap { overflow: auto; margin: 10px 12px 0; border-radius: 12px; background: #fff; max-height: 75vh; }
.mapcanvas { position: relative; min-width: 100%; }
.mapcanvas img { display: block; width: 100%; height: auto; }
.pin {
  --c: var(--maybe);
  position: absolute; transform: translate(-50%, -50%);
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  border: 2px solid #fff; background: var(--c); color: #fff;
  font: 600 13px "IBM Plex Mono", monospace; line-height: 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.pin[data-p="1"] { --c: var(--must); }
.pin[data-p="2"] { --c: var(--want); color: #1f1c17; }
.pin.guess { border-style: dashed; opacity: .85; }
.pin.has-po { box-shadow: 0 0 0 3px var(--po), 0 1px 4px rgba(0,0,0,.45); }
.pin.sel { transform: translate(-50%, -50%) scale(1.35); z-index: 2; box-shadow: 0 0 0 3px var(--ink), 0 2px 8px rgba(0,0,0,.5); }
.mapnote { font-size: 12px; color: var(--ink-2); margin: 6px 16px 0; }
.mapnote a { color: var(--ink); }
.maphint { color: var(--ink-2); font-size: 14px; margin: 14px 4px 8px; }

/* ---------- friends ---------- */
.title-row { gap: 8px; }
.friends { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.fc {
  --c: var(--maybe);
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c); color: #fff;
  font: 600 10px "IBM Plex Mono", monospace; letter-spacing: -.02em;
}
.fc[data-p="1"] { --c: var(--must); }
.fc[data-p="2"] { --c: var(--want); color: #1f1c17; }
.fc.has-po { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--po); }
.fc.big { width: 36px; height: 36px; font-size: 13px; background: var(--ink); color: var(--paper); flex: none; }
.chip[data-fr] { --c: var(--ink); }
.chip[data-fr][aria-pressed="true"] { color: var(--paper); }
.menu-panel { display: none; }
#menu-btn .ic-close { display: none; }
#menu-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#menu-btn[aria-pressed="true"] .ic-close { display: block; }
#menu-btn[aria-pressed="true"] .ic-menu { display: none; }
.setup-mode #menu-btn { display: none; }
.menu-mode .menu-panel { display: block; }
.menu-mode .filters, .menu-mode .searchrow, .menu-mode .sortbar, .menu-mode .list,
.menu-mode .mapview, .menu-mode .foot, .menu-mode .status, .menu-mode .viewing { display: none; }
.menu-panel h2 { margin-top: 18px; }
.menu-panel #me-form { margin-top: 10px; }
.menu-panel #me-form .search { margin-bottom: 8px; }
.menu-panel #me-form .primary { width: 100%; }

/* people rows in the menu: tap to show that list */
.friend-list li.person { cursor: pointer; }
.friend-list li.person.active { background: color-mix(in srgb, var(--booth) 14%, transparent); border-radius: 10px; padding-left: 6px; padding-right: 6px; }
.friend-list li.off .fc.big { opacity: .35; }
.friend-list li.off b { color: var(--ink-2); }
.tag { font: 600 11px "IBM Plex Mono", monospace; text-transform: uppercase; color: var(--booth); flex: none; }
.tag.go { color: var(--ink-2); border: 1.5px solid var(--line); border-radius: 6px; padding: 3px 7px; }

.small-remove { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
/* show / hide circles switch */
.switch {
  flex: none; width: 42px; height: 24px; border-radius: 12px; border: 0; padding: 0;
  background: var(--line); position: relative;
}
.switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--po); }
.switch[aria-checked="true"] span { left: 21px; }

/* banner while a friend's list is on screen - hard to miss */
.viewing {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 8px 0 2px; padding: 8px 8px 8px 12px; border-radius: 12px;
  background: var(--booth); color: var(--booth-ink); font-weight: 800; font-size: 16px;
}
.viewing[hidden] { display: none; }
.viewing button {
  border: 0; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 13px;
  background: var(--booth-ink); color: var(--booth);
}
.friend-list { list-style: none; padding: 0; margin: 12px 0 16px; }
.friend-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.friend-list li.none { color: var(--ink-2); }
.friend-list .fname { flex: 1; min-width: 0; }
.friend-list small { color: var(--ink-2); }
.friend-list .ferr { color: var(--must); font-weight: 600; }
.friend-list .ghost { height: 36px; }
#friend-form .search { margin-bottom: 8px; }

.empty { text-align: center; color: var(--ink-2); padding: 40px 16px; }

.foot { padding: 8px 16px 40px; color: var(--ink-2); font-size: 13px; text-align: center; }
.foot b { font-family: "IBM Plex Mono", monospace; color: var(--po); }
.ver { font: 500 11px "IBM Plex Mono", monospace; opacity: .7; }

@media (max-width: 380px) {
  .game { grid-template-columns: 72px 1fr auto; gap: 9px; }
  .thumb { width: 72px; }
  h1 { font-size: 30px; }
}
