:root {
  --blue: #2f7bff; --blue-l: #8fc3ff; --red: #ff3344; --red-l: #ff9aa2;
  --ink: #f4eefc; --dim: #b6a8d0; --glass: rgba(20, 10, 40, 0.62); --line: rgba(255, 255, 255, 0.14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #140a24; color: var(--ink); font-family: 'Rajdhani', system-ui, sans-serif; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; }
input { font: inherit; }

.panel { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; text-align: center; z-index: 5; }
.panel.show { display: flex; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.98); } }

.logo { font-family: 'Bangers', cursive; font-size: clamp(56px, 13vw, 128px); letter-spacing: 4px; margin: 0; line-height: .9; transform: skew(-6deg); filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.logo .b { color: var(--blue-l); text-shadow: 0 0 24px var(--blue), 0 0 2px #fff; }
.logo .r { color: var(--red-l); text-shadow: 0 0 24px var(--red), 0 0 2px #fff; margin-left: .2em; }
.tag { margin: -4px 0 6px; color: var(--dim); letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }

.card { background: var(--glass); border: 1px solid var(--line); border-radius: 18px; padding: 18px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(10px); text-align: left; }
.card label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--dim); }
.card .hint { text-transform: none; font-weight: 500; opacity: .7; letter-spacing: 0; }
.card input { background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); font-size: 18px; outline: none; width: 100%; }
.card input:focus { border-color: var(--blue-l); }
.row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.card .row { flex-wrap: nowrap; }
.train { justify-content: space-between; color: var(--dim); font-weight: 700; text-transform: uppercase; font-size: 13px; letter-spacing: 1px; }

