/* Skyreach interface: carved stone, brass, glass, parchment and wood. Textures are painted at runtime (src/ui/textures.js)
   and handed in as CSS variables, so every surface belongs to the world rather than to a web page. */
:root {
  --ink: #2c1d11;
  --parch: #ecdcb4;
  --cream: #f7ecd2;
  --brass: #c89b48;
  --brass-hi: #efcf86;
  --brass-lo: #5e4219;
  --stone: #5d554b;
  --glass: rgba(150, 206, 222, 0.24);
  --display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --text: Constantia, Georgia, "Times New Roman", serif;
  --stone-img: #5d554b;
  --parch-img: #ecdcb4;
  --wood-img: #7a5230;
  --logo-img: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #17131c;
  font-family: var(--text);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.hidden { display: none !important; }

button { font: inherit; }

:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#compass {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(470px, 74vw);
  height: 54px;
  background: var(--stone-img) center / 256px auto;
  border: 2px solid var(--brass-lo);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(20, 12, 6, 0.4);
}

#compass-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 22px;
  color: var(--cream);
  text-shadow: 0 2px 0 #241a10;
}

#compass-strip span {
  display: inline-block;
  width: 58px;
  text-align: center;
  line-height: 50px;
}

#compass-strip span.major { font-size: 27px; color: #fff0c7; }

#compass-mark {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 12px solid var(--brass-hi);
  transform: translateX(-50%);
}

.beacon-dot {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 11px;
  height: 11px;
  background: #ffe6a0;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px #7c5a25;
}

.goal-label {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 19px;
  color: var(--cream);
  text-shadow: 0 2px 0 #2a1d10, 0 0 2px rgba(20, 10, 4, 0.7);
  white-space: nowrap;
}

.goal-label b { font-weight: normal; color: #ffe0a0; }

#gauge {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 190px;
  height: min(400px, 62vh);
}

#gauge-rod {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: var(--stone-img) center / 256px auto;
  border: 2px solid var(--brass-lo);
  border-radius: 14px 14px 6px 6px;
  overflow: hidden;
}

#gauge-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#gauge-marker {
  position: absolute;
  right: 38px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid var(--brass-hi);
  transform: translateY(-50%);
  transition: top 0.25s linear;
}

.gauge-tag {
  position: absolute;
  right: 54px;
  font-family: var(--display);
  font-size: 15px;
  color: var(--cream);
  text-shadow: 0 1px 0 #2a1d10;
  white-space: nowrap;
  text-align: right;
  transform: translateY(-50%);
  line-height: 1;
  transition: top 0.25s linear;
}

#gauge-summit { top: 0; }
#gauge-clouds { top: 100%; }
#gauge-here { color: #ffe6a6; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
}

#crosshair i {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #fff3d6;
  box-shadow: 0 0 0 1px rgba(30, 20, 12, 0.85);
}

#crosshair i:nth-child(1) { left: 0; top: 0; }
#crosshair i:nth-child(2) { right: 0; top: 0; }
#crosshair i:nth-child(3) { left: 0; bottom: 0; }
#crosshair i:nth-child(4) { right: 0; bottom: 0; }

.ink-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 22px);
  font-family: var(--display);
  font-size: 18px;
  color: var(--cream);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  transition: opacity 0.3s;
}

.parchment-note {
  position: absolute;
  background: var(--parch-img) center / 512px auto;
  color: var(--ink);
  border: 1px solid #5b3f20;
  border-radius: 3px;
  padding: 10px 16px;
  font-size: 16px;
  line-height: 1.4;
  box-shadow: 0 3px 0 rgba(20, 12, 6, 0.3);
  max-width: min(420px, 80vw);
}

#toast {
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--display);
  font-size: 18px;
  transition: opacity 0.5s;
}

#hint {
  left: 22px;
  bottom: 120px;
  transition: opacity 1.6s;
}

#hotbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.slot {
  position: relative;
  width: 62px;
  height: 66px;
  padding: 0;
  border: 3px solid var(--brass);
  border-radius: 4px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 3px 0 rgba(20, 12, 6, 0.5);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background-color 0.12s;
}

.slot canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: 52px;
  height: 52px;
  pointer-events: none;
}

.slot .num {
  position: absolute;
  top: 1px;
  left: 6px;
  font-family: var(--display);
  font-size: 14px;
  color: #fff0c9;
  text-shadow: 0 1px 0 #1f150b;
  pointer-events: none;
}

.slot .count {
  position: absolute;
  right: 5px;
  bottom: 2px;
  font-family: var(--display);
  font-size: 15px;
  color: #fff6dd;
  text-shadow: 0 1px 0 #1f150b, 0 0 3px #1f150b;
  pointer-events: none;
}

.slot.selected {
  transform: translateY(-9px);
  border-color: var(--brass-hi);
  background-color: rgba(170, 222, 236, 0.4);
}

.slot.empty canvas { opacity: 0.35; }

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 11, 8, 0.28);
  z-index: 10;
}

.title-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -2vh;
}

.logo {
  width: min(560px, 86vw);
  aspect-ratio: 1100 / 330;
  background: var(--logo-img) center / 100% 100% no-repeat;
  filter: drop-shadow(0 8px 10px rgba(10, 6, 2, 0.5));
}

