/* Game layout on top of the pixel UI kit (ui.css). The world fills the window;
   everything else is wood panels stuck to the edges, sized for thumbs. */
#world {
  aspect-ratio: auto;
  position: fixed;
  left: 0;
  top: 0;
  touch-action: none;
}

.bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Top: where you are, and what you have left today. */
.bar.top {
  top: 0;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 8px) 12px 10px;
  background: rgba(20, 14, 9, 0.94);
  border-bottom: calc(2px * var(--ui)) solid #4a3526;
  color: var(--wood-ink);
}
.where b { display: block; font-weight: normal; font-size: 20px; line-height: 1.25; padding-top: 2px; }
.where small { color: var(--wood-dim); font-size: 13px; }
.enc { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; color: var(--wood-dim); }
.enc .pips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.enc .pip { width: 9px; height: 9px; background: var(--gold); box-shadow: inset 0 0 0 2px #7a5410; }
.enc .pip.used { background: #58493a; box-shadow: inset 0 0 0 2px #3a2f26; }

/* Bottom: four ways in. Big targets, labels only. */
.bar.bottom {
  bottom: 0;
  gap: 6px;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: #241a12;
  border-top: calc(2px * var(--ui)) solid #120c08;
}
.bar.bottom .btn-wood {
  flex: 1;
  min-height: 62px;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.ico {
  width: 20px;
  height: 20px;
  background: currentColor;
  opacity: 0.85;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.ico[data-ico='bag'] { -webkit-mask-image: url('/art/ui/bag.png'); mask-image: url('/art/ui/bag.png'); }
.ico[data-ico='log'] { -webkit-mask-image: url('/art/ui/book.png'); mask-image: url('/art/ui/book.png'); }
.ico[data-ico='hunts'] { -webkit-mask-image: url('/art/ui/track.png'); mask-image: url('/art/ui/track.png'); }
.ico[data-ico='practice'] { -webkit-mask-image: url('/art/ui/scroll.png'); mask-image: url('/art/ui/scroll.png'); }

/* The context strip: a dialog box with a portrait, then one clear action. */
.strip {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(86px + var(--safe-b));
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #1a120b;
  border: calc(2px * var(--ui)) solid #6b4a2f;
  box-shadow: inset 0 0 0 2px #2a1d14;
  color: var(--wood-ink);
}
.strip .face { width: 44px; height: 44px; flex: none; image-rendering: pixelated; }
.strip .info { flex: 1; min-width: 0; line-height: 1.35; }
.strip .info b { display: block; font-weight: normal; font-size: 18px; }
.strip .info small { color: var(--wood-dim); font-size: 13px; display: block; }
.strip .info p { margin: 0; font-size: 15px; }
.strip .btn-wood { flex: none; min-height: 48px; }
@media (max-width: 420px) {
  .strip { flex-wrap: wrap; }
  .strip .btn-wood { flex: 1 1 auto; }
}

.toast {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(96px + var(--safe-b));
  padding: 13px 14px;
  z-index: 60;
  text-align: center;
  font-size: 16px;
  background: #1a120b;
  border: calc(2px * var(--ui)) solid #6b4a2f;
  box-shadow: inset 0 0 0 2px #2a1d14;
  color: var(--wood-ink);
}
.toast.bad { color: #ffd0c8; }

/* ---- title ---- */
.title-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 40;
  background: rgba(22, 23, 31, 0.3);
}
.title-top {
  padding: calc(40px + var(--safe-t)) 20px 24px;
  text-align: center;
  background: linear-gradient(rgba(16, 12, 8, 0.92), rgba(16, 12, 8, 0));
}
.title-top h1 {
  margin: 0;
  font-weight: normal;
  font-size: clamp(38px, 10.5vw, 84px);
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 5px 0 #3a2508;
}
.title-top p { margin: 14px auto 0; font-size: 17px; max-width: 22em; color: #e6dcc6; }
.title-bottom {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px calc(18px + var(--safe-b));
  background: #241a12;
  border-top: calc(2px * var(--ui)) solid #120c08;
}
#title-hero { width: 96px; height: 96px; margin-top: -88px; image-rendering: pixelated; }
.title-bottom .btn-wood { width: min(340px, 100%); }
.linkish {
  appearance: none;
  border: 0;
  background: none;
  color: var(--wood-dim);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 8px;
  cursor: pointer;
}

/* ---- sheets ---- */
.sheet {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #171009;
  z-index: 45;
}
.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 8px) 10px 10px;
  background: #241a12;
  border-bottom: calc(2px * var(--ui)) solid #4a3526;
  color: var(--wood-ink);
}
.sheet-head h2 { flex: 1; margin: 0; font-weight: normal; font-size: 22px; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px calc(20px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-foot {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: #241a12;
  border-top: calc(2px * var(--ui)) solid #120c08;
}
.sheet-foot .btn-wood { flex: 1; }

/* A section is a wood header with its rows in a panel under it. */
.section {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 4px 2px -4px;
  font-size: 15px;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}
.section span:last-child { color: var(--wood-dim); font-size: 13px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 60px;
  background: #221a12;
  border: 2px solid #3c2c1e;
  color: var(--wood-ink);
}
.row.tap { cursor: pointer; }
.row.tap:active { background: #2c2217; }
.row.picked { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.row .face { width: 44px; height: 44px; flex: none; image-rendering: pixelated; }
.row .grow { flex: 1; min-width: 0; line-height: 1.3; }
.row .grow b { display: block; font-weight: normal; font-size: 17px; }
.row .grow small { color: var(--wood-dim); font-size: 13px; }
.row .count { font-size: 16px; color: var(--wood-dim); white-space: nowrap; }
.row .btn-wood { flex: none; min-height: 46px; font-size: 15px; }

.note {
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--wood-ink);
  background: #221a12;
  border: 2px solid #3c2c1e;
}
.note.muted { color: var(--wood-dim); }
.empty { padding: 30px 14px; color: var(--wood-dim); text-align: center; font-size: 15px; }

/* Faces in a grid of inventory slots. */
.grid-faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.grid-faces .cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-width: calc(4px * var(--ui));
  border-style: solid;
  border-color: transparent;
  border-image: url('/art/ui/wood/inventory_cell.png') 4 fill repeat;
  image-rendering: pixelated;
}
.grid-faces .cell canvas { width: 40px; height: 40px; }
.grid-faces .cell.unseen canvas { filter: brightness(0) opacity(0.45); }

.rates {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.rates div {
  padding: 9px 2px;
  text-align: center;
  font-size: 12px;
  color: var(--wood-dim);
  background: #221a12;
  border: 2px solid #3c2c1e;
}
.rates div b { display: block; font-weight: normal; font-size: 18px; margin-bottom: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .btn-wood { min-height: 46px; font-size: 15px; padding: 8px 12px; }

.banner { display: block; width: 100%; height: 96px; image-rendering: pixelated; }
.stars { color: var(--gold); }

.rar-0 { color: #e9e0cc; }
.rar-1 { color: #86d3f2; }
.rar-2 { color: #d2a6ff; }
.rar-3 { color: var(--gold); }

/* Text fields: dark ground, cream ink, thumb-sized. */
.field {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 17px;
  padding: 12px;
  min-height: 50px;
  background: #120c08;
  border: 2px solid #4a3526;
  color: var(--wood-ink);
}
.field:focus { outline: 3px solid var(--gold); outline-offset: 1px; }

/* ---- menu components (UX pass) ------------------------------------------
   Art first: a monster is a picture in a slot. Text supports it, never replaces it. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.cards.two { grid-template-columns: repeat(2, 1fr); }
.card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 6px 10px; min-height: 124px;
  background: #221a12; border: 2px solid #3c2c1e; color: var(--wood-ink);
  font: inherit; text-align: center; cursor: pointer;
}
.card:disabled { cursor: default; }
.card:active { background: #2c2217; }
.card.picked { border-color: var(--gold); box-shadow: inset 0 0 0 2px rgba(242, 181, 68, 0.3); }
.card.dim { opacity: 0.5; }
.card b { font-weight: normal; font-size: 14px; line-height: 1.2; }
.card small { color: var(--wood-dim); font-size: 11px; line-height: 1.2; }
.card-art {
  position: relative; width: 66px; height: 66px; display: grid; place-items: center;
  border-width: calc(4px * var(--ui)); border-style: solid; border-color: transparent;
  border-image: url('/art/ui/wood/inventory_cell.png') 4 fill repeat; image-rendering: pixelated;
}
.card-art canvas { width: 52px; height: 52px; }
.card-art .badge {
  position: absolute; right: -8px; bottom: -8px; font-style: normal; font-size: 11px;
  padding: 1px 5px; background: #120c08; border: 2px solid #4a3526; color: var(--wood-ink);
}
.card-art .stars { position: absolute; left: -2px; top: -10px; font-style: normal; font-size: 12px; color: var(--gold); }

/* Who this is: picture big, facts as chips, prose kept to one line. */
.hero { display: flex; gap: 12px; align-items: center; padding: 10px; background: #221a12; border: 2px solid #3c2c1e; }
.hero-art {
  width: 112px; height: 112px; flex: none; display: grid; place-items: center;
  border-width: calc(4px * var(--ui)); border-style: solid; border-color: transparent;
  border-image: url('/art/ui/wood/inventory_cell.png') 4 fill repeat; image-rendering: pixelated;
}
.hero-art canvas { width: 88px; height: 88px; }
.hero-facts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.hero-facts p { margin: 0; font-size: 14px; color: var(--wood-dim); line-height: 1.4; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-style: normal; font-size: 12px; padding: 3px 7px; background: #120c08; border: 1px solid #4a3526; color: var(--wood-dim); }
.tag.gold { color: var(--gold); }

/* The wheel, shown as faces instead of a sentence. */
.wheel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wheel-side { padding: 8px; background: #221a12; border: 2px solid #3c2c1e; }
.wheel-side small { color: var(--wood-dim); font-size: 12px; }
.faces { display: flex; gap: 10px; margin-top: 6px; }
.mini { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.mini canvas { width: 34px; height: 34px; image-rendering: pixelated; }
.mini i { font-style: normal; color: var(--wood-dim); }

.bigstat { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: #221a12; border: 2px solid #3c2c1e; }
.bigstat b { font-weight: 700; font-size: 44px; line-height: 1; color: var(--gold); }
.bigstat span { font-size: 13px; color: var(--wood-dim); }
.meter { position: relative; height: 16px; background: #120c08; border: 2px solid #4a3526; }
.meter i { display: block; height: 100%; background: var(--gold); }
.meter b { position: absolute; inset: 0; font-weight: normal; font-size: 11px; line-height: 16px; text-align: center; color: #fff6df; text-shadow: 0 1px 0 #000; }

.pips4 { display: flex; gap: 3px; margin-top: 2px; }
.pip { font-style: normal; font-size: 11px; min-width: 28px; padding: 3px 0; text-align: center; background: #120c08; border: 1px solid #3c2c1e; color: #6b5a48; }
.pip.on { border-color: #5a4632; }

/* The trader's deal, drawn: three in, one out. */
.deal { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; background: #221a12; border: 2px solid #3c2c1e; }
.deal-slot {
  width: 62px; height: 62px; display: grid; place-items: center; opacity: 0.5;
  border-width: calc(4px * var(--ui)); border-style: solid; border-color: transparent;
  border-image: url('/art/ui/wood/inventory_cell.png') 4 fill repeat; image-rendering: pixelated;
}
.deal-slot.full, .deal-slot.out { opacity: 1; }
.deal-slot canvas { width: 48px; height: 48px; }
.deal .arrow { font-style: normal; font-size: 22px; color: var(--gold); }

.list { display: flex; flex-direction: column; gap: 8px; }
.sheet-foot { flex-wrap: wrap; }
.foot-row { display: flex; gap: 8px; flex: 1 0 100%; }
.foot-row .btn-wood { flex: 1; }
.grid-faces .cell { position: relative; }
.grid-faces .cell .cap { position: absolute; left: 0; right: 0; bottom: 1px; font-style: normal; font-size: 9px; color: var(--wood-dim); }

/* ---- wide screens -------------------------------------------------------
   A phone layout stretched to 1470px is a black void with specks in it.
   On a desktop the menus become a centred window over the dimmed world, and
   nothing inside runs wider than a comfortable reading column. */
@media (min-width: 720px) {
  .sheet {
    inset: auto;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(900px, 94vw);
    height: min(880px, 90vh);
    border: calc(2px * var(--ui)) solid #6b4a2f;
    box-shadow: inset 0 0 0 2px #2a1d14, 0 0 0 100vmax rgba(8, 5, 3, 0.66);
  }
  .sheet-head { padding: 12px 14px; }
  .sheet-body { padding: 14px; gap: 12px; }
  .sheet-foot { padding: 12px 14px; }
  .sheet-foot .btn-wood { flex: 0 1 260px; }
  .foot-row { flex: 1 0 100%; }

  /* Bars and the strip stop being full-bleed: they sit in a centred column. */
  .bar.top > * { max-width: 460px; }
  .bar.top { padding-left: max(12px, calc((100vw - 1100px) / 2)); padding-right: max(12px, calc((100vw - 1100px) / 2)); }
  .bar.bottom { left: 50%; transform: translateX(-50%); width: min(760px, 96vw); border-radius: 0; }
  .strip { left: 50%; transform: translateX(-50%); width: min(760px, 96vw); }
  .toast { left: 50%; transform: translateX(-50%); width: min(560px, 90vw); }

  /* Tiles get room to be pictures rather than specks. */
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { min-height: 168px; padding: 12px 10px 14px; }
  .card-art { width: 92px; height: 92px; }
  .card-art canvas { width: 72px; height: 72px; }
  .card b { font-size: 16px; }
  .card small { font-size: 12px; }
  .pip { min-width: 40px; font-size: 12px; padding: 5px 0; }

  /* A progress bar 1400px wide reads as a loading screen. Cap it and keep the numbers close. */
  .row { padding: 10px 14px; }
  .row .grow { display: flex; align-items: center; gap: 14px; }
  .row .grow b { flex: 0 0 auto; min-width: 120px; }
  .row .grow .meter { flex: 0 1 340px; }
  .row .grow small { flex: 1; }
  .hero-art { width: 132px; height: 132px; }
  .hero-art canvas { width: 108px; height: 108px; }
  .grid-faces { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .grid-faces .cell canvas { width: 56px; height: 56px; }
  .bigstat b { font-size: 56px; }
  .note, .empty { font-size: 16px; }

  /* Minigame furniture keeps to the middle too. */
  .mg-prompt { padding: 14px; }
  .mg-prompt, .mg-controls { margin: 0 auto; width: min(760px, 100%); }
}

/* ---- the seal: the reveal ----------------------------------------------- */
.reveal { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; background: radial-gradient(circle at 50% 40%, rgba(60, 40, 10, 0.55), rgba(10, 7, 4, 0.94) 70%); z-index: 5; }
.reveal-fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.reveal-card {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 0 auto; width: min(560px, 100%);
  padding: 16px 16px calc(18px + var(--safe-b));
  background: #1a120b; border-top: calc(2px * var(--ui)) solid #6b4a2f;
  opacity: 0; transform: translateY(18px);
  transition: opacity 260ms ease-out, transform 260ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.reveal-card.in { opacity: 1; transform: none; }
.reveal-banner { font-size: 15px; letter-spacing: 3px; text-transform: uppercase; }
.reveal-name { margin: 0; font-weight: normal; font-size: clamp(26px, 7vw, 40px); line-height: 1.1; text-align: center; color: var(--wood-ink); }
.reveal-line { margin: 0; font-size: 15px; color: var(--wood-dim); text-align: center; }
.reveal-card .btn-wood { width: min(320px, 100%); margin-top: 4px; }
.reveal-new {
  position: absolute; top: -14px; right: 14px; font-style: normal; font-size: 13px; letter-spacing: 2px;
  padding: 4px 10px; background: var(--gold); color: #231a06; transform: rotate(-6deg);
}
@media (min-width: 720px) {
  .reveal-card { width: min(620px, 92%); margin-bottom: 24px; border: calc(2px * var(--ui)) solid #6b4a2f; box-shadow: inset 0 0 0 2px #2a1d14; }
}
