@font-face { font-family: 'Bangers'; src: url('fonts/Bangers-Regular.ttf') format('truetype'); font-display: swap; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0618; color: #fff; overscroll-behavior: none;
  font-family: 'Bangers', 'Avenir Next Condensed', 'Arial Black', Impact, sans-serif; letter-spacing: .04em;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }
#safe { position: fixed; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.hidden { display: none !important; }
button { font-family: inherit; letter-spacing: .06em; color: #fff; cursor: pointer; border: 3px solid #1b1026; border-radius: 14px;
  background: linear-gradient(#5b3bd6, #3a1fa0); box-shadow: 0 5px 0 #1b1026, inset 0 2px 0 rgba(255,255,255,.3); font-size: 22px; padding: 10px 22px; touch-action: manipulation; }
button:active { transform: translateY(3px); box-shadow: 0 2px 0 #1b1026; }
button.big { font-size: 30px; background: linear-gradient(#ff5a3a, #d0201a); padding: 10px 36px; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 10px) calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 10px); }
.screen.dim { background: rgba(8,4,20,.78); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.menu { display: flex; flex-direction: column; gap: 14px; align-items: stretch; min-width: 240px; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.logo { text-align: center; transform: rotate(-4deg); filter: drop-shadow(0 6px 0 #1b1026); }
.logo .l0 { font-size: 20px; color: #9ff; text-shadow: 2px 2px 0 #1b1026; }
.logo .l1 { font-size: clamp(54px, 15vw, 110px); line-height: .9; color: #ffd23a; -webkit-text-stroke: 3px #1b1026; text-shadow: 0 0 22px rgba(255,120,0,.6), 5px 5px 0 #e0331a; }
.logo .l2 { font-size: clamp(30px, 8vw, 58px); line-height: 1; color: #7dff6a; -webkit-text-stroke: 2px #1b1026; text-shadow: 4px 4px 0 #6a2bd0; }
.hint { font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 12px; opacity: .75; text-align: center; max-width: 520px; line-height: 1.5; }
.coin { color: #ffd23a; }

/* ---------- character select ---------- */
#select { justify-content: flex-start; gap: 8px; background: radial-gradient(ellipse at 50% 30%, rgba(80,20,140,.55), rgba(5,2,15,.9)); }
.selhead { font-size: 34px; color: #ffd23a; -webkit-text-stroke: 1.5px #1b1026; text-shadow: 3px 3px 0 #e0331a; transform: skewX(-10deg); }
.selbody { flex: 1; width: 100%; max-width: 980px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.panel { position: relative; flex: 1; min-height: 0; display: flex; gap: 6px; border: 4px solid #ffd23a; border-radius: 16px; overflow: hidden;
  background: linear-gradient(135deg, var(--fc, #3a1fa0) 0%, #1a0b3a 70%); box-shadow: 0 0 30px rgba(255,210,58,.35), inset 0 0 40px rgba(0,0,0,.5); }
.panel::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, rgba(255,255,255,.06) 0 14px, transparent 14px 40px); pointer-events: none; }
.portwrap { position: relative; flex: 0 0 52%; min-width: 0; background: #1a0b3a; }
#bigPort { width: 100%; height: 100%; display: block; }
.p1tag { position: absolute; top: 8px; left: 10px; background: #e0331a; border: 2px solid #1b1026; border-radius: 8px; padding: 0 8px; font-size: 20px; }
.info { flex: 1; min-width: 0; padding: 10px 10px 10px 0; display: flex; flex-direction: column; gap: 5px; overflow: hidden; z-index: 1; }
.fname { font-size: 38px; line-height: 1; color: #fff; -webkit-text-stroke: 1.5px #1b1026; text-shadow: 3px 3px 0 #1b1026; }
.ftitle { font-size: 18px; color: #ffd23a; }
.bars { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; align-items: center; font-size: 15px; }
.bar { display: flex; gap: 3px; }
.bar i { flex: 1; height: 11px; border: 2px solid #1b1026; border-radius: 3px; background: rgba(255,255,255,.12); transform: skewX(-15deg); }
.bar i.on { background: linear-gradient(#fff36a, #ff8a1a); }
.desc { font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 12.5px; line-height: 1.3; background: rgba(0,0,0,.35); border-radius: 8px; padding: 5px 7px; }
.desc b { display: block; font-family: 'Bangers', sans-serif; letter-spacing: .06em; font-weight: normal; font-size: 15px; color: #7dff6a; }
.desc.sp b { color: #ff8ad8; }
.best { font-size: 13px; opacity: .8; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.cell { position: relative; aspect-ratio: 1; border: 3px solid #1b1026; border-radius: 10px; overflow: hidden; background: linear-gradient(160deg, var(--c), #10061f); cursor: pointer; }
.cell canvas { width: 100%; height: 100%; display: block; }
.cell .nm { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 13px; background: rgba(0,0,0,.6); }
.cell.sel { border-color: #ffd23a; box-shadow: 0 0 0 3px #e0331a, 0 0 18px #ffd23a; animation: blink .5s steps(2) infinite; }
.cell.random { display: flex; align-items: center; justify-content: center; font-size: 46px; color: #ffd23a; background: linear-gradient(160deg, #444, #111); }
@keyframes blink { 50% { box-shadow: 0 0 0 3px #fff, 0 0 18px #ffd23a; } }
.selfoot { display: flex; gap: 14px; }
@media (orientation: portrait) {
  .panel { flex-direction: column; gap: 0; }
  .portwrap { flex: 1 1 auto; min-height: 160px; border-bottom: 3px solid #ffd23a; }
  .info { flex: 0 0 auto; padding: 6px 8px 8px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 4px 8px; align-items: start; }
  .info .fname { grid-column: 1; grid-row: 1; font-size: 32px; }
  .info .ftitle { grid-column: 1; grid-row: 2; font-size: 15px; }
  .info .bars { grid-column: 2; grid-row: 1 / 3; font-size: 13px; align-self: center; }
  .info .desc { grid-row: 3; font-size: 11.5px; }
  .info .best { grid-column: 1 / 3; grid-row: 4; }
  .grid { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  .cell { border-width: 2px; border-radius: 7px; }
  .cell .nm { display: none; }
}
@media (orientation: landscape) {
  .selbody { flex-direction: row; }
  .grid { flex: 0 0 auto; width: min(40vw, 360px); align-content: center; }
  .selhead { font-size: 26px; }
  .fname { font-size: 30px; }
  .logo .l1 { font-size: clamp(44px, 12vh, 110px); }
  .logo .l2 { font-size: clamp(26px, 6.5vh, 58px); }
  #title { flex-direction: row; gap: 40px; }
  .screen { gap: 8px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .selfoot button { font-size: 20px; padding: 6px 18px; }
  .selhead { font-size: 22px; }
  .desc { font-size: 11px; }
  button { font-size: 18px; padding: 7px 16px; } button.big { font-size: 24px; padding: 7px 26px; }
}

/* ---------- perks / shop / death ---------- */
.perkhead { font-size: 54px; color: #ffd23a; -webkit-text-stroke: 2px #1b1026; text-shadow: 4px 4px 0 #6a2bd0; transform: rotate(-3deg); }
.perkhead.red { color: #ff4a3a; text-shadow: 4px 4px 0 #1b1026; }
.perksub { font-size: 20px; color: #9ff; text-align: center; }
#perkCards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 900px; }
.card { width: min(92vw, 260px); display: flex; gap: 10px; align-items: center; text-align: left; padding: 12px; border-radius: 16px;
  background: linear-gradient(160deg, #2c1a5c, #160b33); border: 3px solid #ffd23a; box-shadow: 0 6px 0 #1b1026; animation: pop .35s backwards; }
.card:nth-child(2) { animation-delay: .07s; } .card:nth-child(3) { animation-delay: .14s; }
.card .ic { font-size: 40px; font-family: system-ui; }
.card .t { font-size: 22px; color: #ffd23a; }
.card .d { font-family: system-ui, sans-serif; letter-spacing: 0; font-size: 13px; color: #e6dcff; }
.card .lv { font-size: 13px; color: #7dff6a; }
@keyframes pop { from { transform: scale(.6) translateY(30px); opacity: 0; } }
@media (orientation: landscape) and (max-height: 500px) { .card { width: 240px; flex-direction: column; text-align: center; } .perkhead { font-size: 40px; } }
.stats { display: grid; grid-template-columns: auto auto; gap: 4px 22px; font-size: 22px; background: rgba(0,0,0,.4); padding: 12px 20px; border-radius: 14px; border: 2px solid #ffd23a; }
.stats span:nth-child(even) { color: #ffd23a; text-align: right; }
.pinfo { font-family: system-ui; letter-spacing: 0; font-size: 13px; max-width: 420px; text-align: center; opacity: .85; }
#shopList { display: flex; flex-direction: column; gap: 8px; width: min(94vw, 520px); max-height: 60vh; overflow-y: auto; touch-action: pan-y; }
.srow { display: flex; align-items: center; gap: 10px; background: rgba(40,20,90,.8); border: 2px solid #5b3bd6; border-radius: 12px; padding: 8px 10px; }
.srow .n { flex: 1; } .srow .n b { display: block; font-weight: normal; font-size: 20px; color: #ffd23a; } .srow .n span { font-family: system-ui; letter-spacing: 0; font-size: 12px; }
.srow button { font-size: 16px; padding: 6px 12px; min-width: 92px; }
.srow button:disabled { opacity: .45; }

/* ---------- in-game buttons ---------- */
#hudBtns button { position: fixed; border-radius: 50%; padding: 0; }
#btnPause { top: calc(env(safe-area-inset-top) + 8px); right: calc(env(safe-area-inset-right) + 8px); width: 44px; height: 44px; font-size: 16px; border-radius: 12px !important; background: rgba(40,20,90,.8); }
#btnAtk { right: calc(env(safe-area-inset-right) + 16px); bottom: calc(env(safe-area-inset-bottom) + 18px); width: 86px; height: 86px; font-size: 22px; background: radial-gradient(circle at 40% 35%, #ffe066, #e0a010); color: #3a2200; text-shadow: none; }
#btnAtk:active { transform: scale(.94); }
#btnJump { right: calc(env(safe-area-inset-right) + 112px); bottom: calc(env(safe-area-inset-bottom) + 14px); width: 64px; height: 64px; font-size: 15px; background: radial-gradient(circle at 40% 35%, #8af07a, #2a9a3a); }
#btnSpecial { right: calc(env(safe-area-inset-right) + 22px); bottom: calc(env(safe-area-inset-bottom) + 114px); width: 74px; height: 74px; font-size: 13px; line-height: 1;
  background: radial-gradient(circle at 40% 35%, #ff8a3a, #d0201a); overflow: hidden; }
#btnSpecial.ready { animation: glow .8s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 5px 0 #1b1026, 0 0 26px 6px #ffd23a; } }
#spCool { position: absolute; inset: 0; background: conic-gradient(rgba(10,5,25,.72) var(--cd, 0%), transparent 0); pointer-events: none; }
#spName { position: relative; display: block; padding: 0 6px; text-shadow: 2px 2px 0 #1b1026; }
#btnDash { right: calc(env(safe-area-inset-right) + 112px); bottom: calc(env(safe-area-inset-bottom) + 90px); width: 56px; height: 56px; font-size: 13px; background: radial-gradient(circle at 40% 35%, #6ad0ff, #2a6ad0); }
#btnDash.cool { opacity: .5; }
@media (orientation: landscape) and (max-height: 500px) { #btnAtk { width: 78px; height: 78px; } #btnSpecial { bottom: calc(env(safe-area-inset-bottom) + 104px); width: 66px; height: 66px; } #btnDash { bottom: calc(env(safe-area-inset-bottom) + 84px); } }

.spot { position: absolute; left: 8px; bottom: 8px; background: rgba(10,5,25,.75); border: 2px solid #ffd23a; border-radius: 8px; padding: 1px 8px; font-size: 15px; color: #ffd23a; pointer-events: none; }
