/* 鍛冶屋スロット：見た目の決まり
   ・炉の前のような「炭の黒」と「火の橙」。輪郭線は太く、影はぼかさず下へずらすだけ。
   ・書体は 3 つ。見出し＝極太（--display）、本文（--text）、数字＝細長い太字（--num）。
   ・色は先頭の変数で決める。昼（ライト）と夜（ダーク）の両方を用意する。 */
@font-face { font-family: "KJ Display"; src: url("fonts/display.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "KJ Text"; src: url("fonts/text-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "KJ Text"; src: url("fonts/text-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "KJ Num"; src: url("fonts/num-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "KJ Num"; src: url("fonts/num-800i.woff2") format("woff2"); font-weight: 800; font-style: italic; font-display: swap; }

:root {
  --bg: #ece3d3;            /* 地：すすけた紙 */
  --panel: #fbf6ea;
  --panel2: #f1e8d6;
  --ink: #1f1712;           /* 文字と輪郭線 */
  --sub: #6a5c50;
  --line: #1f1712;
  --soft: #d6c9b2;
  --ember: #e8541e;         /* 火の橙：いちばん大事なボタン */
  --ember-ink: #fff8ee;
  --forge: #1f1712;         /* 炉（武器の数字が出る黒い板） */
  --forge-ink: #fbf0dc;
  --forge-sub: #b9a48e;
  --digit: #ffb02e;         /* 炉の数字 */
  --good: #1f8a5b;
  --bad: #c7362b;
  --gold: #f2b705;
  --gold-ink: #7d5c00;
  --s-crack: #8f8a84;
  --s-iron: #64727f;
  --s-fire: #e8541e;
  --s-wind: #2f86d6;
  --s-gold: #f2b705;
  --s-dragon: linear-gradient(120deg, #e6483c, #f0a01a, #3fae4a, #2f7fe0, #9a4ad8);
  --edge: .125rem;
  --drop: 0 .25rem 0 var(--line);
  --drop-s: 0 .125rem 0 var(--line);
  --r: .875rem;
  --r-s: .5rem;
  --display: "KJ Display", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  --text: "KJ Text", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  --num: "KJ Num", "KJ Text", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15100d;
    --panel: #2a201a;
    --panel2: #211813;
    --ink: #f6ead8;
    --sub: #b7a593;
    --line: #050302;
    --soft: #45362b;
    --ember: #f2632b;
    --forge: #0a0705;
    --good: #3fbf87;
    --bad: #f0685c;
    --gold-ink: #f6c93a;
    --s-crack: #6f6862;
    --s-iron: #7f8d9a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--text); font-weight: 500; line-height: 1.6; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
h1, h2, p, ul, ol, dl, dd { margin: 0; padding: 0; font-weight: inherit; }
ul, ol { list-style: none; }
b { font-weight: 700; }
i, em { font-style: normal; }
:focus-visible { outline: .1875rem solid var(--s-wind); outline-offset: .125rem; }

#fxCanvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 29; opacity: 0; }
.flash.on { animation: flash .5s ease-out; }
.flash.good { background: #fff; }
.flash.gold { background: var(--gold); }
.flash.bad { background: var(--bad); }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
.float { position: fixed; z-index: 31; transform: translate(-50%, -100%); padding: .125rem .5rem; border: var(--edge) solid var(--line); border-radius: 99rem; background: var(--panel); color: var(--ink); font-family: var(--num); font-weight: 700; font-size: 1rem; white-space: nowrap; pointer-events: none; animation: float .9s ease-out forwards; }
.float.fire { background: var(--s-fire); color: #fff; }
.float.wind { background: var(--s-wind); color: #fff; }
.float.gold { background: var(--s-gold); color: #1f1712; }
.float.dragon { background: var(--s-dragon); color: #fff; }
@keyframes float { 0% { opacity: 0; margin-top: .5rem; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -3rem; } }

.app { max-width: 27rem; min-height: 100dvh; margin: 0 auto; padding: calc(.75rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left)); display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; }
.screen { display: flex; flex-direction: column; gap: .75rem; flex: 1; }

/* ボタン */
.btn-main, .btn-sub { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-height: 3.25rem; padding: .5rem 1rem; border: var(--edge) solid var(--line); border-radius: var(--r); box-shadow: var(--drop); font-weight: 700; line-height: 1.3; transition: transform .06s, box-shadow .06s; }
.btn-main { background: var(--ember); color: var(--ember-ink); font-family: var(--display); font-size: 1.25rem; }
.btn-sub { background: var(--panel); min-height: 2.75rem; font-size: .9375rem; }
.btn-sub.small { min-height: 2.75rem; font-size: .8125rem; box-shadow: var(--drop-s); }
.btn-main small, .btn-sub small { font-family: var(--text); font-size: .75rem; font-weight: 700; opacity: .9; }
.btn-main:active, .btn-sub:active, .card:active { transform: translateY(.1875rem); box-shadow: 0 .0625rem 0 var(--line); }
button:disabled { opacity: .45; cursor: default; }
.link { border: 0; background: none; padding: .625rem .25rem; min-height: 2.75rem; font-size: .8125rem; font-weight: 700; color: var(--sub); text-decoration: underline; text-underline-offset: .2em; }
.kicker { display: inline-block; align-self: flex-start; padding: .0625rem .625rem; border-radius: .375rem; background: var(--ink); color: var(--bg); font-size: .75rem; font-weight: 700; }
.sub { color: var(--sub); font-size: .8125rem; }
.dim { color: var(--sub); font-size: .75rem; }

/* ホーム */
.hero { margin-top: 1.5rem; padding: 1.5rem 1.25rem; border: var(--edge) solid var(--line); border-radius: var(--r); background: var(--forge); color: var(--forge-ink); box-shadow: var(--drop); display: flex; flex-direction: column; gap: .5rem; }
.hero .kicker { background: var(--ember); color: var(--ember-ink); }
.hero h1 { font-family: var(--display); font-size: 3.25rem; line-height: 1.1; color: var(--digit); }
.hero .lead { font-size: .875rem; color: var(--forge-sub); font-weight: 700; }
.record { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.record > div { padding: .5rem .75rem; border: var(--edge) solid var(--line); border-radius: var(--r-s); background: var(--panel); }
.record dt { font-size: .6875rem; font-weight: 700; color: var(--sub); }
.record dd { font-weight: 700; font-size: .9375rem; }
.home-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
#soundBtn { align-self: center; }

/* 鍛冶場：上の帯 */
.bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.bar-l { display: flex; align-items: baseline; gap: .5rem; }
.bar-l b { font-family: var(--display); font-size: 1.25rem; }
.bar-l small { font-size: .75rem; font-weight: 700; color: var(--sub); }
.bar-r { display: flex; align-items: center; gap: .5rem; }
.stat { display: inline-flex; align-items: center; gap: .1875rem; padding: .125rem .5rem; border: var(--edge) solid var(--line); border-radius: 99rem; background: var(--panel); font-family: var(--num); font-weight: 700; font-size: 1.0625rem; }
.stat small { font-family: var(--text); font-size: .625rem; font-weight: 700; color: var(--sub); margin-right: .125rem; }
.heart { width: .75rem; height: .75rem; border-radius: 50%; border: .09375rem solid var(--line); background: var(--soft); }
.heart.on { background: var(--bad); }
.coin { display: inline-block; width: .875rem; height: .875rem; border-radius: 50%; border: .09375rem solid var(--line); background: var(--gold); flex: none; }

/* 依頼 */
.order { padding: .625rem .875rem .75rem; border: var(--edge) solid var(--line); border-radius: var(--r); background: var(--panel); box-shadow: var(--drop-s); display: flex; flex-direction: column; gap: .25rem; }
.order.big { background: var(--panel2); border-style: double; border-width: .25rem; }
.order-who { font-size: .8125rem; font-weight: 700; color: var(--sub); }
.order-need { font-weight: 700; font-size: .875rem; }
.order-need b { font-family: var(--num); font-size: 1.625rem; margin-left: .25rem; }
.gauge { height: .75rem; border: var(--edge) solid var(--line); border-radius: 99rem; background: var(--soft); overflow: hidden; }
.gauge i { display: block; height: 100%; width: 0; background: var(--ember); transition: width .25s ease-out; }
.order.reached .gauge i { background: var(--good); }
.order-state { font-size: .8125rem; font-weight: 700; }
.order.reached .order-state { color: var(--good); }

/* 武器（炉の黒い板） */
.weapon { padding: .75rem 1rem; border: var(--edge) solid var(--line); border-radius: var(--r); background: var(--forge); color: var(--forge-ink); box-shadow: var(--drop); text-align: center; }
.weapon-label { font-size: .6875rem; font-weight: 700; color: var(--forge-sub); }
.power { font-family: var(--num); font-weight: 800; font-style: italic; font-size: clamp(3rem, 16vw, 4.25rem); line-height: 1; color: var(--digit); }
.formula { display: flex; justify-content: center; align-items: baseline; gap: .625rem; margin-top: .25rem; font-size: .75rem; font-weight: 700; color: var(--forge-sub); }
.formula b { font-family: var(--num); font-size: 1.25rem; color: var(--forge-ink); margin-left: .125rem; }
.formula i { font-family: var(--num); font-size: 1.125rem; color: var(--ember); }

/* 火花の窓 */
.reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.reel { height: clamp(5rem, 15dvh, 7rem); border: var(--edge) solid var(--line); border-radius: var(--r); box-shadow: var(--drop); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .125rem; color: #fff; background: var(--s-iron); }
.reel svg { width: 2.75rem; height: 2.75rem; }
.reel small { font-size: .75rem; font-weight: 700; }
.reel[data-sym="crack"], .mini[data-sym="crack"] { background: var(--s-crack); }
.reel[data-sym="iron"], .mini[data-sym="iron"] { background: var(--s-iron); }
.reel[data-sym="fire"], .mini[data-sym="fire"] { background: var(--s-fire); }
.reel[data-sym="wind"], .mini[data-sym="wind"] { background: var(--s-wind); }
.reel[data-sym="gold"], .mini[data-sym="gold"] { background: var(--s-gold); color: #1f1712; }
.reel[data-sym="dragon"], .mini[data-sym="dragon"] { background: var(--s-dragon); }
.reel.idle { opacity: .5; }
.reel.spin svg { filter: blur(.0625rem); opacity: .8; }
.reel.hit { animation: hit .22s ease-out; }
.reel.tri { animation: tri .5s ease-in-out 2; }
@keyframes hit { 0% { transform: translateY(-.5rem) scale(1.06); } 100% { transform: none; } }
@keyframes tri { 50% { transform: scale(1.07); filter: brightness(1.25); } }
.msg { min-height: 1.5rem; text-align: center; font-size: .875rem; font-weight: 700; }
.msg.good { color: var(--good); }
.msg.bad, .msg.warn { color: var(--bad); }
.msg.dim { color: var(--sub); }

.actions { display: grid; grid-template-columns: 1.3fr 1fr; gap: .5rem; }
.actions .btn-main, .actions .btn-sub { min-height: 4rem; }
.actions .btn-sub b { font-size: .875rem; }
#strikeBtn.risky { background: var(--bad); }
#deliverBtn.ready { background: var(--good); color: #fff; }
#deliverBtn.urge { animation: urge 1s ease-in-out infinite; }
@keyframes urge { 50% { transform: translateY(-.125rem); } }

.own { display: flex; flex-direction: column; gap: .25rem; margin-top: auto; }
.own-head { display: flex; align-items: center; justify-content: space-between; }
.own-head small { font-size: .75rem; font-weight: 700; color: var(--sub); }
.own-head b { color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: .375rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; min-height: 2rem; padding: .125rem .625rem; border: var(--edge) solid var(--line); border-radius: 99rem; background: var(--panel); font-size: .75rem; }
button.chip { min-height: 2.75rem; }
.chip em { font-family: var(--num); font-weight: 700; font-size: .8125rem; color: var(--sub); }
.chip.rare1 { background: color-mix(in srgb, var(--s-wind) 18%, var(--panel)); }
.chip.rare2 { background: color-mix(in srgb, var(--gold) 35%, var(--panel)); }

/* 下から出る紙 */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(10, 6, 4, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 27rem; max-height: 92dvh; overflow-y: auto; padding: 1.125rem 1rem calc(1rem + env(safe-area-inset-bottom)); border: var(--edge) solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; background: var(--bg); display: flex; flex-direction: column; gap: .625rem; }
.sheet-box h2 { font-family: var(--display); font-size: 1.5rem; line-height: 1.25; }
.sheet[data-tone="gold"] .kicker { background: var(--gold); color: #1f1712; }
.sheet[data-tone="good"] .kicker { background: var(--good); color: #fff; }
.sheet[data-tone="bad"] .kicker { background: var(--bad); color: #fff; }
.sheet-body { display: flex; flex-direction: column; gap: .625rem; }
.sheet-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: .25rem; }
.sheet-box.rise { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(2rem); opacity: 0; } }

.cards { display: flex; flex-direction: column; gap: .5rem; }
.card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .125rem; width: 100%; padding: .625rem 4.5rem .625rem .875rem; border: var(--edge) solid var(--line); border-radius: var(--r); background: var(--panel); box-shadow: var(--drop-s); text-align: left; }
li.card { padding-right: .875rem; }
.card b { font-size: 1rem; }
.card small { font-size: .8125rem; color: var(--sub); line-height: 1.45; }
.card .tag { font-size: .6875rem; font-weight: 700; padding: 0 .375rem; border-radius: .25rem; background: var(--ink); color: var(--bg); }
.card .price { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: .25rem; font-family: var(--num); font-weight: 700; font-size: 1.25rem; }
.card.rare1 { background: color-mix(in srgb, var(--s-wind) 14%, var(--panel)); }
.card.rare2 { background: color-mix(in srgb, var(--gold) 30%, var(--panel)); }
.card.mat { background: var(--panel2); }
.card.sold { align-items: center; padding: .875rem; color: var(--sub); font-size: .8125rem; font-weight: 700; box-shadow: none; border-style: dashed; }
li.card:not(.seen) { border-style: dashed; box-shadow: none; }
.order-card { padding-right: .875rem; }
.order-card .need { font-family: var(--num); font-weight: 700; font-size: 1.375rem; }
.order-card.big { border-style: double; border-width: .25rem; background: color-mix(in srgb, var(--gold) 22%, var(--panel)); }
.steps { display: flex; flex-direction: column; gap: .5rem; counter-reset: step; }
.steps li { position: relative; padding-left: 2rem; font-size: .875rem; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: .0625rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--ink); color: var(--bg); font-family: var(--num); font-weight: 700; text-align: center; line-height: 1.5rem; }
.odds { display: flex; flex-direction: column; gap: .375rem; }
.odds li { display: flex; align-items: center; gap: .625rem; padding: .375rem .625rem; border: var(--edge) solid var(--line); border-radius: var(--r-s); background: var(--panel); }
.odds em { margin-left: auto; font-family: var(--num); font-weight: 700; font-size: 1.125rem; }
.mini { width: 2rem; height: 2rem; border-radius: .375rem; border: .09375rem solid var(--line); display: grid; place-items: center; color: #fff; }
.mini svg { width: 1.25rem; height: 1.25rem; }

/* 店じまい */
#scrEnd { padding-top: 1.5rem; }
.end-title { font-family: var(--display); font-size: 2.75rem; line-height: 1.15; }
.fame { font-size: .875rem; font-weight: 700; }

/* ゆれ・はね */
.thud { animation: thud .18s ease-out; }
@keyframes thud { 30% { transform: translateY(.25rem) scale(.99); } }
.pop { animation: pop .22s ease-out; }
@keyframes pop { 40% { transform: scale(1.12); } }
.quake { animation: quake .4s linear; }
@keyframes quake { 20% { transform: translate(-.375rem, .125rem); } 40% { transform: translate(.375rem, -.125rem); } 60% { transform: translate(-.25rem, 0); } 80% { transform: translate(.25rem, 0); } }

@media (max-height: 41rem) {
  .screen { gap: .5rem; }
  .power { font-size: 2.75rem; }
  .reel { height: 4.25rem; }
  .reel svg { width: 2rem; height: 2rem; }
  .actions .btn-main, .actions .btn-sub { min-height: 3.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
