:root {
  color-scheme: dark;
  --ink: #fff8e8;
  --muted: #b9b0a3;
  --line: rgba(255,255,255,.22);
  --panel: rgba(6, 6, 12, .92);
  --gold: #ffd66b;
  --red: #ff4d6d;
  --blue: #58d3ff;
  --phone-width: min(100vw, 430px);
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050509;
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: linear-gradient(#2a2737, #11111c);
  font-weight: 900;
  box-shadow: inset 0 1px rgba(255,255,255,.16), 0 8px 22px rgba(0,0,0,.45);
}
button:active { transform: translateY(1px) scale(.99); }
.hidden { display: none !important; }
#app {
  position: relative;
  width: 100vw;
  max-width: 430px;
  height: auto;
  aspect-ratio: 390 / 844;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 22%, #25223a, #07070c 58%);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
#keyArt {
  display: none;
}
#game {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.hud {
  position: absolute;
  z-index: 10;
  top: calc(10px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.title-card {
  position: absolute;
  z-index: 18;
  left: 24px;
  right: 24px;
  top: 228px;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 4px 18px #000;
}
.title-card h1 {
  margin: 0 0 12px;
  font-size: 31px;
  line-height: 1.1;
}
.title-card p {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 15px;
  font-weight: 950;
}
.title-card small {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}
.load-bar {
  width: 184px;
  height: 8px;
  margin: 14px auto 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.load-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  border-radius: 999px;
  transition: width .2s ease;
}
body.ready .load-bar { opacity: .35; }
body.ready #startHint { animation: startPulse 1.4s ease-in-out infinite; }
@keyframes startPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
body.started .title-card { display: none; }
.hud b {
  display: block;
  font-size: 20px;
  text-shadow: 0 3px 12px #000;
}
.hud span {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #15111b;
  background: var(--gold);
  font-size: 12px;
  font-weight: 950;
}
.icon-btn {
  min-width: 58px;
  height: 42px;
  border-radius: 12px;
  pointer-events: auto;
}
.reset-btn {
  min-width: 74px;
  color: #ffe1e6;
}
.dialog, .battle, .record {
  position: absolute;
  left: 12px;
  right: 12px;
  border: 2px solid rgba(255,255,255,.82);
  background: var(--panel);
  box-shadow: 0 20px 48px rgba(0,0,0,.55);
}
.game-over {
  position: fixed;
  z-index: 90;
  inset: 0;
  width: var(--phone-width);
  display: grid;
  place-content: center;
  gap: 22px;
  text-align: center;
  background: rgba(0,0,0,.82);
}
.game-over h2 {
  margin: 0;
  color: var(--red);
  font-size: 34px;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(255,77,109,.5);
}
.game-over button {
  min-width: 158px;
  height: 58px;
  border-radius: 10px;
  color: #17111a;
  background: linear-gradient(#ffe78d, #ffbd52);
  font-size: 20px;
}
.dialog {
  position: fixed;
  z-index: 36;
  left: 12px;
  right: auto;
  width: calc(var(--phone-width) - 24px);
  bottom: calc(72px + env(safe-area-inset-bottom));
  min-height: 128px;
  max-height: min(42vh, 330px);
  overflow-y: auto;
  padding: 15px 15px 42px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.dialog.dialog-top {
  top: calc(128px + env(safe-area-inset-top));
  bottom: auto;
}
.dialog.dialog-bottom {
  top: auto;
  bottom: calc(72px + env(safe-area-inset-bottom));
}
.dialog b {
  display: block;
  margin-bottom: 7px;
  color: var(--gold);
}
.dialog p, .battle p {
  margin: 0;
  min-height: 52px;
  line-height: 1.6;
  font-size: 16px;
  font-weight: 850;
}
.tap-hint {
  position: absolute;
  right: 12px;
  bottom: 9px;
  min-width: 66px;
  height: 28px;
  border-radius: 7px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0;
}
.dialog.has-choices .tap-hint { display: none; }
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.choices button, .battle-cmds button {
  min-height: 48px;
  border-radius: 8px;
  font-size: 15px;
}
.battle {
  position: fixed;
  z-index: 25;
  width: calc(var(--phone-width) - 24px);
  right: auto;
  top: calc(72px + env(safe-area-inset-top));
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 14px;
  overflow-y: auto;
  touch-action: none;
  overscroll-behavior: none;
}
.battle-transition {
  position: absolute;
  z-index: 80;
  inset: -35%;
  pointer-events: none;
  opacity: 0;
  transform: scale(0);
  border-radius: 50%;
  background: #000;
  filter: blur(24px);
}
.battle-transition.close {
  opacity: 1;
  transform: scale(1.2);
  transition: transform .72s cubic-bezier(.72, 0, .9, .45), opacity .18s linear;
}
.battle-transition.reveal {
  opacity: 0;
  transform: scale(1.2);
  transition: opacity .56s ease-out;
}
body.in-battle .controls { opacity: 1; }
.enemy-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.enemy-face {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #151521;
  color: var(--gold);
  font-size: 34px;
}
#enemyName { display: block; font-size: 20px; }
#enemyMood { color: var(--muted); font-size: 13px; font-weight: 850; }
#soulBox {
  position: relative;
  height: 216px;
  margin: 10px 0 12px;
  border: 3px solid #f9f9f9;
  background: #020207;
}
#soul {
  width: 100%;
  height: 100%;
  display: block;
}
.battle-cmds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.battle.dodging .battle-cmds {
  display: none;
}
.battle-cmds button.spare {
  color: #15111b;
  background: linear-gradient(#ffe78d, #ffbe4d);
}
.battle-cmds .mercy-only {
  grid-column: 1 / -1;
  min-height: 76px;
  font-size: 24px;
}
.record {
  position: fixed;
  width: calc(var(--phone-width) - 24px);
  right: auto;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  top: calc(82px + env(safe-area-inset-top));
  padding: 16px;
  overflow-y: auto;
}
.record h2 { margin: 0 0 12px; color: var(--gold); }
.record p { margin: 8px 0; line-height: 1.55; }
.controls {
  display: none;
}
.pad {
  display: none;
}
.sound-btn {
  min-width: 48px;
  width: 48px;
  height: 42px;
  border-radius: 10px;
  padding: 0;
  font-size: 18px;
  pointer-events: auto;
}
.pad span {
  position: absolute;
  left: 43px;
  top: 43px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.75);
  background: linear-gradient(#fff0a0, #d9566d);
}
body.started:not(.in-battle) #game { cursor: grab; }
@media (min-width: 431px) {
  #app { margin-left: 0; }
}
