@font-face { font-family: "Brush"; src: url("./fonts/brush.woff2") format("woff2"); font-display: swap; }
:root {
  --paper: #f3e9d6; --paper2: #e9dcc2; --ink: #2a2420; --ink2: #4a4038; --red: #c43d2b; --red2: #a52e20;
  --gold: #e0ad4a; --gold2: #f6d58a; --teal: #3d8c86;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); overscroll-behavior: none;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; color: var(--ink); }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
button { font-family: inherit; border: 0; cursor: pointer; color: inherit; touch-action: manipulation; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 0 calc(12px + var(--sal)); }
.round-btn { pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fffaf0, var(--paper2)); box-shadow: 0 2px 0 rgba(42,36,32,.25), inset 0 0 0 2px rgba(42,36,32,.75);
  display: grid; place-items: center; }
.round-btn:active { transform: scale(.92); }
.ico-pause { width: 14px; height: 16px; border-left: 5px solid var(--ink); border-right: 5px solid var(--ink); }
.integrity { flex: 1; min-width: 0; }
.int-label { display: flex; justify-content: space-between; align-items: baseline; font-family: "Brush", serif; font-size: 17px; line-height: 1; padding: 0 4px 4px;
  color: var(--ink); text-shadow: 0 1px 0 rgba(255,250,240,.8); }
