/* ============================================================
   NEONSWARM — style.css
   Neon synthwave UI. Dark, glowing, responsive.
   ============================================================ */

:root {
  --cyan: #5ef2ff;
  --pink: #ff4fa3;
  --gold: #ffd23f;
  --red: #ff5e6c;
  --green: #7dff9a;
  --purple: #c77dff;
  --bg: #0a0a16;
  --panel: rgba(12, 14, 30, 0.92);
  --border: #262c4e;
  --text: #eaf2ff;
  --dim: #7a83a8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: #05050c;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  color: var(--text);
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* FIXED app shell: #app always covers the visual viewport, so centering
   holds in every state — normal, fullscreen, URL-bar show/hide. The old
   flex+JS-transform approach drifted: height:100% evaluates against the
   layout viewport (which does NOT shrink when Android shows the URL bar),
   leaving the canvas shifted. position:fixed + dvh tracks the real view. */
#app {
  position: fixed;
  inset: 0;
  height: 100dvh;            /* dvh = dynamic viewport height (Android safe) */
  display: flex;
  align-items: center;
  justify-content: center;
}
@supports not (height: 100dvh) {
  #app { height: 100vh; }    /* older browsers: flex centering still applies */
}

#game-wrap {
  position: relative;
  image-rendering: pixelated;
  box-shadow: 0 0 60px rgba(94, 242, 255, 0.15), 0 0 120px rgba(255, 79, 163, 0.06);
  border: 1px solid #1a2038;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
}

#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

/* ---------- Overlays ---------- */
.overlay { position: absolute; inset: 0; z-index: 10; }
.menu-screen {
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 5, 12, 0.72);
  backdrop-filter: blur(1px);
}

/* ---------- HUD ---------- */
#hud { pointer-events: none; z-index: 5; }
.hud-top {
  position: absolute; top: max(5px, env(safe-area-inset-top)); left: 6px;
  display: flex; gap: 5px;
}
.hud-chip {
  background: rgba(5, 8, 18, 0.75);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-size: 10px; font-weight: bold;
  padding: 3px 8px; border-radius: 2px;
  letter-spacing: 1px;
}
.hud-hp {
  position: absolute; bottom: max(5px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  width: 40%; height: 12px;
  background: rgba(5, 8, 18, 0.75);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
#hp-fill { height: 100%; width: 100%; background: var(--green); transition: width 0.2s; }
#hp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000;
}
.touch-pause {
  position: absolute; top: max(5px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right));
  width: 34px; height: 30px;
  background: rgba(5, 8, 18, 0.75);
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: inherit; font-size: 10px;
  border-radius: 2px;
  display: none;
  pointer-events: auto;
}
body.touch .touch-pause { display: block; }

.hud-combo {
  position: absolute; top: 18%; left: 50%;
  transform: translateX(-50%);
  font-size: 14px; font-weight: bold; letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 12px currentColor;
  display: none;
  pointer-events: none;
  transition: transform 0.15s;
  z-index: 6;
}
.ns-btn { text-decoration: none; display: block; }

/* ---------- Menu ---------- */
.menu-inner {
  text-align: center; padding: 14px; width: 100%; max-width: 380px;
  background: linear-gradient(160deg, rgba(16,20,44,0.72), rgba(10,10,22,0.5));
  border: 1px solid rgba(94,242,255,0.14);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(94,242,255,0.08), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(3px);
}
.ns-title {
  font-size: 40px; letter-spacing: 4px; color: var(--text);
  text-shadow: 0 0 18px rgba(94, 242, 255, 0.6);
  margin-bottom: 2px; font-weight: bold;
  animation: titleBreathe 3.2s ease-in-out infinite;
}
@keyframes titleBreathe {
  0%, 100% { text-shadow: 0 0 14px rgba(94,242,255,0.45), 0 0 40px rgba(94,242,255,0.12); }
  50%      { text-shadow: 0 0 24px rgba(94,242,255,0.85), 0 0 60px rgba(255,79,163,0.2); }
}
.ns-title span { color: var(--pink); text-shadow: 0 0 18px rgba(255, 79, 163, 0.7); }
.ns-title.small { font-size: 24px; animation: none; }
.ns-sub { font-size: 10px; letter-spacing: 3px; color: var(--dim); margin-bottom: 10px; }
.best-line { font-size: 10px; color: var(--gold); margin-bottom: 14px; letter-spacing: 1px; }
.menu-buttons { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.ns-btn {
  font-family: inherit; font-size: 15px; font-weight: bold; letter-spacing: 2px;
  background: rgba(12, 16, 34, 0.85); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 11px; cursor: pointer; transition: all 0.12s;
  text-decoration: none; display: block;
}
.ns-btn:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 12px rgba(94, 242, 255, 0.25); }
.ns-btn.primary { border-color: rgba(94, 242, 255, 0.5); color: var(--cyan); }
.ns-btn.gold { border-color: rgba(255, 210, 63, 0.4); color: var(--gold); font-size: 12px; padding: 9px; }
.ns-btn.gold:hover { border-color: var(--gold); box-shadow: 0 0 12px rgba(255, 210, 63, 0.25); }
.ns-btn.danger { border-color: rgba(255, 94, 108, 0.4); color: var(--red); font-size: 13px; }
.menu-hint { font-size: 9px; color: var(--dim); letter-spacing: 1px; }

