:root {
  --paper: #fdfdfb;
  --grid: #bfe3d2;
  --grid-soft: #dcefe5;
  --ink: #1d1b24;
  --ink-2: #5b5866;
  --muted: #8b8795;
  --line: rgba(29, 27, 36, 0.12);
  --shu: #e5402f;
  --shu-deep: #b3261b;
  --pink: #ff4f9a;
  --yellow: #ffd23f;
  --cyan: #2ec5e8;
  --purple: #7b4dff;
  --green: #3ccf8e;
  --orange: #ff7a3d;
  --cosmos: #160b33;
  --ui: "dk-ui", system-ui, -apple-system, "Hiragino Sans", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK JP", sans-serif;
  --serif-fallback: "Hiragino Mincho ProN", "Songti SC", "Noto Serif CJK JP", "Yu Mincho", serif;
  --t0: #b9b2a5; --t1: #43a862; --t2: #2f62d0; --t3: #8a4fe0; --t4: #d19a22; --t5: #ff4f9a; --t6: #111111;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ background layers */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--paper); }
#bg > div { position: absolute; inset: -30%; transition: opacity 900ms ease; }
.bg-grid {
  inset: 0 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72'%3E%3Crect x='0.5' y='0.5' width='71' height='71' fill='none' stroke='%23bfe3d2' stroke-width='1.5'/%3E%3Cpath d='M36 0V72M0 36H72' stroke='%23d3eadf' stroke-width='1.2' stroke-dasharray='4 4'/%3E%3C/svg%3E");
  background-position: center;
}
.bg-blobs {
  opacity: 0;
  background:
    radial-gradient(40% 30% at 20% 30%, rgba(255, 79, 154, 0.18), transparent 70%),
    radial-gradient(35% 30% at 80% 25%, rgba(46, 197, 232, 0.18), transparent 70%),
    radial-gradient(40% 35% at 60% 80%, rgba(255, 210, 63, 0.22), transparent 70%);
}
.bg-rays {
  opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 226, 120, 0.55) 0deg 7deg, rgba(255, 255, 255, 0) 7deg 15deg);
  animation: spin 40s linear infinite;
}
.bg-rainbow {
  opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 50%, #ff8fbf 0deg 9deg, #ffe066 9deg 18deg, #8ff0c0 18deg 27deg, #8fd9ff 27deg 36deg, #c7a6ff 36deg 45deg);
  animation: spin 24s linear infinite reverse;
  mix-blend-mode: multiply;
}
.bg-cosmos {
  opacity: 0;
  background:
    radial-gradient(1px 1px at 20% 30%, #fff 60%, transparent 70%),
    radial-gradient(1.5px 1.5px at 70% 20%, #fff 60%, transparent 70%),
    radial-gradient(1px 1px at 40% 70%, #fff 60%, transparent 70%),
    radial-gradient(1.5px 1.5px at 85% 65%, #fff 60%, transparent 70%),
    radial-gradient(60% 50% at 50% 50%, #3a1a7a 0%, var(--cosmos) 70%);
}
@keyframes spin { to { transform: rotate(360deg); } }
#bg[data-lv="1"] .bg-blobs { opacity: 0.6; }
#bg[data-lv="2"] .bg-blobs { opacity: 1; }
#bg[data-lv="3"] .bg-blobs { opacity: 1; }
#bg[data-lv="3"] .bg-rays { opacity: 0.35; }
#bg[data-lv="4"] .bg-blobs { opacity: 1; }
#bg[data-lv="4"] .bg-rays { opacity: 0.75; animation-duration: 18s; }
#bg[data-lv="5"] .bg-rays { opacity: 0.6; animation-duration: 12s; }
#bg[data-lv="5"] .bg-rainbow { opacity: 0.45; }
#bg[data-lv="6"] .bg-rays { opacity: 0.8; animation-duration: 7s; }
#bg[data-lv="6"] .bg-rainbow { opacity: 0.75; animation-duration: 10s; }
#bg[data-lv="7"] .bg-cosmos { opacity: 1; }
#bg[data-lv="7"] .bg-rainbow { opacity: 0.55; mix-blend-mode: screen; animation-duration: 6s; }
#bg[data-lv="7"] .bg-rays { opacity: 0.5; mix-blend-mode: screen; animation-duration: 5s; }
#bg[data-lv="7"] .bg-grid { opacity: 0.12; }
#bg[data-lv="5"] .bg-grid, #bg[data-lv="6"] .bg-grid { opacity: 0.35; }

canvas.fx { position: fixed; inset: 0; pointer-events: none; }
#fx-back { z-index: 1; }
#fx-front { z-index: 60; }

/* ------------------------------------------------------------ shell */
#app { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* title */
#title-screen { align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; text-align: center; overflow-y: auto; }
.logo { display: grid; justify-items: center; line-height: 1; user-select: none; }
.logo .top {
  font-weight: 900; font-size: clamp(40px, 12vw, 72px); color: var(--pink);
  text-shadow: 0 4px 0 #b3165f, 0 0 0 #fff; letter-spacing: 0.04em;
  -webkit-text-stroke: 3px #fff; paint-order: stroke fill;
}
.logo .main {
  margin-top: 6px; font-weight: 900; font-size: clamp(30px, 9vw, 54px); color: #fff;
  background: var(--ink); padding: 6px 14px 8px; border-radius: 10px; transform: rotate(-2deg);
  box-shadow: 0 6px 0 var(--shu);
}
.logo .seal {
  position: relative; top: -10px; right: -120px; width: 46px; height: 46px; border-radius: 8px; background: var(--shu);
  color: #fff; font-family: var(--serif-fallback); font-weight: 700; font-size: 30px; display: grid; place-items: center;
  transform: rotate(12deg); box-shadow: 0 3px 0 var(--shu-deep);
}
.tagline { font-weight: 800; font-size: 17px; }
.title-note { max-width: 34em; color: var(--ink-2); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip {
  border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px;
  box-shadow: 0 3px 0 var(--ink);
}
.chip[aria-pressed="true"] { background: var(--yellow); }
.btn-pop {
  border: 3px solid var(--ink); border-radius: 16px; padding: 12px 34px; font-weight: 900; font-size: 22px;
  background: linear-gradient(#5aa7ff, #2f62d0); color: #fff; box-shadow: 0 6px 0 var(--ink); letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn-pop:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn-pop[disabled] { filter: grayscale(0.8) brightness(1.1); cursor: not-allowed; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.toggle { border: 2px solid var(--ink); background: #fff; border-radius: 10px; padding: 4px 10px; font-size: 13px; font-weight: 700; box-shadow: 0 3px 0 var(--ink); }

/* game hud */
#game { position: relative; }
.hud { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 6px; }
.hud .mini-logo { font-weight: 900; font-size: 15px; line-height: 1; background: var(--ink); color: #fff; padding: 5px 7px; border-radius: 7px; box-shadow: 0 3px 0 var(--shu); white-space: nowrap; }
.dopa { flex: 1; min-width: 0; display: grid; justify-items: center; line-height: 1.05; }
.dopa .label { font-size: 11px; font-weight: 800; color: var(--pink); letter-spacing: 0.08em; }
.dopa .value { font-weight: 900; font-size: clamp(20px, 6vw, 30px); white-space: nowrap; -webkit-text-stroke: 4px #fff; paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.dopa .unit { color: var(--shu); margin-left: 2px; }
.dopa .read { font-size: 10px; color: var(--ink-2); font-weight: 700; min-height: 12px; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; }
.icon-btn { border: 2px solid var(--ink); background: #fff; border-radius: 10px; padding: 5px 9px; font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
.meter { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 0 12px 4px; }
.pips { display: flex; gap: 3px; }
.pip { width: 16px; height: 8px; border-radius: 4px; background: rgba(29, 27, 36, 0.12); border: 1.5px solid rgba(29, 27, 36, 0.25); }
.pip.on:nth-child(1) { background: #9fd9ff; } .pip.on:nth-child(2) { background: #6fe3b0; } .pip.on:nth-child(3) { background: #ffe066; }
.pip.on:nth-child(4) { background: #ffb347; } .pip.on:nth-child(5) { background: #ff6b6b; } .pip.on:nth-child(6) { background: #ff4f9a; }
.pip.on:nth-child(7) { background: #b28bff; } .pip.on:nth-child(8) { background: linear-gradient(90deg, #ff8fbf, #ffe066, #8ff0c0, #8fd9ff, #c7a6ff); }
.lvname { font-weight: 900; font-size: 13px; min-width: 5em; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; }
.chain-tag { font-weight: 900; font-size: 13px; color: #fff; background: var(--shu); border-radius: 999px; padding: 1px 10px; }

#stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 10px; }
.idle { text-align: center; display: grid; gap: 10px; justify-items: center; max-width: 30em; }
.idle .big-seal { width: 132px; height: 132px; border-radius: 22px; background: var(--shu); color: #fff; display: grid; place-items: center; font-size: 86px; font-weight: 700; box-shadow: 0 8px 0 var(--shu-deep); transform: rotate(-4deg); font-family: var(--serif-fallback); }
.idle p { font-weight: 700; color: var(--ink-2); font-size: 14px; background: rgba(255, 255, 255, 0.85); border-radius: 10px; padding: 6px 10px; }
.idle .stats { font-size: 12px; color: var(--muted); }

.controls { display: grid; gap: 6px; justify-items: center; padding: 6px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
.packs { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 13px; background: rgba(255, 255, 255, 0.9); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 12px; }
.packs .pk { display: flex; gap: 3px; align-items: center; }
.pkp { flex: none; width: 13px; height: 13px; box-sizing: border-box; border-radius: 50%; border: 2px solid var(--ink); }
.pkp.full { background: linear-gradient(to bottom, var(--pink) 0 50%, #ffffff 50% 100%); }
.pkp.used { border-color: rgba(29, 27, 36, 0.28); background: transparent; }
#pull-btn { min-width: 220px; font-size: 26px; background: linear-gradient(#ff7fb6, #ff4f9a); }
#refill-btn { font-size: 12px; border: 2px dashed var(--ink-2); background: #fff; border-radius: 10px; padding: 3px 10px; font-weight: 700; }
#summary-bar { min-height: 30px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 0 10px; }
.tchip { font-weight: 900; font-size: 12px; border-radius: 999px; padding: 1px 9px; color: #fff; border: 2px solid rgba(0, 0, 0, 0.15); }
.tchip.t0 { background: #9c968b; } .tchip.t1 { background: var(--t1); } .tchip.t2 { background: var(--t2); } .tchip.t3 { background: var(--t3); }
.tchip.t4 { background: linear-gradient(135deg, #f7d774, #c8932b); color: #3b2600; } .tchip.t5 { background: linear-gradient(90deg, #ff8fbf, #ffb86b, #7ee0b0, #7cc8ff, #b99cff); color: #22123a; }
.tchip.t6 { background: #111; color: #f5d77a; border-color: #e6b93c; }
.schip { font-weight: 800; font-size: 12px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 9px; }

/* ------------------------------------------------------------ cards */
.grid10 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(6px, 1.6vw, 14px); width: min(100%, 720px); }
.slot { perspective: 800px; aspect-ratio: 5 / 7; }
.slot .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 420ms cubic-bezier(.3, 1.4, .5, 1); transform: rotateY(180deg); }
.slot.flipped .inner { transform: rotateY(0deg); }
.slot.deal { animation: deal 420ms cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes deal { from { transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.3) rotate(-20deg); opacity: 0; } }
.face, .back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 10px; overflow: hidden; }
.back {
  transform: rotateY(180deg);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M12 0V24M0 12H24' stroke='%23f3c4bd' stroke-width='1' stroke-dasharray='2 2'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #fff8f1, #fbe7de);
  border: 3px solid var(--shu); display: grid; place-items: center;
}
.back::after { content: "字"; width: 46%; aspect-ratio: 1; border-radius: 16%; background: var(--shu); color: #fff; display: grid; place-items: center; font: 700 clamp(16px, 4vw, 34px)/1 var(--serif-fallback); transform: rotate(-6deg); box-shadow: 0 3px 0 var(--shu-deep); }
.back.glow-3 { box-shadow: 0 0 18px 4px rgba(170, 120, 255, 0.8); }
.back.glow-4 { box-shadow: 0 0 22px 6px rgba(255, 205, 80, 0.95); }
.back.glow-5, .back.glow-6 { box-shadow: 0 0 26px 8px rgba(255, 120, 200, 0.95); }
.face { display: grid; grid-template-rows: auto 1fr auto; border: 3px solid var(--t0); background: #fbfaf6; }
.face .stamp { justify-self: start; margin: 4px 0 0 4px; font-size: clamp(9px, 1.9vw, 13px); font-weight: 900; color: #fff; background: var(--shu); padding: 0 5px; border-radius: 4px; transform: rotate(-6deg); line-height: 1.45; }
.face .gbox { position: relative; display: grid; place-items: center; margin: 0 8%; }
.face .gbox::before { content: ""; position: absolute; inset: 6% 0; background:
  linear-gradient(to right, transparent calc(50% - 0.5px), rgba(229, 64, 47, 0.18) calc(50% - 0.5px), rgba(229, 64, 47, 0.18) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
  linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(229, 64, 47, 0.18) calc(50% - 0.5px), rgba(229, 64, 47, 0.18) calc(50% + 0.5px), transparent calc(50% + 0.5px));
  border: 1px solid rgba(229, 64, 47, 0.2); }
.face .g { position: relative; font-size: clamp(30px, 8.5vw, 64px); line-height: 1; font-weight: 700; }
.face .nm { text-align: center; font-size: clamp(8px, 1.8vw, 12px); font-weight: 800; padding: 0 3px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.face .new { position: absolute; top: 3px; right: 3px; font-size: clamp(7px, 1.5vw, 10px); font-weight: 900; background: var(--yellow); color: var(--ink); border-radius: 4px; padding: 0 4px; border: 1.5px solid var(--ink); }

/* tier materials (shared by .face, .fcard, .mini) */
[data-tier="1"] { --tc: var(--t1); }
.face[data-tier="1"], .fcard[data-tier="1"] { border-color: var(--t1); background: linear-gradient(170deg, #f4fbf5, #e2f3e6); }
.face[data-tier="2"], .fcard[data-tier="2"] { border-color: var(--t2); background: linear-gradient(170deg, #f1f5ff, #dde7fb); }
.face[data-tier="3"], .fcard[data-tier="3"] { border-color: var(--t3); background: linear-gradient(170deg, #f8f2ff, #e7dafb); }
.face[data-tier="4"], .fcard[data-tier="4"] { border-color: #c8932b; background: linear-gradient(135deg, #fff7da 0%, #f5d97c 35%, #fff2c6 55%, #e7b84b 100%); }
.face[data-tier="5"], .fcard[data-tier="5"] { border-color: transparent; background:
  linear-gradient(#fffdfb, #fffdfb) padding-box,
  conic-gradient(from var(--holo, 0deg), #ff8fbf, #ffe066, #8ff0c0, #8fd9ff, #c7a6ff, #ff8fbf) border-box; }
.face[data-tier="5"]::before, .fcard[data-tier="5"]::before { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255, 143, 191, 0.22), rgba(143, 217, 255, 0.22), rgba(255, 224, 102, 0.22)); pointer-events: none; }
.face[data-tier="6"], .fcard[data-tier="6"] { border-color: #e6b93c; background: radial-gradient(120% 80% at 30% 10%, #2a2118, #0b0907 70%); color: #f5d77a; }
.face[data-tier="6"] .gbox::before, .fcard[data-tier="6"] .gbox::before { border-color: rgba(230, 185, 60, 0.35); background:
  linear-gradient(to right, transparent calc(50% - 0.5px), rgba(230, 185, 60, 0.3) calc(50% - 0.5px), rgba(230, 185, 60, 0.3) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
  linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(230, 185, 60, 0.3) calc(50% - 0.5px), rgba(230, 185, 60, 0.3) calc(50% + 0.5px), transparent calc(50% + 0.5px)); }
.face[data-tier="6"] .g, .fcard[data-tier="6"] .g { background: linear-gradient(180deg, #fff3c4, #e6b93c 55%, #b07a1a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.face[data-tier="4"]::after, .fcard[data-tier="4"]::after, .face[data-tier="6"]::after, .fcard[data-tier="6"]::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.65) 48%, transparent 60%);
  background-size: 250% 100%; animation: sheen 2.6s ease-in-out infinite;
}
@keyframes sheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@property --holo { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.face[data-tier="5"], .fcard[data-tier="5"] { animation: holo 3s linear infinite; }
@keyframes holo { to { --holo: 360deg; } }
.stamp[data-tier="4"] { background: linear-gradient(135deg, #d9a52a, #9c6a0e); }
.stamp[data-tier="5"] { background: linear-gradient(90deg, #ff4f9a, #ff9d3d, #3ccf8e, #2ec5e8, #7b4dff); }
.stamp[data-tier="6"] { background: #e6b93c; color: #111 !important; }
.stamp[data-tier="0"] { background: #8d877c; } .stamp[data-tier="1"] { background: var(--t1); } .stamp[data-tier="2"] { background: var(--t2); } .stamp[data-tier="3"] { background: var(--t3); }

/* waterfall */
.fall { width: min(100%, 980px); max-height: 100%; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; align-content: flex-start; padding: 4px; }
.mini { position: relative; width: 34px; height: 42px; border-radius: 6px; border: 2px solid var(--t0); background: #fbfaf6; display: grid; place-items: center; font-size: 22px; line-height: 1; font-weight: 700; animation: pop 260ms cubic-bezier(.2, 1.6, .4, 1) both; }
.mini[data-tier="1"] { border-color: var(--t1); background: #eef9f0; }
.mini[data-tier="2"] { border-color: var(--t2); background: #eaf0ff; }
.mini[data-tier="3"] { border-color: var(--t3); background: #f3ecff; box-shadow: 0 0 8px rgba(138, 79, 224, 0.6); }
.mini[data-tier="4"] { border-color: #c8932b; background: linear-gradient(135deg, #fff5d0, #f1cf6a); box-shadow: 0 0 12px rgba(255, 200, 70, 0.9); z-index: 1; }
.mini[data-tier="5"] { border-color: #ff4f9a; background: linear-gradient(135deg, #ffe3f0, #e3f6ff); box-shadow: 0 0 16px rgba(255, 79, 154, 0.95); z-index: 2; }
.mini[data-tier="6"] { border-color: #e6b93c; background: #111; color: #f5d77a; box-shadow: 0 0 22px rgba(255, 215, 90, 1); z-index: 3; transform: scale(1.15); }
.mini.is-new::after { content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); border: 1.5px solid var(--ink); }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } }
.fall-count { position: absolute; top: 4px; right: 12px; font-weight: 900; font-size: 22px; -webkit-text-stroke: 4px #fff; paint-order: stroke fill; font-variant-numeric: tabular-nums; z-index: 5; }

/* ------------------------------------------------------------ overlay: pre-reveal, banners */
#overlay { position: fixed; inset: 0; z-index: 40; pointer-events: none; display: grid; place-items: center; }
#overlay.active { pointer-events: auto; }
/* gachapon machine */
.gacha-stage { position: relative; width: 260px; height: 420px; animation: gmIn 380ms cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes gmIn { from { transform: translateY(40px) scale(0.7); opacity: 0; } }
.gm-title { height: 44px; display: grid; place-items: center; font-weight: 900; font-size: 26px; color: var(--yellow); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.gm-wrap { position: relative; width: 260px; height: 340px; transition: opacity 360ms ease, transform 360ms ease; }
.gm-wrap.away { opacity: 0; transform: translateY(24px) scale(0.86); }
svg.gm { display: block; width: 100%; height: 100%; overflow: visible; }
.gm-body { fill: #ff4f9a; transition: fill 300ms ease; }
.gacha-stage[data-lv="3"] .gm-body { fill: #ff3b30; }
.gacha-stage[data-lv="4"] .gm-body, .gacha-stage[data-lv="5"] .gm-body { fill: url(#gmGold); }
.gacha-stage[data-lv="6"] .gm-body, .gacha-stage[data-lv="7"] .gm-body { fill: url(#gmRainbow); }
.gm-label { font: 900 22px var(--ui); fill: var(--ink); letter-spacing: 0.02em; }
.gm-handle, .gm-caps { transform-box: fill-box; transform-origin: center; }
.gm-handle.turn { animation: gmTurn 560ms cubic-bezier(.5, 0, .3, 1); }
@keyframes gmTurn { to { transform: rotate(360deg); } }
.gm-caps.jiggle { animation: gmJiggle 280ms ease-in-out 2; }
@keyframes gmJiggle { 25% { transform: translate(-3px, -3px) rotate(-3deg); } 75% { transform: translate(3px, -1px) rotate(3deg); } }
.gm-caption { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font-weight: 900; font-size: 22px; white-space: nowrap; color: var(--shu); -webkit-text-stroke: 6px #fff; paint-order: stroke fill; }
.capsule { --cap: linear-gradient(#ffffff, #d9d9e3); position: absolute; left: 95px; top: 316px; width: 70px; height: 70px; border-radius: 50%; opacity: 0; z-index: 2; transition: transform 480ms cubic-bezier(.3, 1.3, .5, 1), box-shadow 300ms ease; }
.capsule.landed, .capsule.zoom { opacity: 1; }
.capsule i { position: absolute; left: 0; width: 70px; height: 35px; box-sizing: border-box; border: 4px solid var(--ink); transition: transform 380ms ease-out, opacity 380ms ease-out; }
.capsule .top { top: 0; border-radius: 35px 35px 0 0; border-bottom-width: 2px; background: var(--cap); }
.capsule .bot { bottom: 0; border-radius: 0 0 35px 35px; border-top-width: 2px; background: rgba(255, 255, 255, 0.95); }
.capsule .top::after { content: ""; position: absolute; left: 11px; top: 6px; width: 16px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.75); transform: rotate(-20deg); }
.capsule.c1 { --cap: linear-gradient(#8ec9ff, #2f8cff); box-shadow: 0 0 24px 6px rgba(60, 150, 255, 0.75); }
.capsule.c2 { --cap: linear-gradient(#9ff3c9, #22c07a); box-shadow: 0 0 26px 8px rgba(40, 210, 130, 0.8); }
.capsule.c3 { --cap: linear-gradient(#ffa59c, #ff3b30); box-shadow: 0 0 30px 10px rgba(255, 60, 50, 0.85); }
.capsule.c4 { --cap: linear-gradient(135deg, #fff3c4, #f2b705 55%, #c8932b); box-shadow: 0 0 40px 14px rgba(255, 200, 40, 1); }
.capsule.c5 { box-shadow: 0 0 46px 16px rgba(255, 150, 220, 1); }
.capsule.c5 .top { background: conic-gradient(from var(--holo, 0deg), #ff8fbf, #ffe066, #8ff0c0, #8fd9ff, #c7a6ff, #ff8fbf); animation: holo 1s linear infinite; }
.capsule.drop { animation: capDrop 620ms cubic-bezier(.3, 1.4, .5, 1) forwards; }
@keyframes capDrop { 0% { opacity: 0; transform: translateY(-34px) scale(0.5); } 30% { opacity: 1; } 60% { transform: translateY(12px) scale(1); } 80% { transform: translateY(-6px) scale(1); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
.capsule.up { animation: capUp 420ms ease-out; }
@keyframes capUp { 40% { transform: scale(1.35); filter: brightness(1.7); } }
.capsule.zoom { transform: translate(0, -186px) scale(2.3); }
.capsule.open .top { transform: translate(-46px, -54px) rotate(-38deg); opacity: 0; }
.capsule.open .bot { transform: translate(46px, 54px) rotate(30deg); opacity: 0; }
.cutin {
  position: fixed; left: -10%; right: -10%; top: 38%; transform: rotate(-7deg);
  display: grid; place-items: center; font-size: clamp(38px, 11vw, 88px); padding: 0.17em 0 0.29em;
  background: repeating-linear-gradient(90deg, #1d1b24 0 40px, #2c2a36 40px 80px);
  border-top: 8px solid var(--yellow); border-bottom: 8px solid var(--yellow); animation: cutin 900ms cubic-bezier(.2, 1.2, .3, 1) both; z-index: 45;
}
/* text size follows the band (em), and the band grows with the text: glyphs never leave it. JS shrinks long strings to fit the screen width. */
.cutin span { display: block; font-weight: 900; font-size: 1em; line-height: 1; color: #fff; -webkit-text-stroke: 0.07em var(--shu); paint-order: stroke fill; letter-spacing: 0.04em; white-space: nowrap; }
.cutin.hot { border-color: var(--shu); background: repeating-linear-gradient(90deg, #b3261b 0 40px, #e5402f 40px 80px); }
.cutin.hot span { -webkit-text-stroke-color: #1d1b24; color: var(--yellow); }
.cutin.sure { border-color: #fff; background: linear-gradient(90deg, #ff8fbf, #ffe066, #8ff0c0, #8fd9ff, #c7a6ff); }
.cutin.sure span { color: #fff; -webkit-text-stroke-color: #7b4dff; }
@keyframes cutin { 0% { transform: translateX(110%) rotate(-7deg); } 25% { transform: translateX(0) rotate(-7deg); } 80% { transform: translateX(0) rotate(-7deg); } 100% { transform: translateX(-110%) rotate(-7deg); } }
.banner { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 46; text-align: center; pointer-events: none; animation: bannerPop 1100ms cubic-bezier(.2, 1.6, .4, 1) both; }
.banner .b-main { font-weight: 900; font-size: clamp(40px, 13vw, 104px); line-height: 1.15; color: var(--yellow); -webkit-text-stroke: 0.08em var(--ink); paint-order: stroke fill; white-space: nowrap; text-shadow: 0 0.08em 0 var(--shu); }
.banner .b-sub { margin-top: 6px; font-weight: 900; font-size: clamp(16px, 4.5vw, 26px); color: #fff; -webkit-text-stroke: 0.2em var(--ink); paint-order: stroke fill; white-space: nowrap; }
.banner.pink .b-main { color: var(--pink); text-shadow: 0 0.08em 0 #7a1244; }
.banner.rainbow .b-main { background: linear-gradient(90deg, #ff4f9a, #ffb33d, #3ccf8e, #2ec5e8, #7b4dff); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 0.03em var(--ink); text-shadow: none; padding: 0 0.06em; }
.banner.small .b-main { font-size: clamp(28px, 8vw, 56px); }
@keyframes bannerPop { 0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; } 18% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 30% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.05); opacity: 0; } }
.unit-announce { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); z-index: 46; display: grid; justify-items: center; gap: 2px; background: rgba(255, 255, 255, 0.92); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 18px; box-shadow: 0 5px 0 var(--ink); animation: bannerPop2 2200ms ease both; pointer-events: none; }
.unit-announce .uk { font-size: clamp(34px, 9vw, 60px); font-weight: 700; line-height: 1.1; color: var(--shu); }
.unit-announce .ur { font-weight: 800; font-size: 14px; }
.unit-announce .up { font-size: 12px; color: var(--ink-2); font-weight: 700; }
@keyframes bannerPop2 { 0% { transform: translateX(-50%) translateY(-30px); opacity: 0; } 12% { transform: translateX(-50%) translateY(0); opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }

.judge { position: fixed; inset: 0; z-index: 47; display: grid; place-items: center; background: rgba(22, 11, 51, 0.55); }
.judge-box { display: grid; gap: 14px; justify-items: center; }
.judge-title { font-weight: 900; font-size: clamp(24px, 6vw, 40px); color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.judge-row { display: flex; gap: 22px; }
.jk { width: clamp(110px, 30vw, 170px); aspect-ratio: 1; border-radius: 18px; background: #fff; border: 5px solid var(--ink); display: grid; place-items: center; font-size: clamp(64px, 18vw, 110px); font-weight: 700; color: #c9c5d1; transition: transform 80ms; }
.jk.lit { color: var(--ink); background: var(--yellow); transform: scale(1.08); box-shadow: 0 0 40px 10px rgba(255, 220, 80, 0.9); }
.jk.end.lit { background: #cfd4e8; box-shadow: 0 0 30px 6px rgba(160, 170, 210, 0.9); }
.judge-rate { font-weight: 800; color: #fff; font-size: 17px; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-align: center; }
.judge-rate.lock { color: var(--yellow); font-size: 22px; }
.judge-note { margin-top: -6px; max-width: 88vw; text-align: center; font-weight: 700; font-size: 12px; color: #fff; background: rgba(29, 27, 36, 0.78); border-radius: 12px; padding: 4px 12px; line-height: 1.4; }

#flash { position: fixed; inset: 0; z-index: 63; background: #fff; opacity: 0; pointer-events: none; }
#flash.go { animation: flash 520ms ease-out; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
.shake { animation: shake 420ms cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake { 10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); } 30%, 50%, 70% { transform: translate(-7px, 3px); } 40%, 60% { transform: translate(7px, -3px); } }

.skip-btn { position: fixed; right: 12px; top: calc(78px + env(safe-area-inset-top, 0px)); z-index: 64; border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 var(--ink); }

/* ------------------------------------------------------------ cutscene / full card */
#cut { position: fixed; inset: 0; z-index: 61; display: grid; place-items: center; background: rgba(22, 11, 51, 0.55); }
#cut .rays { position: absolute; left: 50%; top: 50%; width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax; background: repeating-conic-gradient(from 0deg, var(--rc, rgba(255, 226, 120, 0.55)) 0deg 8deg, transparent 8deg 16deg); animation: spin 10s linear infinite; }
.cut-body { position: relative; display: grid; justify-items: center; gap: 12px; padding: 16px; max-width: 94vw; }
.cut-tier { font-weight: 900; font-size: clamp(56px, 16vw, 120px); line-height: 1; color: #fff; -webkit-text-stroke: 8px var(--shu); paint-order: stroke fill; animation: slam 520ms cubic-bezier(.2, 1.6, .4, 1) both; letter-spacing: 0.04em; }
.cut-tier[data-tier="5"] { -webkit-text-stroke-color: #7b4dff; }
.cut-tier[data-tier="6"] { color: #f5d77a; -webkit-text-stroke-color: #111; }
@keyframes slam { 0% { transform: scale(3) rotate(-12deg); opacity: 0; } 60% { transform: scale(0.9) rotate(-8deg); opacity: 1; } 100% { transform: scale(1) rotate(-8deg); } }
.fcard { position: relative; width: min(74vw, 300px); aspect-ratio: 5 / 7; border-radius: 16px; border: 5px solid var(--t0); background: #fbfaf6; display: grid; grid-template-rows: auto 1fr auto auto auto; overflow: hidden; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); }
.fcard .row1 { display: flex; justify-content: space-between; align-items: start; padding: 8px 10px 0; position: relative; z-index: 1; }
.fcard .stamp { font-size: 16px; font-weight: 900; color: #fff; background: var(--shu); padding: 0 8px; border-radius: 6px; transform: rotate(-6deg); line-height: 1.5; }
.fcard .one { font-size: 11px; font-weight: 800; opacity: 0.75; font-variant-numeric: tabular-nums; }
.fcard .gbox { position: relative; display: grid; place-items: center; margin: 4px 16%; }
.fcard .gbox::before { content: ""; position: absolute; inset: 4% 0; border: 1.5px solid rgba(229, 64, 47, 0.22); background:
  linear-gradient(to right, transparent calc(50% - 0.5px), rgba(229, 64, 47, 0.2) calc(50% - 0.5px), rgba(229, 64, 47, 0.2) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
  linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(229, 64, 47, 0.2) calc(50% - 0.5px), rgba(229, 64, 47, 0.2) calc(50% + 0.5px), transparent calc(50% + 0.5px)); }
.fcard .g { position: relative; font-size: min(38vw, 150px); line-height: 1; font-weight: 700; }
.fcard .g.reveal { animation: brush 700ms ease-out both; }
@keyframes brush { from { clip-path: inset(0 100% 0 0); filter: blur(4px); } to { clip-path: inset(0 0 0 0); filter: none; } }
.fcard .nm { text-align: center; font-weight: 900; font-size: 20px; line-height: 1.2; padding: 0 10px; position: relative; }
.fcard .rd { text-align: center; font-size: 12px; font-weight: 700; opacity: 0.85; padding: 2px 10px 0; position: relative; }
.fcard .st { display: flex; justify-content: center; gap: 10px; font-size: 12px; font-weight: 800; padding: 6px 10px 10px; position: relative; font-variant-numeric: tabular-nums; }
.fcard .st b { font-size: 10px; opacity: 0.7; margin-right: 2px; }
.fcard .newb { position: absolute; top: 10px; right: -34px; transform: rotate(35deg); background: var(--yellow); border: 2px solid var(--ink); font-weight: 900; font-size: 12px; padding: 1px 36px; z-index: 2; }
.cut-hint { font-weight: 800; color: #fff; font-size: 13px; opacity: 0.85; }

/* ------------------------------------------------------------ panels */
.panel { position: fixed; inset: 0; z-index: 70; background: var(--paper); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px; border-bottom: 2px solid var(--ink); background: #fff; }
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 900; flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px 14px calc(24px + env(safe-area-inset-bottom, 0px)); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.tab { flex: none; border: 2px solid var(--ink); background: #fff; border-radius: 10px; padding: 3px 10px; font-weight: 800; font-size: 13px; display: grid; justify-items: center; line-height: 1.2; }
.tab small { font-weight: 700; font-size: 10px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tab[aria-pressed="true"] { background: var(--yellow); box-shadow: 0 3px 0 var(--ink); }
.dex-progress { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; font-weight: 800; }
.bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(29, 27, 36, 0.1); overflow: hidden; border: 1.5px solid var(--ink); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); }
.dex-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.dex-grid .mini { width: 46px; height: 56px; font-size: 30px; cursor: pointer; animation: none; }
.dex-grid .mini .n { position: absolute; bottom: 1px; right: 3px; font: 800 9px var(--ui); color: var(--ink-2); }
.dex-grid .mini[data-tier="6"] .n { color: #f5d77a; }
.empty { color: var(--muted); font-weight: 700; padding: 20px 0; }
.more-btn { margin-top: 12px; border: 2px solid var(--ink); background: #fff; border-radius: 10px; padding: 4px 14px; font-weight: 800; }

.modal { position: fixed; inset: 0; z-index: 80; background: rgba(22, 11, 51, 0.6); display: grid; place-items: center; padding: 12px; }
.modal-card { background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; width: min(100%, 860px); max-height: 100%; overflow-y: auto; box-shadow: 0 10px 0 var(--ink); }
.modal-head { position: sticky; top: 0; display: flex; justify-content: flex-end; padding: 8px 10px 0; z-index: 3; }
.detail { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 18px; padding: 0 18px 20px; }
@media (max-width: 720px) { .detail { grid-template-columns: minmax(0, 1fr); justify-items: center; } .detail .info { width: 100%; } }
.info { display: grid; gap: 14px; align-content: start; }
.info h3 { margin: 0 0 4px; font-size: 13px; font-weight: 900; color: var(--ink-2); letter-spacing: 0.04em; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; font-size: 14px; }
.kv dt { color: var(--ink-2); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.regions { display: flex; gap: 8px; flex-wrap: wrap; }
.region { display: grid; justify-items: center; gap: 2px; }
.region .rg { width: 64px; height: 64px; display: grid; place-items: center; font-size: 46px; line-height: 1; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; }
.region small { font-size: 11px; font-weight: 800; color: var(--ink-2); }
.pill { display: inline-block; border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 800; margin: 0 4px 4px 0; background: #fff; }
.note { font-size: 12px; color: var(--muted); font-weight: 600; }
.link { color: var(--t2); font-weight: 800; }
.var-ch { font-size: 22px; font-weight: 700; margin-right: 6px; }
.settings-body { display: grid; gap: 18px; padding: 0 18px 22px; }
.settings-body section { display: grid; gap: 8px; }
.settings-body h3 { margin: 0; font-size: 14px; font-weight: 900; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.plain-btn { border: 2px solid var(--ink); background: #fff; border-radius: 10px; padding: 4px 12px; font-weight: 800; box-shadow: 0 3px 0 var(--ink); }
textarea.io { width: 100%; min-height: 70px; font: 12px ui-monospace, Menlo, monospace; border: 2px solid var(--ink); border-radius: 10px; padding: 6px; }
.credits { font-size: 12px; color: var(--ink-2); display: grid; gap: 4px; }
.credits a { color: var(--t2); }
select.sel { font: inherit; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 8px; background: #fff; font-weight: 700; }

/* level 7 text readability on dark cosmos */
body.lv7 .hud .dopa .label, body.lv7 .lvname { color: #fff; -webkit-text-stroke-color: #160b33; }
body.lv7 .dopa .value { color: #fff; -webkit-text-stroke-color: #160b33; }
body.lv7 .dopa .read { color: #ddd; -webkit-text-stroke-color: #160b33; }

/* reduced motion */
html.reduce .bg-rays, html.reduce .bg-rainbow, html.reduce #cut .rays { animation: none !important; }
html.reduce .face::after, html.reduce .fcard::after { animation: none !important; }
html.reduce .face[data-tier="5"], html.reduce .fcard[data-tier="5"], html.reduce .capsule.c5 .top { animation: none !important; }
html.reduce .shake { animation: none !important; }
@media (min-width: 900px) {
  .grid10 { gap: 16px; }
  .mini { width: 40px; height: 50px; font-size: 26px; }
}

/* ------------------------------------------------------------ long play: HUD, home, trophies, missions, ink */
button.mini-logo { border: 0; cursor: pointer; }
.dopa .total { font-size: 10px; font-weight: 800; color: var(--ink-2); -webkit-text-stroke: 3px #fff; paint-order: stroke fill; white-space: nowrap; }
body.lv7 .dopa .total { color: #ddd; -webkit-text-stroke-color: #160b33; }
.icon-btn.ico { position: relative; padding: 4px 7px; line-height: 0; }
.icon-btn.ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--shu); color: #fff; font: 900 11px/18px var(--ui); border: 2px solid #fff; }
.pk-extra { font-weight: 900; font-size: 12px; color: var(--pink); margin-left: 3px; }
.ticket-btn { border: 3px solid var(--ink); border-radius: 14px; padding: 5px 16px; font-weight: 900; font-size: 14px; color: #fff; box-shadow: 0 4px 0 var(--ink);
  background: linear-gradient(90deg, #ff4f9a, #ffb33d, #3ccf8e, #2ec5e8, #7b4dff); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.ticket-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.schip.ink { background: #1d1b24; color: #fff; }
.stage-home { position: absolute; left: 10px; top: 6px; z-index: 4; border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 2px 12px; font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 var(--ink); }

/* home */
.home { width: min(100%, 520px); max-height: 100%; overflow-y: auto; display: grid; gap: 10px; padding: 2px 2px 8px; }
.home-rank { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.92); border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.rank-badge { flex: none; font-weight: 900; font-size: 15px; color: #fff; background: var(--ink); border-radius: 10px; padding: 3px 10px; box-shadow: 0 3px 0 var(--shu); white-space: nowrap; }
.rank-badge.big { font-size: 22px; padding: 6px 14px; }
.rank-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.rank-info small { font-size: 11px; font-weight: 800; color: var(--ink-2); }
.rank-bar { height: 10px; border-radius: 5px; background: rgba(29, 27, 36, 0.1); border: 1.5px solid var(--ink); overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--purple)); }
.home-daily { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; background: linear-gradient(120deg, #fff8e0, #ffe9f3); border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; box-shadow: 0 3px 0 var(--ink); }
.hd-g { flex: none; width: 64px; height: 64px; display: grid; place-items: center; font-size: 48px; line-height: 1; font-weight: 700; background: #fff; border: 2px solid var(--shu); border-radius: 12px; }
.hd-t { display: grid; gap: 1px; min-width: 0; }
.hd-t b { font-size: 13px; color: var(--shu); }
.hd-n { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-t small { font-size: 11px; font-weight: 800; color: var(--pink); }
.home-mis { background: rgba(255, 255, 255, 0.92); border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; box-shadow: 0 3px 0 var(--ink); display: grid; gap: 6px; }
.hm-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hm-head b { font-size: 14px; }
.hm-head small { font-size: 11px; font-weight: 800; color: var(--ink-2); text-align: right; }
.hm-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.hm-row.big { font-size: 15px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.hm-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-row.big .hm-t { white-space: normal; }
.hm-bar { height: 8px; border-radius: 4px; background: rgba(29, 27, 36, 0.1); overflow: hidden; }
.hm-bar i { display: block; height: 100%; background: var(--pink); }
.hm-n { font-weight: 900; font-size: 12px; min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.hm-row.done .hm-t { color: var(--muted); text-decoration: line-through; }
.hm-row.done .hm-bar i { background: var(--green); }
.hm-row.done .hm-n { color: var(--green); }
.home-hint { margin: 0; font-weight: 700; color: var(--ink-2); font-size: 13px; background: rgba(255, 255, 255, 0.85); border-radius: 10px; padding: 6px 10px; }
.home .stats { font-size: 12px; color: var(--muted); text-align: center; font-weight: 700; }

/* toasts */
#toasts { position: fixed; left: 50%; top: calc(96px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 90; display: grid; gap: 6px; width: min(92vw, 380px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; background: #1d1b24; color: #fff; border-radius: 14px; padding: 7px 12px; box-shadow: 0 4px 0 var(--pink), 0 8px 20px rgba(0, 0, 0, 0.25); animation: toastIn 320ms cubic-bezier(.2, 1.5, .4, 1) both; }
.toast.out { animation: toastOut 320ms ease both; }
@keyframes toastIn { from { transform: translateY(-16px) scale(0.9); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }
.toast-t { display: grid; min-width: 0; line-height: 1.3; }
.toast-t b { font-size: 11px; color: var(--yellow); }
.toast-t span { font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* medals */
.medal { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 900 18px/1 var(--ui); color: #3b2600; border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 2px 0 var(--ink); }
.medal.sm { width: 30px; height: 30px; font-size: 14px; }
.medal.big { width: 58px; height: 58px; font-size: 26px; }
.m-none { background: #ecebf0; color: #b3afbd; box-shadow: none; border-style: dashed; border-color: #b3afbd; }
.m-bronze { background: radial-gradient(circle at 35% 30%, #ffd9b0, #cd7f32 60%, #8a4f1c); }
.m-silver { background: radial-gradient(circle at 35% 30%, #ffffff, #c0c4cc 60%, #7d8290); color: #2b2e36; }
.m-gold { background: radial-gradient(circle at 35% 30%, #fff6c8, #f2c230 55%, #b8860b); }
.m-plat { background: radial-gradient(circle at 35% 30%, #ffffff, #cfe9ff 50%, #7fb2e5); color: #173a5e; }
.m-rainbow { background: conic-gradient(#ff8fbf, #ffe066, #8ff0c0, #8fd9ff, #c7a6ff, #ff8fbf); color: #22123a; }
.m-rank { background: radial-gradient(circle at 35% 30%, #ffe1ef, #ff4f9a 60%, #b3165f); color: #fff; }
.toast .medal { border-color: #fff; box-shadow: none; }

/* trophy room */
.tro-sum { display: flex; align-items: center; gap: 12px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 3px 0 var(--ink); }
.tro-sum-i { flex: 1; min-width: 0; display: grid; gap: 4px; }
.tro-sum-i b { font-size: 13px; }
.tro-sum-i small { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.tro-list { display: grid; gap: 8px; margin-top: 6px; }
.tr { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; font: inherit; color: inherit; }
button.tr { cursor: pointer; border-color: rgba(29, 27, 36, 0.25); }
button.tr:hover { border-color: var(--ink); }
.tr.done { background: linear-gradient(90deg, #fffbe8, #ffffff 60%); border-color: #e6c35c; }
.tr.secret { background: #f4f3f7; }
.tr-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tr-name { font-weight: 900; font-size: 15px; }
.tr-desc { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tr-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.tr-pips { display: flex; gap: 2px; flex: none; }
.pip-m { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(29, 27, 36, 0.4); box-shadow: none; }
.pip-m.m-none { background: transparent; border-style: solid; }
.tr-bar { flex: 1; height: 7px; border-radius: 4px; background: rgba(29, 27, 36, 0.1); overflow: hidden; min-width: 40px; }
.tr-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.tr-num { flex: none; font-size: 11px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tro-mis { display: grid; gap: 4px; margin-top: 8px; }
.kv.records { margin-top: 12px; font-size: 15px; gap: 6px 16px; }
.set-body { padding: 0 18px 20px; display: grid; gap: 10px; }
.set-head { display: flex; gap: 14px; align-items: center; }
.set-head h3 { margin: 0; font-size: 22px; }
.set-count { font-size: 14px; }
.dex-grid .mini.miss { opacity: 0.38; border-style: dashed; background: #fff; box-shadow: none; filter: grayscale(0.6); }
.dex-grid .mini.miss:hover { opacity: 0.75; }
.exch { background: #fff7fb; border: 2px dashed var(--pink); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.btn-ink { justify-self: start; border: 3px solid var(--ink); border-radius: 12px; padding: 5px 16px; font-weight: 900; font-size: 15px; background: #1d1b24; color: #fff; box-shadow: 0 4px 0 var(--pink); }
.btn-ink[disabled] { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 380px) {
  .hud { gap: 6px; }
  .icon-btn.ico { padding: 4px 5px; }
  .hm-row { grid-template-columns: minmax(0, 1fr) 46px auto; }
}
@media (min-width: 900px) { .tro-list { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------ reward popup, how-to */
.reward { position: fixed; inset: 0; z-index: 88; display: grid; place-items: center; background: rgba(22, 11, 51, 0.6); padding: 16px; }
.reward-card { width: min(88vw, 340px); display: grid; justify-items: center; gap: 6px; background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; padding: 22px 20px 20px; text-align: center; box-shadow: 0 8px 0 var(--pink); animation: rewardIn 420ms cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes rewardIn { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } }
.reward-title { font-weight: 900; font-size: 28px; color: var(--pink); -webkit-text-stroke: 5px #fff; paint-order: stroke fill; line-height: 1.2; }
.reward-sub { font-weight: 800; font-size: 15px; color: var(--ink-2); }
.reward-items { display: grid; gap: 8px; margin: 10px 0 12px; }
.reward-item { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; font-size: 24px; }
.ri { flex: none; display: inline-block; }
.ri-pack { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--ink); background: linear-gradient(to bottom, var(--pink) 0 50%, #fff 50% 100%); }
.ri-ticket { width: 34px; height: 22px; border-radius: 6px; border: 3px solid var(--ink); background: linear-gradient(90deg, #ff4f9a, #ffb33d, #3ccf8e, #2ec5e8, #7b4dff); }
.ri-ink { width: 22px; height: 26px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #1d1b24; border: 3px solid var(--ink); }
.reward-ok { padding: 10px 40px; }
.packs { position: relative; }
.packs.gain { animation: packGain 900ms ease; }
@keyframes packGain { 0% { box-shadow: 0 0 0 0 rgba(255, 79, 154, 0.9); transform: scale(1); } 25% { transform: scale(1.12); } 100% { box-shadow: 0 0 0 16px rgba(255, 79, 154, 0); transform: scale(1); } }
.pk-float { position: absolute; right: -6px; top: -18px; font-weight: 900; font-size: 18px; color: var(--pink); -webkit-text-stroke: 4px #fff; paint-order: stroke fill; animation: pkFloat 1400ms ease-out forwards; pointer-events: none; }
@keyframes pkFloat { from { transform: translateY(8px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
.link-btn { border: 0; background: none; color: var(--t2); font-weight: 800; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 2px 6px; }
.howto-body { padding: 0 20px 22px; display: grid; gap: 10px; justify-items: start; }
.howto-body h2 { margin: 0; font-size: 22px; }
.howto-body p { margin: 0; font-size: 14px; font-weight: 600; }
.howto-body .how-lead { font-size: 15px; font-weight: 800; }
.how-table { width: 100%; border-collapse: collapse; font-size: 13px; font-weight: 700; }
.how-table th { text-align: left; font-size: 11px; color: var(--ink-2); padding: 4px 6px; border-bottom: 2px solid var(--ink); }
.how-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.how-table td.num { font-variant-numeric: tabular-nums; }
.how-table .stamp { display: inline-block; font-size: 12px; font-weight: 900; color: #fff; padding: 0 6px; border-radius: 4px; }
.how-ex { font-size: 26px; line-height: 1; font-weight: 700; }
.howto-body .btn-pop { justify-self: center; margin-top: 6px; }
.dex-note { margin: -4px 0 8px; }

/* chain result: best card and share */
.best-card { display: flex; align-items: center; gap: 8px; }
.best-card .stamp { font-size: 12px; font-weight: 900; color: #fff; padding: 0 6px; border-radius: 4px; }
.best-g { font-size: 34px; line-height: 1; font-weight: 700; }
.share-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.share-btn { font-size: 17px; padding: 8px 20px; background: linear-gradient(#5aa7ff, #2f62d0); }

/* rotating backgrounds: a centered square bigger than the screen diagonal, so no corner ever shows on wide screens */
#bg > .bg-rays, #bg > .bg-rainbow { inset: auto; left: 50%; top: 50%; width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax; }

/* back-to-title button (top left) */
.back-btn { display: inline-flex; align-items: center; gap: 2px; border: 2px solid var(--ink); background: var(--ink); color: #fff; border-radius: 10px; padding: 4px 9px 4px 5px; font-weight: 900; font-size: 13px; box-shadow: 0 3px 0 var(--shu); white-space: nowrap; }
.back-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.share-row { margin-bottom: 14px; }

/* new-character badge on rarity chips */
.tchip .nbadge { margin-left: 4px; background: var(--yellow); color: var(--ink); border-radius: 999px; padding: 0 5px; font-size: 11px; font-weight: 900; border: 1.5px solid var(--ink); }
.schip.newc { background: var(--yellow); }
/* tappable card in the big reveal */
.fcard.tappable { cursor: pointer; }
/* favorites and search */
.modal-head { gap: 8px; }
.fav-btn { border: 2px solid var(--ink); background: #fff; border-radius: 10px; padding: 3px 10px; font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 var(--ink); }
.fav-btn.on { background: var(--yellow); }
.tab.fav { border-color: #c8932b; }
.dex-search { margin: 0 0 10px; }
.dex-search input { width: 100%; font: 700 15px var(--ui); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; background: #fff; }
.dex-results { margin-top: 6px; }
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.fav-card { position: relative; aspect-ratio: 5 / 7; border-radius: 12px; cursor: pointer; }
.fav-card .g { font-size: clamp(40px, 11vw, 64px); }
.fav-card.miss { opacity: 0.45; }
.new-legend { margin-top: 6px; }
/* long units past 無量大数 (e.g. 12.3万無量大数) */
.dopa .unit.long { font-size: 0.75em; }
.dopa .unit.xlong { font-size: 0.6em; }

/* title footer: legal / support links */
.legal { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; margin-top: 4px; font-size: 12px; }
.legal a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
