:root {
  --ink: #2a1f14;
  --paper: #fff6e4;
  --gold: #e8b84a;
  --moss: #3f6b38;
  --leaf: #6db36a;
  --rose: #e08978;
  --shadow: rgba(42, 31, 20, 0.28);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1b2418;
  color: var(--paper);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#c { display: block; width: 100%; height: 100%; }

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.panel { pointer-events: none; }

#hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding-right: 92px;
}

.card {
  background: rgba(28, 20, 12, 0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(232, 184, 74, 0.28);
  border-radius: 16px;
  padding: 10px 14px;
  min-width: 148px;
  box-shadow: 0 10px 28px var(--shadow);
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
}

.big {
  margin-top: 3px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.sub {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 246, 228, 0.72);
}

.hearts {
  letter-spacing: 3px;
  color: #ff8b8b;
  font-size: 18px;
  line-height: 1.2;
}

#quest {
  position: absolute;
  left: 50%;
  top: max(14px, env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 280px));
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #fff4d8;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  display: none;
}

#msg {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  text-align: center;
  background: rgba(22, 15, 10, 0.78);
  border: 1px solid rgba(232, 184, 74, 0.38);
  border-radius: 18px;
  padding: 13px 20px 14px;
  display: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

#msg .who {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
}

#msg .line {
  font-size: 16px;
  line-height: 1.65;
}

#hint {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0.62;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(90, 58, 24, 0.28), transparent 55%),
    rgba(10, 12, 9, 0.72);
  pointer-events: auto;
  z-index: 8;
}

#overlay.hide { display: none; }

.box {
  width: min(540px, 92vw);
  text-align: center;
  padding: 8px 8px 4px;
}

.seal {
  display: inline-block;
  border: 1px solid rgba(232, 184, 74, 0.45);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.28em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

h1 {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: clamp(48px, 11vw, 86px);
  font-weight: 500;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  line-height: 1.05;
  text-shadow: 0 10px 36px rgba(0, 0, 0, 0.4);
}

h1 em {
  display: block;
  font-style: normal;
  font-size: 0.28em;
  letter-spacing: 0.62em;
  text-indent: 0.62em;
  margin-top: 0.45em;
  opacity: 0.82;
}

.lead {
  margin: 16px auto 0;
  max-width: 28em;
  line-height: 1.8;
  color: #f3e4c6;
  font-size: 15px;
}

button.play {
  pointer-events: auto;
  margin-top: 22px;
  border: 0;
  cursor: pointer;
  background: linear-gradient(180deg, #f6de98, #d7a44a);
  color: #3a2810;
  font-weight: 750;
  border-radius: 999px;
  padding: 13px 34px;
  font-size: 16px;
  letter-spacing: 0.22em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  font-family: inherit;
}

button.play:hover { filter: brightness(1.05); }
button.play:active { transform: translateY(1px) scale(0.98); }

.fine {
  margin-top: 14px;
  font-size: 12px;
  opacity: 0.58;
  letter-spacing: 0.06em;
}

#joy {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: none;
  pointer-events: auto;
}

#stick {
  position: absolute;
  left: 46px;
  top: 46px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(246, 222, 152, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

#btns {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: none;
  gap: 12px;
  pointer-events: auto;
}

#btns.show, #joy.show { display: flex; }
#joy.show { display: block; }

.act {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 1px solid rgba(255, 246, 228, 0.28);
  background: rgba(246, 222, 152, 0.9);
  color: #3a2810;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.act.ghost {
  background: rgba(255, 255, 255, 0.14);
  color: var(--paper);
}

@media (max-width: 720px) {
  #quest { display: none; }
  .card { min-width: 0; padding: 8px 10px; }
  .big { font-size: 15px; }
  #hint { display: none; }
}

#mapWrap {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  top: 108px;
  width: 176px;
  pointer-events: auto;
  cursor: pointer;
  z-index: 6;
}

#minimap {
  width: 176px;
  height: 176px;
  border-radius: 50%;
  display: block;
  background: rgba(22, 32, 18, 0.55);
  border: 2px solid rgba(232, 184, 74, 0.42);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28), inset 0 0 0 6px rgba(255, 246, 228, 0.04);
}

#mapWrap.big { width: 280px; z-index: 8; }
#mapWrap.big #minimap { width: 280px; height: 280px; }

#wayHint {
  position: absolute;
  left: 50%;
  top: max(58px, calc(env(safe-area-inset-top) + 44px));
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 6;
  text-shadow: 0 2px 8px #0008;
}
#wayHint.show { display: flex; }
#wayNeedle {
  font-size: 28px;
  line-height: 1;
  color: #ffe789;
  filter: drop-shadow(0 2px 6px #0008);
}
#wayText {
  margin-top: 2px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: #fff4d0;
}

#mapHint {
  margin-top: 6px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #f6de98;
  text-shadow: 0 1px 6px #0008;
}

#mapLegend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
  margin-top: 6px;
  font-size: 10px;
  color: rgba(255, 246, 228, 0.78);
}

#mapLegend span { display: inline-flex; align-items: center; gap: 3px; }
#mapLegend .d {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}
#mapLegend .you { background: #f6de98; }
#mapLegend .lark { background: #f0c14a; }
#mapLegend .herb { background: #7dff9a; }
#mapLegend .mom { background: #ff8eb0; }
#mapLegend .dad { background: #c48a38; }
#mapLegend .danger { background: #ff6b5b; }

.icon-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(232, 184, 74, 0.4);
  background: rgba(28, 20, 12, 0.62);
  color: #f6de98;
  font: 700 16px/1 "Songti SC", serif;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
#helpBtn { right: max(56px, calc(env(safe-area-inset-right) + 44px)); }
#muteBtn { right: max(14px, env(safe-area-inset-right)); }
.icon-btn.off { opacity: 0.45; }

#help {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 9, 0.66);
  pointer-events: auto;
  z-index: 30;
}
#help.show { display: flex; }
#help .sheet {
  width: min(520px, 92vw);
  background: rgba(28, 20, 12, 0.92);
  border: 1px solid rgba(232, 184, 74, 0.4);
  border-radius: 22px;
  padding: 22px 22px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
#help h2 {
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-weight: 500;
  letter-spacing: 0.2em;
  font-size: 26px;
  text-align: center;
}
#help ol { margin: 14px 0 0 1.2em; line-height: 1.75; font-size: 15px; color: #f3e4c6; }
#help .keys {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 246, 228, 0.06);
  font-size: 13px;
  line-height: 1.7;
  color: #f6de98;
}
#help .close {
  display: block;
  margin: 16px auto 0;
  pointer-events: auto;
}

@media (max-width: 720px) {
  #mapWrap { width: 128px; top: 96px; }
  #minimap { width: 128px; height: 128px; }
  #mapWrap.big { width: 220px; }
  #mapWrap.big #minimap { width: 220px; height: 220px; }
  #mapLegend { display: none; }
}

@media (pointer: coarse) {
  #hint { display: none; }
}
