:root {
  --bg: #0b0d12;
  --stage: #10131a;
  --ink: #e8e6df;
  --muted: #8b9088;
  --faint: #3a3f4a;
  --yellow: #ece675;
  --blue: #58c4dd;
  --teal: #5cd0b3;
  --green: #83c167;
  --red: #fc6255;
  --orange: #ff862f;
  --pink: #ff8080;
  --purple: #c08be0;
  --gold: #f0ac5f;
  --h: var(--blue);
  --z: var(--yellow);
  --action: var(--orange);
  --reward: var(--green);
  --value: var(--purple);
  --obs: var(--teal);
  --font: "M PLUS Rounded 1c", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background:
    linear-gradient(rgba(5, 8, 16, .82), rgba(5, 8, 16, .82)),
    url("../img/garden.svg?v=12") center / cover no-repeat,
    #05060a;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  display: grid;
  place-items: center;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background:
    linear-gradient(180deg, rgba(8, 14, 28, .44) 0%, rgba(8, 14, 26, .52) 55%, rgba(6, 10, 18, .74) 100%),
    url("../img/garden.svg?v=12") center / cover no-repeat,
    var(--stage);
  overflow: hidden;
  box-shadow: 0 0 0 1px #1c2230, 0 30px 80px rgba(0,0,0,.55);
  container-type: size;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

#c {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

#overlay .hit {
  pointer-events: auto;
}

#caption {
  position: absolute;
  left: 4.2%;
  right: 18%;
  bottom: 6.6%;
  z-index: 3;
  font-size: clamp(11px, 2.05cqh, 24px);
  line-height: 1.35;
  color: var(--ink);
  text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 2px 12px rgba(0,0,0,.75);
  min-height: 2.6em;
  pointer-events: none;
}

#caption em {
  font-style: italic;
  font-weight: 700;
  color: #ffffff;
}

#caption .hl-h, #caption .hl-z, #caption .hl-a,
#caption .hl-r, #caption .hl-v, #caption .hl-o {
  color: #ffffff;
  font-weight: 700;
  font-style: normal;
}

#chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7.4%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4.2%;
  z-index: 4;
  pointer-events: none;
  font-family: var(--font);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: clamp(9px, 1.4cqh, 14px);
  color: #c9ced8;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .85);
}

#section-label { opacity: .9; }

#progress {
  display: flex;
  gap: 7px;
  align-items: center;
}

#progress .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2c3342;
}

#progress .dot.on { background: var(--yellow); }
#progress .dot.here { box-shadow: 0 0 0 3px rgba(236,230,117,.22); }

#hint {
  position: absolute;
  right: 4.2%;
  bottom: 6.8%;
  z-index: 4;
  font-family: var(--font);
  font-size: clamp(9px, 1.5cqh, 15px);
  color: #c9ced8;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .85);
  letter-spacing: .04em;
  pointer-events: none;
}

#eq-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.eq {
  position: absolute;
  color: var(--ink);
  font-size: 2.3cqh;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 2px 14px rgba(0,0,0,.8);
}

.eq.on-light { text-shadow: none; }

.eq.show {
  opacity: 1;
  transform: none;
}

.eq .katex { color: inherit; }

.title-block {
  position: absolute;
  left: 8%;
  top: 28%;
  pointer-events: none;
}

.title-block h1 {
  font-size: clamp(42px, 8.4vh, 92px);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--yellow);
  line-height: .95;
}

.title-block p {
  margin-top: 1.1rem;
  font-size: clamp(16px, 2.4vh, 26px);
  color: var(--ink);
  max-width: 22em;
}