/* ---------- Draft ---------- */
.draft-inner { width: 100%; max-width: 480px; padding: 12px; text-align: center; }
.draft-title {
  font-size: 14px; font-weight: bold; letter-spacing: 3px;
  color: var(--gold); margin-bottom: 12px;
  text-shadow: 0 0 12px rgba(255, 210, 63, 0.5);
}
.draft-choices { display: flex; flex-direction: column; gap: 8px; }
.draft-card {
  --c: var(--cyan);
  font-family: inherit; text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c);
  border-radius: 3px;
  padding: 11px 13px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.12s;
}
.draft-card:hover {
  border-color: var(--c);
  background: rgba(20, 26, 52, 0.95);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c) 30%, transparent);
  transform: translateX(2px);
}
.dc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.dc-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  background: color-mix(in srgb, var(--c) 20%, transparent);
  color: var(--c); font-weight: bold; font-size: 11px;
  border-radius: 2px; flex-shrink: 0;
}
.dc-name { font-weight: bold; font-size: 14px; color: var(--c); letter-spacing: 1px; }
.dc-desc { font-size: 11px; color: var(--dim); line-height: 1.4; }
.dc-type {
  margin-top: 5px; font-size: 8px; letter-spacing: 2px;
  color: var(--c); opacity: 0.7;
}

/* ---------- Game over stats ---------- */
.over-stats { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.ov-row {
  display: flex; justify-content: space-between; gap: 24px;
  font-size: 12px; background: rgba(255, 255, 255, 0.04);
  padding: 7px 12px; border-radius: 2px;
}
.ov-row span { color: var(--dim); }
.ov-row b { color: var(--text); }
.ov-row.big b { color: var(--cyan); font-size: 15px; }
.ov-loadout { font-size: 9px; color: var(--cyan); letter-spacing: 1px; text-align: center; padding: 4px; }
.ov-loadout.dim { color: var(--dim); }

/* ---------- Settings ---------- */
.set-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px; border-radius: 2px;
}
.set-btn {
  font-family: inherit; font-size: 11px; font-weight: bold;
  background: rgba(94, 242, 255, 0.1); color: var(--cyan);
  border: 1px solid rgba(94, 242, 255, 0.3);
  border-radius: 2px; padding: 5px 12px; cursor: pointer;
}
.set-btn.danger {
  width: 100%; margin-top: 8px;
  background: rgba(255, 94, 108, 0.08); color: var(--red);
  border-color: rgba(255, 94, 108, 0.3);
  padding: 9px;
}

/* ---------- Toasts ---------- */
.toasts {
  position: absolute; top: max(40px, calc(env(safe-area-inset-top) + 36px));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 5px; z-index: 60; pointer-events: none;
  width: max-content; max-width: 88%;
}
.toast {
  background: rgba(8, 10, 22, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px; border-radius: 3px; font-size: 11px; letter-spacing: 1px;
  opacity: 0; transform: translateY(-6px);
  transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-long { border-color: rgba(255, 210, 63, 0.5); color: var(--gold); }

/* ---------- Touch controller (mobile-first) ---------- */
#touch-ui { position: absolute; inset: 0; z-index: 20; pointer-events: none; }

/* resting joystick: bottom-left, always visible on touch devices */
.joy-rest {
  position: absolute;
  left: max(18px, env(safe-area-inset-left) + 14px);
  bottom: max(18px, env(safe-area-inset-bottom) + 14px);
  width: 96px; height: 96px;
  border-radius: 50%;
  display: none;
}
body.touch .joy-rest { display: block; }
.joy-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(94, 242, 255, 0.28);
  background: rgba(94, 242, 255, 0.06);
}
.joy-dot {
  position: absolute; left: 50%; top: 50%;
  width: 40px; height: 40px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(94, 242, 255, 0.3);
  border: 2px solid rgba(94, 242, 255, 0.6);
  box-shadow: 0 0 14px rgba(94, 242, 255, 0.35);
}

/* floating joystick appears where the thumb lands */
#joy-base {
  position: absolute; width: 96px; height: 96px; border-radius: 50%;
  background: rgba(94, 242, 255, 0.05);
  border: 2px solid rgba(94, 242, 255, 0.2);
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
}
#joy-base.on { display: block; }
#joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(94, 242, 255, 0.25);
  border: 2px solid rgba(94, 242, 255, 0.55);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 14px rgba(94, 242, 255, 0.3);
}