.int-label b { font-weight: normal; font-size: 19px; color: var(--red2); }
.int-bar { position: relative; height: 14px; border-radius: 8px; background: rgba(42,36,32,.18); box-shadow: inset 0 0 0 2px rgba(42,36,32,.75), 0 2px 0 rgba(42,36,32,.15); overflow: visible; }
.int-fill, .int-ghost { position: absolute; left: 3px; top: 3px; bottom: 3px; border-radius: 5px; width: calc(100% - 6px); transform-origin: left; }
.int-ghost { background: #fff3d6; transition: transform .6s .25s ease-out; }
.int-fill { background: linear-gradient(90deg, #3d8c86, #7fbf9a 55%, #e9c66a); z-index: 1; transition: transform .18s ease-out, filter .2s; }
.int-fill.low { background: linear-gradient(90deg, #c43d2b, #e07a3c 60%, #f0b75a); }
.int-mark { position: absolute; left: 30%; top: -5px; bottom: -5px; width: 2px; background: var(--red); z-index: 2; }
.int-mark span { position: absolute; top: 16px; left: -9px; width: 18px; height: 18px; border-radius: 3px; background: var(--red); color: #fff3e0;
  font: 12px/18px "Brush", serif; text-align: center; transform: rotate(-6deg); }
.score { flex: none; text-align: right; font-family: "Brush", serif; line-height: 1; min-width: 74px; }
.score span { display: block; font-size: 14px; color: var(--ink2); }
.score b { font-weight: normal; font-size: 28px; color: var(--ink); text-shadow: 0 2px 0 rgba(255,250,240,.9); display: inline-block; }
.score b.bump { animation: bump .25s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); color: var(--red2); } }
.barrier-tag { position: absolute; top: calc(78px + var(--sat)); left: 50%; transform: translateX(-50%); padding: 3px 12px; border-radius: 20px;
  font: 14px "Brush", serif; color: #6b4a10; background: rgba(255,226,140,.75); box-shadow: 0 0 0 1.5px rgba(160,110,20,.6), 0 0 16px rgba(255,210,100,.7);
  transition: opacity .5s, transform .5s; white-space: nowrap; }
.barrier-tag.off { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.8); }
.hint { position: absolute; left: 50%; bottom: calc(150px + var(--sab)); transform: translateX(-50%); padding: 8px 16px; border-radius: 22px; white-space: nowrap;
  background: rgba(42,36,32,.72); color: #f8efdc; font-size: 14px; letter-spacing: 1px; opacity: 0; transition: opacity .35s; }
.hint.show { opacity: 1; animation: hintpulse 2.2s ease-in-out infinite; }
@keyframes hintpulse { 50% { transform: translateX(-50%) translateY(-4px); } }

/* ammo cards */
.cards { position: absolute; left: 50%; bottom: calc(14px + var(--sab)); transform: translateX(-50%); display: flex; gap: 14px; pointer-events: auto; }
.card { position: relative; width: 92px; height: 116px; border-radius: 14px; padding: 0; overflow: visible;
  background: linear-gradient(170deg, #fffaf0, #eadcc0); box-shadow: inset 0 0 0 2px rgba(42,36,32,.8), 0 4px 0 rgba(42,36,32,.3);
  transition: transform .2s cubic-bezier(.3,1.6,.5,1), box-shadow .2s; }
.card img { width: 84px; height: 84px; margin: 2px 4px 0; display: block; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(42,36,32,.25)); }
.card .nm { position: absolute; left: 0; right: 0; bottom: 6px; font: 19px/1 "Brush", serif; text-align: center; }
.card .el { position: absolute; top: -8px; left: -8px; width: 28px; height: 28px; border-radius: 50%; font: 16px/28px "Brush", serif; color: #fff7e6;
  box-shadow: 0 0 0 2px rgba(255,248,230,.9), 0 2px 0 rgba(42,36,32,.3); text-align: center; }
.card .el.fire { background: radial-gradient(circle at 35% 30%, #ff9a52, #c43d2b); }
.card .el.thunder { background: radial-gradient(circle at 35% 30%, #8ab8ff, #4058b0); }
.card .cnt { position: absolute; top: -8px; right: -8px; min-width: 28px; height: 28px; border-radius: 14px; padding: 0 6px; background: var(--ink); color: #fff3df;
  font: 17px/28px "Brush", serif; text-align: center; box-shadow: 0 0 0 2px rgba(255,248,230,.9); }
.card.sel { transform: translateY(-12px) scale(1.06); box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 2px rgba(42,36,32,.8), 0 8px 18px rgba(196,140,40,.45); }
.card.sel::after { content: "下一发"; position: absolute; left: 50%; top: -26px; transform: translateX(-50%); font: 13px "Brush", serif; color: var(--red2); white-space: nowrap; }
.card.empty { filter: grayscale(1) opacity(.45); }
.card.lock { pointer-events: none; }
.card:active { transform: scale(.95); }

/* floating fx text */
#fx-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.ftxt { position: absolute; left: 0; top: 0; font-family: "Brush", serif; white-space: nowrap; will-change: transform, opacity; color: #fff6dc;
  --o: #2a1a10; text-shadow: 2px 0 0 var(--o), -2px 0 0 var(--o), 0 2px 0 var(--o), 0 -2px 0 var(--o), 1.4px 1.4px 0 var(--o), -1.4px 1.4px 0 var(--o), 1.4px -1.4px 0 var(--o), -1.4px -1.4px 0 var(--o), 0 4px 6px rgba(0,0,0,.35); }
.ftxt.pts { font-size: 22px; color: #fff; }
.ftxt.counter { font-size: 26px; color: #ffd36a; --o: #7a1e08; }
.ftxt.weak { font-size: 20px; color: #fff1c4; --o: #6a4a10; }
.ftxt.combo { font-size: 30px; color: #ff8a5c; --o: #4a1206; }
.ftxt.big { font-size: min(44px, 11vw); white-space: pre; text-align: center; line-height: 1.15; color: #ffe08a; --o: #5a2a04; }
.ftxt.skill { font-size: 28px; color: #fff; --o: #8a2a10; }
#flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle, #fff8e0, #ffd98a 60%, rgba(255,210,120,0)); opacity: 0; }
#flash.on { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; }
#title .paper { position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 38%, rgba(243,233,214,.25), rgba(243,233,214,.82) 62%, rgba(233,220,194,.97));
  backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px); }
.title-wrap { position: relative; text-align: center; padding: 0 24px; transform: translateY(-4vh); }
.title-wrap h1 { margin: 0; font: 400 clamp(56px, 17vw, 112px)/1.1 "Brush", serif; letter-spacing: 4px; color: var(--ink);
  text-shadow: 0 0 1px rgba(42,36,32,.6), 3px 4px 0 rgba(42,36,32,.08); animation: inkin 1.6s ease-out both; white-space: nowrap; }
.title-wrap h1 .bracket { font-size: .55em; color: var(--red); vertical-align: .25em; }
@keyframes inkin { 0% { opacity: 0; filter: blur(14px); letter-spacing: 30px; } 100% { opacity: 1; filter: blur(0); } }
.seal-stamp { position: absolute; right: 6%; top: -28px; width: 54px; padding: 6px 0; border-radius: 6px; background: var(--red); color: #fbe9d2;
  font: 19px/1.15 "Brush", serif; transform: rotate(8deg); box-shadow: inset 0 0 0 3px rgba(251,233,210,.75), 0 0 0 1px var(--red2);
  animation: stamp .5s 1.2s cubic-bezier(.2,1.8,.4,1) both; opacity: .95; }
@keyframes stamp { 0% { opacity: 0; transform: rotate(8deg) scale(2.4); } 100% { opacity: .95; transform: rotate(8deg) scale(1); } }
.chapter { margin: 6px 0 0; font: 20px "Brush", serif; color: var(--red2); letter-spacing: 3px; animation: fadeup .8s .7s both; }
.lore { margin: 14px auto 34px; max-width: 22em; font-size: 15px; color: var(--ink2); letter-spacing: 1.5px; line-height: 1.7; animation: fadeup .8s .9s both; }
.tip { margin-top: 22px; font-size: 12.5px; color: rgba(42,36,32,.6); letter-spacing: 1px; animation: fadeup .8s 1.3s both; }
@keyframes fadeup { 0% { opacity: 0; transform: translateY(12px); } }
.ink-btn { position: relative; min-width: 168px; padding: 12px 34px 14px; font: 30px/1 "Brush", serif; letter-spacing: 8px; text-indent: 8px; color: #fff4e2;
  border-radius: 999px 860px 999px 900px / 420px 520px 460px 500px; background: radial-gradient(ellipse at 40% 30%, #3a322c, #1d1814 75%);
  box-shadow: 0 5px 0 rgba(42,36,32,.35), inset 0 0 0 2px rgba(255,244,226,.12); animation: fadeup .8s 1.1s both; display: block; margin: 0 auto; }
.ink-btn::before { content: ""; position: absolute; right: -6px; top: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px var(--paper); }
.ink-btn:active { transform: translateY(3px) scale(.97); box-shadow: 0 2px 0 rgba(42,36,32,.35); }
.ink-btn:disabled { opacity: .4; }
.ink-btn.alt { background: radial-gradient(ellipse at 40% 30%, #fffaf0, #e7d8bc 75%); color: var(--ink); box-shadow: 0 4px 0 rgba(42,36,32,.3), inset 0 0 0 2px rgba(42,36,32,.75); font-size: 24px; }
.ink-btn.alt::before { display: none; }
.loading { position: absolute; bottom: calc(40px + var(--sab)); left: 0; right: 0; text-align: center; font: 16px "Brush", serif; color: var(--ink2); letter-spacing: 3px; }
.modal { background: rgba(42,36,32,.42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { position: relative; width: min(84vw, 340px); padding: 26px 22px 24px; border-radius: 20px; text-align: center; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(175deg, #fbf4e6, #ecdfc5); box-shadow: inset 0 0 0 2px rgba(42,36,32,.8), inset 0 0 0 7px #fbf4e6, inset 0 0 0 8px rgba(196,61,43,.5), 0 18px 40px rgba(0,0,0,.3);
  animation: pop .4s cubic-bezier(.2,1.5,.4,1) both; }
.panel .ink-btn { animation: none; }
@keyframes pop { 0% { opacity: 0; transform: scale(.7); } }
.panel h2 { margin: 0; font: 400 40px/1.1 "Brush", serif; letter-spacing: 4px; }
.result-panel h2 { font-size: 46px; }
.result-panel h2.fail { color: var(--ink2); }
.stars { display: flex; justify-content: center; gap: 6px; margin: 2px 0 4px; }
.star { width: 64px; height: 64px; display: block; position: relative; }
.star::before, .star::after { content: ""; position: absolute; inset: 0;
  clip-path: polygon(50% 2%, 63% 36%, 99% 37%, 70% 59%, 81% 95%, 50% 74%, 19% 95%, 30% 59%, 1% 37%, 37% 36%); }
.star::before { background: rgba(42,36,32,.18); }
.star::after { background: radial-gradient(circle at 40% 35%, #fff2b8, #f2b33d 55%, #c4711c); transform: scale(0); }
.star:nth-child(2) { transform: translateY(-10px) scale(1.15); }
.star.on::after { animation: starin .5s cubic-bezier(.2,1.8,.4,1) forwards; }
@keyframes starin { 0% { transform: scale(2.2) rotate(-40deg); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.res-score { font-family: "Brush", serif; line-height: 1; }
.res-score span { font-size: 16px; color: var(--ink2); margin-right: 8px; }
.res-score b { font-weight: normal; font-size: 40px; color: var(--red2); }
.res-stats { font-size: 13.5px; color: var(--ink2); line-height: 1.8; letter-spacing: 1px; }
.soon { margin: 0; font-size: 12px; color: rgba(42,36,32,.55); letter-spacing: 1px; }

@media (orientation: landscape) and (max-height: 500px) {
  .card { width: 76px; height: 96px; }
  .card img { width: 68px; height: 68px; }
  .card .nm { font-size: 16px; bottom: 5px; }
  .cards { left: auto; right: calc(14px + var(--sar)); transform: none; bottom: calc(12px + var(--sab)); }
  .hud-top { padding-top: calc(8px + var(--sat)); }
  .integrity { max-width: 46vw; margin: 0 auto; }
  .barrier-tag { top: calc(56px + var(--sat)); }
  .hint { bottom: calc(18px + var(--sab)); left: calc(16px + var(--sal)); transform: none; }
  .hint.show { animation: none; }
  .title-wrap h1 { font-size: clamp(48px, 13vh, 96px); }
  .lore { margin: 8px auto 18px; }
  .tip { margin-top: 12px; }
  .panel { gap: 8px; padding: 18px 20px; }
  .star { width: 48px; height: 48px; }
  .result-panel h2 { font-size: 36px; }
}
