@import url('./type.css');
:root {
  color-scheme: dark;
  --bone: #e6dfca;
  --chalk: #c2bba8;
  --ink: #1c1b1a;
  --line: #494448;
  --paper: #242327;
  --left: max(22px, env(safe-area-inset-left));
  --right: max(22px, env(safe-area-inset-right));
  --top: max(17px, env(safe-area-inset-top));
  --bottom: max(20px, env(safe-area-inset-bottom));
  background: #16151b;
  color: var(--bone);
  font: 16px/1.4 var(--lettering);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #game, #stage { margin: 0; width: 100%; height: 100%; overflow: hidden; }
#game, #stage { position: relative; }
#scene {
  position: absolute;
  inset: 0 auto auto 0;
  display: block;
  outline: none;
  image-rendering: pixelated;
  touch-action: none;
}
button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid #e0cb94;
  outline-offset: 2px;
}
button { -webkit-tap-highlight-color: transparent; }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.condition, .utilities { position: absolute; }
h2 { margin: 0; font-family: var(--lettering); font-weight: 700; }
.utilities {
  top: var(--top);
  right: var(--right);
  display: flex;
  align-items: center;
  gap: 2px;
}
.utilities button {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: manipulation;
}
#hud img { display: block; image-rendering: pixelated; }
.utilities img { filter: drop-shadow(0 1px 1px #171511); }
.utilities button:hover img,
.utilities button:focus-visible img { filter: brightness(1.2) drop-shadow(0 1px 1px #171511); }
.pause-mark {
  width: 16px;
  height: 20px;
  border-inline: 6px solid #d5cdb6;
  box-shadow: 0 1px 1px #181613;
  filter: drop-shadow(0 1px 1px #181613);
}
.tip {
  position: absolute;
  z-index: 2;
  width: max-content;
  padding: 4px 8px;
  background: #23221cf5;
  color: var(--bone);
  font: 14px/1.25 var(--lettering);
  pointer-events: none;
  visibility: hidden;
}
.utilities .tip { inset: 100% 0 auto auto; }
@media (hover: hover) {
  button:hover > .tip { visibility: visible; }
}
button:focus-visible > .tip { visibility: visible; }
.condition {
  left: var(--left);
  bottom: var(--bottom);
  display: grid;
  grid-template: auto 22px / 128px;
  align-items: center;
}
/* The potions he carries, one tap or key from his mouth. */
#belt { display: flex; gap: 6px; margin: 0 0 8px 8px; }
#belt button { display: flex; align-items: center; gap: 3px; padding: 2px 7px 2px 3px; background: #24241fd9; border: 0; border-bottom: 1px solid #8e856a; }
#belt canvas { width: 28px; height: 28px; image-rendering: pixelated; }
#belt kbd { font-size: 13px; }
@media (pointer: coarse) { #belt button { min-height: 44px; min-width: 44px; } #belt kbd { display: none; } }
.stamina-label {
  padding-left: 13px;
  color: var(--chalk);
  font: 14px/1 var(--lettering);
  text-shadow: 0 1px 2px #0e100c, 0 0 5px #161611;
}
.stamina-shell {
  position: relative;
  grid-area: 2 / 1;
  width: 128px;
  height: 22px;
  background: url('./art/hud/stamina.png') center / 100% 100% no-repeat;
  image-rendering: pixelated;
}
#health-block {
  position: absolute;
  left: 0;
  bottom: 100%;
  display: grid;
  grid-template: auto 22px / 128px;
  align-items: center;
  margin-bottom: 4px;
}
#health-block[hidden] { display: none; }
/* The combat exit cooldown: weapons stay out until this yellow bar runs dry. */
#combat-block {
  position: absolute;
  left: 0;
  bottom: calc(100% + 44px);
  display: grid;
  grid-template: auto 22px / 128px;
  align-items: center;
}
#combat-block[hidden] { display: none; }
#combat {
  appearance: none;
  position: absolute;
  left: 14px;
  top: 8px;
  width: 102px;
  height: 6px;
  border: none;
  background: transparent;
  --fill: linear-gradient(to bottom, #f2d47a 0 33%, #c99a2e 33% 100%);
}
#combat::-webkit-meter-inner-element { display: block; }
#combat::-webkit-meter-bar { height: 100%; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
#combat::-webkit-meter-optimum-value, #combat::-webkit-meter-suboptimum-value, #combat::-webkit-meter-even-less-good-value { border-radius: 0; background: var(--fill); }
#combat::-moz-meter-bar { border: 0; background: var(--fill); }
#health {
  appearance: none;
  position: absolute;
  left: 14px;
  top: 8px;
  width: 102px;
  height: 6px;
  border: none;
  background: transparent;
  --fill: linear-gradient(to bottom, #b56a5e 0 33%, #8a3f39 33% 100%);
}
#health::-webkit-meter-inner-element { display: block; }
#health::-webkit-meter-bar { height: 100%; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
#health::-webkit-meter-optimum-value, #health::-webkit-meter-suboptimum-value, #health::-webkit-meter-even-less-good-value { border-radius: 0; background: var(--fill); }
#health::-moz-meter-bar { border: 0; background: var(--fill); }
#stamina {
  appearance: none;
  position: absolute;
  left: 14px;
  top: 8px;
  width: 102px;
  height: 6px;
  border: none;
  background: transparent;
  --fill: linear-gradient(to bottom, #bcc19a 0 33%, #929d75 33% 100%);
}
#stamina::-webkit-meter-inner-element { display: block; }
#stamina::-webkit-meter-bar { height: 100%; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
#stamina::-webkit-meter-optimum-value { border-radius: 0; background: var(--fill); }
#stamina::-moz-meter-bar { border: 0; background: var(--fill); }
kbd { color: #bcb69e; font: 14px var(--lettering); }
#action {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 5px 9px;
  background: #24241ff2;
  border: 0;
  border-bottom: 1px solid #8e856a;
  font: 16px var(--lettering);
  white-space: nowrap;
}
#action kbd { margin-left: 8px; }
/* A thought over the traveler's head; the dungeon's remarks across the top of the room. */
#blurb {
  position: absolute;
  z-index: 3;
  max-width: min(300px, calc(100% - 24px));
  transform: translate(-50%, calc(-100% - 10px));
  padding: 5px 10px 6px;
  background: #e6dfcaf0;
  color: #24221f;
  border-radius: 9px;
  font: 15px/1.25 var(--lettering);
  text-align: center;
  pointer-events: none;
}
#blurb::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 6px; height: 6px;
  margin-left: -9px;
  border-radius: 50%;
  background: #e6dfcaf0;
  box-shadow: 7px 6px 0 -1px #e6dfcae0;
}
#voice {
  position: absolute;
  width: max-content;
  z-index: 3;
  left: 50%;
  top: calc(var(--top) + 52px);
  text-align: center;
  pointer-events: none;
  font-family: var(--lettering);
  line-height: 1.25;
  transform: translateX(-50%);
  max-width: min(460px, calc(100% - 32px));
  padding: 4px 12px;
  background: none;
  color: #e8a3a0;
  font-size: 17px;
  letter-spacing: .04em;
  text-shadow: 0 0 6px #8f2f3acc, 0 1px 0 #1a0d10, 0 0 14px #5e1a24;
}
#blurb.in, #voice.in { animation: blurb-in .32s ease-out; }
@keyframes blurb-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #blurb.in, #voice.in { animation: none; } }
#fade { position: absolute; inset: 0; z-index: 4; background: #000; opacity: 0; pointer-events: none; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: #18171a; font: 22px var(--lettering); }
dialog {
  width: min(380px, calc(100% - 28px));
  max-height: calc(100dvh - max(32px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  padding: 16px 20px;
  color: var(--bone);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 6px 30px #100f0d94;
}
dialog::backdrop { background: #12121070; }
dialog[data-panel=trunk], dialog[data-panel=pack] { margin: auto var(--right) var(--bottom) auto; }
dialog[data-panel=trunk]::backdrop, dialog[data-panel=pack]::backdrop { background: transparent; }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h2 { font-size: 24px; line-height: 1.1; }
#close { margin-right: -4px; border: 0; background: none; min-width: 36px; min-height: 36px; color: var(--chalk); font: 24px var(--lettering); }
#sheet-body p { margin: 12px 0; font-size: 15px; }
#sheet-body p.note { margin: 0 0 8px; color: #e0a39f; font-size: 14px; }
#sheet-body a { font-size: 14px; color: #c5cba5; }
.settings, #sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings { padding: 12px 0; font-size: 14px; }
.settings input { accent-color: #aeb78c; vertical-align: middle; }
.item { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.item + .item { border-top: 1px solid var(--line); }
.item canvas { flex: none; width: 32px; height: 32px; image-rendering: pixelated; }
.item strong { font: 700 16px var(--lettering); }
.item small, #sheet-foot small { display: block; font-size: 14px; color: var(--chalk); }
.item button, #sheet-foot button {
  min-height: 36px;
  padding: 4px 10px;
  background: #35362c;
  color: #e3e5ce;
  border: 1px solid #5c5e4c;
  font: 15px var(--lettering);
}
.item button { margin-left: auto; }
.item button:hover, #sheet-foot button:hover { background: #424336; }
#sheet-foot { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; justify-content: flex-end; gap: 8px 10px; }
#sheet-foot small { margin-right: auto; }
#sheet-foot:empty { display: none; }
.chart { display: block; width: 100%; height: auto; margin-top: 6px; image-rendering: pixelated; }
.bindings { margin: 10px 0 2px; }
.bindings > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-block: 5px; }
.bindings dt { font: 15px var(--lettering); }
.bindings dd { margin: 0; color: var(--chalk); font: 14px var(--lettering); text-align: right; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 600px), (max-height: 480px) {
  :root { --left: max(12px, env(safe-area-inset-left)); --right: max(12px, env(safe-area-inset-right)); --top: max(8px, env(safe-area-inset-top)); --bottom: max(10px, env(safe-area-inset-bottom)); }
  .utilities { gap: 0; }
}
@media (pointer: coarse) {
  #action kbd { display: none; }
  .bindings button {
    min-height: 44px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    background: transparent;
  }
  #action, #close, #sheet-foot button, .item button { min-height: 44px; }
  .tip { display: none; }
}

.stamina-shell.short { animation: short-breath .32s steps(2) 2; }
@keyframes short-breath { 50% { filter: brightness(1.7) saturate(.4); } }