/* dedicated mobile buttons (big, thumb-friendly) */
.m-btn {
  position: absolute;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(5, 8, 18, 0.7);
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: inherit; font-size: 15px;
  display: none;
  pointer-events: auto;
}
body.touch .m-btn { display: block; }
.m-pause {
  right: max(14px, env(safe-area-inset-right) + 10px);
  bottom: max(14px, env(safe-area-inset-bottom) + 10px);
}

/* ---------- Character select ---------- */
.menu-inner.wide { max-width: 560px; }
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.char-card {
  --c: var(--cyan);
  font-family: inherit;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--c);
  border-radius: 3px;
  padding: 10px 8px;
  cursor: pointer;
  color: var(--text);
  text-align: center;
  transition: all 0.12s;
}
.char-card:hover { border-color: var(--c); background: rgba(20, 26, 52, 0.95); }
.char-card.sel {
  border-color: var(--c);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 35%, transparent);
  background: rgba(24, 30, 60, 0.95);
}
.char-card canvas { width: 40px; height: 40px; image-rendering: pixelated; margin-bottom: 4px; }
.char-name { font-size: 12px; font-weight: bold; letter-spacing: 1px; color: var(--c); margin-bottom: 3px; }
.char-desc { font-size: 9px; color: var(--dim); line-height: 1.35; min-height: 34px; }
.char-weapon { font-size: 8px; letter-spacing: 1px; color: var(--text); opacity: 0.75; margin-top: 3px; }

/* ---------- Endless abyss button ---------- */
.ns-btn.abyss { border-color: rgba(181, 108, 255, 0.5); color: #b56cff; }
.ns-btn.abyss:hover { border-color: #b56cff; box-shadow: 0 0 12px rgba(181, 108, 255, 0.3); }
.ns-btn.big { font-size: 17px; padding: 13px; }

/* ---------- Rank grades ---------- */
.ov-rank {
  text-align: center;
  font-size: 13px; letter-spacing: 4px;
  color: var(--dim);
  margin-bottom: 4px;
}
.ov-rank b {
  font-size: 22px;
  margin-left: 6px;
  vertical-align: middle;
}
.rank-D b, .rank-Dp b { color: #8a93c9; }
.rank-C b, .rank-Cp b { color: #7dff9a; }
.rank-B b, .rank-Bp b { color: #5ef2ff; }
.rank-A b, .rank-Ap b { color: #c77dff; text-shadow: 0 0 10px rgba(199,125,255,0.6); }
.rank-S b { color: #ffd23f; text-shadow: 0 0 14px rgba(255,210,63,0.8); }
.rank-Sp b { color: #ffd23f; text-shadow: 0 0 20px rgba(255,210,63,1); animation: rankGlow 1.2s ease-in-out infinite; }
@keyframes rankGlow { 0%,100% { text-shadow: 0 0 12px rgba(255,210,63,0.8); } 50% { text-shadow: 0 0 26px rgba(255,210,63,1); } }

/* ---------- Evolution draft cards ---------- */
.draft-card.evolution {
  position: relative;
  border-color: #fff6d8;
  border-left-width: 4px;
  background: linear-gradient(90deg, rgba(70, 58, 14, 0.95), rgba(20, 18, 40, 0.95));
  animation: evoPulse 1s ease-in-out infinite;
  overflow: hidden;
}
.draft-card.evolution::after {
  /* sheen sweep — the card feels like it is charging */
  content: '';
  position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.22), transparent);
  animation: evoSheen 1.6s linear infinite;
  pointer-events: none;
}
@keyframes evoSheen { to { left: 120%; } }
@keyframes evoPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 246, 216, 0.3); }
  50% { box-shadow: 0 0 24px rgba(255, 246, 216, 0.65); }
}
.dc-evo {
  margin-left: auto;
  font-size: 8px; letter-spacing: 1px;
  color: #fff6d8;
  border: 1px solid rgba(255, 246, 216, 0.6);
  padding: 2px 6px; border-radius: 2px;
}

/* ---------- Loadout bar (VS-style) ---------- */
.loadout {
  position: absolute;
  top: max(34px, calc(env(safe-area-inset-top) + 30px));
  left: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 6;
}
/* evolved weapon cells: gold ring pulse */
.lo-cell.evo {
  border-color: #ffd23f;
  box-shadow: 0 0 8px rgba(255,210,63,0.5);
  animation: evoCell 1.6s ease-in-out infinite;
}
@keyframes evoCell {
  0%, 100% { box-shadow: 0 0 5px rgba(255,210,63,0.35); }
  50% { box-shadow: 0 0 12px rgba(255,210,63,0.7); }
}
/* the whole loadout bar breathes gold when an evolution is ready to draft */
.loadout.evo-ready .lo-cell { border-color: rgba(255,210,63,0.55); }
.loadout.evo-ready {
  animation: evoReadyGlow 1.1s ease-in-out infinite;
}
@keyframes evoReadyGlow {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(255,210,63,0.35)); }
  50% { filter: drop-shadow(0 0 8px rgba(255,210,63,0.8)); }
}
.lo-row { display: flex; flex-wrap: wrap; gap: 3px; max-width: 170px; }
.lo-cell {
  --c: var(--cyan);
  position: relative;
  width: 26px; height: 26px;
  background: rgba(5, 8, 18, 0.8);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--c);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
}
.lo-cell.evo { border-color: #ffd23f; box-shadow: 0 0 6px rgba(255, 210, 63, 0.45); }
.lo-cell canvas { width: 20px; height: 20px; image-rendering: pixelated; }
.lo-pips {
  position: absolute; bottom: -1px; left: 1px; right: 1px;
  display: flex; gap: 1px;
}
.lo-pips i {
  flex: 1; height: 2px;
  background: rgba(255, 255, 255, 0.15);
}
.lo-pips i.on { background: var(--c); }
.lo-star {
  position: absolute; top: -4px; right: -3px;
  font-size: 8px; color: #ffd23f;
  text-shadow: 0 0 4px rgba(255, 210, 63, 0.9);
}
.lo-empty {
  width: 26px; height: 26px;
  border: 1px dashed rgba(122, 131, 168, 0.35);
  border-radius: 3px;
}
.lo-full {
  align-self: center;
  font-size: 8px; letter-spacing: 1px; font-weight: bold;
  color: var(--gold);
  border: 1px solid rgba(255, 210, 63, 0.5);
  border-radius: 2px;
  padding: 1px 4px;
}

/* ---------- Draft card icons ---------- */
.dc-icon {
  width: 30px; height: 30px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: 3px;
  padding: 2px;
}
.dc-icon canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.dc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }

/* ---------- Hyper draft cards ---------- */
.draft-card.hyper {
  border-color: #bfe8ff;
  border-left-width: 4px;
  background: linear-gradient(90deg, rgba(20, 42, 58, 0.95), rgba(12, 14, 30, 0.92));
  animation: hyperPulse 1.1s ease-in-out infinite;
}
@keyframes hyperPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(191, 232, 255, 0.25); }
  50% { box-shadow: 0 0 20px rgba(191, 232, 255, 0.55); }
}

/* ---------- Legendary draft cards ---------- */
.draft-card.legendary {
  border-color: #ffd23f;
  border-left-width: 4px;
  background: linear-gradient(90deg, rgba(60, 48, 10, 0.9), rgba(12, 14, 30, 0.92));
  animation: legPulse 1.6s ease-in-out infinite;
}
@keyframes legPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 210, 63, 0.25); }
  50% { box-shadow: 0 0 18px rgba(255, 210, 63, 0.5); }
}
.dc-legend {
  margin-left: auto;
  font-size: 8px; letter-spacing: 1px;
  color: #ffd23f;
  border: 1px solid rgba(255, 210, 63, 0.5);
  padding: 2px 6px; border-radius: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 520px) {
  .ns-title { font-size: 30px; }
  .ns-btn { font-size: 15px; padding: 13px; }
  .hud-hp { width: 50%; }
  .draft-card { padding: 12px 12px; }
  .dc-name { font-size: 14px; }
  .dc-desc { font-size: 12px; }
  .draft-card.legendary { padding: 14px 12px; }
}
/* Portrait phones: bigger UI everywhere (VS-style readability) */
@media (orientation: portrait) and (max-width: 640px) {
  .ns-title { font-size: 34px; }
  .ns-btn { font-size: 16px; padding: 14px; }
  .draft-title { font-size: 16px; }
  .dc-name { font-size: 15px; }
  .dc-desc { font-size: 13px; }
  .hud-chip { font-size: 12px; padding: 5px 10px; }
  #hp-text { font-size: 10px; }
  .toast { font-size: 13px; }
}
body.reduced-motion * { transition: none !important; animation: none !important; }
