/* ドット絵風UI（角ばった枠・ベタ塗り・ドットフォント） */
:root {
  --ink: #2b1708;
  --ink-2: #6a4428;
  --panel: #fbe9c4;
  --panel-hi: #fffaf0;
  --panel-lo: #d9b97a;
  --sand: #f4dfb0;
  --rust: #c8562a;
  --rust-hi: #e8784a;
  --rust-lo: #8a3418;
  --gold: #ffd23a;
  --gold-lo: #c89a10;
  --pink: #e8578f;
  --red: #d8283a;
  --green: #4caf3c;
  --gutter: max(8px, env(safe-area-inset-left));
  --font: "DotGothic16", "MS Gothic", "Osaka-Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #e2b070;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#cv {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
}

img { image-rendering: pixelated; image-rendering: crisp-edges; }

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

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  pointer-events: none;
}
.screen.active { display: flex; }
.screen button, .screen input, .card, .bottom-panel, .topbar, .sheet { pointer-events: auto; }
.hidden { display: none !important; }

/* ---------- ドット枠の共通部品 ---------- */
.px-box, .stat, .bottom-panel, .card, .modal-card, .sheet {
  background: var(--panel);
  border: 3px solid var(--ink);
  box-shadow:
    inset -3px -3px 0 var(--panel-lo),
    inset 3px 3px 0 var(--panel-hi),
    4px 4px 0 rgba(43, 23, 8, 0.55);
}

