:root { --o: #ff8a1e; --o2: #ffc04a; --p: #8b5cf6; --ink: #f4ead8; --panel: rgba(18, 9, 32, .92); --line: #3d2a5a; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { height: 100%; overflow: hidden; background: #0c0716; color: var(--ink); font-family: 'M PLUS 1p', sans-serif; touch-action: none; overscroll-behavior: none; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ===== HUD ===== */
#hud { position: fixed; inset: 0; pointer-events: none; }
#xpbar { position: absolute; top: 0; left: 0; right: 0; height: calc(14px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); background: rgba(8, 4, 18, .85); border-bottom: 2px solid #000; }
#xpfill { height: 100%; width: 0; background: linear-gradient(90deg, #2a6aff, #7ad8ff); box-shadow: 0 0 12px #5ab0ff; transition: width .12s; }
#lvtxt { position: absolute; right: 10px; bottom: 0; font: 800 11px 'M PLUS 1p'; line-height: 14px; text-shadow: 0 1px 2px #000; }
#hpbox { position: absolute; top: calc(24px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); display: flex; align-items: center; gap: 8px; }
#hpbar { width: min(180px, 34vw); height: 16px; background: #1a0a14; border: 2px solid #000; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px #5a2a3a; }
#hpfill { height: 100%; width: 100%; background: linear-gradient(#ff6a6a, #c21e3a); transition: width .15s; }
#hptxt { position: absolute; left: 0; top: 0; width: min(180px, 34vw); text-align: center; font: 800 11px "M PLUS 1p"; line-height: 20px; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
#inv { position: absolute; top: calc(50px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); display: flex; flex-wrap: wrap; gap: 4px; width: 164px; }
#inv .br { flex-basis: 100%; height: 0; }
.slot { width: 36px; height: 36px; background: rgba(15, 8, 28, .78); border: 1.5px solid var(--line); border-radius: 7px; position: relative; flex: none; }
.slot canvas { width: 100%; height: 100%; display: block; }
.slot i { position: absolute; right: 2px; bottom: 0; font: 800 9px 'M PLUS 1p'; font-style: normal; text-shadow: 0 1px 2px #000, 0 0 2px #000; color: #ffe0a0; }
#timer { position: absolute; top: calc(20px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font: 30px 'Dela Gothic One'; letter-spacing: 2px; text-shadow: 0 3px 0 #000, 0 0 16px rgba(255, 140, 30, .55); }
#kills { position: absolute; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; font: 800 14px 'M PLUS 1p'; text-shadow: 0 1px 3px #000; }
#btns { position: absolute; top: calc(22px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); display: flex; gap: 8px; pointer-events: auto; }
.ib { width: 42px; height: 42px; border-radius: 10px; background: rgba(20, 10, 35, .78); border: 2px solid var(--line); display: grid; place-items: center; }
.ib:active { transform: scale(.94); }
#bsound .x { display: none; }
#bsound.off .x { display: inline; }
#bsound.off .on { display: none; }
#bossbar { position: absolute; top: calc(90px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(520px, 78vw); text-align: center; }
#bossname { font: 17px 'Dela Gothic One'; color: #ffb08a; text-shadow: 0 2px 0 #000, 0 0 12px rgba(255, 60, 30, .6); margin-bottom: 4px; letter-spacing: 2px; }
#bosshp { height: 14px; background: #1a0a14; border: 2px solid #000; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px #6a2a1a, 0 0 18px rgba(255, 60, 30, .35); }
#bossfill { height: 100%; width: 100%; background: linear-gradient(#ff9a4a, #c2381e); transition: width .12s; }
#banner { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font: clamp(24px, 5.4vw, 44px) 'Dela Gothic One'; color: #ffd27a; text-shadow: 0 4px 0 #2a0e00, 0 0 24px rgba(255, 140, 30, .6); opacity: 0; padding: 0 16px; }
#banner.warn { color: #ff5a4a; text-shadow: 0 4px 0 #2a0000, 0 0 30px rgba(255, 30, 30, .8); }
#banner.show { animation: ban 2.8s ease forwards; }
@keyframes ban { 0% { opacity: 0; transform: scale(1.5); letter-spacing: 10px; } 12% { opacity: 1; transform: scale(1); letter-spacing: 2px; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
#toast { position: absolute; bottom: calc(150px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 10px); background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 16px; font: 700 14px 'M PLUS 1p'; opacity: 0; transition: .3s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#dashbtn { position: absolute; right: calc(24px + env(safe-area-inset-right)); bottom: calc(34px + env(safe-area-inset-bottom)); width: 100px; height: 100px; border-radius: 50%; pointer-events: auto; font: 17px 'Dela Gothic One'; letter-spacing: 1px; color: #fff; text-shadow: 0 2px 0 #000;
  background: radial-gradient(circle, rgba(30, 16, 50, .9) 56%, transparent 57%), conic-gradient(rgba(255, 160, 40, .95) calc(var(--cd, 1) * 360deg), rgba(60, 40, 90, .7) 0);
  border: 3px solid rgba(255, 220, 160, .5); display: none; touch-action: none; }
#dashbtn.ready { border-color: #ffd27a; box-shadow: 0 0 18px rgba(255, 170, 60, .5); }
#dashbtn:active { transform: scale(.94); }
.touch #dashbtn { display: block; }

/* ===== 画面 ===== */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); overflow-y: auto; touch-action: pan-y; }
.screen h2 { font: clamp(26px, 6vw, 40px) 'Dela Gothic One'; color: var(--o2); text-shadow: 0 4px 0 #2a0e00, 0 0 24px rgba(255, 140, 30, .5); text-align: center; }
.big { font: 20px 'Dela Gothic One'; letter-spacing: 2px; padding: 15px 44px; border-radius: 14px; background: linear-gradient(#ffa63a, #e2600e); color: #2a0e00; box-shadow: 0 5px 0 #7a2a00, 0 0 30px rgba(255, 130, 30, .35); border: 2px solid #ffd58a; min-width: 180px; }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #7a2a00; }
.big:disabled { opacity: .5; }
.big.ghost { background: rgba(30, 16, 50, .9); color: var(--ink); border-color: var(--line); box-shadow: 0 5px 0 #0a0414; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

#title { background: radial-gradient(ellipse at 50% 30%, rgba(40, 10, 60, .15), rgba(6, 2, 14, .55) 70%); justify-content: center; }
.logo { position: relative; text-align: center; margin-bottom: 2px; }
.logo .moon { position: absolute; width: clamp(90px, 18vw, 150px); aspect-ratio: 1; border-radius: 50%; right: -8%; top: -30%; background: radial-gradient(circle at 40% 40%, #fff8d8, #f2d88a 60%, #c8a050); box-shadow: 0 0 60px rgba(255, 230, 150, .5), 0 0 140px rgba(255, 200, 100, .25); z-index: -1; opacity: .9; }
.logo .en { font: clamp(46px, 12vw, 112px) 'Creepster', cursive; letter-spacing: 3px; line-height: .95; background: linear-gradient(#ffe08a, #ff8a1e 55%, #c2380e); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #2a0800) drop-shadow(0 0 22px rgba(255, 120, 20, .55)); }
.logo .jp { font: clamp(16px, 3.6vw, 26px) 'Dela Gothic One'; letter-spacing: .4em; color: #e8d8ff; text-shadow: 0 2px 0 #000, 0 0 14px rgba(160, 100, 255, .7); margin-top: 4px; }
.tag { font-weight: 700; font-size: clamp(14px, 3.2vw, 17px); text-shadow: 0 2px 4px #000; }
.tag b { color: var(--o2); font-size: 1.2em; }
#chars { display: flex; gap: 12px; justify-content: center; flex-wrap: nowrap; width: 100%; max-width: 640px; }
.char { flex: 1 1 0; max-width: 200px; min-width: 0; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform .15s, border-color .15s, box-shadow .15s; }
.char.sel { border-color: var(--hc); box-shadow: 0 0 0 2px var(--hc), 0 0 28px color-mix(in srgb, var(--hc) 45%, transparent); transform: translateY(-4px); }
.char .cport { width: 100%; max-width: 120px; aspect-ratio: 1; }
.cn { font: 19px 'Dela Gothic One'; color: var(--hc); }
.ct { font-size: 12px; font-weight: 700; opacity: .8; }
.cw { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; margin-top: 4px; background: rgba(255, 255, 255, .06); border-radius: 6px; padding: 2px 8px 2px 2px; }
.cw .wic { width: 24px; height: 24px; }
.cnote { font-size: 11px; opacity: .75; text-align: center; line-height: 1.35; margin-top: 2px; }
.cbest { font-size: 11px; color: var(--o2); font-weight: 800; min-height: 1em; }
.howto { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; opacity: .85; text-align: center; text-shadow: 0 1px 3px #000; }
.howto .sp { display: none; }
.touch .howto .sp { display: inline; }
.touch .howto .pc { display: none; }
kbd { font: 800 11px 'M PLUS 1p'; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.gold { color: #ffd84a; }

#levelup, #chest, #pause, #result { background: rgba(6, 2, 14, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#levelup h2 small { font-size: .55em; color: #e8d8ff; margin-left: 6px; }
.sub { font-weight: 700; opacity: .8; margin-top: -8px; }
#cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; max-width: 960px; }
.card { position: relative; width: 210px; background: linear-gradient(170deg, #2a1648, #140a26); border: 2px solid #5a3a8a; border-radius: 16px; padding: 16px 14px 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; animation: cardin .35s ease both; box-shadow: 0 8px 0 #07020f; }
.card.pas { background: linear-gradient(170deg, #1a2a48, #0a1426); border-color: #3a5a8a; }
.card.new::before { content: 'NEW'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: linear-gradient(#ffd27a, #ff8a1e); color: #2a0e00; font: 12px 'Dela Gothic One'; padding: 2px 10px; border-radius: 6px; letter-spacing: 1px; }
.card:hover, .card:focus-visible { border-color: var(--o2); transform: translateY(-4px); box-shadow: 0 12px 0 #07020f, 0 0 24px rgba(255, 180, 60, .35); outline: none; }
.card:active { transform: translateY(1px); }
.cic { width: 76px; height: 76px; background: radial-gradient(circle, rgba(255, 255, 255, .1), transparent 70%); border-radius: 50%; }
.cname { font: 18px 'Dela Gothic One'; color: #fff; }
.clv { font: 800 12px 'M PLUS 1p'; color: var(--o2); }
.cdesc { font-size: 13px; font-weight: 700; line-height: 1.5; opacity: .9; }
.ckey { position: absolute; top: 8px; left: 10px; font: 800 11px 'M PLUS 1p'; opacity: .45; }
.touch .ckey { display: none; }
@keyframes cardin { from { opacity: 0; transform: translateY(26px) scale(.92); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); } }

#chestimg svg { display: block; filter: drop-shadow(0 0 26px rgba(255, 200, 80, .4)); animation: wob 1.2s ease-in-out infinite; }
#chestimg .lid { transform-box: view-box; transform-origin: 60px 44px; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); }
#chestimg .glow { opacity: 0; }
#chestimg.open svg { animation: none; }
#chestimg.open .lid { transform: translateY(-26px) rotate(-18deg); }
#chestimg.open .glow { opacity: 1; filter: drop-shadow(0 -10px 20px #ffe08a); }
@keyframes wob { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
#chestcards { width: 100%; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; min-height: 10px; }
#chestcards .card { width: 190px; animation: pop .35s ease; }
.slotspin { width: 190px; height: 200px; border-radius: 16px; border: 2px dashed #ffd27a; display: grid; place-items: center; background: rgba(40, 20, 60, .8); }
.slotspin canvas { width: 76px; height: 76px; }

.rinv { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 420px; }
.rinv .slot { width: 46px; height: 46px; }
#rport { width: 140px; height: 140px; }
#result.win h2 { color: #ffe08a; }
#rstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(420px, 100%); }
#rstats div { background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; }
#rstats span { font-size: 12px; opacity: .7; font-weight: 700; }
#rstats b { font: 22px 'Dela Gothic One'; color: var(--o2); }

@media (max-width: 640px) {
  .card { width: 100%; max-width: 400px; flex-direction: row; text-align: left; padding: 12px 14px; gap: 12px; }
  .card .ctx { flex: 1; }
  .cic { width: 60px; height: 60px; flex: none; }
  .card.new::before { left: auto; right: 12px; transform: none; }
  #cards { width: 100%; flex-direction: column; align-items: center; gap: 10px; }
  .cname { font-size: 17px; }
  #chars { gap: 8px; }
  .char { padding: 6px 4px 8px; border-radius: 12px; }
  .cn { font-size: 16px; }
  .cnote { font-size: 10px; }
  .cw { font-size: 10px; }
  #timer { font-size: 24px; }
  #kills { top: calc(52px + env(safe-area-inset-top)); }
  #inv { width: 124px; }
  .slot { width: 28px; height: 28px; border-radius: 6px; }
  #bossbar { top: calc(80px + env(safe-area-inset-top)); }
  .big { padding: 13px 34px; font-size: 18px; min-width: 150px; }
  #chestcards .card, .slotspin { width: 100%; max-width: 360px; }
  .slotspin { height: 90px; }
}
@media (max-height: 560px) {
  .screen { justify-content: flex-start; }
  .logo .en { font-size: 48px; }
  .char .cport { max-width: 76px; }
  .howto { display: none; }
}

/* ===== 進化 ===== */
.card.evo { background: linear-gradient(170deg, #5a3a0a, #2a1404); border-color: #ffd27a; box-shadow: 0 8px 0 #07020f, 0 0 30px rgba(255, 190, 70, .55); }
.card.evo .cname { color: #ffe08a; }
.chint { font-size: 11px; font-weight: 800; color: #c9a8ff; background: rgba(160, 100, 255, .14); border-radius: 6px; padding: 2px 8px; }
.card.pas .chint { color: #ffd27a; background: rgba(255, 200, 80, .12); }
.slot.evo { border-color: #ffd27a; box-shadow: 0 0 10px rgba(255, 190, 70, .55); }
.slot.evo i { color: #fff2b0; }
#precipes { display: flex; flex-direction: column; gap: 5px; width: min(440px, 100%); background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 700; }
#precipes b { font: 14px 'Dela Gothic One'; color: var(--o2); }
#precipes div { opacity: .75; }
#precipes .ready { opacity: 1; color: #ffe08a; }
#precipes .done { opacity: 1; color: #c9a8ff; }
