:root {
  --display: "Sitka Banner", "Sitka Display", "Sitka Heading", Constantia, "Palatino Linotype", Georgia, serif;
  --text: Bahnschrift, Corbel, Candara, "Segoe UI", sans-serif;
  --ink: #2b1d11;
  --cream: #f4e6c6;
  --brass: #c4933f;
  --brass-dark: #5d3f17;
  --brass-light: #efcd7a;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1420; user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; font-family: var(--text); color: var(--cream); }
.hidden { display: none !important; }

/* ---------- plaques (buttons) ---------- */
.plaque {
  pointer-events: auto; position: relative; display: block; margin: 34px auto 0; min-width: 320px; padding: 14px 34px 15px;
  background: var(--wood); background-size: 512px 128px; border: 3px solid #2e1b0d; border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(255, 214, 150, 0.16), 0 6px 0 rgba(20, 10, 4, 0.55), 0 10px 22px rgba(0, 0, 0, 0.35);
  color: #f6e5c0; font-family: var(--display); font-size: 29px; font-weight: 600; cursor: pointer;
  text-shadow: 0 2px 0 rgba(30, 14, 4, 0.75); transition: transform 0.12s ease, filter 0.12s ease;
  transform-origin: 50% -30px;
}
.plaque span { position: relative; z-index: 1; }
.plaque::before, .plaque::after {
  content: ""; position: absolute; top: -34px; width: 4px; height: 31px;
  background: repeating-linear-gradient(170deg, #d1ad6e 0 3px, #8c6a38 3px 6px); border-radius: 1px;
}
.plaque::before { left: 30px; } .plaque::after { right: 30px; }
.plaque:hover:not([disabled]) { transform: translateY(-2px) rotate(-0.7deg); filter: brightness(1.13) saturate(1.05); }
.plaque:active:not([disabled]) { transform: translateY(3px); filter: brightness(0.9); box-shadow: inset 0 0 0 2px rgba(255, 214, 150, 0.1), 0 2px 0 rgba(20, 10, 4, 0.55); }
.plaque:focus-visible { outline: 3px solid var(--brass-light); outline-offset: 4px; }
.plaque[disabled] { cursor: progress; filter: saturate(0.6) brightness(0.85); }
.plaque.small { min-width: 210px; font-size: 21px; padding: 9px 24px 10px; margin-top: 30px; }
.plaque.small::before, .plaque.small::after { top: -30px; height: 27px; }

/* ---------- title ---------- */
.title { position: absolute; inset: 0; pointer-events: none; }
.title .tagline {
  position: absolute; top: 40.5%; left: 0; right: 0; text-align: center; font-family: var(--display); font-style: italic;
  font-size: 25px; color: #fbe9c9; text-shadow: 0 2px 3px rgba(40, 14, 30, 0.85), 0 0 1px rgba(0,0,0,0.6);
  opacity: 0; transition: opacity 1.2s ease 0.4s;
}
.title.ready .tagline { opacity: 1; }
.title .menu { position: absolute; top: 52%; left: 50%; transform: translateX(-50%); text-align: center; }
.title .loadbar { position: absolute; top: calc(52% + 98px); left: 50%; width: 260px; height: 6px; transform: translateX(-50%); background: rgba(30, 16, 8, 0.6); border: 1px solid #3b2612; }
.title .loadbar i { display: block; height: 100%; width: 0; background: var(--brass-light); transition: width 0.2s; }
.title.ready .loadbar { opacity: 0; transition: opacity 0.6s; }
.controls {
  position: absolute; right: 36px; bottom: 34px; width: 330px; padding: 18px 22px 16px; color: var(--ink);
  background: var(--parchment); background-size: 512px; border: 2px solid #8a6a3e; border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); transform: rotate(0.8deg);
  font-family: var(--text); font-size: 15px;
}
.controls .ctitle { font-family: var(--display); font-size: 23px; font-weight: 600; margin-bottom: 8px; color: #3a2614; }
.controls .row { display: flex; align-items: center; gap: 12px; margin: 5px 0; }
.controls .keys { display: flex; gap: 3px; min-width: 112px; align-items: center; }
.controls .keys i { font-style: normal; padding: 0 2px; }
.controls b {
  display: inline-block; min-width: 22px; padding: 2px 5px 3px; text-align: center; font-weight: 600; font-size: 13px;
  color: #f2e2bd; background: #4c3420; border: 1px solid #2a1a0c; border-bottom-width: 3px; border-radius: 3px;
}
.controls b.wide { min-width: 52px; } .controls b.mouse { min-width: 86px; background: #5b4632; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; }
.compass { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); text-align: center; }
.compass .ribbon {
  position: relative; width: 500px; height: 40px; overflow: hidden;
  background: var(--parchment); background-size: 512px; border-top: 2px solid #7a5a32; border-bottom: 2px solid #7a5a32;
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%);
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.4));
}
.compass .strip { position: absolute; left: 50%; top: 0; height: 100%; }
.compass .strip span, .compass .strip i { position: absolute; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; width: 40px; margin-left: -20px; }
.compass .strip span.major { font-family: var(--display); font-weight: 700; font-size: 23px; color: #3a2513; }
.compass .strip span.minor { font-family: var(--display); font-size: 15px; color: #6a4c2c; }
.compass .strip i.tick { width: 2px; margin-left: -1px; height: 9px; top: 15px; background: #8a6c47; }
.compass .beaconmark {
  position: absolute; left: 50%; top: 0; width: 0; height: 0; margin-left: -9px;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 13px solid #b8411f;
  filter: drop-shadow(0 1px 0 #3a1508);
}
.compass .beaconmark.off { border-top-color: #b8411f; opacity: 0.75; }
.compass .goal { margin-top: 6px; font-family: var(--display); font-size: 19px; text-shadow: 0 1px 3px rgba(0,0,0,0.85); color: #fbeacb; }
.compass .goal .gname { font-weight: 700; margin-right: 10px; }
.compass .goal .gdist { font-family: var(--text); font-size: 15px; opacity: 0.9; }

.gauge { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); width: 46px; text-align: center; }
.gauge .cap { font-family: var(--display); font-size: 14px; margin-bottom: 6px; text-shadow: 0 1px 3px #000; }
.gauge .col {
  position: relative; height: 300px; width: 22px; margin: 0 auto; background: var(--stone); background-size: 128px;
  border: 3px solid #3c3833; border-radius: 2px; box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.gauge .water {
  position: absolute; left: 3px; right: 3px; bottom: 0; height: 0;
  background: repeating-linear-gradient(180deg, #7fc4d8 0 5px, #4a93b3 5px 9px, #a9dbe6 9px 11px);
  background-size: 100% 22px; animation: fall 0.8s linear infinite; opacity: 0.92; transition: height 0.3s;
}
@keyframes fall { from { background-position: 0 0; } to { background-position: 0 22px; } }
.gauge .marks { position: absolute; inset: 0; }
.gauge .mark { position: absolute; left: -6px; right: -6px; height: 2px; background: #e9d3a1; box-shadow: 0 1px 0 #2a1d10; }
.gauge .me {
  position: absolute; left: -15px; width: 0; height: 0; margin-bottom: -7px;
  border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 11px solid var(--brass-light);
  filter: drop-shadow(0 1px 1px #000); transition: bottom 0.3s;
}
.gauge .alt { margin-top: 8px; font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px #000; }

.cross { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --m: 0; }
.cross i { position: absolute; width: 4px; height: 4px; background: rgba(255, 246, 228, 0.85); box-shadow: 0 0 0 1px rgba(30, 18, 8, 0.6); transition: transform 0.08s; }
.cross i:nth-child(1) { transform: translate(calc(-2px - 6px + var(--m) * 4px), -2px); }
.cross i:nth-child(2) { transform: translate(calc(-2px + 6px - var(--m) * 4px), -2px); }
.cross i:nth-child(3) { transform: translate(-2px, calc(-2px - 6px + var(--m) * 4px)); }
.cross i:nth-child(4) { transform: translate(-2px, calc(-2px + 6px - var(--m) * 4px)); }
.cross.on i { background: #fff6dc; }

.hotbar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; }
.slot {
  position: relative; width: 62px; height: 66px; padding: 5px; box-sizing: border-box;
  background: var(--brass); background-size: 128px; border: 2px solid var(--brass-dark); border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 150, 0.35), 0 4px 8px rgba(0,0,0,0.45); transition: transform 0.12s ease;
}
.slot::after { content: ""; position: absolute; left: 4px; top: 4px; width: 5px; height: 5px; border-radius: 50%; background: #7a5420; box-shadow: 47px 0 #7a5420, 0 51px #7a5420, 47px 51px #7a5420; }
.slot .well { width: 100%; height: 100%; background: rgba(16, 30, 33, 0.72); border: 1px solid #3d2a10; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.slot .well::before { content: ""; position: absolute; left: -10px; top: -30px; width: 16px; height: 120px; background: rgba(255,255,255,0.07); transform: rotate(32deg); }
.slot img { width: 46px; height: 46px; image-rendering: pixelated; transition: opacity 0.2s; }
.slot.empty img { opacity: 0.32; }
.slot .key { position: absolute; top: -17px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 600; color: #fff1d2; text-shadow: 0 1px 2px #000; }
.slot .count { position: absolute; right: 7px; bottom: 5px; font-size: 16px; font-weight: 700; color: #fff7e4; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.slot.sel { transform: translateY(-7px); background-color: #e2b45b; border-color: #2d1d08; box-shadow: inset 0 0 0 2px var(--brass-light), 0 8px 12px rgba(0,0,0,0.5); }
.slot.sel .key { color: var(--brass-light); }
.slot.pop { animation: pop 0.28s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.slot.sel.pop { animation: popsel 0.28s ease; }
@keyframes popsel { 0% { transform: translateY(-7px) scale(1); } 40% { transform: translateY(-7px) scale(1.12); } 100% { transform: translateY(-7px) scale(1); } }
.slot.shake { animation: shake 0.3s ease; }
@keyframes shake { 0%,100% { margin-left: 0; } 25% { margin-left: -4px; } 75% { margin-left: 4px; } }
.slotname { position: absolute; bottom: 104px; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 19px; text-shadow: 0 1px 3px #000; opacity: 0; }
.slotname.show { animation: fadeinout 1.6s ease forwards; }
@keyframes fadeinout { 0% { opacity: 0; } 12% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

.hint {
  position: absolute; bottom: 136px; left: 50%; transform: translateX(-50%); padding: 8px 18px 9px; color: var(--ink);
  background: var(--parchment); background-size: 512px; border: 2px solid #8a6a3e; border-radius: 2px; font-size: 17px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35); opacity: 0; transition: opacity 0.4s; white-space: nowrap;
}
.hint.show { opacity: 1; }
.hint b { display: inline-block; padding: 1px 6px 2px; margin: 0 2px; font-size: 14px; color: #f2e2bd; background: #4c3420; border: 1px solid #2a1a0c; border-bottom-width: 3px; border-radius: 3px; }
.card { position: absolute; top: 22%; left: 0; right: 0; text-align: center; opacity: 0; }
.card .c1 { font-family: var(--display); font-size: 54px; font-weight: 600; color: #fff0d2; text-shadow: 0 3px 6px rgba(20, 8, 20, 0.8); }
.card .c2 { font-family: var(--display); font-style: italic; font-size: 21px; margin-top: 2px; color: #fbe3bf; text-shadow: 0 2px 4px rgba(20,8,20,0.9); }
.card.show { animation: card 4.5s ease forwards; }
@keyframes card { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }
.msg { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-family: var(--display); font-size: 30px; text-shadow: 0 2px 5px rgba(0,0,0,0.85); opacity: 0; }
.msg.show { animation: fadeinout 3.5s ease forwards; }

/* ---------- pause and ending ---------- */
.pause { position: absolute; inset: 0; background: rgba(18, 10, 22, 0.45); pointer-events: auto; display: flex; align-items: center; justify-content: center; }
.pause .sheet, .ending .page {
  width: 440px; padding: 30px 40px 40px; color: var(--ink); text-align: center;
  background: var(--parchment); background-size: 512px; border: 2px solid #8a6a3e; box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.pause .ptitle, .ending .etitle { font-family: var(--display); font-size: 46px; font-weight: 600; color: #3a2513; }
.pause p { font-size: 17px; margin: 4px 0 0; }
.ending { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: flex-end; padding-right: 8%; }
.ending .page { transform: rotate(-1deg); animation: rise 1.2s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(30px) rotate(-1deg); } to { opacity: 1; transform: rotate(-1deg); } }
.ending .esub { font-family: var(--display); font-style: italic; font-size: 22px; margin-bottom: 16px; }
.ending .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin: 10px 0 4px; }
.ending .stats div { display: flex; flex-direction: column; align-items: center; padding: 8px; border-top: 1px solid rgba(90, 60, 30, 0.35); }
.ending .stats b { font-family: var(--display); font-size: 34px; color: #4a2c14; }
.ending .stats span { font-size: 14px; color: #5d4227; }
.pause .plaque, .ending .plaque { margin-left: auto; margin-right: auto; }
.pause .pkeys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 24px; font-size: 14px; color: #4a3420; }
.pause .pkeys b { display: inline-block; padding: 1px 6px 2px; margin-right: 4px; font-size: 12px; color: #f2e2bd; background: #4c3420; border: 1px solid #2a1a0c; border-bottom-width: 3px; border-radius: 3px; }