.title-block .by {
  margin-top: .85rem;
  font-family: var(--font);
  font-size: clamp(11px, 1.5vh, 14px);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud {
  position: absolute;
  pointer-events: auto;
  font-family: var(--font);
}

.panel {
  background: rgba(12, 16, 24, .72);
  border: 1px solid #2a3142;
  border-radius: 10px;
  padding: 12px 14px;
  backdrop-filter: blur(8px);
}

.panel h3 {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

button.ctl, .ctl {
  appearance: none;
  border: 1px solid #3a4254;
  background: #171c28;
  color: var(--ink);
  font: 500 12px/1 var(--font);
  padding: 7px 11px;
  border-radius: 7px;
  cursor: pointer;
}

button.ctl:hover { border-color: var(--yellow); color: var(--yellow); }
button.ctl.active {
  background: #2a2610;
  border-color: var(--yellow);
  color: var(--yellow);
}

label.slider {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  min-width: 120px;
}

label.slider input[type=range] {
  width: 140px;
  accent-color: var(--yellow);
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

#overview {
  position: fixed;
  inset: 0;
  background: rgba(5,6,10,.92);
  z-index: 20;
  display: none;
  padding: 6vh 6vw;
  overflow: auto;
  font-family: var(--font);
}

#overview.open { display: block; }

#overview h2 {
  font-family: var(--font);
  font-weight: 600;
  font-size: 28px;
  color: var(--yellow);
  margin-bottom: 24px;
}

.ov-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #3a4254;
  background: #171c28;
  color: var(--ink);
  font: 600 16px/1 var(--font);
  cursor: pointer;
}
.ov-close:hover { border-color: var(--yellow); color: var(--yellow); }

.talk-switch {
  margin: -8px 0 22px;
  display: flex;
  gap: 10px;
}
.talk-switch a {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid #2a3142;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.talk-switch a:hover { color: var(--yellow); border-color: var(--yellow); }

.ov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.ov-card {
  border: 1px solid #2a3142;
  background: #121620;
  border-radius: 10px;
  padding: 16px 16px 14px;
  cursor: pointer;
  color: var(--ink);
}

.ov-card:hover { border-color: var(--yellow); }
.ov-card .n {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.ov-card .t { font-size: 16px; }

.help {
  position: absolute;
  left: 4.2%;
  top: 8.6%;
  font-family: var(--font);
  font-size: clamp(9px, 1.35cqh, 13px);
  color: #c9ced8;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .85);
  z-index: 4;
  pointer-events: none;
}

kbd {
  font-family: var(--font);
  font-size: 10px;
  border: 1px solid #3a4254;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: #b8bdb4;
}

#toast {
  position: absolute;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  background: #1b2130;
  border: 1px solid #3a4254;
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
#toast.show { opacity: 1; }

#touchnav,
#rotate-tip { display: none; }

.tn-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(12, 16, 24, .55);
  backdrop-filter: blur(6px);
  color: #f4f2ec;
  font: 600 18px/1 var(--font);
  display: grid;
  place-items: center;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.tn-btn.tn-big { width: 48px; height: 48px; font-size: 28px; }
.tn-btn:active { background: rgba(236, 230, 117, .35); }

@media (pointer: coarse) {
  .help { display: none; }

  #touchnav {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  }
  .tn-group { display: flex; flex-direction: column; gap: 10px; align-items: center; }

  #caption {
    background: rgba(5, 8, 16, .45);
    border-radius: 8px;
    padding: .25em .5em;
    margin-left: -.5em;
  }
  #caption:empty { background: none; }
  #caption:empty { background: none; }
}

@media (pointer: coarse) and (max-aspect-ratio: 16/9) {
  #touchnav {
    inset: auto 0 0 0;
    padding: 0 0 max(14px, env(safe-area-inset-bottom));
    justify-content: center;
    gap: 14px;
  }
  .tn-group { flex-direction: row; }
  .tn-left { gap: 14px; }
  .tn-left .tn-big { order: -1; }
}

@media (orientation: portrait) and (max-width: 900px) {
  #app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: max(64px, 13vh);
  }
  #stage {
    width: 100vw;
    height: 56.25vw;
    overflow: visible;
  }
  #chrome {
    top: auto;
    bottom: calc(100% + 6px);
    height: auto;
    font-size: 11px;
  }
  #caption {
    top: calc(100% + 18px);
    bottom: auto;
    left: 5%;
    right: 5%;
    margin-left: 0;
    padding: .6em .8em;
    font-size: 16px;
    line-height: 1.45;
    min-height: 0;
  }
  #hint {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(76px + env(safe-area-inset-bottom));
    text-align: center;
    font-size: 12px;
  }
  #rotate-tip {
    display: block;
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(236, 230, 117, .92);
    color: #1f2633;
    font: 700 13px/1.2 var(--font);
    white-space: nowrap;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
  }
  #rotate-tip.hidden { display: none; }
}