.drip {
  width: 22px;
  height: 64px;
  margin-top: -8px;
  background: linear-gradient(90deg, #9ad8f2 0%, #d5f2ff 45%, #6eb6dd 100%);
  border-radius: 0 0 12px 12px;
  opacity: 0.9;
  animation: drip 2.4s ease-in-out infinite;
  transform-origin: top;
}

@keyframes drip {
  0%, 100% { transform: scaleY(1); opacity: 0.9; }
  50% { transform: scaleY(0.82); opacity: 0.7; }
}

.scroll {
  width: min(430px, 84vw);
  padding: 24px 34px 28px;
  margin-top: -4px;
  background: var(--parch-img) center / 512px auto;
  border: 2px solid var(--brass-lo);
  border-radius: 6px;
  box-shadow: 0 12px 26px rgba(10, 6, 2, 0.45);
  color: var(--ink);
  text-align: center;
}

.tagline {
  margin: 0 0 4px;
  font-family: var(--display);
  font-style: italic;
  font-size: 19px;
  color: #4a3218;
}

.plaques { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.plaque {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  background: var(--wood-img) center / 256px auto;
  border: 2px solid #33220f;
  border-radius: 4px;
  color: var(--cream);
  font-family: var(--display);
  font-size: 22px;
  text-shadow: 0 2px 0 #26180a;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 150, 0.28), 0 3px 0 rgba(20, 12, 6, 0.55);
  cursor: pointer;
  transition: transform 0.08s, filter 0.12s;
}

.plaque:hover { filter: brightness(1.16) saturate(1.05); transform: translateY(-1px); }
.plaque:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px rgba(255, 220, 150, 0.2), 0 1px 0 rgba(20, 12, 6, 0.5); }
.plaque-main { color: #ffe6a6; }

.card {
  background: var(--parch-img) center / 512px auto;
  color: var(--ink);
  border: 2px solid var(--brass-lo);
  border-radius: 6px;
  padding: 26px 34px;
  box-shadow: 0 14px 30px rgba(10, 6, 2, 0.5);
  width: min(460px, 88vw);
  text-align: center;
}

.card h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-weight: normal;
  font-size: 34px;
  color: #3b2412;
}

.card p { margin: 6px 0; font-size: 17px; line-height: 1.45; }

.eyebrow {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px !important;
  color: #5a3c1c;
}

.controls-card {
  position: absolute;
  right: 6vw;
  top: 50%;
  transform: translateY(-50%);
  width: min(360px, 84vw);
  padding: 20px 24px;
  text-align: left;
}

.controls-card h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: normal;
  font-size: 24px;
  color: #3b2412;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(91, 63, 32, 0.25);
  font-size: 16px;
}

.ctl:last-child { border-bottom: none; }

.ctl .keys { display: flex; gap: 4px; min-width: 128px; flex-wrap: wrap; }

kbd {
  display: inline-block;
  min-width: 28px;
  padding: 2px 7px;
  background: var(--wood-img) center / 256px auto;
  border: 2px solid #33220f;
  border-radius: 3px;
  color: var(--cream);
  font-family: var(--display);
  font-size: 15px;
  text-align: center;
  text-shadow: 0 1px 0 #26180a;
  box-shadow: 0 2px 0 #1e1308;
}

.fineprint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: rgba(247, 236, 210, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#title .controls-card { z-index: 2; }

.pause-card { width: min(380px, 88vw); }

#pause-controls { margin-top: 12px; text-align: left; }

/* ---------- Journal ---------- */
.journal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(1000px, 95vw);
  height: min(600px, 88vh);
  background: var(--parch-img) center / 512px auto;
  border: 16px solid #5a3a1c;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(10, 6, 2, 0.6);
  color: var(--ink);
  overflow: hidden;
}

.page {
  padding: 24px 28px;
  overflow: hidden;
}

.page-left { border-right: 2px solid rgba(91, 63, 32, 0.35); }

.page h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-weight: normal;
  font-size: 30px;
  color: #3b2412;
}

.page-note { margin: 0 0 14px; font-size: 15px; color: #5a4128; }

#pack-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.cell {
  position: relative;
  height: 74px;
  padding: 0;
  background: rgba(255, 250, 230, 0.35);
  border: 1px solid rgba(91, 63, 32, 0.5);
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.12s, transform 0.08s;
}

.cell:hover { background: rgba(255, 245, 210, 0.7); }
.cell:active { transform: translateY(1px); }
.cell.empty { opacity: 0.4; cursor: default; }
.cell canvas { width: 52px; height: 52px; display: block; margin: 2px auto 0; }
.cell .c-count {
  position: absolute;
  right: 5px;
  bottom: 3px;
  font-family: var(--display);
  font-size: 15px;
  color: #3b2412;
}

.cell .c-name {
  position: absolute;
  left: 4px;
  top: 3px;
  font-size: 10.5px;
  line-height: 1.1;
  color: #5a4128;
  max-width: 90%;
}

#map-canvas {
  width: 100%;
  height: auto;
  border: 1px solid rgba(91, 63, 32, 0.6);
  border-radius: 3px;
}

/* ---------- Ending, loading, flash, error ---------- */
.ending-card { width: min(540px, 90vw); }

.ending-card p { font-size: 18px; }

.ending-card .plaques { margin-top: 18px; }

.loading-card { width: min(420px, 86vw); }

#flash {
  position: fixed;
  inset: 0;
  background: #f7e7c4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
  z-index: 20;
}

#error {
  z-index: 30;
  background: rgba(16, 11, 8, 0.9);
  padding: 24px;
  text-align: center;
  font-size: 18px;
}

@media (max-width: 760px) {
  .journal { grid-template-columns: 1fr; height: 92vh; }
  .page-right { display: none; }
  #gauge { display: none; }
  .controls-card { position: static; transform: none; margin-top: 16px; }
  #title { overflow-y: auto; }
  .title-wrap { margin-top: 0; }
  .slot { width: 40px; height: 46px; }
  .slot canvas { width: 34px; height: 34px; }
  #hotbar { gap: 4px; }
  #hint { display: none; }
}
