:root {
  color-scheme: dark;
  --ink: #1c2b24;
  --cream: #f3ead8;
  --teal: #2a8f7f;
  --gold: #c9a15b;
  --pine: #142018;
  font-family: Nunito, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--pine); color: var(--cream); }
button, input { font: inherit; }
button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--teal);
  color: var(--cream);
  cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
button.gold { background: var(--gold); color: var(--ink); font-weight: 800; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
img { max-width: 100%; }
h1, h2, p { margin: 0; }
h1 { font-family: Fraunces, Palatino, serif; font-size: 2rem; line-height: 1.05; }
h2 { font-family: Fraunces, Palatino, serif; font-size: 1.45rem; }

.screen { min-height: 100dvh; padding: 20px 16px calc(28px + env(safe-area-inset-bottom)); }
.title {
  display: flex;
  align-items: flex-end;
  background: #1c2b24 url("../assets/bg/title.jpg") center/cover no-repeat;
}
.card {
  width: min(100%, 480px);
  margin: 0 auto;
  background: rgba(243, 234, 216, 0.95);
  color: var(--ink);
  border-radius: 22px;
  padding: 18px;
}
.stack { display: grid; gap: 10px; margin-top: 14px; }
.muted { color: #3d5348; }
label { display: grid; gap: 6px; font-weight: 700; }
input[type="text"] {
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid #1c2b24;
  padding: 8px 12px;
  background: white;
  color: var(--ink);
}
.grades, .heroes, .list { display: grid; gap: 10px; }
.grade, .hero, .world, .level {
  text-align: left;
  background: white;
  color: var(--ink);
  border: 2px solid transparent;
}
.grade small, .world small, .level small, .hero small { display: block; font-weight: 600; color: #3d5348; }
.grade.pick { border-color: var(--gold); background: #fff8e8; }
.heroes { grid-template-columns: repeat(3, 1fr); }
.hero { display: grid; justify-items: center; gap: 4px; padding: 10px; }
.hero img, .portrait { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; }
.face {
  width: 84px;
  height: 84px;
  margin: 0 auto 8px;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  image-rendering: pixelated;
}
.owl { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 auto 8px; }

.play {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--pine);
}
.hud, .compass, .toast {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
}
.hud { padding-top: calc(8px + env(safe-area-inset-top)); }
.hud strong { display: block; }
.hud-actions { display: flex; gap: 8px; }
.hud-actions button { min-height: 40px; padding: 8px 12px; }
.stage { position: relative; flex: 1; min-height: 0; }
#view { width: 100%; height: 100%; display: block; touch-action: none; background: #142018; }
#mini {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 132px;
  height: 132px;
  border-radius: 12px;
  border: 2px solid var(--cream);
  background: #142018;
  touch-action: manipulation;
}
.compass { display: block; margin: 0; padding-bottom: 0; line-height: 1.35; }
.toast { min-height: 1.2em; color: var(--gold); font-weight: 800; }
.toast:empty { display: none; }
.pad {
  display: grid;
  grid-template-columns: 64px 64px 64px;
  grid-template-areas: ". up ." "left down right";
  gap: 6px;
  justify-content: end;
  padding: 4px 12px calc(12px + env(safe-area-inset-bottom));
  touch-action: none;
}
.pad button { min-height: 56px; font-size: 1.2rem; }
.pad [data-dir="up"] { grid-area: up; }
.pad [data-dir="left"] { grid-area: left; }
.pad [data-dir="down"] { grid-area: down; }
.pad [data-dir="right"] { grid-area: right; }

#overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(12, 22, 16, 0.45);
  overflow: auto;
}
#overlay:empty { display: none; }
#overlay .card { max-height: calc(100% - 8px); overflow: auto; }
#overlay .card > .go { position: sticky; bottom: 0; }
.answers { display: grid; gap: 8px; }
.answers button { text-align: left; background: white; color: var(--ink); }
.answers b { display: inline-block; width: 1.4em; }
#fullmap { width: min(100%, 420px); height: auto; background: #142018; border-radius: 12px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; font-size: 0.92rem; }
.dot { width: 12px; height: 12px; border-radius: 99px; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.stars { letter-spacing: 2px; color: #8a6a22; font-weight: 800; }

@media (max-width: 720px) {
  .heroes { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 72px 1fr; justify-items: start; align-items: center; }
  #mini { width: 104px; height: 104px; }
  h1 { font-size: 1.7rem; }
}