button {
  font-family: var(--font);
  color: inherit;
  cursor: pointer;
  border-radius: 0;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button:focus { outline: none; }
button:focus-visible { outline: 3px dashed #1d5f9a; outline-offset: 2px; }

.btn {
  border: 3px solid var(--ink);
  background: var(--sand);
  padding: 8px 16px;
  font-size: 19px;
  line-height: 1.2;
  box-shadow: inset -3px -3px 0 var(--panel-lo), inset 3px 3px 0 var(--panel-hi), 3px 3px 0 var(--ink);
  white-space: nowrap;
}
.btn:active, .btn.pressed {
  transform: translate(3px, 3px);
  box-shadow: inset -3px -3px 0 var(--panel-lo), inset 3px 3px 0 var(--panel-hi);
}
.btn.primary {
  background: var(--rust);
  color: #fff6dc;
  text-shadow: 2px 2px 0 var(--rust-lo);
  box-shadow: inset -3px -3px 0 var(--rust-lo), inset 3px 3px 0 var(--rust-hi), 3px 3px 0 var(--ink);
}
.btn.primary:active { box-shadow: inset -3px -3px 0 var(--rust-lo), inset 3px 3px 0 var(--rust-hi); }
.btn.big { font-size: 29px; padding: 12px 30px; }
.btn.small { font-size: 16px; padding: 6px 10px; }
.btn.ghost { background: #efd9aa; }
.btn:disabled { filter: grayscale(0.8) brightness(0.9); cursor: default; }

.icon-btn {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  top: max(8px, env(safe-area-inset-top));
  z-index: 30;
  width: 40px; height: 40px;
  border: 3px solid var(--ink);
  background: var(--sand);
  font-size: 24px;
  pointer-events: auto;
  box-shadow: inset -3px -3px 0 var(--panel-lo), inset 3px 3px 0 var(--panel-hi), 3px 3px 0 var(--ink);
}
.icon-btn.muted { background: #b8a888; text-decoration: line-through; }

/* ---------- 上部バー ---------- */
.topbar {
  margin: max(8px, env(safe-area-inset-top)) var(--gutter) 0;
  margin-right: calc(var(--gutter) + 50px);
  display: flex;
  gap: 6px;
  align-items: stretch;
  flex-wrap: wrap;
}
.stat {
  padding: 4px 10px 5px;
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat label { font-size: 14px; color: var(--ink-2); display: block; line-height: 1.2; }
.stat b { font-size: 22px; font-weight: normal; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat.main b { font-size: 26px; color: var(--rust); }
.stat small { font-size: 13px; color: var(--ink-2); line-height: 1.2; }
.topbar .btn { align-self: center; }

/* 耐久ゲージ */
.stat.hp { min-width: 110px; }
.hpbar {
  height: 14px;
  margin-top: 3px;
  border: 2px solid var(--ink);
  background: #4a2a1a;
  position: relative;
}
.hpbar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 100%;
  background: var(--green);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35);
  transition: width .2s steps(5);
}
.hpbar i.warn { background: #e8b020; }
.hpbar i.danger { background: var(--red); animation: hpblink .4s steps(2) infinite; }
@keyframes hpblink { 50% { opacity: .35; } }
.hpbar::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 8px, rgba(43, 23, 8, .6) 8px 10px);
}

/* ---------- 下部パネル ---------- */
.bottom-panel {
  margin: auto var(--gutter) max(8px, env(safe-area-inset-bottom));
  padding: 10px;
}
#bank-panel { min-height: 0; overflow-y: auto; touch-action: pan-y; }

.qty-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.qlabel { font-size: 16px; color: var(--ink-2); margin-right: 2px; }
.q {
  border: 3px solid var(--ink);
  background: var(--sand);
  padding: 4px 8px;
  font-size: 18px;
  flex: 1;
  max-width: 96px;
  box-shadow: inset -2px -2px 0 var(--panel-lo), inset 2px 2px 0 var(--panel-hi);
}
.q.on { background: var(--gold); box-shadow: inset -2px -2px 0 var(--gold-lo), inset 2px 2px 0 #fff2a0; }

.coin-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.coin-card { position: relative; display: flex; flex-direction: column; }
.coin-add {
  border: 3px solid var(--ink);
  background: #fff4dc;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: inset -3px -3px 0 var(--panel-lo), inset 3px 3px 0 #ffffff, 3px 3px 0 var(--ink);
  min-height: 96px;
}
.coin-add.pressed { transform: translate(3px, 3px); box-shadow: inset -3px -3px 0 var(--panel-lo), inset 3px 3px 0 #ffffff; }
.coin-add img { width: 40px; height: 40px; pointer-events: none; }
.coin-add .ctext { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.coin-add .cname { font-size: 18px; line-height: 1.15; }
.coin-add .cmass { font-size: 13px; color: var(--ink-2); }
.coin-add .ccount { font-size: 17px; color: var(--rust); font-variant-numeric: tabular-nums; }
.coin-sub {
  position: absolute;
  top: -8px; right: -6px;
  width: 26px; height: 26px;
  border: 3px solid var(--ink);
  background: #fff4dc;
  font-size: 19px;
  line-height: 1;
  padding: 0;
  box-shadow: 2px 2px 0 var(--ink);
}
.coin-sub:disabled { opacity: .3; }
.coin-sub.pressed { transform: translate(2px, 2px); box-shadow: none; }

.action-row { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.action-row #b-go { margin-left: auto; }

/* ---------- 発射 ---------- */
.hint {
  align-self: center;
  margin-top: 10px;
  background: var(--ink);
  color: #fff2c8;
  font-size: 17px;
  padding: 5px 12px;
  text-align: center;
  max-width: calc(100% - 20px);
  box-shadow: 3px 3px 0 rgba(43, 23, 8, .4);
}
.angle-row { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink-2); margin-bottom: 8px; }
.angle-row input { flex: 1; accent-color: var(--rust); height: 28px; }
.gauge-row { display: flex; gap: 10px; align-items: center; }
.gauge {
  position: relative;
  flex: 1;
  height: 44px;
  border: 3px solid var(--ink);
  background: repeating-linear-gradient(90deg,
    #4caf3c 0 10%, #8cc83a 10% 25%, #e8d02a 25% 45%, #f0a020 45% 65%, #e8602a 65% 85%, #d8283a 85% 100%);
  overflow: hidden;
}
.gauge::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 10px, rgba(43, 23, 8, .45) 10px 12px);
  z-index: 1;
}
.gauge-fill {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 100%;
  background: #4a2a1a;
}
.gauge-mark {
  position: absolute; top: 0; bottom: 0; left: 95%; right: 0;
  border-left: 3px solid #fff6dc;
  z-index: 2;
}
.gauge-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  color: #fff6dc;
  text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink);
  z-index: 3;
}
.gauge-label b { font-weight: normal; }
.btn.fire { min-width: 130px; }

/* ---------- 飛行 ---------- */
.zone-banner {
  position: absolute;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 31px;
  color: #fff2c8;
  background: var(--ink);
  padding: 4px 16px;
  box-shadow: inset 0 0 0 3px #8a5428, 4px 4px 0 rgba(43, 23, 8, .5);
  opacity: 0;
  transition: opacity .3s steps(3);
}
.zone-banner.show { opacity: 1; }
.bottom-panel.flight {
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 8px;
  background: rgba(251, 233, 196, 0.92);
}
.jet-coins { flex: 1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.jet-coin {
  border: 3px solid var(--ink);
  background: #fff4dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 2px;
  font-size: 14px;
  line-height: 1.15;
  min-width: 0;
  box-shadow: inset -2px -2px 0 var(--panel-lo);
}
.jet-coin img { width: 28px; height: 28px; pointer-events: none; }
.jet-coin .jc-n { color: var(--rust); font-variant-numeric: tabular-nums; }
.jet-coin.sel { background: var(--gold); box-shadow: inset -2px -2px 0 var(--gold-lo), inset 2px 2px 0 #fff2a0; }
.jet-coin:disabled { opacity: .35; }
.jet-btn {
  width: 132px;
  border: 3px solid var(--ink);
  background: var(--gold);
  font-size: 22px;
  box-shadow: inset -4px -4px 0 var(--gold-lo), inset 4px 4px 0 #fff2a0, 4px 4px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.jet-btn small { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.jet-btn.on {
  transform: translate(4px, 4px);
  background: #ff9a2a;
  box-shadow: inset -4px -4px 0 #c86010, inset 4px 4px 0 #ffd080;
}
.jet-btn.empty { filter: grayscale(.9); opacity: .6; }

/* ---------- 結果 ---------- */
.screen.center { align-items: center; justify-content: center; padding: 12px; overflow-y: auto; }
.card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 14px 18px 18px;
  text-align: center;
  animation: pop .3s steps(4);
  touch-action: pan-y;
}
@keyframes pop { from { transform: scale(.5); } to { transform: scale(1); } }
.res-badge {
  display: inline-block;
  background: var(--ink);
  color: #fff2c8;
  font-size: 14px;
  padding: 2px 10px;
}
.res-title {
  font-size: 36px;
  color: var(--rust);
  margin: 6px 0 2px;
  line-height: 1.25;
  text-shadow: 2px 2px 0 #f0c890;
}
.res-desc { font-size: 17px; color: var(--ink-2); margin-bottom: 10px; }
.res-main { display: flex; gap: 8px; }
.res-main > div {
  flex: 1;
  border: 3px solid var(--ink);
  padding: 6px;
  background: #fff8e8;
}
.res-main label { display: block; font-size: 14px; color: var(--ink-2); }
.res-main b { font-size: 34px; font-weight: normal; font-variant-numeric: tabular-nums; }
.res-main .score { background: #ffe58a; }
.res-main .score b { color: var(--red); }
.newrec { margin-top: 8px; }
.newrec span {
  display: inline-block;
  background: var(--red);
  color: #fff;
  padding: 3px 10px;
  margin: 2px;
  font-size: 17px;
  box-shadow: 2px 2px 0 var(--ink);
  animation: blink 0.6s steps(2) infinite;
}
@keyframes blink { 50% { background: #ff8a20; } }
.res-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 18px; }
.res-table th { text-align: left; font-weight: normal; color: var(--ink-2); padding: 3px 2px; }
.res-table td { text-align: right; padding: 3px 2px; font-variant-numeric: tabular-nums; }
.res-table td.minus { color: var(--red); }
.res-table tr.total { border-top: 3px dotted var(--ink-2); }
.res-table tr.total td { font-size: 23px; color: var(--rust); }
.res-formula { font-size: 16px; color: var(--ink-2); margin-top: 4px; }
.res-best { font-size: 16px; margin-top: 6px; }
.res-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.res-btns .row { display: flex; flex-wrap: wrap; gap: 8px; }
.res-btns .row .btn { flex: 1; }
kbd {
  font-family: var(--font);
  font-size: 14px;
  background: var(--rust-lo);
  padding: 0 5px;
  margin-left: 4px;
}

/* ---------- タイトル ---------- */
#scr-title { align-items: center; justify-content: center; padding: 16px; }
.title-box { text-align: center; pointer-events: auto; }
.title-sub {
  letter-spacing: .2em;
  color: #fff2c8;
  font-size: 17px;
  text-shadow: 2px 2px 0 var(--ink);
}
.logo {
  font-weight: normal;
  margin: 6px 0 4px;
  font-size: clamp(32px, 8.5vw, 68px);
  line-height: 1.2;
  color: #fff6dc;
  text-shadow:
    3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink),
    3px 3px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink),
    6px 6px 0 var(--rust-lo);
}
.logo span { color: #ffb0cc; font-size: .8em; }
.catch {
  color: #fff2c8;
  background: var(--ink);
  display: inline-block;
  padding: 4px 14px;
  font-size: clamp(11px, 3.4vw, 15px);
  white-space: nowrap;
  margin: 10px 0 18px;
}
.title-btns { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.title-btns .row { display: flex; gap: 12px; }
.title-best { margin-top: 16px; font-size: 17px; color: #fff2c8; text-shadow: 2px 2px 0 var(--ink); }

/* ---------- モーダル ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(43, 23, 8, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  pointer-events: auto;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(540px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px;
  text-align: center;
  touch-action: pan-y;
}
.modal-card h2 { font-weight: normal; font-size: 31px; margin: 0 0 10px; color: var(--rust); text-shadow: 2px 2px 0 #f0c890; }
.modal-card .howto { text-align: left; font-size: 18px; line-height: 1.7; }
.modal-card .howto h3 { font-size: 19px; font-weight: normal; margin: 12px 0 2px; background: var(--ink); color: #fff2c8; display: inline-block; padding: 0 8px; }
.modal-card .howto p { margin: 0; }
.modal-card .howto b { font-weight: normal; color: var(--red); }
.rec-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 19px; }
.rec-table th { text-align: left; font-weight: normal; padding: 7px 4px; color: var(--ink-2); border-bottom: 2px dotted var(--panel-lo); }
.rec-table td { text-align: right; padding: 7px 4px; border-bottom: 2px dotted var(--panel-lo); font-variant-numeric: tabular-nums; }
.modal-card > .btn { margin-top: 14px; }

/* ---------- ローグライト共通 ---------- */
.card.wide { width: min(620px, 100%); }
.progress {
  height: 10px;
  margin-top: 3px;
  border: 2px solid var(--ink);
  background: #4a2a1a;
  position: relative;
}
.progress i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--gold);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4);
}
.stat.goal { min-width: 150px; }
.toast {
  align-self: center;
  margin-top: 12px;
  background: var(--ink);
  color: #fff2c8;
  font-size: 22px;
  padding: 6px 16px;
  box-shadow: inset 0 0 0 3px var(--gold), 4px 4px 0 rgba(43, 23, 8, .5);
  opacity: 0;
  transition: opacity .3s steps(3);
  pointer-events: none;
  text-align: center;
  max-width: calc(100% - 20px);
}
.toast.show { opacity: 1; }
.note { font-size: 14px; color: var(--ink-2); margin: 4px 0; }
.note b { font-weight: normal; color: var(--red); }

/* 封入アイテムのバッジ */
.fx-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  font-size: 18px;
  border: 2px solid var(--ink);
  background: #fff4dc;
  color: var(--ink);
  flex: none;
  vertical-align: middle;
  margin-right: 3px;
}
.fx-badge.r1 { background: #bfe0ff; }
.fx-badge.r2 { background: #ffd6f0; box-shadow: inset 0 0 0 2px var(--gold); }
.fx-badge.locked { outline: 2px solid var(--ink); outline-offset: 1px; }
.fx-badge.pending { border-style: dashed; }
.fx-badge.empty { background: transparent; border-style: dotted; opacity: .6; }

/* 豚のカード */
.pig-card { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.pig-card.in-shop { background: #fff4dc; border: 2px solid var(--ink); padding: 8px; margin-bottom: 8px; }
.pc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-row .hpbar { flex: 1; min-width: 120px; margin-top: 0; }
.pc-name { font-weight: normal; font-size: 22px; color: var(--rust); }
.pc-mult { font-size: 16px; color: var(--ink-2); margin-left: auto; }
.pc-label { font-size: 16px; color: var(--ink-2); min-width: 104px; }
.pc-slots { display: flex; gap: 3px; flex-wrap: wrap; }

/* タブ */
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tab {
  flex: 1;
  border: 3px solid var(--ink);
  background: #e8d2a2;
  padding: 5px 8px;
  font-size: 18px;
}
.tab.on { background: var(--panel-hi); box-shadow: inset 0 -3px 0 var(--rust); }
#tab-fx { max-height: 36vh; overflow-y: auto; touch-action: pan-y; }
.fx-slots { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 8px; }
.slot {
  display: flex; align-items: center; gap: 4px;
  min-width: 120px;
  padding: 4px 6px;
  border: 3px solid var(--ink);
  background: #fff4dc;
  font-size: 16px;
  text-align: left;
}
.slot small { display: block; font-size: 12px; color: var(--ink-2); }
.slot.locked { background: #d8c8a8; }
.slot.pending { border-style: dashed; background: #fffaf0; }
.slot.empty { border-style: dotted; background: transparent; color: var(--ink-2); justify-content: center; }
.fx-inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.item {
  display: flex; align-items: center; gap: 6px;
  border: 3px solid var(--ink);
  background: #fff4dc;
  padding: 4px 6px;
  text-align: left;
  box-shadow: 2px 2px 0 var(--ink);
}
.item b { font-weight: normal; font-size: 17px; display: block; }
.item small { font-size: 13px; color: var(--ink-2); }
.item:disabled { opacity: .45; }
.coin-add.poor { filter: grayscale(.7); opacity: .6; }

/* ショップ */
.sheet {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  bottom: max(8px, env(safe-area-inset-bottom));
  left: var(--gutter);
  right: calc(var(--gutter) + 50px);
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
}
.sheet-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 3px dotted var(--panel-lo); padding-bottom: 6px; }
.sheet-head h2 { margin: 0; font-weight: normal; font-size: 29px; color: var(--rust); text-shadow: 2px 2px 0 #f0c890; }
.sheet-wallet { font-size: 18px; }
.sheet-wallet b { font-weight: normal; font-size: 24px; color: var(--rust); }
.sheet-head .btn { margin-left: auto; }
.sheet-body { overflow-y: auto; flex: 1; touch-action: pan-y; padding-right: 4px; }
.shop-sec { margin-top: 12px; }
.shop-sec h3 { font-weight: normal; font-size: 20px; margin: 0 0 6px; background: var(--ink); color: #fff2c8; padding: 2px 8px; }
.shop-sec h3 small { font-size: 13px; color: #e8c890; margin-left: 6px; }
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.offer {
  border: 3px solid var(--ink);
  background: #fff4dc;
  padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: 3px 3px 0 rgba(43, 23, 8, .4);
}
.offer.r1 { background: #e4f1ff; }
.offer.r2 { background: #ffe8f6; box-shadow: inset 0 0 0 2px var(--gold), 3px 3px 0 rgba(43, 23, 8, .4); }
.offer.sold { justify-content: center; align-items: center; color: var(--ink-2); min-height: 100px; border-style: dotted; background: transparent; box-shadow: none; }
.of-top { display: flex; gap: 6px; align-items: center; }
.of-top b { font-weight: normal; font-size: 17px; display: block; }
.of-top small { font-size: 12px; color: var(--ink-2); }
.offer p { margin: 0; font-size: 14px; flex: 1; }
.offer .btn { align-self: stretch; }
.shop-line {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px;
  border-bottom: 2px dotted var(--panel-lo);
}
.shop-line > span { flex: 1; font-size: 18px; text-align: left; }
.shop-line small { display: block; font-size: 13px; color: var(--ink-2); }
.shop-line .btn { min-width: 96px; }
.kind { font-size: 13px; background: var(--ink-2); color: #fff2c8; padding: 0 4px; margin-right: 6px; }
.inv-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.inv-name { font-size: 16px; margin-right: 8px; }
.pig-buy { margin-top: 6px; }

/* 精算・転生など */
.settle-pay { margin: 8px 0; }
.settle-pay label { display: block; font-size: 16px; color: var(--ink-2); }
.settle-pay b { font-weight: normal; font-size: 41px; color: var(--rust); text-shadow: 2px 2px 0 #f0c890; }
.settle-pay small { display: block; font-size: 17px; }
.plus { color: #2e8a2a; }
.minus { color: var(--red); }
.wallet-line { margin-top: 8px; font-size: 18px; }
.wallet-line b { font-weight: normal; font-size: 24px; color: var(--rust); }
.goal-line { margin-top: 8px; font-size: 16px; color: var(--ink-2); }
.goal-line .progress { margin: 3px 0; }
.clear-box {
  margin-top: 10px;
  background: var(--gold);
  border: 3px solid var(--ink);
  padding: 6px;
  font-size: 17px;
}
.clear-box b { font-weight: normal; font-size: 24px; display: block; animation: blinktext .6s steps(2) infinite; }
@keyframes blinktext { 50% { color: var(--rust); } }
.fail-box { margin-top: 10px; background: var(--ink); color: #ff9aa8; padding: 6px; font-size: 18px; }
.pick-head { margin: 12px 0 8px; font-size: 19px; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.skill-card {
  border: 3px solid var(--ink);
  background: #f4e8ff;
  padding: 10px 8px;
  text-align: left;
  box-shadow: inset -3px -3px 0 #c8b0e8, inset 3px 3px 0 #ffffff, 3px 3px 0 var(--ink);
}
.skill-card:active { transform: translate(3px, 3px); }
.skill-card b { font-weight: normal; font-size: 22px; color: #5a2a8a; display: block; }
.skill-card small { font-size: 14px; color: var(--ink-2); }
.skill-card p { margin: 6px 0 0; font-size: 16px; }
.skill-list { text-align: left; font-size: 16px; line-height: 1.6; }
.skill-list b { font-weight: normal; color: #5a2a8a; }
.rec-h { font-weight: normal; font-size: 19px; text-align: left; margin: 10px 0 4px; background: var(--ink); color: #fff2c8; padding: 0 8px; display: inline-block; }
.modal-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* カットシーン */
.cut-text {
  position: absolute;
  left: 50%; top: 18%;
  transform: translateX(-50%);
  text-align: center;
  color: #fff2c8;
  opacity: 0;
  transition: opacity .6s steps(4);
  white-space: nowrap;
}
.cut-text.show { opacity: 1; }
.cut-text b { display: block; font-weight: normal; font-size: clamp(24px, 6vw, 40px); color: #ff6a7a; text-shadow: 3px 3px 0 var(--ink); }
.cut-text span { display: block; margin-top: 8px; font-size: 22px; text-shadow: 2px 2px 0 var(--ink); }
.cut-next { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); pointer-events: auto; }
.cut-next:active { transform: translate(calc(-50% + 3px), 3px); }

@media (max-width: 720px) {
  .sheet { right: var(--gutter); top: calc(max(8px, env(safe-area-inset-top)) + 48px); }
  .shop-line .btn { min-width: 80px; }
  .settle-pay b { font-size: 34px; }
  .pc-label { min-width: 90px; }
  .action-row { flex-wrap: wrap; }
}

/* ---------- ショップ（すっきり版） ---------- */
.shop-tabs { display: flex; gap: 6px; margin-top: 8px; }
.stab {
  flex: 1;
  border: 3px solid var(--ink);
  background: #e8d2a2;
  padding: 8px 6px;
  font-size: 20px;
}
.stab.on { background: var(--panel-hi); box-shadow: inset 0 -4px 0 var(--rust); }
.sheet-body { padding-top: 6px; }
.shop-lead { font-size: 17px; color: var(--ink-2); margin: 8px 2px; line-height: 1.5; }
.shop-lead.warn { color: var(--red); }
.shop-sub { font-size: 20px; margin: 16px 0 6px; padding: 2px 10px; background: var(--ink); color: #fff2c8; display: inline-block; }
.shop-empty { font-size: 18px; color: var(--ink-2); }
.shop-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  margin-bottom: 8px;
  border: 3px solid var(--ink);
  background: #fff8e6;
  box-shadow: 3px 3px 0 rgba(43, 23, 8, .35);
}
.shop-row.current { background: #fff0c0; }
.sr-icon {
  flex: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 29px;
  border: 3px solid var(--ink);
  background: var(--sand);
}
.sr-icon.pig-ceramic { background: #f6a8c8; }
.sr-icon.pig-iron { background: #b4bcc6; }
.sr-icon.pig-gold { background: #f6cf4a; }
.sr-icon.pig-diamond { background: #9ae4f4; }
.sr-icon.pig-orichalcum { background: #6edcb4; }
.sr-icon.pig-divine { background: #fff6dc; box-shadow: inset 0 0 0 3px var(--gold); }
.sr-main { flex: 1; min-width: 0; text-align: left; }
.sr-name { font-size: 23px; line-height: 1.3; }
.sr-lv { font-size: 17px; color: var(--ink-2); margin-left: 10px; }
.sr-fx { font-size: 18px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
.sr-fx b { font-weight: normal; color: var(--ink); }
.sr-fx b.next { color: #2e8a2a; }
.sr-fx .arrow { margin: 0 6px; color: var(--ink-2); }
.buy {
  flex: none;
  min-width: 112px;
  border: 3px solid var(--ink);
  background: #d8cbb0;
  color: #6a5a48;
  padding: 10px 10px;
  font-size: 19px;
  box-shadow: 3px 3px 0 var(--ink);
}
.buy.ok {
  background: var(--rust);
  color: #fff6dc;
  text-shadow: 2px 2px 0 var(--rust-lo);
  box-shadow: inset -3px -3px 0 var(--rust-lo), inset 3px 3px 0 var(--rust-hi), 3px 3px 0 var(--ink);
}
.buy.ok:active { transform: translate(3px, 3px); box-shadow: inset -3px -3px 0 var(--rust-lo), inset 3px 3px 0 var(--rust-hi); }
.buy:disabled { cursor: default; }
.offer-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.offer { padding: 10px; gap: 8px; }
.of-name { font-size: 22px; line-height: 1.2; }
.of-rar { font-size: 16px; color: var(--ink-2); }
.of-desc { font-size: 19px; flex: 1; line-height: 1.4; }
.offer .buy { width: 100%; }
.fx-badge.big { width: 40px; height: 40px; font-size: 26px; }
.inv-line { gap: 8px; }
.inv-item { display: inline-flex; align-items: center; gap: 4px; font-size: 18px; padding: 4px 8px 4px 4px; border: 2px solid var(--ink); background: #fff8e6; }
.pig-card.in-shop { padding: 10px; }
.pig-card .pc-name { font-size: 24px; }
.pig-card .pc-label, .pig-card .pc-mult { font-size: 18px; }

/* 拠点の豚カードも少し大きく */
#hub-pig .pc-name { font-size: 24px; }
#hub-pig .pc-label, #hub-pig .pc-mult { font-size: 18px; }
#hub-pig .fx-badge { width: 30px; height: 30px; font-size: 20px; }

/* ---------- スキルツリー ---------- */
.card.wide { width: min(860px, 100%); }
#reinc-card { max-height: 100%; }
.tree-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: left; }
.tree-title { font-size: 31px; color: var(--rust); text-shadow: 2px 2px 0 #f0c890; }
.tree-pts {
  flex: none;
  border: 3px solid var(--ink);
  background: #f4e8ff;
  padding: 6px 12px;
  font-size: 17px;
  text-align: center;
}
.tree-pts b { display: block; font-weight: normal; font-size: 36px; color: #5a2a8a; }
.tree-wrap { overflow-x: auto; margin: 10px -6px 0; padding: 0 6px; touch-action: pan-x pan-y; }
.tree {
  position: relative;
  min-width: 640px;
  height: 420px;
  background: repeating-linear-gradient(0deg, #2a1c4a 0 20px, #2e2052 20px 40px);
  border: 3px solid var(--ink);
}
.tree-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.tree-lines line { stroke: #5a4a7a; stroke-width: 4; }
.tree-lines line.on { stroke: #ffd23a; }
.branch {
  position: absolute; top: 4px;
  transform: translateX(-50%);
  color: #e8d8ff;
  font-size: 22px;
  text-shadow: 2px 2px 0 #000;
}
.node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 108px;
  padding: 5px 4px;
  border: 3px solid var(--ink);
  background: #5a4a6a;
  color: #b8a8c8;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1.2;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .4);
}
.node .nd-name { font-size: 18px; white-space: nowrap; }
.node .nd-lv { font-size: 14px; }
.node.open { background: #8a7aa0; color: #f0e8ff; }
.node.got { background: #c8a0ff; color: var(--ink); }
.node.can { background: #fff2a0; color: var(--ink); animation: nodeglow .8s steps(2) infinite; }
.node.done { background: var(--gold); color: var(--ink); }
.node.god { width: 132px; }
.node.sel { outline: 3px solid #ffffff; outline-offset: 2px; }
@keyframes nodeglow { 50% { background: #ffd23a; } }
.node-detail {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px;
  padding: 10px;
  border: 3px solid var(--ink);
  background: #fff8e6;
  text-align: left;
  min-height: 64px;
}
.nd-head { flex: none; min-width: 120px; }
.nd-head b { display: block; font-weight: normal; font-size: 24px; color: #5a2a8a; }
.nd-head span { font-size: 16px; color: var(--ink-2); }
.nd-body { flex: 1; font-size: 18px; line-height: 1.5; }
.nd-body .next { color: #2e8a2a; }
.nd-body .warn { color: var(--red); font-size: 16px; }

/* ---------- オープニング ---------- */
.op-top {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: var(--gutter); right: calc(var(--gutter) + 50px);
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
.op-top .btn { pointer-events: auto; }
.op-page { color: #fff2c8; font-size: 19px; text-shadow: 2px 2px 0 var(--ink); }
.op-box {
  position: absolute;
  left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(760px, calc(100% - 20px));
  background: rgba(30, 16, 8, 0.92);
  border: 3px solid #f0d29a;
  box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 rgba(0, 0, 0, .4);
  padding: 14px 16px 12px;
  pointer-events: auto;
}
.op-cap { color: #fff2c8; font-size: clamp(16px, 2.6vw, 21px); line-height: 1.7; min-height: 3.4em; }
.op-cap b { font-weight: normal; color: var(--gold); }
.op-ctrl { display: flex; justify-content: space-between; margin-top: 10px; }

@media (max-width: 720px) {
  .stab { font-size: 18px; padding: 7px 4px; }
  .shop-row { padding: 8px 6px; gap: 8px; }
  .sr-icon { width: 36px; height: 36px; font-size: 24px; }
  .sr-name { font-size: 20px; }
  .sr-fx { font-size: 17px; }
  .buy { min-width: 92px; font-size: 18px; padding: 9px 6px; }
  .offer-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .of-name { font-size: 19px; }
  .of-desc { font-size: 17px; }
  .node-detail { flex-wrap: wrap; }
  .tree-title { font-size: 26px; }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 720px) {
  .coin-grid { grid-template-columns: repeat(3, 1fr); }
  .coin-add { min-height: 0; flex-direction: row; justify-content: flex-start; gap: 5px; padding: 5px 12px 5px 5px; }
  .coin-add img { width: 32px; height: 32px; }
  .coin-add .ctext { align-items: flex-start; }
  .coin-add .cname, .coin-add .ccount { white-space: nowrap; }
  .coin-add .cname { font-size: 17px; }
  .coin-add .ccount { font-size: 16px; }
  .coin-sub { width: 24px; height: 24px; font-size: 17px; top: -8px; right: -6px; }
  .stat b { font-size: 18px; }
  .stat.main b { font-size: 22px; }
  .stat { padding: 3px 7px; }
  .stat label { font-size: 13px; }
  .stat.hp { min-width: 90px; }
  .topbar { gap: 4px; }
  .jet-btn { width: 100px; font-size: 17px; }
  .jet-btn .jl { white-space: nowrap; }
  .jet-coins { grid-template-columns: repeat(3, 1fr); }
  .jet-coin { flex-direction: row; justify-content: center; gap: 3px; padding: 3px 2px; }
  .jet-coin img { width: 22px; height: 22px; }
  .btn.big { font-size: 24px; padding: 10px 22px; }
  .btn.fire { min-width: 100px; }
  .res-title { font-size: 29px; }
  .res-main b { font-size: 26px; }
}
@media (max-width: 380px) {
  .coin-add .cmass { display: none; }
  .action-row .btn.small { padding: 5px 7px; font-size: 14px; }
  .action-row #b-go { padding: 8px 10px; font-size: 17px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .coin-add { min-height: 0; padding: 3px; }
  .coin-add img { width: 26px; height: 26px; }
  .coin-add .cmass { display: none; }
  .bottom-panel { padding: 6px; }
  .qty-row { margin-bottom: 4px; }
  .action-row { margin-top: 6px; }
}
@media (hover: none) {
  kbd { display: none; }
}
#scr-reinc, #scr-ending { justify-content: flex-end; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

.coin-grid { max-height: 34vh; overflow-y: auto; touch-action: pan-y; padding: 8px 6px 4px 0; }

/* ショップは中央にまとめる */
.sheet { left: 50%; right: auto; width: min(900px, calc(100% - 120px)); transform: translateX(-50%); }
.sr-name { font-size: 24px; }
.sr-fx { font-size: 19px; }
.buy { font-size: 20px; }
@media (max-width: 720px) {
  .sheet { width: calc(100% - 16px); top: calc(max(8px, env(safe-area-inset-top)) + 48px); }
  .sr-name { font-size: 20px; }
  .sr-fx { font-size: 17px; }
  .buy { font-size: 18px; }
}

/* ---------- レビュー対応で追加した部品 ---------- */
.hud-ctrl { display: flex; gap: 4px; align-items: center; }
.hud-ctrl .btn { min-width: 44px; }
.pause-cover {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(43, 23, 8, .55);
  color: #fff2c8; font-size: 34px;
  pointer-events: auto; z-index: 5;
}
.pause-cover b { font-weight: normal; text-shadow: 3px 3px 0 var(--ink); }
.save-warn {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%);
  background: var(--red); color: #fff; padding: 6px 14px; font-size: 18px;
  border: 3px solid var(--ink); z-index: 60; pointer-events: none; max-width: calc(100% - 20px);
}
.resume-note { margin: 6px 0; padding: 4px 8px; background: #e4f1ff; border: 2px solid var(--ink); font-size: 16px; }
.pt-gain { margin: 4px 0; font-size: 20px; color: #5a2a8a; }
.zone-banner small { display: block; font-size: 17px; text-align: center; color: var(--gold); }
.s-need { display: block; font-size: 16px; color: var(--ink-2); }
.bulk-row { display: flex; gap: 6px; align-items: center; margin: 4px 0 10px; font-size: 18px; }
.bulk { border: 3px solid var(--ink); background: var(--sand); padding: 6px 10px; font-size: 18px; }
.bulk.on { background: var(--gold); }
.buy small { font-size: 14px; }
.compare { font-size: 17px; margin: -2px 2px 10px; color: var(--ink-2); }
.compare b { font-weight: normal; color: var(--ink); }
.coin-grid { overflow-x: hidden; }

/* 狭い画面：硬貨は2列、取り出しボタンを大きく */
@media (max-width: 360px) {
  .coin-grid { grid-template-columns: repeat(2, 1fr); }
  .coin-sub { width: 32px; height: 32px; font-size: 22px; }
}

/* 横向きの低い画面：操作パネルを右側に並べ、豚は左側に */
@media (orientation: landscape) and (max-height: 520px) {
  #bank-panel, #hub-panel {
    position: absolute;
    right: calc(var(--gutter) + 4px);
    top: 64px;
    bottom: 8px;
    width: 56%;
    margin: 0;
    overflow-y: auto;
    touch-action: pan-y;
  }
  #bank-panel .coin-grid { max-height: none; grid-template-columns: repeat(3, 1fr); }
}

/* ---------- ドット絵アイコン ---------- */
.px-icon { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
.fx-badge { padding: 1px; }
.fx-badge.empty { padding: 0; }
.sr-icon { padding: 3px; }
.sr-icon .px-icon { width: 100%; height: 100%; }
.clear-box .fx-badge, .clear-modal .fx-badge { width: 22px; height: 22px; margin: 0 4px 0 0; }

/* ---------- 目標金額の支払い ---------- */
.btn.gold {
  background: var(--gold);
  color: var(--ink);
  box-shadow: inset -3px -3px 0 var(--gold-lo), inset 3px 3px 0 #fff4a8, 3px 3px 0 var(--ink);
  animation: paypulse 1.2s steps(2) infinite;
}
.btn.gold:active { box-shadow: inset -3px -3px 0 var(--gold-lo), inset 3px 3px 0 #fff4a8; }
@keyframes paypulse { 50% { background: #ffe680; } }
.hub-pay { font-size: 16px; color: var(--ink-2); margin: 2px 0 6px; line-height: 1.5; text-align: left; }
.hub-pay:empty { display: none; }
.hub-pay .hp-ok { font-weight: normal; color: var(--rust); font-size: 18px; }
.hub-pay .hp-perk { display: block; }
.hub-pay .hp-perk b { font-weight: normal; color: #2e8a2a; }
.pay-hint { margin-top: 8px; padding: 5px 8px; border: 2px dashed var(--ink); background: #fff4c0; font-size: 17px; }
.pay-hint b { font-weight: normal; color: var(--rust); }
.clear-box small { font-size: 14px; color: var(--ink-2); margin-left: 4px; }
.clear-box .perk, .clear-modal .perk { color: #1e6a1a; }
.clear-modal > div { margin: 3px 0; display: flex; align-items: center; flex-wrap: wrap; }
.clear-modal > b { font-weight: normal; font-size: 24px; color: var(--rust); display: block; margin-bottom: 4px; }
.tree-pts small { display: block; font-size: 13px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
.clear-box > div { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; }
/* アイコンは 18ドットの整数倍で表示（にじみ防止） */
.fx-badge { width: 24px; height: 24px; }
.fx-badge.big { width: 42px; height: 42px; }
.sr-icon { width: 48px; height: 48px; }
.shop-row .sr-icon.pig-ceramic, .shop-row .sr-icon[class*="pig-"] { padding: 2px; }
@media (max-width: 560px) {
  .sr-icon { width: 42px; height: 42px; padding: 0; }
}
@media (max-width: 380px) {
  .shop-tabs .stab { font-size: 16px; padding-left: 2px; padding-right: 2px; white-space: nowrap; }
  .bulk-row { gap: 4px; }
  .bulk-row span { white-space: nowrap; font-size: 14px; }
  .bulk { white-space: nowrap; font-size: 16px; padding-left: 6px; padding-right: 6px; }
  .sr-lv { display: block; margin-left: 0; }
  .buy { min-width: 84px; }
}
@media (max-width: 380px) { .sr-name { font-size: 18px; } }
#hub-panel .action-row { flex-wrap: wrap; }

/* ---------- 飛行：ジャストボタンとロケット花火 ---------- */
.just-btn, .rocket-btn {
  border: 3px solid var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.2;
  touch-action: manipulation;
}
.just-btn {
  flex: 1;
  min-height: 64px;
  background: #7dff6a;
  font-size: 26px;
  box-shadow: inset -4px -4px 0 #3aa830, inset 4px 4px 0 #d4ffc8, 4px 4px 0 var(--ink);
}
.just-btn small, .rocket-btn small { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.just-btn.on { transform: translate(4px, 4px); box-shadow: inset -4px -4px 0 #3aa830, inset 4px 4px 0 #d4ffc8; background: #c8ffb8; }
.rocket-btn {
  width: 132px;
  background: #ff8a3a;
  font-size: 19px;
  box-shadow: inset -4px -4px 0 #c4520c, inset 4px 4px 0 #ffc890, 4px 4px 0 var(--ink);
}
.rocket-btn:active { transform: translate(4px, 4px); box-shadow: inset -4px -4px 0 #c4520c, inset 4px 4px 0 #ffc890; }
@media (max-width: 720px) {
  .rocket-btn { width: 104px; font-size: 17px; }
  .just-btn { font-size: 23px; min-height: 56px; }
}

/* ---------- 貯金：ロケット花火を積む ---------- */
.rocket-row { margin-top: 8px; }
.rocket-tog {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  border: 3px dashed var(--ink);
  background: #fff4dc;
  padding: 4px 8px;
  text-align: left;
  font-size: 18px;
}
.rocket-tog .px-icon { width: 36px; height: 36px; flex: none; }
.rocket-tog span { flex: 1; min-width: 0; }
.rocket-tog small { display: block; font-size: 14px; color: var(--ink-2); }
.rocket-tog b { font-weight: normal; font-size: 26px; width: 32px; text-align: center; }
.rocket-tog.on { border-style: solid; background: #ffd9b0; }

/* ---------- 封入アイテムの品ぞろえ（貯金画面） ---------- */
#tab-fx .shop-sub { margin-top: 8px; }
#tab-fx .item { position: relative; }
#tab-fx .item em { font-style: normal; margin-left: auto; padding-left: 6px; color: var(--rust); white-space: nowrap; font-size: 17px; flex: none; }
#tab-fx .item.r1 { background: #e4f1ff; }
#tab-fx .item.r2 { background: #ffe8f6; }

/* ---------- コーティング ---------- */
.shop-row.done { opacity: .55; }
.cut-text b.good { color: #ffe14a; }

/* ---------- 飛行：貯金ジェット（ワンボタン） ---------- */
.jet-btn.wide {
  flex: 1;
  width: auto;
  min-height: 64px;
  flex-direction: row;
  gap: 12px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.jet-btn .jl { display: flex; flex-direction: column; align-items: flex-start; font-size: 24px; }
.jet-btn .jl small { margin-top: 0; }
.jet-coin-img { width: 34px; height: 34px; image-rendering: pixelated; pointer-events: none; }
.jet-sub { font-size: 16px !important; color: var(--ink) !important; margin-left: auto; white-space: nowrap; }
@media (max-width: 480px) {
  .jet-btn .jl { font-size: 20px; }
  .jet-sub { font-size: 13px !important; white-space: normal; text-align: right; }
}

/* ---------- 発射：角度のときはゲージの色を変える ---------- */
.gauge.angle { background: linear-gradient(90deg, #a8d8ff, #2a62b0); }
.gauge.angle .gauge-mark { display: none; }
#bank-panel .note { margin: 6px 0 0; }
.jet-btn.pricey .jet-sub { color: var(--red) !important; }
.jet-btn.pricey { background: #ffb070; }

/* ---------- 貯金箱を選ぶ ---------- */
.bank-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.bank-opt {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  border: 3px solid var(--ink);
  background: #fff4dc;
  padding: 8px 10px;
  text-align: left;
  box-shadow: 3px 3px 0 rgba(43, 23, 8, .4);
}
.bank-opt:active { transform: translate(3px, 3px); box-shadow: none; }
.bank-opt.on { background: #ffe58a; }
.bank-opt img { width: 60px; height: 51px; flex: none; }
.bk-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.bk-name { font-size: 22px; color: var(--rust); }
.bk-name em { font-style: normal; font-size: 14px; margin-left: 8px; padding: 0 6px; background: var(--ink); color: #fff2c8; vertical-align: middle; }
.bk-desc { font-size: 16px; color: var(--ink-2); }
.bk-stats { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 16px; }
.bk-stats > span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.bk-stats label { color: var(--ink-2); min-width: 4em; }
.bk-stats small { font-size: 13px; color: var(--ink-2); }
.bk-bar { color: var(--rust); letter-spacing: -1px; font-size: 13px; }
.bk-bar i { font-style: normal; color: #d9c49a; }
#b-cap.full { color: var(--red); }

/* ---------- 精算前：割る？割らない？ ---------- */
.settle-choose { display: flex; gap: 10px; }
.settle-opt { flex: 1; min-width: 0; white-space: normal; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 24px; padding: 10px 8px; }
.settle-opt small { font-size: 16px; color: var(--ink-2); }
.settle-opt.primary small { color: #fff2c8; }
.res-table td.plus { color: var(--rust); }
@media (max-width: 480px) {
  .settle-choose { flex-direction: column; }
  .settle-opt { font-size: 19px; }
  .bk-stats { font-size: 14px; }
  .bank-opt img { width: 44px; height: 37px; }
}

/* ---------- 転生の間 ---------- */
#scr-rebirth .bottom-panel { background: rgba(251, 233, 196, 0.92); }
.rb-hit { width: 100%; min-height: 64px; touch-action: manipulation; }
#scr-rebirth .hint { background: #2a1656; color: #fff2c8; }

/* ---------- 結果カード（派手め） ---------- */
.rs-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  pointer-events: auto;
  padding: 20px 18px 16px;
  color: #fff2d8;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.035) 0 12px, transparent 12px 24px),
    linear-gradient(180deg, #2c1a52 0%, #1a0f34 55%, #120a24 100%);
  border: 4px solid #ffd23a;
  box-shadow: 0 0 0 4px #2b1708, 0 0 0 8px #c89a10, 8px 10px 0 8px rgba(0,0,0,.45), inset 0 0 40px rgba(255,210,58,.12);
  text-align: center;
}
.rs-card.play { animation: rsIn .5s steps(6) both; }
@keyframes rsIn { from { transform: translateY(40px) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.rs-card.smashed { background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.04) 0 12px, transparent 12px 24px),
    linear-gradient(180deg, #3a2a6e 0%, #241848 55%, #160e30 100%); }

/* ランクのハンコ */
.rs-rank {
  position: absolute; right: 10px; top: 10px;
  width: 92px; height: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 5px solid currentColor; border-radius: 50%;
  transform: rotate(-14deg);
  color: #ffd23a;
  background: rgba(0,0,0,.25);
  text-shadow: 3px 3px 0 #2b1708;
  box-shadow: 0 0 18px currentColor;
}
.rs-rank span { font-size: 13px; letter-spacing: 2px; line-height: 1; }
.rs-rank b { font-weight: normal; font-size: 54px; line-height: 1; }
.rs-card.play .rs-rank { animation: stamp .45s steps(5) 1.3s both; }
@keyframes stamp { from { transform: rotate(-14deg) scale(3); opacity: 0; } 70% { transform: rotate(-14deg) scale(.9); opacity: 1; } to { transform: rotate(-14deg) scale(1); opacity: 1; } }
.rank-S .rs-rank { color: #ffe14a; animation: none; }
.rs-card.play.rank-S .rs-rank { animation: stamp .45s steps(5) 1.3s both, rainbow 1.2s steps(6) 1.8s infinite; }
@keyframes rainbow { 0% { color: #ffe14a; } 33% { color: #ff7ab0; } 66% { color: #7ae8ff; } 100% { color: #ffe14a; } }
.rank-A .rs-rank { color: #ff8a4a; }
.rank-B .rs-rank { color: #7ad0ff; }
.rank-C .rs-rank { color: #9ad08a; }
.rank-D .rs-rank { color: #a0a0b0; }

.rs-head { padding-right: 96px; text-align: left; }
.rs-badge { display: inline-block; font-size: 14px; background: #ffd23a; color: #2b1708; padding: 1px 10px; letter-spacing: 2px; }
.rs-title {
  position: relative; overflow: hidden;
  font-size: 34px; line-height: 1.2; margin-top: 6px;
  color: #ffe14a;
  text-shadow: 3px 0 0 #2b1708, -3px 0 0 #2b1708, 0 3px 0 #2b1708, 0 -3px 0 #2b1708, 4px 5px 0 #8a3418;
}
.rs-title::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shine 2.6s steps(10) 1s infinite;
}
@keyframes shine { 0% { left: -60%; } 60%, 100% { left: 130%; } }
.rs-desc { font-size: 16px; color: #e8d0ff; margin-top: 4px; }

.rs-score { margin: 14px 0 8px; }
.rs-score label { display: block; font-size: 15px; letter-spacing: 6px; color: #c8b0ff; }
.rs-score b {
  display: block; font-weight: normal; font-size: 64px; line-height: 1.05;
  color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 4px 0 0 #2b1708, -4px 0 0 #2b1708, 0 4px 0 #2b1708, 0 -4px 0 #2b1708, 0 0 24px #ffd23a, 0 0 6px #ffd23a;
}
.rs-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rs-stats > div { background: rgba(255,255,255,.07); border: 2px solid rgba(255,210,58,.45); padding: 6px 4px; }
.rs-stats label { display: block; font-size: 13px; color: #c8b0ff; }
.rs-stats b { font-weight: normal; font-size: 21px; color: #fff2c8; white-space: nowrap; }
.rs-new { margin-top: 10px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.rs-new span { font-size: 17px; background: #ff4d6d; color: #fff; padding: 3px 12px; box-shadow: 3px 3px 0 #2b1708; animation: blink .5s steps(2) infinite; }

.rs-talk { display: flex; align-items: center; gap: 10px; margin-top: 12px; text-align: left; }
.rs-talk img { width: 72px; height: 69px; flex: none; image-rendering: pixelated; filter: drop-shadow(0 0 6px rgba(255,255,255,.35)); }
.rs-talk p {
  position: relative; flex: 1; margin: 0;
  background: #fff8e8; color: #2b1708; font-size: 18px; line-height: 1.45;
  padding: 10px 12px; border: 3px solid #2b1708; box-shadow: 4px 4px 0 rgba(0,0,0,.35);
}
.rs-talk p::before { content: ""; position: absolute; left: -12px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-right: 9px solid #2b1708; }
.rs-advice { margin-top: 10px; text-align: left; font-size: 16px; line-height: 1.5; background: rgba(90,210,255,.1); border-left: 5px solid #5ad0ff; padding: 8px 10px; color: #e8f6ff; }
.rs-advice b { font-weight: normal; display: inline-block; background: #5ad0ff; color: #12203a; padding: 0 6px; margin-right: 8px; font-size: 14px; }
.rs-detail { margin-top: 10px; text-align: left; }
.rs-detail summary { cursor: pointer; font-size: 15px; color: #c8b0ff; }
.rs-detail .res-table { color: #fff2d8; }
.rs-detail .res-table th { color: #c8b0ff; }
.rs-detail .res-formula { color: #c8b0ff; }
.rs-best { font-size: 15px; margin-top: 8px; color: #ffe14a; }
.rs-card .res-btns { margin-top: 12px; }
.rs-card .btn { color: var(--ink); }
.rs-card .btn.primary { color: #fff6dc; }
.rs-talk img { width: 84px; height: 80px; }
@media (max-width: 480px) {
  .rs-card { padding: 16px 12px 12px; }
  .rs-rank { width: 72px; height: 72px; right: 6px; top: 6px; }
  .rs-rank b { font-size: 40px; }
  .rs-head { padding-right: 74px; }
  .rs-title { font-size: 26px; }
  .rs-score b { font-size: 48px; }
  .rs-stats b { font-size: 17px; }
  .rs-talk img { width: 56px; height: 54px; }
  .rs-talk p { font-size: 16px; }
}

/* ---------- 予算・貯金箱の選択（選んで決定） ---------- */
.budget-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.budget-opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  border: 3px solid var(--ink); background: #fff4dc; padding: 10px 14px;
  box-shadow: 3px 3px 0 rgba(43, 23, 8, .4); text-align: left;
}
.budget-opt b { font-weight: normal; font-size: 24px; color: var(--rust); }
.budget-opt small { font-size: 14px; color: var(--ink-2); }
.pick-opt.on { background: #ffe58a; outline: 3px solid var(--rust); outline-offset: -6px; }
.modal-btns .btn { min-width: 120px; }

/* 文字を大きくしたぶんの狭い画面向け調整 */
.q { white-space: nowrap; }
@media (max-width: 480px) {
  .q { padding: 4px 4px; font-size: 15px; }
  .qlabel { font-size: 14px; }
  .coin-sub { right: -2px; }
  .action-row .btn.small { font-size: 14px; padding: 5px 8px; }
}

/* ---------- 音量パネル ---------- */
.vol-panel {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 52px);
  right: var(--gutter);
  width: min(300px, calc(100% - 2 * var(--gutter)));
  z-index: 40;
  pointer-events: auto;
  background: var(--panel);
  border: 3px solid var(--ink);
  box-shadow: inset -3px -3px 0 var(--panel-lo), inset 3px 3px 0 var(--panel-hi), 4px 4px 0 rgba(43, 23, 8, .5);
  padding: 8px 12px 10px;
}
.vol-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.vol-head b { font-weight: normal; font-size: 20px; color: var(--rust); }
.vol-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 18px; }
.vol-row span { width: 3.6em; flex: none; }
.vol-row input { flex: 1; accent-color: var(--rust); height: 28px; min-width: 0; }
.vol-row em { font-style: normal; width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- SS・SSSランク ---------- */
.rank-SS .rs-rank b { font-size: 46px; letter-spacing: -2px; }
.rank-SSS .rs-rank b { font-size: 36px; letter-spacing: -3px; }
.rank-SS .rs-rank, .rank-SSS .rs-rank { color: #ffe14a; animation: none; }
.rs-card.play.rank-SS .rs-rank { animation: stamp .45s steps(5) 1.3s both, rainbow .9s steps(6) 1.8s infinite; }
.rs-card.play.rank-SSS .rs-rank {
  animation: stamp .55s steps(6) 1.3s both, rainbow .6s steps(6) 1.9s infinite, glowPulse .8s steps(4) 1.9s infinite;
  background: radial-gradient(circle, rgba(255,240,160,.35), rgba(0,0,0,.25) 70%);
}
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 18px currentColor; } 50% { box-shadow: 0 0 40px currentColor, 0 0 70px #fff; } }
/* SSSはカードの枠も虹色に光る */
.rs-card.rank-SSS { border-color: #ffe14a; animation: rsIn .5s steps(6) both, frameRainbow 1.2s steps(6) 1.9s infinite; }
@keyframes frameRainbow { 0% { border-color: #ffe14a; } 33% { border-color: #ff7ab0; } 66% { border-color: #7ae8ff; } 100% { border-color: #ffe14a; } }
.rs-card.rank-SSS .rs-score b { text-shadow: 4px 0 0 #2b1708, -4px 0 0 #2b1708, 0 4px 0 #2b1708, 0 -4px 0 #2b1708, 0 0 30px #ffe14a, 0 0 60px #ff7ab0; }
@media (max-width: 480px) {
  .rank-SS .rs-rank b { font-size: 34px; }
  .rank-SSS .rs-rank b { font-size: 26px; }
}
.best-rank { display: inline-block; margin-left: 6px; padding: 0 6px; background: var(--ink); color: #ffe14a; font-size: .85em; }

/* ---------- 貯金箱アイコン（記録・ランキング） ---------- */
.pig-ico { width: 1.9em; height: 1.6em; vertical-align: -0.35em; margin-right: 3px; image-rendering: pixelated; }
.rec-item { display: inline-block; white-space: nowrap; margin-right: 10px; }
.title-best .pig-ico { filter: drop-shadow(1px 1px 0 var(--ink)); }
.rs-best .pig-ico { filter: drop-shadow(0 0 3px rgba(255,255,255,.4)); }
.rs-online { font-size: 14px; color: #c8b0ff; margin-top: 4px; min-height: 1.2em; }
.title-btns .row { flex-wrap: wrap; justify-content: center; }

/* ---------- オンラインランキング ---------- */
.rk-name { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 18px; margin-bottom: 10px; }
.rk-name input {
  width: 11em; font: inherit; font-size: 18px; padding: 4px 8px;
  border: 3px solid var(--ink); background: #fffaf0; color: var(--ink);
  user-select: text; -webkit-user-select: text;
}
.rk-tabs { display: flex; gap: 6px; margin: 6px 0; }
.rk-tabs .btn { flex: 1; }
.rk-tabs .btn.on { background: var(--gold); box-shadow: inset -3px -3px 0 var(--gold-lo), inset 3px 3px 0 #fff2a0, 3px 3px 0 var(--ink); }
.rk-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 18px; table-layout: fixed; }
.rk-table th { font-weight: normal; font-size: 14px; color: var(--ink-2); text-align: left; padding: 6px 4px; border-bottom: 3px solid var(--ink); }
.rk-table th:first-child { width: 3em; }
.rk-table th:last-child { width: 7.5em; text-align: right; }
.rk-table td { padding: 6px 4px; border-bottom: 2px dotted var(--panel-lo); text-align: left; overflow-wrap: anywhere; }
.rk-table td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--rust); }
.rk-no { font-variant-numeric: tabular-nums; }
.rk-no.top1 { color: #c89a10; font-size: 22px; }
.rk-no.top2 { color: #8a96a4; font-size: 20px; }
.rk-no.top3 { color: #b8703a; font-size: 20px; }
.rk-table tr[data-own="true"] { background: #ffe8a8; }
.rk-table tr[data-own="true"] td:first-child { box-shadow: inset 4px 0 var(--rust); }
.rk-you { display: inline-block; margin-left: 6px; padding: 0 5px; background: var(--rust); color: #fff6dc; font-size: 12px; vertical-align: middle; }
.rk-msg { font-size: 16px; color: var(--ink-2); min-height: 1.4em; margin: 8px 0 0; }
.rk-note { font-size: 13px; color: var(--ink-2); margin: 6px 0; line-height: 1.5; }
.rk-status { font-size: 14px; color: var(--rust); min-height: 1.2em; margin: 4px 0 8px; }
@media (max-width: 480px) {
  .rk-table { font-size: 16px; }
  .rk-table th:last-child { width: 6.2em; }
}
.modal-card h2.rk-h { font-size: clamp(20px, 6vw, 28px); white-space: nowrap; }
.rk-name span { white-space: nowrap; }
.rk-name input { flex: 1; min-width: 0; max-width: 12em; }
.rec-table th { white-space: nowrap; }
@media (max-width: 480px) { .rec-table { font-size: 15px; } .rec-table td .rec-item { margin-right: 0; } }
