/* XataWorks Quest — the page around the game picture. The picture itself is pixels on a canvas. */
:root {
  --bg: #0e1a15;
  --panel: #13241d;
  --panel-2: #1a3027;
  --line: #2c4a3d;
  --ink: #ece2c8;
  --muted: #a9b8ab;
  --green: #07563f;
  --green-2: #1f7d5a;
  --mint: #6cc29a;
  --gold: #d9a441;
  --red: #a8322d;
  --focus: #f3d36b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input { font: inherit; }
a { color: var(--mint); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

button, .button {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { border-color: var(--mint); }
button.primary, .button.primary { background: var(--green); border-color: var(--green-2); font-weight: 600; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* ---- title and hero select */
.screen[hidden] { display: none !important; }
#title, #select {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 16px;
  text-align: center;
}
.logo { border-radius: 16px; }
h1 { font-size: 40px; margin: 12px 0 6px; letter-spacing: .5px; }
h2 { margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 auto 10px; max-width: 520px; }
.fine { color: var(--muted); font-size: 13px; margin-top: 22px; }
.edition { display: inline-flex; gap: 18px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 16px 10px; margin-top: 18px; }
.edition legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.edition .soon { color: var(--muted); }
.edition .soon span { font-size: 12px; }

#heroes {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: stretch;
}
#heroes button {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 8px 12px;
  min-height: 250px;
}
#heroes canvas { image-rendering: pixelated; }
#heroes .name { font-weight: 700; font-size: 16px; }
#heroes .who, #heroes .item { color: var(--muted); font-size: 12px; }
#heroes .item { min-height: 2.9em; }
.hello { min-height: 1.5em; color: var(--gold); margin-top: 16px; }

/* ---- the game */
#game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
  height: 100vh;
}
#stageWrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  min-height: 0;
}
#stage {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
}
#stage.over { cursor: zoom-in; }
.overlay3d { position: absolute; pointer-events: none; }
#tip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 22, 16, .92);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  transform: translate(-50%, -130%);
}

/* Hotspot buttons: hidden until focused, then shown as a small label so keyboard players see where they are. */
#hotspots button {
  position: absolute;
  left: 8px;
  top: 8px;
  opacity: 0;
  pointer-events: none;
  font-size: 13px;
  padding: 3px 10px;
}
#hotspots button:focus-visible { opacity: 1; pointer-events: auto; }

#panel {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  background: rgba(13, 26, 20, .96);
  border: 1px solid var(--green-2);
  border-radius: 10px;
  padding: 14px 16px 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
}
#panel h3 { margin: 0 28px 6px 0; font-size: 17px; }
#panel .story { margin: 0 0 10px; font-style: italic; color: #d9cfb3; }
#panel .inx { border-top: 1px solid var(--line); padding-top: 8px; }
#panel h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mint); }
#panel .inx p { margin: 0 0 6px; }
#panelClose { position: absolute; right: 8px; top: 6px; padding: 0 9px; font-size: 18px; line-height: 1.4; }
.suggest { margin-top: 6px; font-size: 13px; }

#side {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
#hud { display: flex; justify-content: space-between; padding: 10px 14px 6px; font-size: 13px; color: var(--muted); }
#hud b { color: var(--ink); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 8px; }
.tools button { font-size: 13px; padding: 4px 10px; }
.logTitle { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mint); margin: 4px 14px 4px; }
#log {
  list-style: none;
  margin: 0;
  padding: 0 14px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}
