/* Brunnengräber on top of Survivor's HerpDerp skin (../css/style.css): same HUD and panel frame
   as the other Puddlehold games; windows and parchment cards come from ../css/phone.css, buttons
   are the shared menu's (.phm-btn).
   Jersey 10 is sharp only at 56/3 px or twice that. */
html, body { margin: 0; height: 100%; overflow: hidden; background: #160d06; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#game { display: block; position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; }
img { image-rendering: pixelated; }
/* the rope pulls the digger up: a short black-out between the shaft and the surface */
#fade { position: fixed; inset: 0; background: #0c0703; opacity: 0; pointer-events: none; z-index: 15; transition: opacity .35s steps(5); }
#fade.on { opacity: 1; }

/* HUD: Survivor's .xpbar shows the Puste, #topbar depth, basket and coins.
   Icons are 9 art px files (18 px) shown at 27 CSS px: 3 CSS px per art pixel. */
#topbar .tb { display: flex; align-items: baseline; gap: 4px; }
#topbar img { width: 27px; height: 27px; display: block; align-self: center; }
#topbar b { font-size: var(--nx2, 28px); line-height: 1; font-variant-numeric: tabular-nums; }
#topbar small { color: var(--muted); text-shadow: var(--ink-outline); }
.xpbar.puste .fill { background: linear-gradient(#ffe08a, #e0a030); transition: width .15s; }
.xpbar.puste.low .fill { background: linear-gradient(#ff8a60, #d42a1c); }
#hud .banner { top: calc(env(safe-area-inset-top, 0px) + 96px); bottom: auto; width: max-content; max-width: calc(100vw - 32px); }
/* the rope button: bottom right, a big thumb target */
#hud .rope { position: absolute; right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 6px; padding: 4px 14px 4px 8px; font-family: var(--font); }
#hud .rope img { width: 48px; height: 48px; }

/* the notes (how to play, last receipt) and the upgrades: one column upright, two columns on a
   phone held sideways, so "Runter!" and the upgrades show without scrolling the window (BG-12) */
.hnote { display: contents; }
@media (orientation: landscape) and (max-height: 520px) {
  #shop .hpanel {
    width: min(660px, calc(100vw - 24px)); height: calc(100vh - 24px); height: calc(100dvh - 24px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px; justify-items: stretch; align-items: start;
  }
  #shop .hpanel > h2, #shop .hpanel > .hsub, #shop .hpanel > .purse { grid-column: 1; justify-self: center; }
  #shop .hpanel > .purse { grid-row: 3; }
  #shop .hscroll { display: contents; }
  #shop .hnote { grid-column: 1; grid-row: 4; display: flex; flex-direction: column; gap: 6px; min-height: 0; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
  #shop .hnote > * { flex: none; }
  #shop #ups { grid-column: 2; grid-row: 1 / 5; min-height: 0; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
  #shop .hbtns { grid-column: 1 / 3; grid-row: 5; justify-self: center; }
  #shop .hpanel > h2 { margin-top: 0; }
}
.receipt .row { display: flex; justify-content: space-between; gap: 8px; }
.receipt .row b { color: #6b4a22; font-weight: 400; }
.receipt .lost { color: #b3361a; }
.purse { display: flex; align-items: center; gap: 6px; }
.purse img { width: 27px; height: 27px; }
.purse b { color: var(--gold); text-shadow: var(--ink-outline); font-size: var(--nx2, 28px); line-height: 1; }

/* upgrade rows: icon, name and effect, level pips, buy button */
.ups { align-self: stretch; display: flex; flex-direction: column; gap: 4px; }
.up { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 8px; text-align: left;
  background: rgba(43, 26, 14, .55); border: 2px solid #2b1a0e; border-radius: 10px; padding: 3px 6px; }
.up img { width: 48px; height: 48px; }
.up .nm { color: var(--text); text-shadow: var(--ink-outline); line-height: 1; }
.up .fx { color: var(--muted); text-shadow: var(--ink-outline); line-height: 1; }
.up .pips { display: flex; gap: 2px; margin-top: 2px; }
.up .pips i { width: 9px; height: 9px; background: #2a1708; border: 2px solid #2b1a0e; border-radius: 2px; }
.up .pips i.on { background: var(--gold); }
.up .phm-btn { display: flex; align-items: center; gap: 4px; padding: 2px 10px; min-width: 76px; justify-content: center; }
.up .phm-btn img { width: 18px; height: 18px; }
.up .phm-btn:disabled { opacity: .55; cursor: default; }
.up.max .phm-btn { visibility: hidden; }

/* shown until the first sheets are in, and while a late sheet is awaited (BG-05) */
#loading { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; pointer-events: none; }
#loading.hidden { display: none; }
#loading p { margin: 0; align-self: auto; text-align: center; }
.book .dev { margin: 2px 0 0; text-align: center; color: var(--phm-brown); }
.book h3 { margin: 0; font-weight: 400; text-align: center; color: var(--phm-brown); }
.book ol { margin: 0; padding: 0; list-style: none; }
.book li { display: flex; gap: 8px; font-variant-numeric: tabular-nums; }
.book li .n { width: 24px; color: var(--phm-brown); }
.book li .nm { flex: 1; }
.book li.me { color: #b3361a; }

/* Phones (BG-04): the status tab sits left of the music and menu buttons, numbers in the 18.667 px
   size, so depth, basket and four-digit coins fit at 360 px */
@media (max-width: 640px) {
  #topbar { left: calc(8px + var(--sal, 0px)); transform: none; max-width: calc(100vw - 124px); gap: 8px; padding: 4px 10px 6px; }
  #topbar b { font-size: var(--px); }
  #topbar img { width: 27px; height: 27px; }
}
/* Phones: Survivor moves its level bar into the hero block; here it sits just below the status tab. */
@media (max-width: 640px), (max-height: 520px) {
  #hud > .xpbar { position: fixed; left: calc(12px + var(--sal)); right: calc(64px + env(safe-area-inset-right, 0px));
    top: calc(56px + var(--sat)); z-index: 1; margin: 0; height: 22px; border: 3px solid #2b1a0e; border-radius: 11px; }
  #hud > .xpbar { height: 26px; }
  /* Survivor's phone rule sets 15 px here; the Puste text is 18.667 px like the other HUD text */
  #hud > .xpbar span { line-height: 20px; font-size: var(--px); }
}
