:root {
  --bg: #0f150d;
  --olive: #1c2519;
  --olive2: #2b3825;
  --glass: rgba(21, 29, 18, 0.84);
  --honey: #e8b64d;
  --honey2: #f8da86;
  --honey-d: #8f6218;
  --cream: #f6efde;
  --muted: #c9c3aa;
  --danger: #d95b43;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #24301e, var(--bg) 72%);
  color: var(--cream);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  display: grid; place-items: center; touch-action: none; user-select: none;
}
.stage {
  position: relative; width: 100vw; height: 100dvh; overflow: hidden; background: var(--olive);
}
@media (min-aspect-ratio: 10/16) {
  .stage {
    width: min(100vw, calc(min(100dvh, 940px) * 9 / 16));
    height: min(100dvh, 940px);
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .65), 0 0 0 1px rgba(232, 182, 77, .3);
  }
}
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.err {
  position: absolute; inset: 16px 14px auto; z-index: 40; padding: 12px 14px;
  border-radius: 12px; background: rgba(90, 22, 16, .94); border: 1px solid #f08a72;
  color: #fff3ef; font-size: 13px; line-height: 1.5;
}
.hud {
  position: absolute; inset: 0 0 auto; z-index: 10; pointer-events: none;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
  display: flex; flex-direction: column; gap: 7px;
}
.hud-top { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.pill, .icon-btn {
  background: var(--glass); border: 1px solid rgba(232, 182, 77, .35);
  border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700;
  color: var(--cream); backdrop-filter: blur(6px);
}
.stages-box { display: flex; align-items: center; gap: 6px; }
.pips { display: inline-flex; gap: 4px; }
.pips i {
  font-style: normal; width: 17px; height: 17px; border-radius: 50%; font-size: 10px;
  display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: var(--muted);
}
.pips i.done { background: var(--olive2); color: var(--honey2); border: 1px solid var(--honey); }
.pips i.cur { background: var(--honey); color: #1d1607; }
.top-btns { display: flex; gap: 5px; pointer-events: auto; }
.icon-btn { cursor: pointer; }
.icon-btn[aria-pressed="true"] { border-color: var(--honey2); color: var(--honey2); }
.bar-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid rgba(232, 182, 77, .28);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700;
}
.lbl { color: var(--honey2); }
.val { font-variant-numeric: tabular-nums; font-size: 11px; color: var(--muted); }
.bar { height: 9px; border-radius: 999px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; transition: width .12s linear;
  background: linear-gradient(90deg, #8ec95b, var(--honey2)); }
.boss {
  background: rgba(34, 20, 17, .86); border: 1px solid rgba(232, 182, 77, .48);
  border-radius: 12px; padding: 6px 10px;
}
.boss-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--honey2); margin-bottom: 4px; }
.boss-bar i { background: linear-gradient(90deg, var(--danger), var(--honey)); }
.controls {
  position: absolute; inset: auto 0 0; z-index: 10; pointer-events: none;
  padding: 0 14px max(12px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px;
}
.stick {
  pointer-events: auto; position: relative; width: 112px; height: 112px; border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 182, 77, .14), var(--glass));
  border: 2px solid rgba(232, 182, 77, .42); display: grid; place-items: center;
}
.knob {
  width: 46px; height: 46px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, var(--honey2), var(--honey-d));
  box-shadow: 0 4px 12px rgba(0, 0, 0, .45);
}
.actions { pointer-events: auto; display: flex; align-items: flex-end; gap: 10px; }
.act {
  border-radius: 50%; border: 2px solid var(--honey2); font-weight: 800; cursor: pointer;
  color: #1f1606; box-shadow: 0 8px 20px rgba(0, 0, 0, .42); transition: transform .08s, opacity .12s;
}
.atk { width: 78px; height: 78px; font-size: 16px; background: linear-gradient(180deg, var(--honey2), var(--honey)); }
.dash { width: 62px; height: 62px; font-size: 14px; color: var(--cream); background: linear-gradient(180deg, #3c4e33, var(--olive)); }
.act.is-down { transform: scale(.92); }
.act.is-cd { opacity: .48; }
.hint {
  grid-column: 1 / -1; margin: 0; text-align: center; font-size: 10.5px;
  color: rgba(246, 239, 222, .8); text-shadow: 0 1px 3px rgba(0, 0, 0, .85);
}
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; }
.title-view { align-items: end; }
.cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(16, 22, 14, .18) 10%, rgba(16, 22, 14, .78) 62%, rgba(14, 19, 12, .96) 100%);
}
.title-panel {
  position: relative; width: 100%; padding: 20px 18px max(22px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.title-panel h1 {
  margin: 0; font-size: 32px; letter-spacing: .08em; color: var(--honey2);
  text-shadow: 0 3px 16px rgba(0, 0, 0, .8);
}
.diff {
  border: 1px solid rgba(232, 182, 77, .35); border-radius: 999px; padding: 4px;
  background: var(--glass); display: flex; gap: 4px; margin: 0;
}
.diff label { position: relative; cursor: pointer; }
.diff input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.diff span {
  display: block; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--muted);
}
.diff input:checked + span { background: var(--honey); color: #1e1606; }
.cta {
  width: min(260px, 100%); padding: 13px 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--honey2); font-size: 16px; font-weight: 800; color: #1e1606;
  background: linear-gradient(180deg, var(--honey2), var(--honey));
  box-shadow: 0 10px 24px rgba(0, 0, 0, .42);
}
.cta.alt { background: var(--olive2); color: var(--cream); border-color: rgba(232, 182, 77, .45); }
.title-hint { margin: 0; font-size: 11px; color: var(--muted); }
.dialog-wrap { background: rgba(11, 16, 10, .66); backdrop-filter: blur(5px); padding: 18px; }
.card {
  width: min(320px, 100%); padding: 22px 18px; border-radius: 20px; text-align: center;
  background: linear-gradient(180deg, rgba(35, 46, 30, .96), rgba(20, 27, 17, .98));
  border: 1px solid rgba(232, 182, 77, .5); box-shadow: 0 18px 44px rgba(0, 0, 0, .6);
}
.card h2 { margin: 0 0 8px; font-size: 24px; color: var(--honey2); }
.dlg-body { margin: 0 0 14px; font-size: 13px; color: var(--cream); line-height: 1.5; }
.stats {
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
  font-size: 12px; color: var(--muted);
}
.stats span { background: rgba(0, 0, 0, .28); padding: 4px 9px; border-radius: 8px; }
.dlg-btns { display: flex; flex-direction: column; gap: 9px; align-items: center; }

.title-goal {
  margin: 8px auto 14px;
  max-width: 30ch;
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.5;
  font-weight: 500;
  color: inherit;
  opacity: 0.92;
}

.touch-guide {
  display: none;
}

.title-hint,
.hint {
  font-size: 12px;
  line-height: 1.45;
}

@media (pointer: coarse) {
  .keyboard-guide {
    display: none;
  }
  .touch-guide {
    display: inline;
  }
  .title-hint {
    font-size: 13px;
  }
  .hint {
    display: block;
    font-size: 12px;
    pointer-events: none;
    text-align: center;
  }
}

.danger-hint {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + clamp(144px, 20vh, 166px));
  transform: translateX(-50%);
  z-index: 12;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  max-width: calc(100% - 24px);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  padding: 6px 14px;
  color: #fff6f2;
  background: rgba(155, 28, 28, 0.88);
  border: 1px solid rgba(255, 190, 160, 0.78);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
}

#dangerHint[hidden],
#dangerHint:has(+ #controls[hidden]) {
  display: none;
}

.act.dash {
  position: relative;
}

.act.dash::after {
  content: "";
  position: absolute;
  inset: 2px;
  box-sizing: border-box;
  padding: 3px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: conic-gradient(
    rgba(255, 255, 255, 0.92) calc(var(--dash-progress, 1) * 360deg),
    rgba(255, 255, 255, 0.18) 0
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.act.dash.is-cd::after {
  opacity: 1;
}