#log li { margin: 0 0 8px; }
#log .narrator { color: #d9cfb3; font-style: italic; }
#log .hero b { color: var(--gold); }
#log .you { color: var(--muted); }
#log .you b { color: var(--ink); }
#log .award { color: var(--mint); font-size: 13px; }
#log details { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
#log summary { cursor: pointer; }
#log summary::marker { color: var(--mint); }
#log dl { margin: 6px 0 2px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
#log dt { color: var(--muted); }
#log dd { margin: 0; }
#chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 0; }
#chips button { font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.controls { display: flex; gap: 14px; padding: 0 14px 12px; font-size: 13px; color: var(--muted); }
.controls select { margin-left: 4px; background: #0b1611; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; }
.context { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 14px 0; }
.ctxEmpty { color: var(--muted); font-size: 12px; font-style: italic; }
.ctxChip { display: inline-flex; align-items: center; gap: 4px; background: #0b1611; border: 1px solid var(--green-2); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; }
.ctxChip.pinned { border-color: var(--gold); }
.ctxChip.out { opacity: .5; text-decoration: line-through; }
.ctxChip button { font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.ctxChip .pin[aria-pressed="true"] { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.ctxWhat { font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.askbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; width: min(520px, calc(100% - 24px)); background: rgba(13, 26, 20, .97); border: 1px solid var(--gold); border-radius: 10px; padding: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.5); z-index: 5; }
.askbar input { flex: 1; min-width: 0; background: #0b1611; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
#ask { display: flex; gap: 8px; padding: 10px 14px 14px; }
#ask input { flex: 1; min-width: 0; background: #0b1611; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
#ask input:focus { border-color: var(--mint); outline: none; }

/* ---- dialogs */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 6, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.overlay[hidden] { display: none; }
.card {
  background: var(--panel);
  border: 1px solid var(--green-2);
  border-radius: 12px;
  max-width: 620px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 20px 22px;
  text-align: center;
}
.kicker { color: var(--mint); text-transform: uppercase; font-size: 12px; letter-spacing: .1em; margin: 0 0 4px; }
.big { font-size: 19px; margin: 6px 0 14px; }
figure { margin: 0; }
figure img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }
figcaption { color: var(--muted); font-size: 13px; margin-top: 4px; }
#satchelList { list-style: none; padding: 0; text-align: left; }
#satchelList li { border-bottom: 1px solid var(--line); padding: 8px 0; }
#satchelList li span { display: block; color: var(--muted); font-size: 13px; }

.seal { max-width: 460px; text-align: left; border-color: var(--gold); position: relative; }
.seal h2 { font-size: 18px; margin-right: 40px; }
.seal .wax { position: absolute; right: 16px; top: 14px; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #c84a40, #7a1f1a); box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.badge { display: inline-block; background: #5a2420; color: #ffd9d3; border: 1px solid var(--red); border-radius: 4px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.badge[hidden] { display: none; }
.seal .detail { color: var(--muted); font-size: 13px; }
.answers { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.answers button { text-align: left; }

.pui { max-width: 980px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; text-align: left; }
.fcell { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; }
.fphoto { position: relative; aspect-ratio: 232 / 288; border-radius: 4px; overflow: hidden; touch-action: none; cursor: ns-resize; }
.fphoto img { width: 100%; height: 100%; display: block; }
.fcrop { position: absolute; left: 0; right: 0; top: var(--top, 9.7%); aspect-ratio: 1; border: 2px solid var(--gold); box-shadow: 0 0 0 999px rgba(0, 0, 0, .45); pointer-events: none; }
.fcap { margin: 6px 0 4px; color: var(--muted); }
.fcell label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.fcell select { flex: 1; background: #0b1611; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 3px; font: inherit; }
.fcell input[type=range] { flex: 1; min-width: 0; }
.ferror { color: #f3a39a; min-height: 1.2em; }
.chooseImg { max-height: 240px; border-radius: 6px; border: 1px solid var(--line); }

.appstore { max-width: 640px; text-align: left; }
.asSearch { width: 100%; background: #0b1611; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 6px 0 10px; font: inherit; }
.asList, .shopList { list-style: none; padding: 0; margin: 0; }
.asList li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.asTile { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--tile); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.asInfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.asBlurb, .asAddr { color: var(--muted); }
.asRibbon { display: inline-block; width: fit-content; background: var(--green); color: var(--ink); border-radius: 999px; padding: 0 8px; font-size: 11px; }
.asBtns { display: flex; gap: 6px; }
.asEmpty { color: var(--muted); font-style: italic; }
.shopList li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); text-align: left; }
.shopNote { grid-column: 1; color: var(--muted); font-size: 13px; }
.shopList button { grid-column: 2; grid-row: 1 / span 2; }

.dock { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: rgba(13, 26, 20, .9); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px; z-index: 4; }
.dockItem { width: 38px; height: 38px; padding: 0; border-radius: 10px; font-size: 18px; position: relative; }
.dockItem.app { background: #6a3fa8; color: #fff; font-weight: 700; }
.dockItem.open::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--mint); }
.dockApp { display: inline-flex; align-items: center; gap: 2px; }
.dockMore { display: none; width: 22px; height: 38px; padding: 0; border-radius: 8px; }
@media (pointer: coarse) { .dockMore { display: inline-block; } }
.dockDivider { width: 1px; height: 28px; background: var(--line); margin: 0 2px; }
.dockMenu { position: absolute; z-index: 6; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--green-2); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.dockMenu button { text-align: left; border: 0; background: transparent; padding: 6px 12px; }
.dockMenu button:hover, .dockMenu button:focus-visible { background: var(--green); }
#stageWrap.split #stage { transform: translateX(-24%); }
.beside { position: absolute; top: 8%; right: 2%; width: 46%; bottom: 14%; background: #f4efe2; color: #222; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); overflow: auto; z-index: 3; }
.beside header { display: flex; justify-content: space-between; align-items: center; background: #6a3fa8; color: #fff; padding: 6px 10px; font-weight: 700; }
.beside header button { background: transparent; color: #fff; border: 0; font-size: 18px; padding: 0 6px; }
.beside #besideBody { padding: 10px; font-size: 13px; }
.tbGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; list-style: none; padding: 0; margin: 8px 0 0; }
.tbGrid li { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 6px; }
.tbGrid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; }
.agGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; list-style: none; padding: 0; text-align: left; }
.agGrid li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.agHead { text-align: left; font-size: 14px; margin: 12px 0 4px; }
.finaleList { text-align: left; padding-left: 20px; }
.finaleList li { margin-bottom: 8px; }
.finaleList span { display: block; color: var(--muted); font-size: 13px; }

.outfitter { position: absolute; top: 12px; right: 12px; width: min(300px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; background: rgba(13, 26, 20, .97); border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; z-index: 5; }
.outfitter header { display: flex; justify-content: space-between; align-items: center; }
.outfitter h3 { margin: 0; font-size: 15px; }
.outfitter h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mint); }
.outfitter header button { padding: 0 9px; font-size: 18px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 30px; height: 24px; padding: 0; border-radius: 5px; background: var(--swatch); }
.swatch[aria-pressed="true"], .accOpt[aria-pressed="true"] { outline: 2px solid var(--gold); outline-offset: 2px; }
.accList { display: flex; flex-direction: column; gap: 4px; }
.accOpt, .accList button { text-align: left; font-size: 13px; padding: 5px 10px; }
.ofRow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.ofRow button { font-size: 13px; padding: 5px 10px; }

/* ---- phones */
@media (max-width: 860px) {
  #game { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  #side { border-left: 0; border-top: 1px solid var(--line); }
  #log { max-height: 34vh; }
  #heroes { grid-template-columns: repeat(2, 1fr); }
  #heroes button { min-height: 200px; }
  #panel { position: relative; left: auto; bottom: auto; transform: none; width: auto; margin: 8px; }
  #stageWrap { flex-direction: column; }
  .dock { position: static; transform: none; margin: 8px auto; }
  #stageWrap.split #stage { transform: none; }
  .outfitter { position: static; width: auto; margin: 8px; max-height: none; }
  .beside { position: static; width: auto; margin: 8px; max-height: 60vh; }
  .tbGrid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
