/* Reflex Slayer — dark neon cyberpunk theme */

:root {
  --bg: #07080c;
  --bg-card: #0f1118;
  --bg-card-2: #161a26;
  --fg: #e6ecf5;
  --fg-dim: #8b94a5;
  --neon-red: #ff2a4d;
  --neon-cyan: #00e5ff;
  --gold: #ffd34d;
  --border: #1f2535;
  --rank-god: #ffd34d;
  --rank-shadow: #b388ff;
  --rank-elite: #00e5ff;
  --rank-assassin: #ff2a4d;
  --rank-fighter: #9aa3b2;
  --rank-human: #6f7a8d;
  --rank-turtle: #4a5260;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(255,42,77,0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 80%, rgba(0,229,255,0.08), transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--neon-cyan); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; outline: none; }
a:focus-visible { outline: 2px solid var(--neon-cyan); outline-offset: 2px; border-radius: 2px; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

input[type="text"] {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-card-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--neon-cyan); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7,8,12,0.6);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 900;
  letter-spacing: 0.08em;
  font-size: 1.1rem;
  color: var(--neon-red);
  text-shadow: 0 0 8px rgba(255,42,77,0.5);
}
.brand:hover { text-decoration: none; }
.brand-text { color: var(--fg); }
.site-nav a {
  margin-left: 1.2rem;
  font-size: 0.95rem;
  color: var(--fg-dim);
}
.site-nav a:hover, .site-nav a:focus-visible { color: var(--neon-cyan); text-decoration: none; }

.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1, h2, h3 {
  font-weight: 900;
  letter-spacing: 0.02em;
  margin: 0 0 0.6rem 0;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.4rem; }

.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 0.8rem 1.4rem;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-height: 44px;
  font-size: 1rem;
  text-align: center;
}
.btn-primary {
  background: linear-gradient(180deg, var(--neon-red), #c41d3a);
  color: white;
  box-shadow: 0 0 18px rgba(255,42,77,0.45);
  border: 1px solid #ff5c78;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  background: var(--bg-card-2);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.mono { font-family: var(--mono); }
.dim { color: var(--fg-dim); }
.error-msg { color: var(--neon-red); margin-top: 0.5rem; min-height: 1.2em; font-size: 0.95rem; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 30px rgba(255,42,77,0.18);
}
.modal-sub { color: var(--fg-dim); margin-top: 0; margin-bottom: 1rem; }
.modal-card form { display: flex; flex-direction: column; gap: 0.6rem; }

/* Rank chips */
.rank-chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.rank-god_reflex     { background: rgba(255,211,77,0.12); color: var(--gold); border-color: rgba(255,211,77,0.4); }
.rank-shadow_legend  { background: rgba(179,136,255,0.12); color: var(--rank-shadow); border-color: rgba(179,136,255,0.4); }
.rank-elite_slayer   { background: rgba(0,229,255,0.12); color: var(--neon-cyan); border-color: rgba(0,229,255,0.4); }
.rank-assassin       { background: rgba(255,42,77,0.12); color: var(--neon-red); border-color: rgba(255,42,77,0.4); }
.rank-fighter        { background: rgba(154,163,178,0.12); color: var(--rank-fighter); border-color: rgba(154,163,178,0.4); }
.rank-human          { background: rgba(111,122,141,0.12); color: var(--rank-human); border-color: rgba(111,122,141,0.4); }
.rank-slow_turtle    { background: rgba(74,82,96,0.18); color: var(--rank-turtle); border-color: rgba(74,82,96,0.4); }

/* Home */
.hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}
.hero .tagline { color: var(--fg-dim); margin-top: -0.4rem; }
.player-badge { display: inline-flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; color: var(--fg-dim); }
.player-badge .edit-pencil { font-size: 0.9rem; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}
.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  text-align: center;
  display: flex; flex-direction: column; gap: 0.5rem;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--neon-cyan); box-shadow: 0 0 30px rgba(0,229,255,0.2); }
.mode-card .mode-name { font-size: 1.3rem; font-weight: 900; letter-spacing: 0.06em; }
.mode-card .mode-blurb { color: var(--fg-dim); flex: 1; }
.mode-card.classic .mode-name { color: var(--neon-cyan); }
.mode-card.survival .mode-name { color: var(--neon-red); }
.mode-card.boss .mode-name { color: var(--gold); }

