* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overscroll-behavior: none; }
body { background: #fdf6e3; font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", sans-serif; color: #333;
  background-image: linear-gradient(#ebe2cb 1px, transparent 1px); background-size: 100% 28px; }
#app { max-width: 460px; margin: 0 auto; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
header { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
header b { flex: 1; font-size: 19px; }
.pill { background: #fff; border: 2px solid #333; border-radius: 99px; padding: 1px 10px; font-weight: bold; font-size: 14px; }
.screen { display: flex; flex-direction: column; gap: 8px; }
.hidden { display: none !important; }
.card { background: #fff; border: 3px solid #333; border-radius: 14px; padding: 10px; box-shadow: 3px 3px 0 #333; }
.center { text-align: center; }
.name { font-weight: bold; font-size: 18px; }
.small { font-size: 12px; color: #6a6a6a; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; }
button { font: inherit; font-weight: bold; padding: 11px; border: 3px solid #333; border-radius: 12px; background: #fff; color: #333;
  box-shadow: 3px 3px 0 #333; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button:active, button.on:not(.chip):not(.swatch) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #333; }
button:disabled { opacity: .4; }
button.big { background: #ffd54f; font-size: 18px; }
button.ghost { background: transparent; box-shadow: none; border-style: dashed; font-weight: normal; }
.tog { font-size: 12px; display: block; }

/* ホーム */
.hero canvas { width: 72%; aspect-ratio: 1; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1.5deg); } }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 11px; text-align: center; margin: 6px 0 2px; }
.stats div { background: #faf6ec; border-radius: 8px; padding: 3px 0; } .stats b { display: block; font-size: 16px; }
.special { display: flex; gap: 10px; align-items: center; } .special .ic { font-size: 30px; } .special b { font-size: 15px; }
.rar { font-size: 11px; font-weight: bold; padding: 0 6px; border-radius: 6px; color: #fff; }

/* お絵かき */
.slots { display: flex; gap: 4px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.slots button { flex: 0 0 auto; padding: 5px 9px; font-size: 13px; border-width: 2px; box-shadow: 2px 2px 0 #333; position: relative; }
.slots button span { margin-right: 2px; }
.slots button.on { background: #ffd54f; }
.slots button.done::after { content: '✓'; position: absolute; top: -6px; right: -4px; background: #4cd964; color: #fff; border-radius: 99px; font-size: 10px; padding: 0 4px; }
.canvas-box { position: relative; border: 3px solid #333; border-radius: 14px; overflow: hidden; background: #fffdf6; box-shadow: 3px 3px 0 #333; }
#draw-cv { width: 100%; aspect-ratio: 1; display: block; touch-action: none; }
.tools { position: relative; align-items: flex-start; min-height: 30px; }
.mini { position: absolute; right: 6px; top: 6px; width: 68px; background: rgba(255,255,255,.92); border: 2px solid #333; border-radius: 10px; transition: width .2s; cursor: pointer; z-index: 3; }
.mini.big { width: 220px; } .mini canvas { width: 100%; display: block; } .mini .small { font-size: 10px; margin-bottom: 2px; }
.chip { padding: 4px 10px; font-size: 13px; border-width: 2px; box-shadow: 2px 2px 0 #333; border-radius: 99px; }
.chip.on { background: #bff0c0; }
.palette { display: flex; gap: 5px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.swatch { flex: 0 0 28px; height: 28px; padding: 0; border-radius: 99px; border-width: 2px; box-shadow: none; }
.swatch.on { outline: 3px solid #ff9f43; outline-offset: 1px; }
.ink-row { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.ink-bar { flex: 1; height: 12px; background: #eee; border: 2px solid #333; border-radius: 99px; overflow: hidden; }
#ink-fill { height: 100%; background: #333; transition: width .1s; }
.actionbar { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 8px 0 calc(4px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, #fdf6e3 30%); }
.actionbar button { flex: 1; } .actionbar .big { flex: 1.4; }

/* バトル */
.battle-top { display: flex; align-items: center; justify-content: space-between; }
.time { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.stage-wrap { position: relative; border: 3px solid #333; border-radius: 14px; overflow: hidden; box-shadow: 3px 3px 0 #333; }
#battle-cv { width: 100%; height: 50vh; min-height: 280px; max-height: 480px; display: block; touch-action: none; }
.banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.3); opacity: 0; pointer-events: none;
  font-size: 54px; font-weight: 900; color: #fff; -webkit-text-stroke: 3px #2d2a32; white-space: nowrap; }
.banner.show { animation: banner 1s ease-out forwards; }
.banner.ko { color: #ff5a5a; } .banner.crit { color: #ffcc00; font-size: 36px; top: 25%; } .banner.game { color: #ffd54f; font-size: 64px; }
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { transform: translate(-50%, -60%) scale(1); opacity: 0; } }
.hud { display: flex; gap: 8px; }
.hud-card { flex: 1; display: flex; gap: 6px; align-items: center; background: #fff; border: 3px solid #333; border-radius: 12px; padding: 4px 6px; box-shadow: 3px 3px 0 #333; min-width: 0; }
.hud-card.a { border-color: #e74c3c; } .hud-card.b { border-color: #2e86de; }
.hud-card canvas { width: 46px; height: 46px; flex: 0 0 46px; }
.hud-card > div { min-width: 0; }
.hud-name { font-size: 11px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-pct { font-size: 28px; font-weight: 900; line-height: 1; -webkit-text-stroke: 1.5px #2d2a32; font-variant-numeric: tabular-nums; }
.hud-pct.bump { animation: bump .25s; } @keyframes bump { 40% { transform: scale(1.3) rotate(-4deg); } }
.hud-stock { font-size: 11px; letter-spacing: 1px; } .hud-sp { font-size: 10px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; user-select: none; -webkit-user-select: none; }
.train-bar { position: absolute; left: 6px; right: 6px; top: 6px; z-index: 4; pointer-events: none; }
.train-bar .row { gap: 5px; pointer-events: auto; }
.train-bar .chip { flex: 1; font-size: 11px; padding: 4px 2px; background: rgba(255,255,255,.92); white-space: nowrap; }
#tr-info { margin-top: 5px; min-height: 1.3em; display: inline-block; background: rgba(255,255,255,.85); border-radius: 8px; padding: 1px 8px; color: #555; }
#tr-info b { color: #e17055; }
.stick { position: relative; width: 132px; height: 132px; border-radius: 50%; background: radial-gradient(circle, #fff 0 55%, #f1ece0 56%); border: 3px solid #333; box-shadow: 3px 3px 0 #333; touch-action: none; margin-left: 4px; }
.stick::before { content: '▲\A◀　　　　　▶\A▼'; white-space: pre; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13px; line-height: 2.6; color: #bbb; pointer-events: none; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: #555; border: 3px solid #333; box-shadow: inset -4px -4px 0 rgba(0,0,0,.25); pointer-events: none; transition: transform .03s; }
.abtn { position: relative; width: 176px; height: 150px; justify-self: end; }
.abtn button { position: absolute; width: 64px; height: 64px; border-radius: 99px; padding: 0; font-size: 22px; font-weight: 900; touch-action: none; display: flex; align-items: center; justify-content: center; }
.abtn .a { right: 0; top: 43px; background: #ff6b6b; color: #fff; -webkit-text-stroke: 1px #333; }
.abtn .b { left: 56px; bottom: 0; background: #ffd54f; }
.abtn .jump { left: 56px; top: 0; width: 64px; height: 44px; font-size: 13px; background: #b9f6ca; }
.abtn .shield { left: 0; top: 46px; width: 54px; height: 54px; font-size: 13px; background: linear-gradient(0deg, #82b1ff var(--sh, 100%), #e3ecff var(--sh, 100%)); }
.abtn .b.ready { background: linear-gradient(135deg, #ff6ec7, #7c4dff, #40c4ff); color: #fff; animation: pulse .6s infinite alternate; }
.abtn .b.ready::after { content: '超'; position: absolute; top: -6px; right: -6px; font-size: 12px; background: #333; color: #fff; border-radius: 99px; padding: 1px 5px; }
.pad button.on { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #333; filter: brightness(.9); }
.help { grid-column: span 2; text-align: center; }

/* 共通オーバーレイ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.overlay .card { max-width: 380px; width: 100%; max-height: 90vh; overflow-y: auto; }
.pop { animation: pop .3s both; } @keyframes pop { from { transform: scale(.8); opacity: 0; } }
.win { color: #e67e22; font-size: 34px; font-weight: 900; } .lose { color: #2e86de; font-size: 30px; font-weight: 900; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 40px); opacity: 0; transition: .25s; background: #333; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 13px; z-index: 20; max-width: 90%; text-align: center; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.combo { position: absolute; top: 12%; font-weight: 900; font-size: 18px; color: #fff; -webkit-text-stroke: 1.5px #2d2a32; opacity: 0; pointer-events: none; }
.combo b { font-size: 40px; color: #ffcc00; }
.combo.a { left: 10px; } .combo.b { right: 10px; text-align: right; }
.combo.show { animation: combo 1.1s ease-out forwards; }
@keyframes combo { 0% { opacity: 1; transform: scale(1.5); } 15% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #fff; }
.flash.ko { background: #fff3c4; } .flash.crit { background: #ffd6d6; }
.flash.show { animation: flash .22s ease-out; }
@keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }
.tip { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(45,42,50,.85); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 99px; opacity: 0; transition: .2s; pointer-events: none; white-space: nowrap; }
.tip.show { opacity: 1; }
.movelist { position: absolute; inset: 8px; background: rgba(255,255,255,.96); border: 2px solid #333; border-radius: 10px; padding: 8px; font-size: 12px; overflow-y: auto; }
.movelist table { width: 100%; border-collapse: collapse; margin-top: 4px; } .movelist td { border-bottom: 1px dashed #ddd; padding: 3px 2px; }
.movelist td:first-child { font-weight: bold; white-space: nowrap; color: #e67e22; }

.tool-row { display: flex; gap: 4px; }
.tool { flex: 1; padding: 6px 0; font-size: 16px; border-width: 2px; box-shadow: 2px 2px 0 #333; }
.tool.on { background: #ffd54f; }
.width-row { display: flex; gap: 4px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.wbtn { flex: 0 0 auto; padding: 3px 7px; font-size: 11px; border-width: 2px; box-shadow: none; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 34px; }
.wbtn i { display: block; width: 18px; background: #2d2a32; border-radius: 9px; }
.wbtn.on { background: #ffd54f; }
.swatch.sm { flex: 0 0 22px; height: 22px; }
.fbtn { flex: 0 0 auto; padding: 3px 7px; font-size: 11px; border-width: 2px; box-shadow: none; }
.fbtn.on { background: #ffd54f; }
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tpl { padding: 4px; display: flex; flex-direction: column; align-items: center; font-size: 11px; box-shadow: 2px 2px 0 #333; border-width: 2px; }
.tpl canvas { width: 100%; aspect-ratio: 1; }

.meter { height: 6px; background: #eee; border: 1.5px solid #333; border-radius: 99px; overflow: hidden; margin: 2px 0; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd54f, #ff7043); transition: width .2s; }
.meter.full i { background: linear-gradient(90deg, #ff6ec7, #7c4dff, #40c4ff, #ffd54f); background-size: 300% 100%; animation: rainbow 1s linear infinite; }
@keyframes rainbow { to { background-position: 300% 0; } }
@keyframes pulse { to { transform: scale(1.08); } }
.supercut { position: absolute; left: 0; right: 0; top: 30%; height: 90px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: linear-gradient(90deg, rgba(45,42,50,.92), rgba(124,77,255,.85)); color: #fff; opacity: 0; pointer-events: none; transform: translateX(-100%); }
.supercut.b { flex-direction: row-reverse; text-align: right; background: linear-gradient(270deg, rgba(45,42,50,.92), rgba(255,112,67,.85)); transform: translateX(100%); }
.supercut canvas { width: 84px; height: 84px; background: #fff; border-radius: 10px; border: 2px solid #fff; }
.supercut small { display: block; font-size: 11px; opacity: .8; } .supercut b { font-size: 24px; -webkit-text-stroke: 1px #2d2a32; }
.supercut.show { animation: cut 1.1s ease-out forwards; }
@keyframes cut { 0% { opacity: 1; } 15% { transform: none; opacity: 1; } 80% { transform: none; opacity: 1; } 100% { opacity: 0; transform: none; } }

.sub-head { display: flex; align-items: center; gap: 8px; } .sub-head b { flex: 1; font-size: 17px; }
.itm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.itm { padding: 4px; display: flex; flex-direction: column; align-items: center; position: relative; border-width: 2px; box-shadow: 2px 2px 0 #333; font-size: 10px; }
.itm canvas { width: 100%; aspect-ratio: 1; } .itm .q { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 28px; color: #bbb; }
.itm.on { background: #fff3c4; outline: 3px solid #ff9f43; } .itm.lock { opacity: .55; }
.itm .rdot { position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; border-radius: 9px; }
.itm .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.adjust .row { margin-top: 6px; } .adjust button { padding: 6px 0; font-size: 13px; }
.sk-list { display: flex; flex-direction: column; gap: 8px; }
.sk-slot { background: #fff; border: 3px solid #333; border-radius: 12px; padding: 6px 8px; box-shadow: 3px 3px 0 #333; cursor: pointer; }
.skc { border: 2.5px solid #999; border-radius: 10px; padding: 6px 8px; background: #fff; }
.skc.pick { cursor: pointer; } .skc.pick.on { background: #fff3c4; } .skc.lock { opacity: .5; }
.skc-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.gacha-btn { background: linear-gradient(135deg, #ffd54f, #ff8a80); }
.machine { display: flex; flex-direction: column; gap: 6px; } .machine.skill { background: #fff8e1; } .machine.item { background: #f3e5f5; }
.machine small { font-size: 10px; font-weight: normal; }
.caps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 8px; }
.cap { border: 2px solid #333; border-radius: 10px; padding: 6px; font-size: 12px; animation: capin .4s both; display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; }
.cap canvas { width: 48px; height: 48px; }
.cap .ball { width: 26px; height: 26px; border-radius: 99px; border: 2px solid #333; }
.cap .tag { font-weight: 900; color: #e67e22; font-size: 11px; }
.cap.r-SSR { background: linear-gradient(135deg, #fff3c4, #ffd6f0, #d6ecff); box-shadow: 0 0 12px #ffcc00; }
.cap.r-SR { background: #f3e5f5; }
@keyframes capin { from { transform: scale(0) rotate(-20deg); opacity: 0; } 70% { transform: scale(1.15); } }
.gacha-res.SSR { box-shadow: 0 0 0 4px #ffcc00, 0 0 30px #ff6ec7; }
.skchip { display: inline-block; border: 2px solid #999; border-radius: 99px; padding: 1px 7px; margin: 2px 3px 0 0; font-size: 11px; font-weight: bold; background: #fff; }

.rig-bar { padding: 8px 10px; background: #f3f8ff; } .rig-bar .row { margin-top: 6px; } .rig-bar button { padding: 8px; font-size: 13px; }
#draw.rig .tool-row, #draw.rig .width-row, #draw.rig .tools, #draw.rig .palette, #draw.rig .slots { display: none; }

.bt { text-align: left; margin: 6px 0; font-size: 12px; }
.bt-type { margin-bottom: 3px; } .bt-type b { color: #e67e22; }
.bt-row { display: grid; grid-template-columns: 54px 1fr 36px; align-items: center; gap: 4px; }
.bt-row small { grid-column: 1 / -1; color: #888; font-size: 10px; margin: -2px 0 3px 58px; }
.bt-bar { position: relative; height: 8px; background: #eee; border: 1.5px solid #333; border-radius: 99px; }
.bt-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #ffb74d; border-radius: 99px; }
.bt-bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #333; }
.bt-row em { font-style: normal; font-weight: bold; text-align: right; }

/* PC・横長画面：バトル中はステージを大きく。マウス操作の端末ではタッチ用ボタンを隠してキー説明だけ出す */
@media (min-width: 820px) {
  body.in-battle #app { max-width: min(1180px, 96vw); }
  body.in-battle #battle-cv { height: min(66vh, calc(96vw * 9 / 16)); max-height: 680px; }
  body.in-battle .hud, body.in-battle .pad { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
  body.in-battle .hud-pct { font-size: 34px; }
}
@media (min-width: 820px) and (hover: hover) and (pointer: fine) {
  body.in-battle .pad .stick, body.in-battle .pad .abtn { display: none; }
  body.in-battle .pad .help { font-size: 13px; padding: 6px; background: #fff; border: 2px dashed #bbb; border-radius: 10px; }
}
