:root {
  color-scheme: dark;
  font-family: "Yu Gothic", "Hiragino Sans", Meiryo, sans-serif;
  color: #f9f2df;
  background: #070b13;
  font-synthesis: none;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  --gold: #dfc084;
  --muted: #b9bdc6;
  --rule: #ad8b514f;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-block-size: 100vh;
  min-block-size: 100svh;
  background:
    radial-gradient(ellipse at 50% -18%, #253758 0%, transparent 68%),
    radial-gradient(ellipse at 50% 118%, #241b1c 0%, transparent 58%), #070b13;
}

button { font: inherit; }

.game-scene {
  --gutter: clamp(12px, 4.1vw, 23px);
  display: flex;
  flex-direction: column;
  position: relative;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
  padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
  background: linear-gradient(145deg, #161d30, #0b101c 53%, #111722);
  box-shadow: 0 0 65px #000b, 0 0 0 1px #d6ac5b29;
  overflow-wrap: anywhere;
}

.scene-heading {
  position: relative;
  display: grid;
  gap: 5px;
  padding: 14px var(--gutter) 13px;
  border-bottom: 1px solid var(--rule);
  background: radial-gradient(ellipse at 50% -100%, #5d482b91, transparent 75%), linear-gradient(#1b2031, #101625);
  text-align: center;
}

.scene-heading::after {
  content: '';
  position: absolute;
  z-index: 1;
  left: calc(50% - 3px);
  bottom: -4px;
  width: 7px;
  height: 7px;
  background: #d7b470;
  box-shadow: 0 0 12px #dab66990;
  transform: rotate(45deg);
}

.scene-meta {
  margin: 0;
  color: var(--gold);
  font-size: .76rem;
  letter-spacing: .1em;
  line-height: 1.4;
}

.quest-number { font-family: Georgia, serif; font-weight: 700; letter-spacing: .16em; }
.quest-number + .scene-section { border-left: 1px solid var(--rule); margin-left: .62rem; padding-left: .62rem; }

.scene-title {
  margin: 0;
  color: #fff4dc;
  font-family: var(--serif);
  font-size: clamp(1.32rem, 5.5vw, 1.9rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: .025em;
  text-shadow: 0 2px 3px #000a;
}

.scene-title:focus-visible { outline: 2px solid #f6dca0; outline-offset: 4px; }
.scene-subtitle { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }

.scene-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  flex: none;
  position: relative;
  isolation: isolate;
  min-block-size: 140px;
  border-bottom: 1px solid var(--rule);
  background: radial-gradient(ellipse at center, #283545 0%, #0b0f19 75%);
  overflow: hidden;
}

.scene-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(0deg, #0d131e42 0%, transparent 18%, transparent 89%, #0d131e35 100%);
  box-shadow: inset 0 0 22px #0a0a0a35;
}

.scene-stage--empty { min-block-size: 250px; }
.scene-sigil { color: #a89466; font-family: Georgia, serif; font-size: 4.5rem; text-shadow: 0 0 32px #f5bc6755; }

.art-frame { position: relative; width: 100%; overflow: hidden; }
.scene-image { display: block; width: 100%; user-select: none; }
.art-frame--crop .scene-image { position: absolute; max-width: none; }
.game-scene:not(.game-scene--weapon) .scene-stage--portrait .art-frame:not(.art-frame--crop) .scene-image {
  height: min(56svh, 550px);
  object-fit: cover;
  object-position: center 57%;
}
.scene-stage--wide .art-frame { width: 100%; }

.game-scene--title .scene-heading {
  position: absolute;
  z-index: 3;
  inset: calc(env(safe-area-inset-top, 0px) + clamp(32px, 10svh, 90px)) 0 auto;
  gap: 8px;
  padding: 10px var(--gutter) 19px;
  background: radial-gradient(ellipse at 50% 48%, #090c19cf 0, #090c1969 56%, transparent 90%);
  border: 0;
}

.game-scene--title .scene-heading::after { display: none; }
.game-scene--title .scene-title { font-size: clamp(1.64rem, 7.15vw, 2.48rem); letter-spacing: 0; text-shadow: 0 3px 12px #06070b, 0 1px 2px #000; }

.title-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #ffe6af;
  font-size: 1.25rem;
  text-shadow: 0 0 13px #f6c16f;
}

.title-ornament::before, .title-ornament::after {
  content: '';
  width: min(25%, 102px);
  height: 1px;
  background: linear-gradient(90deg, transparent, #e1ba77);
}

.title-ornament::after { transform: scaleX(-1); }
.game-scene--title .scene-stage { min-height: 290px; }
.game-scene--title .scene-stage::after { background: linear-gradient(0deg, #090f19 0%, transparent 20%); }
.game-scene--title .scene-body { position: relative; z-index: 2; margin-top: -15px; background: linear-gradient(0deg, #090e16, #090f19 75%, transparent); }
.game-scene--title .actions { width: min(86%, 366px); margin: 0 auto; }
.game-scene--title .action,
.game-scene--guild .action {
  border-color: #bea277;
  background: linear-gradient(180deg, #30486a, #142743 56%, #111d33);
  box-shadow: inset 0 0 0 2px #dcc08737, inset 0 0 0 4px #142741, 0 4px 12px #0009;
  font-family: var(--serif);
}

.game-scene--title-art .scene-heading,
.game-scene--battle-art .scene-heading {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.scene-stage--battle {
  min-block-size: 0;
  background: radial-gradient(ellipse at 50% 22%, #252f41, #0b101a 76%);
}
.scene-stage--battle .art-frame { width: 100%; align-self: end; }
.scene-stage--battle::after { background: linear-gradient(0deg, #0c111ec9 0%, transparent 18%); }

.fairy-callout {
  position: absolute;
  z-index: 1;
  display: grid;
  align-content: center;
  padding: 3px 4px 3px 9px;
  border-radius: 9px;
  background: #f7f1e6;
  color: #19191d;
  font-size: clamp(8px, 2.4vw, 13px);
  font-weight: 700;
  line-height: 1.23;
  white-space: pre-line;
  box-shadow: 0 3px 8px #0009;
}
.fairy-callout::before { content: ''; position: absolute; inset: 41% auto auto -4px; border-block: 4px solid transparent; border-right: 5px solid #f7f1e6; }

.enemy-status {
  position: absolute;
  z-index: 3;
  inset: 9px auto auto 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 34px), 280px);
  padding: 8px 11px 9px;
  border: 1px solid #9b9ca4;
  border-radius: 8px;
  background: linear-gradient(#151b25f2, #0a101bed);
  box-shadow: inset 0 0 0 2px #fff1, 0 5px 12px #0008;
}

.enemy-meta, .hp-line { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.enemy-name { color: #fff; line-height: 1.3; font-size: .98rem; }
.enemy-level, .hp-label { color: #d6d6db; font-size: .78rem; white-space: nowrap; }
.hp-line { margin-top: 3px; }
.hp-bar { flex: 1; height: 10px; border: 1px solid #737984; border-radius: 20px; overflow: hidden; background: #10151a; }
.hp-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(180deg, #ff6775, #d71938); box-shadow: inset 0 1px #ffffff61; }

.enemy-status--in-art {
  transform: none;
  display: grid;
  align-content: center;
  padding: 4px 8px 5px;
  border-radius: 7px;
  background: linear-gradient(155deg, #1b2530, #090c11);
}
.enemy-status--in-art .enemy-name { font-size: clamp(.71rem, 3.3vw, 1.13rem); white-space: nowrap; }
.enemy-status--in-art .enemy-level, .enemy-status--in-art .hp-label { font-size: clamp(.58rem, 2.6vw, .85rem); }
.enemy-status--in-art .hp-bar { height: clamp(7px, 2.1vw, 12px); }

.hero-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border: 1px solid #5d8296;
  border-radius: 7px;
  color: #e9f4f9;
  background: linear-gradient(#192934, #0c1722);
  font-size: .79rem;
}
.hero-status .hp-line { margin-top: 0; }
.hero-status .hp-fill { background: linear-gradient(#9ee8eb, #368796); }
.hero-hp-values { position: relative; font-variant-numeric: tabular-nums; }
.hero-hp-change {
  position: absolute;
  inset: auto 0 100% auto;
  z-index: 3;
  padding: 1px 4px;
  border-radius: 4px;
  background: #121920;
  font-weight: 700;
}
.hero-hp-change--damage { color: #ff9ca6; }
.hero-hp-change--heal { color: #9ee8eb; }
.game-scene[data-effect="heal"] .hero-status { animation: recovered 460ms ease-out; }

.scene-stage--guild { background: linear-gradient(135deg, #231b17, #141725); }
.scene-stage--guild .art-frame { container-type: inline-size; }
.dialogue--guild {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 0 1.15cqw;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c5a670 #131821;
  border: 0;
  border-radius: 0;
  background: linear-gradient(150deg, #171b25, #0f141e 80%);
  box-shadow: none;
}
.dialogue--guild .dialogue-speaker {
  margin: 0 0 .7cqw;
  padding: 0 0 .4cqw;
  border-bottom: 1px solid #c5a67065;
  font-size: clamp(.625rem, 2.6cqw, .84rem);
  line-height: 1.25;
}
.dialogue--guild .dialogue-line { font-size: clamp(.675rem, 2.85cqw, .93rem); line-height: 1.32; }
.quest-card {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 112px;
  overflow: hidden;
  border: 2px solid #b89151;
  border-radius: 5px;
  background: radial-gradient(ellipse at 30% 30%, #fcf0cc, #e1c58f);
  color: #211b1e;
  box-shadow: inset 0 0 0 3px #eedab0, 0 5px 13px #0008;
}
.quest-card-copy { position: relative; z-index: 1; width: 63%; padding: 10px 12px; }
.quest-card-number { margin: 0 0 4px; color: #674e32; font: bold .9rem Georgia, serif; letter-spacing: .14em; }
.quest-card-title { margin: 0; font: 700 clamp(1.15rem, 5.4vw, 1.6rem)/1.3 var(--serif); }
.quest-card .art-frame {
  position: absolute;
  inset: 0 0 0 47%;
  width: auto;
  mask-image: linear-gradient(to right, transparent, #000 33%);
}
.quest-card .scene-image { height: 100%; object-fit: cover; }
.quest-card .art-frame--crop .scene-image { height: auto; min-height: 100%; }

.scene-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 13px;
  padding: 15px var(--gutter) 22px;
}

.scene-content { display: grid; gap: 11px; }

.dialogue {
  padding: 11px 13px 12px;
  border: 1px solid #828c9d;
  border-radius: 8px;
  background: radial-gradient(ellipse at 20% 0%, #28303e50, transparent 70%), #0b1019;
  color: #f4f3f0;
  box-shadow: inset 0 0 0 2px #fff1, 0 3px 7px #0006;
}

.dialogue-speaker { margin: 0 0 3px; color: #e9cc93; font-weight: 700; font-size: .82rem; letter-spacing: .04em; }
.dialogue-speaker--fairy { color: #aee7f5; }
.dialogue-line { margin: 0; font-size: .99rem; line-height: 1.64; white-space: pre-line; }

.actions { display: grid; grid-auto-rows: 1fr; gap: 8px; }

.action {
  --button-top: #344254;
  --button-bottom: #202c3b;
  --button-edge: #a9b9c9;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  position: relative;
  min-height: 48px;
  padding: 9px 11px;
  border: 1px solid var(--button-edge);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--button-top), var(--button-bottom));
  color: #fff;
  font-size: .97rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  text-shadow: 0 1px 2px #0008;
  box-shadow: inset 0 0 0 1px #ffffff28, 0 2px 6px #0005;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.action:active:not(:disabled) { transform: translateY(1px); filter: brightness(.9); }
.action:focus-visible { outline: 3px solid #ffe6a5; outline-offset: 2px; }
.action:disabled { opacity: .55; cursor: default; }
.action-label { overflow-wrap: anywhere; }

@media (hover: hover) { .action:hover:not(:disabled) { filter: brightness(1.16); } }

.game-scene--battle .scene-heading { padding-block: 9px 10px; }
.game-scene--battle .scene-title { font-size: clamp(1.04rem, 4vw, 1.35rem); }
.game-scene--battle .scene-body { gap: 9px; padding-top: 8px; background: linear-gradient(#10161f, #080b12); }
.game-scene--battle .scene-content { gap: 7px; }
.game-scene--battle .action { min-height: 44px; }

.game-scene--weapon .scene-stage {
  padding: 16px 0 13px;
  background: radial-gradient(ellipse at 50% 42%, #ab793a5e, transparent 64%), #0b111e;
}

.game-scene--weapon .art-frame {
  width: clamp(122px, 41vw, 183px);
  border: 1px solid #b99455;
  box-shadow: 0 0 23px #e2ac4649, 0 4px 18px #000b;
}

.game-scene--weapon .art-frame .scene-image { max-height: min(42svh, 370px); object-fit: contain; }
.weapon-name { margin: 0; color: #f8e1ab; font: 700 clamp(1.3rem, 5.6vw, 1.72rem)/1.3 var(--serif); text-align: center; }
.weapon-description { margin: -4px 0 2px; color: #ece3d5; text-align: center; font-size: .88rem; line-height: 1.6; }

.reward-fields, .commission-fields, .report-fields { margin: 0; }

.reward-fields, .commission-fields {
  padding: 5px 13px;
  border: 1px solid #846c47;
  border-radius: 6px;
  background: linear-gradient(140deg, #312b26, #1a1e28);
}

.field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 11px; padding: 8px 0; align-items: baseline; }
.field + .field { border-top: 1px solid var(--rule); }
.field dt { color: var(--gold); font-size: .84rem; }
.field dd { margin: 0; font-weight: 700; text-align: right; font-size: .93rem; }

.game-scene--epilogue .commission-fields {
  padding: 6px 16px;
  border-color: #d4b274;
  background: radial-gradient(ellipse at top, #fff0ca, #e3c993);
  color: #2f2318;
}

.game-scene--epilogue .commission-fields dt { color: #654625; }

.game-scene--report { --rule: #e1e3e6; background: #fff; color: #20242a; color-scheme: light; }
.game-scene--report .scene-heading { padding: 28px var(--gutter) 17px; border-color: #cfd3d7; background: #fff; text-align: left; }
.game-scene--report .scene-heading::after { display: none; }
.game-scene--report .scene-title { color: #171a1e; font-family: inherit; font-size: 1.45rem; text-shadow: none; }
.game-scene--report .scene-body { padding-block: 14px 22px; }
.game-scene--report .actions { margin-top: 4px; }
.game-scene--report .action { --button-top: #353a42; --button-bottom: #252a31; --button-edge: #252a31; text-shadow: none; }
.game-scene--report :focus-visible { outline-color: #2b6296; }
.report-content { display: grid; gap: 17px; }
.report-fields { border-block: 1px solid var(--rule); }
.report-fields dt { color: #454c55; }
.report-fields .field { grid-template-columns: 1fr 1fr; }
.report-statistics-title { margin: 13px 0 4px; font-size: .97rem; }
.report-table { border-collapse: collapse; width: 100%; font-size: .86rem; }
.report-table tr { border-bottom: 1px solid var(--rule); }
.report-table th, .report-table td { padding: 6px 0; }
.report-table th { text-align: left; font-weight: 600; }
.report-table td { text-align: right; font-weight: 700; }
.report-collecting, .report-ratio { color: #505864; font-weight: 400; }
.report-method, .report-note { margin: 10px 0 0; color: #525b66; font-size: .75rem; line-height: 1.65; }
.report-note { border-top: 1px solid var(--rule); margin: 0; padding-top: 10px; }

.scene-damage {
  position: absolute;
  inset: 37% 0 auto;
  z-index: 4;
  pointer-events: none;
  color: #ffede6;
  font-size: 2.7rem;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 6px #9e0c21, 0 0 2px #000;
}

.scene-stage:is([data-effect="attack"], [data-effect="beam"], [data-effect="enemy-attack"], [data-effect="heal"], [data-effect="reveal"])::before {
  content: '';
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  animation: effect 400ms ease-out both;
  background: linear-gradient(145deg, transparent 47%, #ffdedcbd 50%, transparent 53%);
}

.scene-stage:is([data-effect="attack"], [data-effect="beam"])::before { animation: swing 420ms ease-out both; }
.scene-stage[data-effect="beam"]::before { background: linear-gradient(145deg, transparent 44%, #ef74223d 47%, #fff4ad 50%, #ef74223d 53%, transparent 56%); }
.scene-stage[data-effect="enemy-attack"]::before { background: radial-gradient(ellipse at center, transparent 34%, #a52237bd 100%); }
.scene-stage[data-effect="enemy-attack"] .art-frame { animation: lunge 420ms ease-out both; }
.scene-stage[data-effect="heal"]::before {
  background: radial-gradient(ellipse at 18% 85%, #d8fdff9e 0%, #5ee3eb40 31%, transparent 65%);
  transform-origin: 18% 85%;
  animation: fairy-bloom 550ms ease-out both;
}
.scene-stage[data-effect="reveal"]::before { background: radial-gradient(ellipse at center, #ad79ff65, transparent 75%); animation-duration: 620ms; }
.scene-damage { animation: damage 550ms ease-out both; }
@keyframes effect { 0%, 100% { opacity: 0; } 22% { opacity: 1; } }
@keyframes swing {
  0% { opacity: 0; transform: translate(-19%, 16%); }
  29% { opacity: 1; }
  100% { opacity: 0; transform: translate(16%, -13%); }
}
@keyframes fairy-bloom {
  0% { opacity: 0; transform: scale(.3); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.2); }
}
@keyframes damage { 0% { opacity: 0; transform: translateY(10px); } 24% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes lunge { 0%, 100% { transform: none; } 26% { transform: scale(1.045) translateY(3px); } }
@keyframes recovered { 0%, 100% { box-shadow: none; } 35% { box-shadow: inset 0 0 16px #61dccc80, 0 0 10px #61dccc54; } }

.game-scene--gaze .scene-stage > .art-frame {
  transform: scale(1.025);
  transform-origin: 51% 37%;
}

.game-scene--fourth-wall {
  background: #05070c;
  color: #f4f2ef;
}
.game-scene--fourth-wall .scene-heading,
.game-scene--fourth-wall .enemy-status,
.game-scene--fourth-wall .hero-status,
.game-scene--fourth-wall .fairy-callout,
.game-scene--fourth-wall .actions,
.game-scene--fourth-wall .scene-stage > .art-frame:not(.fourth-wall-portrait) {
  display: none;
}
.game-scene--fourth-wall .scene-stage {
  border: 0;
  background: #05070c;
}
.game-scene--fourth-wall .scene-stage::before { display: none; }
.game-scene--fourth-wall .scene-stage::after {
  background: linear-gradient(0deg, #05070c, transparent 29%, #05070c17 100%);
  box-shadow: none;
}
.game-scene--fourth-wall .scene-stage > .fourth-wall-portrait {
  display: block;
  width: 120%;
  transform: scale(1.025);
  transform-origin: 48% 35%;
  animation: king-gaze 1700ms ease-out both;
}
.game-scene--fourth-wall .fourth-wall-portrait .scene-image {
  filter: saturate(.78) brightness(.87);
}
.game-scene--fourth-wall .scene-body {
  justify-content: center;
  padding: 20px clamp(20px, 7vw, 40px) max(28px, env(safe-area-inset-bottom));
  background: #05070c;
}
.game-scene--fourth-wall .scene-content { width: 100%; }
.game-scene--fourth-wall .dialogue {
  display: block;
  width: 100%;
  min-height: 136px;
  margin: 0;
  padding: 12px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  text-align: left;
}
.game-scene--fourth-wall .dialogue-speaker {
  margin-bottom: 11px;
  color: #b5adbf;
  font-size: .875rem;
  font-weight: 400;
}
.game-scene--fourth-wall .dialogue-line {
  font-family: var(--serif);
  font-size: clamp(1.125rem, 4.8vw, 1.4rem);
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.dialogue--advance {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.dialogue--advance:focus-visible { outline: 2px solid #d9d0e8; outline-offset: 8px; }
@keyframes king-gaze {
  from { transform: scale(1); }
  to { transform: scale(1.025); }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 560px) {
  .game-scene { min-height: calc(100svh - 32px); margin-block: 16px; border-radius: 13px; overflow: hidden; }
}

@media (max-height: 650px) {
  .scene-body { padding-bottom: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .scene-damage { display: none; }
}
