:root {
  --night: #070c20;
  --deep: #0c1a4d;
  --royal: #22419a;
  --groove: #0a1644;
  --marble: #ece6d6;
  --cloud: #c9d6ec;
  --muted: #8fa0cc;
  --line: #4a64b0;
  --gold: #ffd84a;
  --gold-dark: #b8892a;
  --sky: #5ec8ff;
  --burn: #ff6b5e;
  --frame: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--night); }

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  color: var(--marble);
  font: 18px/1.45 'Pixelify Sans', ui-sans-serif, system-ui, sans-serif;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 52vh);
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  -webkit-font-smoothing: none;
}

a { color: var(--sky); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .pane:focus-visible {
  outline: 3px dashed var(--gold);
  outline-offset: 3px;
}

/* the scene ---------------------------------------------------------------------------------------- */

.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.plate {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  image-rendering: pixelated;
}
.bolts { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.flash { position: absolute; inset: 0; background: #fff4c8; opacity: 0; pointer-events: none; mix-blend-mode: screen; }

/* windows: 16-bit RPG boxes -------------------------------------------------------------------------- */

.win {
  position: relative;
  z-index: 1;
  border: var(--frame) solid transparent;
  border-image: url(/img/frame.svg) 4 / var(--frame) / 0 stretch;
  background: linear-gradient(180deg, var(--royal) 0%, #12266a 55%, var(--deep) 100%) padding-box;
}

/* head-up display ---------------------------------------------------------------------------------- */

.hud { grid-column: 1; grid-row: 1; position: relative; z-index: 1; align-self: start; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--marble); text-decoration: none; }
.brand img { image-rendering: pixelated; }
.brand-name {
  font-family: 'Jersey 10', 'Pixelify Sans', sans-serif;
  font-size: 64px;
  line-height: .8;
  text-shadow: 4px 4px 0 var(--night);
}
.brand-line { margin: 8px 0 0; font-size: 18px; color: var(--marble); text-shadow: 2px 2px 0 var(--night); }

.plaque { grid-column: 2; grid-row: 1; align-self: start; width: 272px; padding: 6px 10px 10px; }
.price { margin: 0; font-family: 'Jersey 10', sans-serif; font-size: 48px; line-height: 1; color: var(--gold); }
.price small { font-family: 'Pixelify Sans', sans-serif; font-size: 15px; color: var(--cloud); }
.facts { margin: 8px 0 12px; display: grid; gap: 2px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.facts dt { color: var(--cloud); }
.facts dd { margin: 0; }
.plaque .btn { width: 100%; }

/* the command window ------------------------------------------------------------------------------- */

.console {
  grid-column: 1 / 3;
  grid-row: 3;
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: 0;
}

.commands { display: flex; flex-direction: column; padding: 8px 0; box-shadow: inset -4px 0 0 var(--groove); }
.commands a {
  position: relative;
  display: block;
  padding: 7px 12px 7px 34px;
  color: var(--marble);
  text-decoration: none;
  font-size: 24px;
  line-height: 1.2;
}
.commands a:hover { color: var(--gold); }
.commands a[aria-current="page"] { color: var(--gold); }
.commands a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 12px;
  height: 18px;
  margin-top: -9px;
  background: var(--gold);
  clip-path: polygon(0 0, 33% 0, 33% 17%, 67% 17%, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 83%, 33% 83%, 33% 100%, 0 100%);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: .15; } }

.pane { overflow-y: auto; min-height: 0; min-width: 0; padding: 6px 12px 16px 28px; scrollbar-color: var(--cloud) var(--groove); }

h2 { font-family: 'Jersey 10', sans-serif; font-weight: 400; font-size: 44px; line-height: 1; margin: 4px 0 6px; }
h3 { font-family: 'Jersey 10', sans-serif; font-weight: 400; font-size: 30px; line-height: 1.05; margin: 22px 0 4px; color: var(--gold); }
p { margin: 0 0 10px; }
.lede { max-width: 64ch; color: var(--cloud); }
.note { color: var(--muted); font-size: 16px; margin: 6px 0 0; }
.msg { min-height: 1.45em; margin: 10px 0 0; color: var(--cloud); }
.msg.bad { color: var(--burn); }
.msg.good { color: var(--gold); }

/* controls ---------------------------------------------------------------------------------------- */

.btn {
  font: inherit;
  font-size: 20px;
  background: var(--gold);
  color: #1a1204;
  border: 0;
  padding: 9px 18px 11px;
  box-shadow: inset -4px -4px 0 var(--gold-dark), inset 4px 4px 0 #fff3b0;
  cursor: pointer;
}
.btn:active:not(:disabled) { box-shadow: inset 4px 4px 0 var(--gold-dark); }
.btn:disabled { background: #4b5689; color: var(--cloud); box-shadow: inset -4px -4px 0 #343d66; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--marble); box-shadow: inset 0 0 0 4px var(--marble); }
.btn.ghost:hover { color: var(--gold); box-shadow: inset 0 0 0 4px var(--gold); }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.field > span { color: var(--cloud); }
.inrow { display: flex; align-items: stretch; min-width: 0; }
.num {
  flex: 1;
  min-width: 0;
  width: 100%;
  font-family: 'Jersey 10', sans-serif;
  font-size: 40px;
  line-height: 1;
  background: var(--night);
  color: var(--marble);
  border: 4px solid var(--line);
  border-right: 0;
  padding: 6px 12px 4px;
}
.num:focus { outline: none; border-color: var(--gold); }
.num:disabled { color: var(--muted); }
.unit { display: grid; place-items: center; padding: 0 14px; background: var(--line); color: var(--marble); font-weight: 400; }
.num::placeholder { color: #3e4a7a; }

select {
  font: inherit;
  font-size: 17px;
  background: var(--night);
  color: var(--marble);
  border: 4px solid var(--line);
  padding: 4px 8px;
  border-radius: 0;
}

.trade { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 32px; align-items: start; }
.readout { font-family: 'Jersey 10', sans-serif; font-size: 36px; line-height: 1; color: var(--gold); }
.out { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 10px 0 4px; }
.out > span { color: var(--cloud); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 8px; }
.row label { display: inline-flex; align-items: center; gap: 8px; color: var(--cloud); }

.preview { padding-top: 30px; }
.big { font-family: 'Jersey 10', sans-serif; font-size: 64px; line-height: .95; color: var(--marble); }
.big.burn { color: var(--burn); }

/* arcs ---------------------------------------------------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 14px; margin-top: 14px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--night);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 0 0 4px var(--groove);
}
.tile:hover { box-shadow: 0 0 0 4px var(--gold); }
.tile img { display: block; width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.tile span { display: flex; justify-content: space-between; gap: 6px; padding: 3px 6px 4px; font-size: 15px; }
.tile.burning { box-shadow: 0 0 0 4px var(--burn); }
.r0 { color: var(--cloud); }
.r1 { color: var(--marble); }
.r2 { color: var(--sky); }
.r3 { color: var(--gold); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 4px; }
.filters .count { color: var(--cloud); margin-left: auto; }
.more { margin: 18px 0 4px; }

.detail { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: start; }
.detail img { width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; box-shadow: 0 0 0 4px var(--marble); }
.traits { width: 100%; max-width: 420px; border-collapse: collapse; margin: 6px 0 12px; }
.traits th, .traits td { text-align: left; padding: 5px 0; box-shadow: inset 0 -2px 0 var(--groove); font-weight: 400; }
.traits th { color: var(--cloud); width: 38%; }
.traits td.pct { color: var(--muted); text-align: right; }
.back { margin-bottom: 10px; }

.summary { display: flex; flex-wrap: wrap; gap: 28px; margin: 6px 0 4px; }
.summary div { display: grid; }
.summary span { color: var(--cloud); font-size: 16px; }
.summary b { font-family: 'Jersey 10', sans-serif; font-weight: 400; font-size: 40px; line-height: 1; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tile b { font-weight: 400; }
.tile small { font-size: 15px; }
.find { font: inherit; font-size: 17px; width: 110px; background: var(--night); color: var(--marble); border: 4px solid var(--line); padding: 4px 8px; }
.find:focus { outline: none; border-color: var(--gold); }
.linkish { font: inherit; font-size: inherit; background: none; border: 0; padding: 0; color: var(--sky); text-decoration: underline; cursor: pointer; }
.pager { display: flex; gap: 18px; }

.codex { max-width: 68ch; }
.codex dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 18px; }
.codex dt { color: var(--cloud); }
.codex dd { margin: 0; overflow-wrap: anywhere; }

/* narrow screens: the scene above, the window below --------------------------------------------------- */

@media (max-width: 900px) {
  .trade, .detail { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .preview { padding-top: 8px; }
  .detail img { max-width: 260px; }
}

@media (max-width: 720px) {
  :root { --frame: 8px; }
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(90px, 1fr) auto minmax(0, 58svh);
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    font-size: 17px;
  }
  /* lift the tall plate so the temple sits in the gap above the window, not behind the plaque */
  .plate { object-position: 50% 0; transform: translateY(-10%); }
  .brand-name { font-size: 48px; }
  .brand img { width: 38px; height: 38px; }
  .brand-line { font-size: 16px; }
  .plaque {
    grid-column: 1;
    grid-row: 3;
    width: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 2px 6px 4px;
    margin-bottom: 6px;
  }
  .price { font-size: 34px; }
  .price small { display: block; font-size: 13px; }
  .facts { display: none; }
  .plaque .btn { width: auto; font-size: 16px; padding: 7px 10px 9px; }
  .console { grid-column: 1; grid-row: 4; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .commands { flex-direction: row; overflow-x: auto; padding: 2px 0 4px; box-shadow: inset 0 -4px 0 var(--groove); scrollbar-width: none; }
  .commands { justify-content: space-between; }
  .commands a { font-size: 17px; padding: 6px 3px 8px 13px; white-space: nowrap; }
  .commands a[aria-current="page"]::before { left: 2px; width: 8px; height: 12px; margin-top: -7px; }
  .pane { padding: 8px 4px 16px; }
  h2 { font-size: 36px; }
  .num, .readout { font-size: 34px; }
  .big { font-size: 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
  /* four filters in two columns, so the arcs start on the first screen */
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filters label, .filters select, .find { width: 100%; }
  .filters .count { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .commands a[aria-current="page"]::before { animation: none; }
}