.preview-table {
  width: 100%;
  border-collapse: collapse;
}
.preview-table th, .preview-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.preview-table th { color: var(--fg-dim); font-weight: 600; }
.preview-table td.mono { font-family: var(--mono); }

/* Game arena */
.game-shell {
  display: flex; flex-direction: column; align-items: stretch; gap: 1rem;
}
.hud {
  display: flex; gap: 0.8rem; justify-content: space-between; flex-wrap: wrap;
  font-family: var(--mono);
}
.hud .hud-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  flex: 1 1 auto;
  min-width: 110px;
  text-align: center;
}
.hud .hud-label { display: block; color: var(--fg-dim); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }
.hud .hud-value { font-size: 1.2rem; font-weight: 700; color: var(--fg); }

.rage-track {
  position: relative;
  height: 12px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.rage-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, var(--neon-red), var(--gold));
  width: 0;
  transition: width 0.18s ease;
}
.rage-track.full .rage-fill { background: linear-gradient(90deg, var(--gold), #fff8c8); box-shadow: 0 0 12px var(--gold); }

.hp-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.hp-row { display: flex; align-items: center; gap: 0.6rem; }
.hp-label { width: 70px; font-family: var(--mono); font-size: 0.85rem; color: var(--fg-dim); }
.hp-track { flex: 1; height: 14px; background: var(--bg-card-2); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; position: relative; }
.hp-fill { height: 100%; transition: width 0.25s ease; }
.hp-fill.boss { background: linear-gradient(90deg, var(--neon-red), #ff8a47); }
.hp-fill.player { background: linear-gradient(90deg, var(--neon-cyan), #5cd4ff); }
.hp-num { font-family: var(--mono); width: 88px; text-align: right; font-size: 0.85rem; }

.arena {
  position: relative;
  background: radial-gradient(ellipse at center, #0e1320 0%, #060812 65%, #03050a 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: 360px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
}
.arena .enemy {
  width: 140px; height: 140px;
  display: block;
  filter: drop-shadow(0 0 18px rgba(255,42,77,0.5));
  animation: breathe 3.5s ease-in-out infinite;
  transform-origin: center;
}
.arena .arena-status {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--fg-dim);
}
.arena .attack-text {
  position: absolute;
  font-family: var(--sans);
  font-size: clamp(3rem, 12vw, 7rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: white;
  text-shadow: 0 0 18px rgba(255,42,77,0.8);
  opacity: 0;
  transform: translateY(-20px) scale(0.85);
  transition: opacity 0.08s ease, transform 0.15s ease;
  pointer-events: none;
}
.arena .countdown-num {
  font-family: var(--mono);
  font-size: clamp(4rem, 14vw, 8rem);
  font-weight: 900;
  color: var(--neon-cyan);
  opacity: 0.95;
  text-shadow: 0 0 20px rgba(0,229,255,0.6);
}
.arena .ms-readout {
  position: absolute;
  font-family: var(--mono);
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  font-weight: 800;
  color: var(--neon-cyan);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.25s ease;
  text-shadow: 0 0 22px rgba(0,229,255,0.55);
}
.arena .rank-label-pop {
  position: absolute;
  bottom: 14%;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.arena.show-attack { background: var(--neon-red); }
.arena.show-attack .attack-text { opacity: 1; transform: translateY(0) scale(1); }
.arena.show-attack .enemy { animation: lunge 0.35s ease-out forwards; }
.arena.show-finisher { background: radial-gradient(ellipse at center, #4d3a00, #1a1300 70%); }
.arena.show-finisher .attack-text { color: var(--gold); text-shadow: 0 0 25px rgba(255,211,77,0.9); opacity: 1; transform: translateY(0) scale(1); }
.arena.show-result .ms-readout { opacity: 1; transform: translateY(0); }
.arena.show-result .rank-label-pop { opacity: 1; }
.arena.shake { animation: shake 0.22s linear; }
.arena.slowmo .enemy { animation: kill-anim 1.4s cubic-bezier(0.2,0.7,0.3,1) forwards; }

@keyframes breathe {
  0%, 100% { transform: scale(1.0); }
  50%      { transform: scale(1.025); }
}
@keyframes lunge {
  0%   { transform: translateX(0) scale(1.0); }
  60%  { transform: translateX(-12px) scale(1.12); }
  100% { transform: translateX(0) scale(1.02); }
}
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20%     { transform: translate(-4px, 2px); }
  40%     { transform: translate(4px, -2px); }
  60%     { transform: translate(-3px, -2px); }
  80%     { transform: translate(2px, 3px); }
}
@keyframes kill-anim {
  0%   { transform: translateX(0) rotate(0) scale(1); opacity: 1; filter: drop-shadow(0 0 18px var(--gold)); }
  60%  { transform: translateX(8px) rotate(-12deg) scale(0.85); opacity: 0.7; }
  100% { transform: translateX(40px) rotate(-90deg) scale(0.3); opacity: 0; }
}

.start-row { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }

.result-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 1rem;
}
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  text-align: center;
}
.result-card .big-ms { font-family: var(--mono); font-size: 3rem; font-weight: 900; color: var(--neon-cyan); margin: 0.4rem 0 0.2rem; }
.result-card .big-rank { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.06em; margin-bottom: 0.6rem; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; font-family: var(--mono); font-size: 0.9rem; margin-bottom: 1rem; }
.result-stats .stat-label { color: var(--fg-dim); }
.result-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--neon-cyan); color: var(--fg);
  padding: 0.5rem 1rem; border-radius: 8px;
  z-index: 200; box-shadow: 0 8px 30px rgba(0,229,255,0.2);
  font-size: 0.9rem;
  opacity: 0; transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

/* Tables */
.leaderboard-table, .history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.leaderboard-table th, .history-table th { color: var(--fg-dim); font-weight: 600; text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.leaderboard-table td, .history-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid rgba(31,37,53,0.6); }
.leaderboard-table td.num, .history-table td.num { font-family: var(--mono); }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-btn {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  background: var(--bg-card);
  font-weight: 600;
  min-height: 40px;
}
.tab-btn.active { color: var(--fg); border-color: var(--neon-cyan); box-shadow: inset 0 0 0 1px var(--neon-cyan); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8rem; }
.stat-cell { padding: 0.8rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; text-align: center; }
.stat-cell .stat-num { font-family: var(--mono); font-size: 1.4rem; font-weight: 800; color: var(--neon-cyan); }
.stat-cell .stat-name { color: var(--fg-dim); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }

.sparkline { display: block; width: 100%; height: 60px; margin-top: 0.5rem; }

/* Skins gallery */
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.skin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  display: flex; flex-direction: column; gap: 0.4rem; align-items: center;
}
.skin-card.locked { opacity: 0.55; }
.skin-card .skin-emblem {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  margin: 0.3rem auto;
  font-size: 1.8rem;
}
.skin-card .skin-cta { margin-top: auto; }
.skin-card.active { border-color: var(--neon-cyan); box-shadow: 0 0 22px rgba(0,229,255,0.25); }

/* Settings */
.settings-list { display: flex; flex-direction: column; gap: 1rem; max-width: 520px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; }
.settings-row label { font-weight: 600; }
.danger-btn { background: rgba(255,42,77,0.1); color: var(--neon-red); border: 1px solid var(--neon-red); padding: 0.6rem 1rem; border-radius: 8px; min-height: 44px; font-weight: 700; }

/* Toggle */
.switch { position: relative; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 999px; transition: 0.2s;
}
.switch .slider:before {
  position: absolute; content: ""; height: 20px; width: 20px; left: 3px; top: 3px;
  background: var(--fg-dim); transition: 0.2s; border-radius: 50%;
}
.switch input:checked + .slider { background: rgba(0,229,255,0.2); border-color: var(--neon-cyan); }
.switch input:checked + .slider:before { background: var(--neon-cyan); transform: translateX(22px); }

/* Mobile */
@media (max-width: 768px) {
  .mode-grid { grid-template-columns: 1fr; }
  .site-header { padding: 0.8rem 1rem; }
  .site-nav a { margin-left: 0.7rem; font-size: 0.85rem; }
  .site-main { padding: 1rem; }
  .arena { min-height: 50vh; }
  .hud { gap: 0.4rem; }
  .hud .hud-cell { min-width: 80px; padding: 0.4rem 0.5rem; }
  .result-stats { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .brand-text { display: none; }
}
