:root {
  --bg: #120a33; --bg2: #1d1250; --pink: #ff4f9d; --cyan: #22d3ee; --gold: #fbbf24; --violet: #8b5cf6; --ink: #fff;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: Fredoka, "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; background: radial-gradient(1200px 700px at 70% -10%, #3b2a8f 0%, transparent 60%), linear-gradient(180deg, #120a33 0%, #1d1250 100%); }
.screen { position: absolute; inset: 0; display: none; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.screen.active { display: flex; }
.hidden { display: none !important; }

.logo { font-weight: 700; font-size: clamp(30px, 7vw, 64px); line-height: 0.95; text-align: center; letter-spacing: 1px; color: #fff;
  text-shadow: 0 4px 0 #ff4f9d, 0 8px 0 #7c3aed, 0 12px 24px rgba(0,0,0,.45); }
.logo span { display: block; font-size: 0.55em; margin-top: 10px; color: #ffe66d; text-shadow: 0 3px 0 #b45309, 0 6px 18px rgba(0,0,0,.5); letter-spacing: 6px; }

.btn { font: inherit; font-weight: 700; font-size: 1.05rem; color: #fff; border: 0; border-radius: 16px; padding: 14px 18px; cursor: pointer; text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.35), 0 10px 22px rgba(0,0,0,.25); transition: transform .08s, filter .15s; min-height: 48px; }
.btn small { display: block; font-weight: 400; font-size: .72rem; opacity: .85; }
.btn:hover { filter: brightness(1.1); } .btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn:focus-visible, .icon-btn:focus-visible, .hcard:focus-visible, .field:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn-pink { background: linear-gradient(180deg, #ff7ab8, #e11d74); } .btn-cyan { background: linear-gradient(180deg, #38d9f5, #0891b2); }
.btn-gold { background: linear-gradient(180deg, #ffd24a, #d97706); color: #3a1e00; } .btn-violet { background: linear-gradient(180deg, #a78bfa, #6d28d9); }
.btn-ghost { background: rgba(255,255,255,.12); box-shadow: 0 3px 0 rgba(0,0,0,.3); } .btn-sm { padding: 8px 12px; min-height: 40px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(20,10,60,.6); color: #fff; font-size: 20px; cursor: pointer; line-height: 1; }
.icon-btn.off { opacity: .45; text-decoration: line-through; }
.field { background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.25); border-radius: 12px; color: #fff; padding: 8px 12px; font: inherit; font-weight: 600; user-select: text; -webkit-user-select: text; }
.field::placeholder { color: rgba(255,255,255,.45); }
.code-field { width: 6.5em; text-align: center; letter-spacing: .3em; text-transform: uppercase; font-size: 1.4rem; }
.code-big { font-size: clamp(56px, 16vw, 110px); font-weight: 700; letter-spacing: .15em; color: #ffe66d; text-shadow: 0 5px 0 #b45309; margin: 4px 0; }
.panel { background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.14); border-radius: 18px; padding: 14px; backdrop-filter: blur(6px); }

/* hero cards */
.hcard { position: relative; background: rgba(255,255,255,.07); border: 3px solid rgba(255,255,255,.12); border-radius: 16px; padding: 4px; cursor: pointer; color: #fff; font: inherit; transition: transform .1s, border-color .15s; }
.hcard canvas { width: 100%; height: auto; display: block; border-radius: 12px; aspect-ratio: 4/5; }
.hcard:hover { transform: translateY(-2px); }
.hcard.sel { border-color: #ffe66d; box-shadow: 0 0 0 3px rgba(255,230,109,.3), 0 0 26px rgba(255,230,109,.4); }
.hcard .nm { font-weight: 700; font-size: .85rem; text-align: center; padding: 2px 0; }
.hcard .pk { position: absolute; top: 6px; left: 6px; background: #ffe66d; color: #3a1e00; font-weight: 700; font-size: .7rem; padding: 1px 7px; border-radius: 999px; }

/* tables */
.row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08); border-radius: 14px; padding: 6px 10px; border: 2px solid transparent; }
.row.r1 { border-color: #ffd24a; background: linear-gradient(90deg, rgba(255,210,74,.25), rgba(255,255,255,.06)); }
.row.r2 { border-color: #cfd8e3; background: linear-gradient(90deg, rgba(207,216,227,.22), rgba(255,255,255,.06)); }
.row.r3 { border-color: #d98a4a; background: linear-gradient(90deg, rgba(217,138,74,.25), rgba(255,255,255,.06)); }
.rank { width: 2.2em; text-align: center; font-weight: 700; font-size: 1.1rem; }
.medal { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #2a1a00; font-weight: 700; }
.m1 { background: radial-gradient(circle at 30% 30%, #fff3b0, #ffc400); } .m2 { background: radial-gradient(circle at 30% 30%, #fff, #b9c4d0); } .m3 { background: radial-gradient(circle at 30% 30%, #ffd9b0, #c27535); }
.badge { width: 40px; height: 48px; border-radius: 10px; flex: none; }
.bar { height: 14px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; transition: width .6s ease; }

/* game */
#game-wrap { touch-action: none; }
#game-canvas { max-width: 100%; max-height: 100%; background: #000; touch-action: none; }
.pause-btn { position: absolute; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(86px); width: 38px; height: 38px; font-size: 16px; z-index: 5; }
.overlay { position: absolute; inset: 0; background: rgba(8,4,28,.7); display: flex; align-items: center; justify-content: center; z-index: 20; }
#vs-bar { position: absolute; top: calc(var(--safe-t) + 4px); left: 50%; transform: translateX(-50%); width: min(520px, 62vw); z-index: 4; font-size: .78rem; font-weight: 700; margin-top: 62px; pointer-events: none; }
#vs-bar .track { display: flex; height: 12px; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.4); }
#vs-bar .me { background: linear-gradient(90deg, #22d3ee, #7dffcf); transition: width .5s; } #vs-bar .op { background: linear-gradient(90deg, #ffb347, #ff4f9d); transition: width .5s; flex: 1; }
#vs-bar .lbl { display: flex; justify-content: space-between; text-shadow: 0 1px 3px #000; margin-bottom: 2px; }

.touch-controls { position: absolute; inset: 0; pointer-events: none; z-index: 6; display: none; }
body.touch .touch-controls { display: block; }
.touch-side { position: absolute; bottom: calc(var(--safe-b) + 14px); display: flex; gap: 12px; align-items: flex-end; pointer-events: none; }
.touch-side.left { left: calc(var(--safe-l) + 14px); } .touch-side.right { right: calc(var(--safe-r) + 14px); flex-direction: row-reverse; }
.tbtn { pointer-events: auto; border-radius: 50%; border: 3px solid rgba(255,255,255,.7); color: #fff; font: inherit; font-weight: 700; letter-spacing: 1px; touch-action: none;
  background: rgba(20,10,60,.55); backdrop-filter: blur(3px); box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.tbtn-jump { width: 108px; height: 108px; font-size: 1.15rem; background: rgba(255,79,157,.6); }
.tbtn-slide { width: 78px; height: 78px; font-size: .85rem; background: rgba(34,211,238,.5); }
.tbtn-ult { width: 78px; height: 78px; font-size: .95rem; opacity: .55; filter: grayscale(.6); }
.tbtn.charged { opacity: 1; filter: none; background: radial-gradient(circle, #ffe66d, #f59e0b); color: #3a1e00; animation: glow .7s ease-in-out infinite alternate; }
.tbtn.down { transform: scale(.92); filter: brightness(1.3); }
@keyframes glow { from { box-shadow: 0 0 8px 2px #ffe66d, 0 4px 14px rgba(0,0,0,.4); } to { box-shadow: 0 0 28px 10px #ffb347, 0 4px 14px rgba(0,0,0,.4); } }
body:not(.two) #touch-p1 { right: calc(var(--safe-r) + 14px); }
body:not(.two) #touch-p1 .tbtn-slide { margin-right: auto; }
body.two .tbtn-slide, body.two .tbtn-jump { display: none; }
body.touch.two .tbtn-jump { width: 90px; height: 90px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%); background: rgba(10,5,40,.92); border: 2px solid rgba(255,255,255,.3); padding: 10px 16px; border-radius: 14px; z-index: 99; font-weight: 600; max-width: 90vw; text-align: center; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 6px 0; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pod .blk { width: 130px; border-radius: 12px 12px 0 0; display: grid; place-items: center; font-weight: 700; font-size: 2rem; color: #2a1a00; }
.stat { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat div { background: rgba(255,255,255,.1); border-radius: 12px; padding: 8px 4px; } .stat b { display: block; font-size: 1.4rem; color: #ffe66d; } .stat span { font-size: .7rem; opacity: .8; text-transform: uppercase; letter-spacing: 1px; }

@media (max-height: 520px) { .btn { padding: 8px 14px; min-height: 40px; } .logo { font-size: 34px; } }
@media (prefers-reduced-motion: reduce) { .btn, .hcard, .bar > i { transition: none; } .tbtn.charged { animation: none; } }
