/* 匙加減 -SAJIKAGEN- 意匠: 明治期の引札・売薬ラベルの翻案
   基調: 生成り#EDE4D1 / 墨#2B2620 / 洗朱#B3402B / 藍#2A4C6E / 芥子#C8942A */

@font-face {
  font-family: "YujiBoku";
  src: url("../assets/fonts/YujiBoku-sub.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "KaiseiTokumin";
  src: url("../assets/fonts/KaiseiTokumin-sub.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "KaiseiTokumin";
  src: url("../assets/fonts/KaiseiTokumin-Bold-sub.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "BodoniModa";
  src: url("../assets/fonts/BodoniModa-sub.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --paper: #EDE4D1;
  --paper-dim: #DDD2BA;
  --sumi: #2B2620;
  --shu: #B3402B;
  --ai: #2A4C6E;
  --karashi: #C8942A;
}

* { margin: 0; padding: 0; box-sizing: border-box; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100dvh; background: #1A1611; overflow: hidden; }
body {
  font-family: "KaiseiTokumin", serif;
  color: var(--sumi);
  display: flex;
  align-items: center;
  justify-content: center;
}

.num { font-family: "BodoniModa", "KaiseiTokumin", serif; }

/* ===== 16:9 ステージ(コンテナクエリ単位で組む) ===== */
#app {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  container-type: size;
  overflow: hidden;
  background: var(--paper);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  background-size: cover;
  background-position: center;
}
.screen.active { display: block; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* 引札ボタン(9-slice) */
.btn-plate {
  border: 0 solid transparent;
  border-image: url("../assets/img/ui_btn.png") 45 fill / 2.2cqh stretch;
  font-size: 2.9cqh;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  padding: 1.4cqh 3.4cqh;
  color: var(--sumi);
}
.btn-plate:active { border-image-source: url("../assets/img/ui_btn_press.png"); transform: translateY(0.3cqh); }
.btn-plate:disabled { opacity: 0.45; cursor: default; }
.btn-plate.small { font-size: 2.2cqh; padding: 1cqh 2.2cqh; letter-spacing: 0.15em; text-indent: 0.15em; }

/* 効能書きパネル(9-slice) */
.panel {
  border: 0 solid transparent;
  border-image: url("../assets/img/ui_panel.png") 65 fill / 2.8cqh stretch;
  padding: 2.6cqh;
}

/* ===== タイトル ===== */
#scr-title { background-image: url("../assets/img/bg_title.jpg"); }
.title-logo {
  position: absolute;
  top: 7cqh; right: 8cqw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.title-main {
  font-family: "YujiBoku", serif;
  font-size: 13.5cqh;
  color: var(--sumi);
  letter-spacing: 0.08em;
  line-height: 1.05;
  text-shadow: 0 0 1.2cqh rgba(237, 228, 209, 0.9);
}
.title-sub {
  font-family: "BodoniModa", serif;
  font-size: 2.6cqh;
  letter-spacing: 0.62em;
  text-indent: 0.62em;
  color: var(--shu);
  margin-top: 1.2cqh;
}
.title-stamp {
  position: absolute;
  bottom: 4.6cqh; right: 2.2cqh;
  width: 6cqh; height: 6cqh;
  background: url("../assets/img/piece_senri.png") center/contain no-repeat;
  opacity: 0.92;
}
.title-menu {
  position: absolute;
  right: 8cqw; bottom: 16cqh;
  display: flex;
  flex-direction: column;
  gap: 2.2cqh;
  align-items: center;
}
.title-lang {
  position: absolute;
  top: 2.4cqh; left: 2.4cqh;
  display: flex;
  gap: 0.8cqh;
}
.lang-btn {
  font-size: 2cqh;
  padding: 0.7cqh 1.6cqh;
  border: 0.22cqh solid var(--sumi);
  background: rgba(237, 228, 209, 0.85);
  color: var(--sumi);
}
.lang-btn.on { background: var(--sumi); color: var(--paper); }
#btn-title-settings {
  position: absolute;
  bottom: 2.4cqh; left: 2.4cqh;
  font-size: 2.2cqh;
  padding: 0.8cqh 1.8cqh;
  border: 0.22cqh solid var(--sumi);
  background: rgba(237, 228, 209, 0.85);
}
.title-credit {
  position: absolute;
  bottom: 1.6cqh; right: 2cqh;
  font-size: 1.7cqh;
  color: rgba(43, 38, 32, 0.75);
  letter-spacing: 0.1em;
}

/* ===== プロローグ ===== */
#scr-prologue { background: #211D17; }
.prologue-senri {
  position: absolute;
  right: 9cqw; bottom: 0;
  height: 66cqh;
  opacity: 0;
  animation: senriIn 1.2s 0.3s forwards;
}
@keyframes senriIn { to { opacity: 0.94; } }
.prologue-line {
  position: absolute;
  left: 42cqw; top: 42cqh;
  transform: translateX(-50%);
  width: 58cqw;
  text-align: center;
  font-size: 3.4cqh;
  line-height: 2;
  color: var(--paper);
  letter-spacing: 0.14em;
  opacity: 0;
  transition: opacity 0.8s;
}
.prologue-line.show { opacity: 1; }
.prologue-next {
  position: absolute;
  bottom: 8cqh; left: 50%;
  transform: translateX(-50%);
}
.prologue-skip {
  position: absolute;
  top: 2.4cqh; right: 2.4cqh;
  font-size: 2cqh;
  color: var(--paper-dim);
  border: 0.2cqh solid rgba(237, 228, 209, 0.4);
  padding: 0.6cqh 1.6cqh;
}

/* ===== 道中図 ===== */
#scr-map { background-image: url("../assets/img/bg_map.jpg"); }
.map-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8.4cqh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.2cqh;
  background: rgba(43, 38, 32, 0.82);
  color: var(--paper);
}
.map-title { font-family: "YujiBoku", serif; font-size: 3.6cqh; letter-spacing: 0.3em; }
.hud-right { display: flex; align-items: center; gap: 2.6cqh; font-size: 2.6cqh; }
.hud-item { display: flex; align-items: center; gap: 0.7cqh; }
.hud-icon { width: 3cqh; height: 3cqh; background-size: contain; background-repeat: no-repeat; background-position: center; }
.hud-icon.coin { background-image: url("../assets/img/ui_coin.png"); }
.trust-seals { display: flex; gap: 0.4cqh; }
.trust-seal {
  width: 3cqh; height: 3cqh;
  background: url("../assets/img/prop_seal_round.png") center/contain no-repeat;
}
.trust-seal.lost { filter: grayscale(1); opacity: 0.28; }

.map-node {
  position: absolute;
  width: 9.5cqh; height: 9.5cqh;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3cqh;
  opacity: 0.55;
}
.map-node .node-disc {
  width: 6.4cqh; height: 6.4cqh;
  background-color: rgba(237, 228, 209, 0.92);
  border: 0.3cqh solid var(--sumi);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-node .node-glyph { width: 4.2cqh; height: 4.2cqh; background-size: contain; background-repeat: no-repeat; background-position: center; }
.map-node .node-label {
  font-size: 1.9cqh;
  font-weight: 700;
  background: rgba(237, 228, 209, 0.9);
  padding: 0.1cqh 0.7cqh;
  white-space: nowrap;
}
.map-node.done { opacity: 0.35; filter: grayscale(0.7); }
.map-node.open { opacity: 1; cursor: pointer; }
.map-node.open .node-disc { border-color: var(--shu); box-shadow: 0 0 0 0.5cqh rgba(179, 64, 43, 0.35); animation: nodePulse 1.6s infinite; }
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 0 0.4cqh rgba(179, 64, 43, 0.35); }
  50% { box-shadow: 0 0 0 1cqh rgba(179, 64, 43, 0.12); }
}
.map-node.elite .node-disc { border-color: var(--shu); border-width: 0.45cqh; }
.map-piece {
  position: absolute;
  width: 6.2cqh; height: 6.6cqh;
  transform: translate(-50%, -108%);
  background: url("../assets/img/piece_senri.png") center/contain no-repeat;
  filter: drop-shadow(0 0.4cqh 0.4cqh rgba(43, 38, 32, 0.45));
  transition: left 0.7s ease, top 0.7s ease;
  pointer-events: none;
  z-index: 3;
}

/* ===== 治療 ===== */
#scr-treat { background-image: url("../assets/img/bg_sick.jpg"); }
.treat-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8.4cqh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.2cqh;
  background: rgba(43, 38, 32, 0.82);
  color: var(--paper);
  z-index: 5;
}
.treat-name { font-size: 3cqh; font-weight: 700; letter-spacing: 0.12em; }
.treat-night { font-size: 2.4cqh; margin-left: 2cqh; color: var(--paper-dim); }

.patient-area {
  position: absolute;
  left: 1cqw; bottom: 30cqh;
  width: 34cqw;
  height: 46cqh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.patient-img {
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 1cqh 1.4cqh rgba(43, 38, 32, 0.35));
}
.hp-wrap {
  position: absolute;
  left: 2cqw; top: 10.5cqh;
  width: 30cqw;
  z-index: 4;
}
.hp-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 2.2cqh;
  color: var(--paper);
  text-shadow: 0 0 0.7cqh rgba(43, 38, 32, 0.9);
  margin-bottom: 0.4cqh;
}
.gauge {
  position: relative;
  height: 5cqh;
  background: url("../assets/img/ui_gauge_frame.png") center/100% 100% no-repeat;
}
.gauge-fill {
  position: absolute;
  inset: 31% 17% 33% 17%;
  background: url("../assets/img/ui_gauge_fill.png") left center/auto 100% repeat-x;
  transform-origin: 0 50%;
  transition: transform 0.5s;
}
.forecast {
  margin-top: 0.6cqh;
  font-size: 2.1cqh;
  color: #F4C9B8;
  text-shadow: 0 0 0.7cqh rgba(43, 38, 32, 0.95);
}
.forecast.calm { color: #BCD6EA; }

.symptom-row {
  position: absolute;
  left: 34cqw; top: 12cqh;
  width: 30cqw;
  display: flex;
  flex-wrap: wrap;
  gap: 1cqh;
  z-index: 4;
}
.symptom-chip {
  position: relative;
  width: 9.4cqh;
  border: 0 solid transparent;
  border-image: url("../assets/img/ui_card.png") 65 fill / 1.4cqh stretch;
  padding: 0.8cqh 0.6cqh 0.6cqh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2cqh;
  transition: opacity 0.5s, transform 0.5s;
}
.symptom-chip .sym-icon { width: 5cqh; height: 5cqh; background-size: contain; background-repeat: no-repeat; background-position: center; }
.symptom-chip .sym-name { font-size: 1.8cqh; font-weight: 700; }
.symptom-chip .sym-depth { font-size: 2.4cqh; color: var(--ai); font-weight: 700; }
.symptom-chip.gone-anim { opacity: 0; transform: scale(0.85) translateY(-1cqh); }
.symptom-chip .sym-stamp {
  position: absolute;
  inset: 0;
  background: url("../assets/img/prop_seal_square.png") center/72% no-repeat;
  opacity: 0;
  transform: scale(1.7) rotate(-8deg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sym-stamp-char {
  font-family: "YujiBoku", serif;
  font-size: 5.4cqh;
  color: var(--shu);
  line-height: 1;
}
.symptom-chip.stamped .sym-stamp { animation: stampIn 0.45s forwards; }
@keyframes stampIn {
  0% { opacity: 0; transform: scale(1.7) rotate(-8deg); }
  55% { opacity: 1; transform: scale(0.94) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(-8deg); }
}

.log-band {
  position: absolute;
  right: 1.2cqw; bottom: 31cqh;
  width: 38cqw;
  max-height: 30cqh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 4;
}
.log-line {
  font-size: 2.2cqh;
  line-height: 1.55;
  background: rgba(237, 228, 209, 0.88);
  border-left: 0.5cqh solid var(--ai);
  padding: 0.35cqh 1cqh;
  margin-top: 0.5cqh;
  opacity: 0;
  animation: logIn 0.35s forwards;
}
.log-line.log-bad { border-left-color: var(--shu); color: var(--shu); }
.log-line.log-formula { border-left-color: var(--karashi); font-weight: 700; }
@keyframes logIn { from { opacity: 0; transform: translateX(1.2cqh); } to { opacity: 1; transform: none; } }

.hand-area {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 29cqh;
  background: rgba(43, 38, 32, 0.72);
  display: flex;
  align-items: center;
  padding: 0 1.6cqw;
  gap: 1cqw;
  z-index: 5;
}
.hand-cards {
  flex: 1;
  display: flex;
  gap: 1cqw;
  align-items: center;
  justify-content: center;
}
.card {
  position: relative;
  width: 13.4cqh;
  border: 0 solid transparent;
  border-image: url("../assets/img/ui_card.png") 65 fill / 1.5cqh stretch;
  padding: 1cqh 0.8cqh 0.8cqh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35cqh;
  cursor: pointer;
  transition: transform 0.18s;
}
.card .card-icon { width: 7.4cqh; height: 7.4cqh; background-size: contain; background-repeat: no-repeat; background-position: center; }
.card .card-name { font-size: 2cqh; font-weight: 700; white-space: nowrap; }
.card .card-desc { font-size: 1.55cqh; line-height: 1.3; text-align: center; color: rgba(43, 38, 32, 0.85); min-height: 4cqh; }
.card.sel { transform: translateY(-2.4cqh); box-shadow: 0 0 0 0.5cqh var(--shu); }
.card.dim { opacity: 0.55; }

.treat-actions {
  display: flex;
  flex-direction: column;
  gap: 1.2cqh;
  align-items: stretch;
  width: 21cqw;
}
.action-note { font-size: 1.8cqh; color: var(--paper-dim); text-align: center; }

/* 薬包演出 */
.pack-fx {
  position: absolute;
  left: 50%; bottom: 31cqh;
  width: 12cqh; height: 12cqh;
  transform: translateX(-50%);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 8;
  pointer-events: none;
}

/* ===== 薬草市 ===== */
#scr-market { background-image: url("../assets/img/bg_ichi.jpg"); }
.market-body {
  position: absolute;
  left: 6cqw; top: 13cqh;
  right: 6cqw;
  display: flex;
  gap: 2cqw;
  justify-content: center;
}
.market-slot { display: flex; flex-direction: column; align-items: center; gap: 1cqh; }
.market-slot .price { font-size: 2.6cqh; font-weight: 700; color: var(--paper); text-shadow: 0 0 0.8cqh rgba(43,38,32,1); }
.market-slot .sold { font-size: 2.4cqh; color: var(--paper-dim); }
.market-actions {
  position: absolute;
  bottom: 4cqh; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 2cqw;
}

/* ===== リザルト ===== */
#scr-result { background-image: url("../assets/img/bg_result.jpg"); }
.result-fuda {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 52cqw;
  border: 0 solid transparent;
  border-image: url("../assets/img/prop_hikifuda.png") 80 fill / 5cqh stretch;
  padding: 5cqh 4cqh;
  text-align: center;
  animation: fudaIn 0.55s ease-out;
}
@keyframes fudaIn {
  from { opacity: 0; transform: translate(-50%, -58%) scale(1.12) rotate(1.5deg); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
}
.result-title {
  font-family: "YujiBoku", serif;
  font-size: 7.4cqh;
  letter-spacing: 0.18em;
  margin-bottom: 1.6cqh;
}
.result-title.lose { color: var(--shu); }
.result-msg { font-size: 2.7cqh; line-height: 1.8; margin-bottom: 2.2cqh; }
.result-stats { font-size: 2.3cqh; line-height: 1.9; color: rgba(43, 38, 32, 0.85); margin-bottom: 2.6cqh; }
.result-actions { display: flex; justify-content: center; gap: 1.6cqw; }

/* ===== モーダル ===== */
#modal-wrap {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(26, 22, 17, 0.55);
  z-index: 20;
}
#modal-wrap.active { display: flex; }
.modal-box {
  width: 56cqw;
  max-height: 82cqh;
  overflow-y: auto;
  background: var(--paper);
}
.modal-title { font-family: "YujiBoku", serif; font-size: 3.6cqh; letter-spacing: 0.2em; text-align: center; margin-bottom: 1.8cqh; }
.modal-text { font-size: 2.5cqh; line-height: 1.85; text-align: center; margin-bottom: 2.4cqh; }
.modal-actions { display: flex; flex-direction: column; gap: 1.4cqh; align-items: center; }
.modal-actions.row { flex-direction: row; justify-content: center; }
.deck-grid { display: flex; flex-wrap: wrap; gap: 1cqh; justify-content: center; margin-bottom: 2cqh; }
.deck-grid .card { cursor: default; }
.deck-grid .card.sellable { cursor: pointer; }
.card .price { font-size: 1.8cqh; color: var(--karashi); font-weight: 700; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 2.6cqh;
  padding: 1.2cqh 2cqh;
  border-bottom: 0.15cqh solid rgba(43, 38, 32, 0.25);
}
.settings-row .opts { display: flex; gap: 0.8cqh; }

/* ===== チュートリアル ===== */
#tut-overlay {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 30;
}
#tut-overlay.active { display: block; }
.tut-hole {
  position: absolute;
  border-radius: 1cqh;
  box-shadow: 0 0 0 200cqw rgba(26, 22, 17, 0.72);
  border: 0.45cqh solid var(--karashi);
  pointer-events: none;
}
.tut-balloon {
  position: absolute;
  max-width: 40cqw;
  background: var(--paper);
  border: 0.3cqh solid var(--sumi);
  padding: 1.4cqh 1.8cqh;
  font-size: 2.4cqh;
  line-height: 1.7;
}
.tut-balloon::after {
  content: "▼";
  position: absolute;
  bottom: -2.4cqh;
  left: 3cqh;
  color: var(--sumi);
  font-size: 1.8cqh;
}
.tut-balloon.below::after { content: "▲"; bottom: auto; top: -2.4cqh; }
.tut-tap {
  position: absolute;
  bottom: 3cqh; right: 3cqh;
  color: var(--paper-dim);
  font-size: 2cqh;
  animation: tapBlink 1.2s infinite;
}
@keyframes tapBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ===== 汎用エフェクト ===== */
#fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.float-text {
  position: absolute;
  font-size: 3cqh;
  font-weight: 700;
  color: var(--ai);
  text-shadow: 0 0 0.8cqh rgba(237, 228, 209, 0.95);
  animation: floatUp 1s forwards;
}
.float-text.bad { color: var(--shu); }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0.8cqh); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-4.5cqh); }
}
.screen-fade {
  position: absolute;
  inset: 0;
  background: #1A1611;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  z-index: 50;
}
.screen-fade.on { opacity: 1; pointer-events: auto; }

