:root {
  --bg: #12141c;
  --panel: rgba(18, 20, 30, .92);
  --ink: #f4f4f4;
  --dim: #9aa0b4;
  --accent: #ffcc33;
  --accent2: #ff5c7a;
  --blue: #3a86ff;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; }
body { display: flex; align-items: center; justify-content: center; }
button { font: inherit; color: inherit; cursor: pointer; }

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-size: calc(min(100vw, 100vh * 16 / 9) / 60);
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: auto; }
.layer { position: absolute; inset: 0; }
.hidden { display: none !important; }
.screen { display: flex; align-items: center; justify-content: center; }

/* ---------- buttons ---------- */
.btn {
  border: 3px solid #1a1a1a; border-radius: 12px; padding: .55em 1.3em; font-weight: 800; font-size: 1.15em;
  background: #fff; color: #1a1a1a; box-shadow: 0 .28em 0 #1a1a1a; transition: transform .05s, box-shadow .05s; letter-spacing: .02em;
}
.btn:active { transform: translateY(.2em); box-shadow: 0 .08em 0 #1a1a1a; }
.btn.primary { background: var(--accent); }
.btn.small { font-size: .95em; padding: .35em .9em; }
.btn.on { background: var(--blue); color: #fff; }
.icon-btn { position: absolute; border: none; background: rgba(0,0,0,.45); color: #fff; border-radius: 50%; width: 2.4em; height: 2.4em; font-size: 1.1em; font-weight: 800; display: grid; place-items: center; }
#mute { position: fixed; right: 10px; bottom: 10px; z-index: 30; }
.pause-btn { right: .8em; top: 4.6em; }

/* ---------- title ---------- */
#title { background: radial-gradient(ellipse at 50% 40%, #2a2f6e 0%, #12141c 70%); }
#titleArt { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-content { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.2em; }
h1 { margin: 0; font-size: 5.2em; line-height: .9; letter-spacing: .04em; font-weight: 900; display: flex; gap: .25em; }
h1 span:first-child { color: #fff; -webkit-text-stroke: .04em #1a1a1a; text-shadow: .08em .08em 0 #1a1a1a; }
h1 span:last-child { color: var(--accent); -webkit-text-stroke: .04em #1a1a1a; text-shadow: .08em .08em 0 #1a1a1a; }
.tag { margin: 0; font-size: 1.25em; color: #dfe3ff; text-shadow: 0 2px 0 #000; }
.menu { display: flex; gap: 1em; flex-wrap: wrap; justify-content: center; }
.controls { font-size: .95em; color: #cfd3e6; line-height: 1.6; text-shadow: 0 1px 0 #000; }
.controls b { display: inline-block; width: 2.2em; color: var(--accent); }
.controls .dim { color: var(--dim); font-size: .9em; margin-top: .3em; }

/* ---------- customizer ---------- */
#custom { background: linear-gradient(180deg, #1c2040 0%, #12141c 100%); align-items: stretch; }
.custom-wrap { width: 100%; height: 100%; display: flex; flex-direction: column; padding: 1em 1.4em; gap: .6em; }
.custom-head { display: flex; align-items: center; justify-content: space-between; }
.custom-head h2 { margin: 0; font-size: 1.8em; font-weight: 900; letter-spacing: .02em; }
.head-actions { display: flex; gap: .6em; }
.custom-body { flex: 1; display: flex; gap: 1.2em; min-height: 0; }
.preview-col { flex: 0 0 34%; display: flex; flex-direction: column; align-items: center; gap: .5em; }
#preview { width: 100%; max-height: 100%; aspect-ratio: 320 / 360; background: linear-gradient(180deg, #7ec8ff 0%, #d8f0ff 70%, #5da850 70%, #4f9a45 100%); border: 3px solid #1a1a1a; border-radius: var(--radius); }
.weapon-stats { font-size: .9em; color: #cfd3e6; text-align: center; min-height: 1.4em; }
.options { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: .45em .9em; align-content: start; padding-right: .3em; }
.options::-webkit-scrollbar { width: 8px; } .options::-webkit-scrollbar-thumb { background: #3a3f57; border-radius: 4px; }
.row { display: flex; align-items: center; gap: .5em; background: rgba(255,255,255,.06); border-radius: 10px; padding: .4em .6em; min-height: 2.6em; }
.row.wide { grid-column: 1 / -1; }
.row label { flex: 0 0 5.2em; font-weight: 700; font-size: .95em; color: #dfe3ff; }
.row .val { flex: 1; text-align: center; font-weight: 800; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arrow { width: 2em; height: 2em; border-radius: 8px; border: 2px solid #1a1a1a; background: #fff; color: #1a1a1a; font-weight: 900; font-size: 1em; box-shadow: 0 .15em 0 #1a1a1a; display: grid; place-items: center; }
.arrow:active { transform: translateY(.1em); box-shadow: none; }
.row input[type=text] { flex: 1; font: inherit; font-weight: 700; font-size: 1em; border: 2px solid #1a1a1a; border-radius: 8px; padding: .3em .5em; background: #fff; color: #1a1a1a; min-width: 0; }
.swatches { flex: 1; display: flex; flex-wrap: wrap; gap: .3em; align-items: center; }
.sw { width: 1.6em; height: 1.6em; border-radius: 50%; border: 2px solid #1a1a1a; padding: 0; position: relative; }
.sw.on { outline: 3px solid #fff; outline-offset: 1px; }
.sw.same { background: repeating-linear-gradient(45deg, #fff 0 4px, #999 4px 8px); }
.sw.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.sw.custom input { position: absolute; inset: -4px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.custom-foot { display: flex; align-items: center; justify-content: space-between; gap: 1em; }
.diff { display: flex; align-items: center; gap: .5em; color: #dfe3ff; font-weight: 700; }

/* ---------- HUD ---------- */
#hud { pointer-events: none; }
#hud .pause-btn { pointer-events: auto; }
.bars { position: absolute; left: 0; right: 0; top: .9em; display: flex; align-items: flex-start; justify-content: space-between; padding: 0 1.4em; gap: 1em; }
.side { flex: 1; max-width: 42%; }
.side.right { text-align: right; }
.name { font-weight: 900; font-size: 1.15em; letter-spacing: .03em; text-shadow: .08em .08em 0 #1a1a1a, 0 0 .4em rgba(0,0,0,.6); margin-bottom: .25em; }
.bar { position: relative; height: 1.25em; border: 3px solid #1a1a1a; border-radius: 8px; background: #3a3f57; overflow: hidden; box-shadow: 0 .18em 0 #1a1a1a; }
.bar .hp, .bar .lag { position: absolute; top: 0; bottom: 0; left: 0; }
.side.right .bar .hp, .side.right .bar .lag { left: auto; right: 0; }
.bar .lag { background: #ff5c7a; transition: width .05s linear; }
.bar .hp { background: linear-gradient(180deg, #7cff7c, #2ecc71 60%, #1e8449); }
.bar .hp.low { background: linear-gradient(180deg, #ffe66d, #f1c40f 60%, #c98f00); }
.bar .hp.crit { background: linear-gradient(180deg, #ff9a9a, #e63946 60%, #a4161a); }
.pips { margin-top: .3em; display: flex; gap: .35em; }
.side.right .pips { justify-content: flex-end; }
.pips i { width: .9em; height: .9em; border-radius: 50%; border: 2px solid #1a1a1a; background: #3a3f57; display: inline-block; }
.pips i.on { background: var(--accent); }
.timer { font-size: 2.2em; font-weight: 900; color: #fff; text-shadow: .06em .06em 0 #1a1a1a; min-width: 2.2em; text-align: center; line-height: 1; }
.timer.low { color: var(--accent2); }
.center { position: absolute; left: 0; right: 0; top: 34%; text-align: center; }
.msg { font-size: 4.2em; font-weight: 900; letter-spacing: .06em; color: var(--accent); -webkit-text-stroke: .03em #1a1a1a; text-shadow: .08em .08em 0 #1a1a1a; animation: pop .35s ease-out; }
.msg:empty { animation: none; }
.sub { font-size: 1.4em; font-weight: 800; color: #fff; text-shadow: .06em .06em 0 #1a1a1a; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- touch pads ---------- */
#touch { pointer-events: none; }
.pad { position: absolute; bottom: 1em; display: flex; align-items: flex-end; gap: 1em; pointer-events: none; }
.pad[data-p="0"] { left: 1em; }
.pad.p2 { right: 1em; }
.dpad, .acts { display: flex; gap: .6em; }
.acts { flex-wrap: wrap; width: 8.4em; justify-content: flex-end; }
.tb { pointer-events: auto; width: 3.6em; height: 3.6em; border-radius: 50%; border: 3px solid #1a1a1a; background: rgba(255,255,255,.75); color: #1a1a1a; font-size: 1.1em; font-weight: 900; letter-spacing: .02em; display: grid; place-items: center; box-shadow: 0 .2em 0 #1a1a1a; touch-action: none; }
.acts .tb { font-size: .62em; width: 6.2em; height: 6.2em; }
.dpad .tb { font-size: 1.4em; width: 2.8em; height: 2.8em; }
.tb.big { background: rgba(255,204,51,.85); }
.tb:active, .tb.down { transform: translateY(.15em); box-shadow: none; background: #fff; }
#touch.one .pad.p2 { display: none; }

/* ---------- result / pause ---------- */
#result, #pause { background: rgba(0,0,0,.55); }
.panel { background: var(--panel); border: 3px solid #1a1a1a; border-radius: 18px; padding: 1.4em 2em; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .8em; box-shadow: 0 .5em 0 #1a1a1a; max-width: 90%; }
.panel h2 { margin: 0; font-size: 2.4em; font-weight: 900; color: var(--accent); -webkit-text-stroke: .02em #1a1a1a; text-shadow: .06em .06em 0 #1a1a1a; }
.panel p { margin: 0; color: #dfe3ff; }
#winnerArt { width: 9em; height: auto; }

@media (max-aspect-ratio: 16/9) and (max-width: 700px) {
  .options { grid-template-columns: 1fr; }
  .preview-col { flex-basis: 30%; }
}