.big { font-family: 'Bangers', cursive; font-size: 28px; letter-spacing: 2px; padding: 12px 22px; border-radius: 14px; transition: transform .1s, filter .2s; }
.big:active { transform: scale(.96); }
.blue { background: linear-gradient(180deg, #5aa0ff, #1f5fe0); box-shadow: 0 0 24px rgba(47,123,255,.55), inset 0 2px 0 rgba(255,255,255,.35); }
.blue:hover { filter: brightness(1.15); }
.ghost { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.ghost:hover { background: rgba(255,255,255,.16); }
.small { padding: 8px 10px; }
.how { color: var(--dim); max-width: 520px; font-size: 15px; line-height: 1.4; }
kbd { background: rgba(255,255,255,.12); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; font-family: inherit; font-weight: 700; color: var(--ink); }
.foot { position: fixed; bottom: max(10px, env(safe-area-inset-bottom)); left: 16px; right: 16px; display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--dim); }
.dim { color: var(--dim); margin: 0; }

/* search */
.orb { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, #fff 0 18%, #c9b6ff 30%, transparent 62%), conic-gradient(var(--blue), var(--red), var(--blue)); animation: spin 1.4s linear infinite, pulse 1s ease-in-out infinite alternate; filter: blur(.5px) drop-shadow(0 0 30px #a080ff); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { to { scale: 1.12; } }
#search h2 { font-family: 'Bangers', cursive; font-size: 40px; letter-spacing: 2px; margin: 6px 0 0; }

/* versus */
#versus { pointer-events: none; justify-content: flex-start; padding-top: 14vh; }
.vs { font-family: 'Bangers', cursive; font-size: clamp(40px, 9vw, 92px); display: flex; gap: .4em; align-items: center; transform: skew(-6deg); }
.vs em { font-style: normal; color: #ffe066; text-shadow: 0 0 20px #ff9f1a; font-size: .7em; }
.vs .b { color: var(--blue-l); text-shadow: 0 0 20px var(--blue); animation: slideL .6s cubic-bezier(.2,1.6,.4,1); }
.vs .r { color: var(--red-l); text-shadow: 0 0 20px var(--red); animation: slideR .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes slideL { from { transform: translateX(-60vw); } }
@keyframes slideR { from { transform: translateX(60vw); } }
#vsSec { font-size: 15px; background: var(--glass); padding: 6px 12px; border-radius: 999px; }

/* HUD */
#hud { position: fixed; inset: 0; display: none; pointer-events: none; z-index: 4; }
#hud.show { display: block; }
.topbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.side { min-width: 74px; background: rgba(15,10,35,.55); border-radius: 12px; padding: 4px 10px; }
.side .nm { font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.side .pl { font-family: 'Bangers', cursive; font-size: 26px; letter-spacing: 1px; }
.side.me { color: var(--blue-l); text-shadow: 0 0 10px var(--blue); }
.side.opp { color: var(--red-l); text-shadow: 0 0 10px var(--red); text-align: right; }
.meter { position: relative; height: 18px; border-radius: 999px; overflow: hidden; background: rgba(0,0,0,.45); border: 1px solid var(--line); }
.fillMe, .fillOpp { position: absolute; top: 0; bottom: 0; transition: width .2s linear; }
.fillMe { left: 0; width: 50%; background: linear-gradient(90deg, #1340a8, var(--blue), var(--blue-l)); }
.fillOpp { right: 0; width: 50%; background: linear-gradient(270deg, #a80f20, var(--red), var(--red-l)); }
.marker { position: absolute; top: -4px; bottom: -4px; width: 10px; margin-left: -5px; left: 50%; background: #fff; border-radius: 4px; box-shadow: 0 0 14px #fff, 0 0 30px #c9b6ff; transition: left .2s linear; }
.score { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 54px); left: 0; right: 0; text-align: center; font-family: 'Bangers', cursive; font-size: 20px; letter-spacing: 2px; color: var(--dim); }

#callout { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-family: 'Bangers', cursive; font-size: clamp(56px, 14vw, 150px); letter-spacing: 4px; color: #fff; text-shadow: 0 0 30px #a080ff, 0 6px 0 rgba(0,0,0,.4); opacity: 0; transform: skew(-6deg); }
#callout.pop { animation: pop .7s cubic-bezier(.2,1.5,.4,1) forwards; }
#callout.hold { animation: popHold 1.4s cubic-bezier(.2,1.5,.4,1) forwards; }
@keyframes pop { 0% { opacity: 0; transform: skew(-6deg) scale(2.2); } 25% { opacity: 1; transform: skew(-6deg) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: skew(-6deg) scale(.9); } }
@keyframes popHold { 0% { opacity: 0; transform: skew(-6deg) scale(2.2); } 15% { opacity: 1; transform: skew(-6deg) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
#callout.small { font-size: clamp(30px, 7vw, 64px); color: #ffe066; text-shadow: 0 0 24px #ff9f1a; }

#mash { pointer-events: auto; position: absolute; left: 50%; bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px)); width: 150px; height: 150px; margin-left: -75px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #8fc3ff, #2f7bff 55%, #10318a); box-shadow: 0 0 0 4px rgba(255,255,255,.25), 0 0 40px rgba(47,123,255,.8), inset 0 -8px 18px rgba(0,0,0,.35); display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .05s; }
#mash span { font-family: 'Bangers', cursive; font-size: 40px; letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
#mash i { font-style: normal; font-weight: 700; font-size: 14px; opacity: .85; }
#mash.hit { transform: scale(.9); filter: brightness(1.4); }
#mash.off { opacity: .35; filter: grayscale(.6); }

#debug { pointer-events: auto; position: absolute; left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #cfc2ff; background: rgba(0,0,0,.45); border: 1px solid var(--line); padding: 6px 8px; border-radius: 8px; white-space: pre; max-width: 44vw; overflow: hidden; }
#debug.min { width: 28px; height: 26px; padding: 3px 6px; font-size: 0; }
#debug.min::before { content: '⚙'; font-size: 15px; }

#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 3; box-shadow: inset 0 0 160px 40px rgba(255, 30, 60, 0); transition: box-shadow .15s; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 6; }
#flash.go { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* result */
#result { background: radial-gradient(ellipse at center, rgba(20,10,40,.78), rgba(20,10,40,.35) 70%); }
#result h2 { font-family: 'Bangers', cursive; font-size: clamp(64px, 16vw, 140px); margin: 0; letter-spacing: 4px; transform: skew(-6deg); }
#result.win h2 { color: #ffe066; text-shadow: 0 0 40px #ff9f1a, 0 6px 0 rgba(0,0,0,.4); }
#result.lose h2 { color: #c9c3d6; text-shadow: 0 0 30px var(--red), 0 6px 0 rgba(0,0,0,.4); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(90px, 1fr)); gap: 8px; width: min(460px, 100%); }
.stats div { background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.stats b { display: block; font-family: 'Bangers', cursive; font-size: 26px; letter-spacing: 1px; }
.stats span { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }

@media (max-width: 520px) {
  #mash { width: 130px; height: 130px; margin-left: -65px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .side .pl { font-size: 20px; }
}

#bootError { display: none; position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 50; max-width: min(560px, calc(100% - 32px)); background: #3a0d1a; border: 1px solid #ff5a72; color: #ffe3e8; padding: 12px 16px; border-radius: 12px; font-size: 15px; line-height: 1.4; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#bootError code { background: rgba(255,255,255,.12); padding: 0 4px; border-radius: 4px; }

/* ───── Kame Clash additions ───── */
.hidden { display: none !important; }
.tag { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6); font-weight: 700; letter-spacing: 6px; }
.how, .foot { color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.75); }
.foot span { background: rgba(15,10,35,.45); padding: 3px 8px; border-radius: 8px; }
.trophy { font-family: 'Bangers', cursive; font-size: 22px; letter-spacing: 2px; color: #ffe066; background: rgba(15,10,35,.6); padding: 8px 18px; }
.panel > .dim, #search h2, #result .dim { text-shadow: 0 1px 6px rgba(0,0,0,.7); }
#search, #board, #entry, #result { background: radial-gradient(ellipse at center, rgba(20,10,40,.82), rgba(20,10,40,.45) 75%); }

.arcade { font-family: 'Bangers', cursive; font-size: clamp(40px, 9vw, 72px); letter-spacing: 4px; margin: 0; color: #fff; text-shadow: 0 0 24px #a080ff, 0 5px 0 rgba(0,0,0,.4); transform: skew(-6deg); }
.arcade.gold { color: #ffe066; text-shadow: 0 0 30px #ff9f1a, 0 5px 0 rgba(0,0,0,.4); animation: blink 0.9s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.hall { list-style: none; margin: 0; padding: 12px 16px; width: min(420px, 100%); background: var(--glass); border: 1px solid var(--line); border-radius: 16px; font-family: 'Bangers', cursive; font-size: 26px; letter-spacing: 3px; }
.hall li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 10px; padding: 3px 4px; border-radius: 8px; }
.hall li:nth-child(1) { color: #ffd84a; } .hall li:nth-child(2) { color: #e6edf5; } .hall li:nth-child(3) { color: #f0a868; }
.hall .rk { opacity: .7; } .hall .sc { text-align: right; font-variant-numeric: tabular-nums; }
.hall li.mine { background: rgba(47,123,255,.25); }
.hall li.new { background: rgba(255,224,102,.3); animation: blink .6s steps(2) 6; }

.rank { font-family: 'Bangers', cursive; font-size: 30px; letter-spacing: 3px; margin: 0; color: #8fc3ff; }
.bigscore { font-family: 'Bangers', cursive; font-size: clamp(48px, 12vw, 90px); letter-spacing: 3px; color: #fff; text-shadow: 0 0 24px #2f7bff; }
.initials { display: flex; gap: 14px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot b { font-family: 'Bangers', cursive; font-size: 64px; width: 70px; text-align: center; background: rgba(0,0,0,.45); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; line-height: 1.1; }
.slot.cur b { border-color: #ffe066; box-shadow: 0 0 20px rgba(255,224,102,.6); }
.slot button { background: rgba(255,255,255,.1); border-radius: 8px; width: 70px; padding: 4px 0; font-size: 18px; }
.gold-btn { background: linear-gradient(180deg, #ffe066, #ff9f1a); color: #3a1d00; box-shadow: 0 0 24px rgba(255,159,26,.6), inset 0 2px 0 rgba(255,255,255,.5); }

.breakdown { width: min(460px, 100%); border-collapse: collapse; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 16px; }
.breakdown td { padding: 4px 12px; text-align: left; }
.breakdown td.d { color: var(--dim); }
.breakdown td.p { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: #ffe066; }
.breakdown tr.tot td { border-top: 1px solid var(--line); font-weight: 700; font-size: 18px; }
.runline { display: flex; gap: 14px; align-items: baseline; font-family: 'Bangers', cursive; letter-spacing: 2px; }
.runline span { font-size: 22px; color: var(--dim); }
.runline b { font-size: 44px; color: #fff; text-shadow: 0 0 20px #ff9f1a; font-weight: 400; }
.score { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
#result { overflow-y: auto; justify-content: flex-start; padding-top: max(24px, env(safe-area-inset-top)); }
#result h2 { font-size: clamp(54px, 13vw, 110px); }
@media (max-height: 760px) { #result { gap: 8px; } #result h2 { font-size: 56px; } .stats b { font-size: 20px; } }
.logo span { -webkit-text-stroke: 3px #140a2c; paint-order: stroke fill; }
.logo .b { color: #ffe066; text-shadow: 0 0 24px #ff9f1a, 0 6px 0 #140a2c; }
.logo .r { color: #ff7a3d; text-shadow: 0 0 24px #ff3344, 0 6px 0 #140a2c; }
.foot span:empty { display: none; }

/* ───── ad banner (calm screens only) ───── */
.adslot { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 100%; overflow: hidden; }
.adslot:empty { display: none; }
.adlabel { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.75); text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.adslot ins, .adfake { background: rgba(15,10,35,.35); border-radius: 6px; max-width: 100%; }
.adfake { border: 2px dashed rgba(255,255,255,.55); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
#menu { overflow-y: auto; justify-content: safe center; }
#menu .foot { position: static; margin-top: 6px; }
@media (max-height: 700px) { #menu { justify-content: flex-start; gap: 10px; } }
.panel > * { flex-shrink: 0; }
.adslot > * { flex-shrink: 0; }