/* 快癒引札(治癒演出) */
.kaiyu-fuda {
  position: absolute;
  left: 17cqw; top: 18cqh;
  width: 34cqw;
  border: 0 solid transparent;
  border-image: url("../assets/img/prop_hikifuda.png") 80 fill / 4cqh stretch;
  padding: 4.5cqh 3cqh;
  text-align: center;
  z-index: 9;
  animation: fudaSlam 0.5s ease-in forwards;
}
.kaiyu-fuda .kaiyu-text { font-family: "YujiBoku", serif; font-size: 8cqh; letter-spacing: 0.25em; color: var(--shu); }
@keyframes fudaSlam {
  0% { opacity: 0; transform: scale(1.6) rotate(-3deg); }
  60% { opacity: 1; transform: scale(0.97) rotate(-1.5deg); }
  100% { opacity: 1; transform: scale(1) rotate(-1.5deg); }
}
.kaiyu-fuda.fade-out { transition: opacity 0.32s; opacity: 0; }
/* 失敗演出(破れ紙) */
.fail-overlay {
  position: absolute;
  inset: 0;
  background: rgba(43, 38, 32, 0.45);
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fail-overlay .fail-text {
  font-family: "YujiBoku", serif;
  font-size: 7cqh;
  color: var(--paper);
  letter-spacing: 0.2em;
  transform: rotate(-4deg);
}

/* ===== 縦持ちガード ===== */
#rotate-guard { display: none; }
@media (orientation: portrait) {
  #rotate-guard {
    display: flex;
    position: fixed;
    inset: 0;
    background: #1A1611;
    color: #EDE4D1;
    z-index: 100;
    align-items: center;
    justify-content: center;
  }
  .rg-inner { text-align: center; font-size: 4vw; line-height: 2; }
  .rg-icon { font-size: 14vw; }
}
