/* Mossbound Knight: page layout, HUD and screens. Colours follow the game: dusk plum, cream, gold. */
:root {
  --ink: #1b1424;
  --plum: #3a2440;
  --cream: #fff4e0;
  --gold: #f2c14e;
  --gold-hi: #ffe7a0;
  --red: #c8423a;
  --red-lo: #842234;
  --moss: #b5d16a;
  --glass: rgba(30, 18, 36, 0.48);
  --line: rgba(255, 226, 180, 0.2);
  --ui: var(--kit-grotesk);
  --display: 'Hoefler Text', 'Baskerville', var(--kit-serif);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  font: 600 15px/1.35 var(--ui);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app { position: relative; width: 100vw; height: 100vh; height: 100dvh; }
#game { position: absolute; inset: 0; }
#game canvas { display: block; }

/* HUD: two groups of dark glass chips in the top corners. */
.hud {
  position: absolute;
  top: max(2.2vh, env(safe-area-inset-top));
  left: 2.4vw;
  right: 2.4vw;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-size: clamp(14px, 1.45vw, 26px);
}
.hud-group { display: flex; gap: 0.55em; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  height: 2.1em;
  padding: 0 0.85em;
  border-radius: 0.75em;
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: inset 0 0 0 1px var(--line), 0 0.35em 1.2em rgba(20, 8, 24, 0.28);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(20, 8, 24, 0.6);
}
.chip b {
  font-weight: 600;
  font-size: 0.62em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.chip .num { font-weight: 700; color: var(--cream); }
.chip .icon { width: 1.15em; height: 1.15em; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.hearts { gap: 0.3em; }
.heart { width: 1.15em; height: 1.06em; fill: #ef5d58; stroke: #3a0f1c; stroke-width: 1.6; filter: drop-shadow(0 0 0.3em rgba(255, 110, 90, 0.45)); }
.heart.empty { fill: rgba(255, 244, 224, 0.12); stroke: rgba(255, 226, 180, 0.4); filter: none; }

/* Screens. */
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.1vh;
  padding: 24px;
  text-align: center;
  text-shadow: 0 2px 10px rgba(26, 12, 30, 0.75);
}
.screen p { margin: 0; }
.screen-title {
  background:
    radial-gradient(ellipse 60% 55% at 50% 46%, rgba(26, 14, 32, 0.62), rgba(26, 14, 32, 0.15) 70%, rgba(26, 14, 32, 0) 100%),
    linear-gradient(to bottom, rgba(26, 14, 32, 0.5), rgba(26, 14, 32, 0) 30%, rgba(26, 14, 32, 0) 70%, rgba(26, 14, 32, 0.6));
}
.kicker {
  font-size: clamp(12px, 1.05vw, 18px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.screen-title h1 {
  margin: 0.2vh 0 0.6vh;
  display: grid;
  justify-items: center;
  line-height: 0.92;
  font-family: var(--display);
  font-weight: 700;
}
.title-a {
  font-size: clamp(54px, 8.6vw, 150px);
  letter-spacing: -0.01em;
  color: #ffe3a1;
  text-shadow: 0 -1px 0 #fff8e6, 0 2px 0 #e0a24a, 0 4px 0 #a8612a, 0 6px 0 #5c2a1c, 0 14px 30px rgba(30, 10, 30, 0.6);
}
.title-b {
  font-size: clamp(26px, 3.6vw, 64px);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--cream);
}
.tagline { font-size: clamp(15px, 1.35vw, 22px); font-weight: 500; max-width: 34em; color: #fbe9d2; }
.keys { color: rgba(255, 236, 214, 0.78); font-size: clamp(12px, 0.95vw, 15px); font-weight: 500; }
.meta { color: var(--moss); font-size: clamp(12px, 0.9vw, 14px); letter-spacing: 0.08em; text-transform: uppercase; }
.meta span + span::before { content: "· "; color: rgba(255, 236, 214, 0.6); }
.meta span:empty, .meta span:empty + span::before { display: none; }

.panel {
  place-self: center;
  position: relative;
  min-width: min(440px, 86vw);
  padding: 34px 40px 30px;
  border-radius: 22px;
  background: linear-gradient(to bottom, rgba(44, 26, 48, 0.86), rgba(28, 16, 32, 0.9));
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px var(--line), 0 30px 70px rgba(10, 4, 14, 0.5);
}
#app > .panel { position: absolute; inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.panel h2 { margin: 0 0 4px; font-family: var(--display); font-size: clamp(30px, 3.4vw, 54px); color: var(--gold-hi); font-weight: 700; }
#screen-results.won h2 { color: #ffe3a1; text-shadow: 0 2px 0 #c98a3a, 0 4px 0 #5c2a1c, 0 10px 24px rgba(20, 8, 24, 0.5); }
.big { font-size: clamp(20px, 2vw, 30px); font-weight: 700; font-variant-numeric: tabular-nums; }

.cta {
  margin-top: 1.4vh;
  font: inherit;
  font-size: clamp(14px, 1.15vw, 19px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #2a1408;
  background: linear-gradient(to bottom, #ffe7a0, #f2c14e 55%, #d9962e);
  border: 0;
  border-radius: 999px;
  padding: 0.85em 1.9em;
  cursor: pointer;
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 0.3em 0 #8a4a1a, 0 0.8em 1.8em rgba(30, 10, 20, 0.45);
  animation: bob 1.8s ease-in-out infinite;
}
.cta:focus-visible { outline: 3px solid var(--moss); outline-offset: 5px; }
@keyframes bob { 50% { transform: translateY(-3px); } }

.status {
  position: absolute;
  left: 50%;
  bottom: max(2vh, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 0.45em 1.1em;
  max-width: calc(100% - 24px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(12px, 0.95vw, 16px);
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px var(--line);
  pointer-events: none;
}
.is-capturing .status, .status:empty { display: none; }

.touch { position: absolute; inset: 0; pointer-events: none; }
.touch button {
  pointer-events: auto;
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid rgba(255, 236, 214, 0.45);
  background: rgba(30, 18, 36, 0.45);
  backdrop-filter: blur(6px);
  color: var(--cream);
  font: inherit;
  font-size: 22px;
  touch-action: none;
}
.touch button:active { background: rgba(200, 66, 58, 0.6); }
.touch-pad button:first-child { left: 18px; bottom: 44px; }
.touch-pad button:last-child { left: 98px; bottom: 44px; }
.touch-jump { right: 22px; bottom: 52px; width: 84px !important; height: 84px !important; }
.touch-pause { right: 18px; top: 74px; width: 44px !important; height: 44px !important; font-size: 14px !important; }

@media (prefers-reduced-motion: reduce) { .cta { animation: none; } }
