/* One Move Win — Neon Tactical Puzzle. Self-contained stylesheet. */

@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/orbitron-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../assets/fonts/orbitron-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/rajdhani-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/rajdhani-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/rajdhani-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/rajdhani-700.woff2') format('woff2');
}

:root {
  --bg: #0b1020;
  --bg2: #10152b;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(140, 170, 255, 0.16);
  --border-strong: rgba(140, 170, 255, 0.32);
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --yellow: #facc15;
  --red: #fb5568;
  --purple: #a78bfa;
  --wall: #48557a;
  --text: #f3f6ff;
  --muted: #8ea0d4;
  --muted-2: #5c6da3;
  --danger: #ff4d6d;
  --good: #34e5a8;
  --radius: 18px;
  --shadow-glow-cyan: 0 0 24px rgba(34, 211, 238, 0.45);
  --shadow-glow-yellow: 0 0 24px rgba(250, 204, 21, 0.5);
  --shadow-glow-red: 0 0 22px rgba(251, 85, 104, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 20% -10%, #182248 0%, var(--bg) 45%) fixed;
  color: var(--text);
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }

h1, h2, h3, .display {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  letter-spacing: 0.04em;
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:disabled { cursor: default; opacity: 0.5; }

a { color: var(--cyan); }

/* ---------------- App shell ---------------- */

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 14px 28px;
}

.brand-header {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 10px;
}
.brand-header .brand {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-header .brand::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.brand-header .back-link {
  font-size: 12px;
  color: var(--muted-2);
  text-decoration: none;
  letter-spacing: 0.05em;
}
.brand-header .back-link:hover { color: var(--cyan); }

.stage {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* ---------------- Screens ---------------- */

.screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding-top: 6px;
}

.logo-block { text-align: center; margin-top: 10px; }
.logo-title {
  font-size: clamp(34px, 9vw, 52px);
  font-weight: 800;
  background: linear-gradient(90deg, var(--cyan), var(--yellow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.05;
}
.logo-tagline {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.stat-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.stat-chip b { color: var(--text); font-size: 15px; font-weight: 700; }

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 20px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0aa5c9);
  color: #04161c;
  box-shadow: var(--shadow-glow-cyan);
}
.btn-secondary {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: var(--panel-strong); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  padding: 10px 16px;
}
.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(255, 77, 109, 0.5);
  color: var(--danger);
}

.mode-row { display: flex; gap: 10px; width: 100%; max-width: 340px; }
.mode-row .btn { flex: 1; font-size: 14px; padding: 12px; }

.seo-copy {
  max-width: 560px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 6px;
  padding: 0 8px 6px;
}
.seo-copy h2 { font-size: 13px; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.08em; }
.seo-keywords { margin-top: 6px; opacity: 0.7; }

/* ---------------- HUD (playing) ---------------- */

.hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  min-width: 58px;
  text-align: center;
}
.hud-stat b { display: block; font-size: 18px; color: var(--text); font-family: 'Orbitron', sans-serif; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.streak-banner {
  position: absolute;
  top: 8px; left: 50%;
  transform: translate(-50%, -8px);
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(250,204,21,0.18), rgba(34,211,238,0.18));
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--yellow);
  white-space: nowrap;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5;
}
.streak-banner.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Board ---------------- */

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  border: 1px solid var(--border);
  box-shadow: inset 0 0 60px rgba(34, 211, 238, 0.04), 0 20px 60px rgba(0,0,0,0.4);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#boardCanvas, #fxCanvas {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  border-radius: 12px;
}
#fxCanvas { pointer-events: none; }

.timer-pill {
  margin-top: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  color: var(--yellow);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  letter-spacing: 0.05em;
}

.think-fast {
  color: var(--danger);
  animation: pulse-fast 0.6s infinite;
}
@keyframes pulse-fast { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------------- Action buttons ---------------- */

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin-top: 16px;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px 12px;
  min-height: 74px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  position: relative;
}
.action-btn .glyph { font-size: 20px; line-height: 1; }
.action-btn .key-hint {
  position: absolute;
  top: 4px; right: 6px;
  font-size: 9px;
  color: var(--muted-2);
  font-weight: 400;
}
.action-btn:hover { border-color: var(--border-strong); background: var(--panel-strong); }
.action-btn:active { transform: scale(0.95); }
.action-btn[data-action="MOVE"] { color: var(--cyan); }
.action-btn[data-action="ATTACK"] { color: var(--red); }
.action-btn[data-action="PUSH"] { color: var(--yellow); }
.action-btn[data-action="BLOCK"] { color: var(--purple); }
.action-btn.selected {
  background: var(--panel-strong);
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor, 0 0 16px currentColor;
}
.action-btn.disabled-action { opacity: 0.3; pointer-events: none; }
/* Which action is chosen is communicated ONLY by .selected — a leftover
   native focus ring after a mouse click on a different button would look
   like a second, contradictory selection. Keyboard play uses global
   number/arrow-key shortcuts rather than Tab-focusing these buttons, so
   suppressing the ring here doesn't cost keyboard accessibility. */
.action-btn:focus, .dpad-btn:focus { outline: none; }

.direction-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted-2);
  text-align: center;
  min-height: 16px;
}

.dpad {
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 6px;
  margin-top: 8px;
  justify-content: center;
}
.dpad-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.dpad-btn:hover { background: var(--panel-strong); color: var(--text); }
.dpad-btn:active { transform: scale(0.92); }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; background: transparent; border: none; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* ---------------- Overlays ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 20, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}
.overlay-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(165deg, #141a34, #0d1226);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  animation: card-in 0.28s cubic-bezier(.2,.9,.25,1.1);
}
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.result-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 4px;
}
.result-title.win { color: var(--good); text-shadow: 0 0 18px rgba(52, 229, 168, 0.55); }
.result-title.fail { color: var(--danger); text-shadow: 0 0 18px rgba(255, 77, 109, 0.5); }
.result-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.score-line { font-size: 15px; color: var(--muted); margin: 4px 0; }
.score-line b { color: var(--text); font-family: 'Orbitron', sans-serif; }
.gain-list { display: flex; flex-direction: column; gap: 3px; margin: 10px 0 16px; font-size: 13px; color: var(--good); }

.new-best {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: var(--yellow);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.overlay-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.nickname-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 16px;
  font-family: 'Rajdhani', sans-serif;
  text-align: center;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}
.nickname-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,0.18); }
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: -4px; margin-bottom: 6px; }

.leaderboard-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; justify-content: center; }
.tab-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
}
.tab-btn.active { background: var(--cyan); color: #04161c; border-color: var(--cyan); font-weight: 700; }

.leaderboard-list { list-style: none; margin: 0; padding: 0; text-align: left; max-height: 300px; overflow-y: auto; }
.leaderboard-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 14px;
}
.leaderboard-list .rank { width: 26px; text-align: center; color: var(--muted-2); font-weight: 700; }
.leaderboard-list li:nth-child(1) .rank { color: var(--yellow); }
.leaderboard-list li:nth-child(2) .rank { color: #cbd5e1; }
.leaderboard-list li:nth-child(3) .rank { color: #d69a5a; }
.leaderboard-list .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list .lb-score { font-family: 'Orbitron', sans-serif; color: var(--cyan); font-size: 13px; }
.leaderboard-empty { color: var(--muted-2); font-size: 13px; padding: 20px 0; }

.share-box {
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 10px;
}

.close-x {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}

.overlay-card { position: relative; }

.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 14px; }
.toggle {
  width: 44px; height: 24px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border);
  position: relative; transition: background 0.15s;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s, background 0.15s;
}
.toggle.on { background: rgba(34,211,238,0.25); border-color: var(--cyan); }
.toggle.on::after { transform: translateX(20px); background: var(--cyan); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(20,26,52,0.95);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Footer / ad slot ---------------- */
.ad-slot {
  width: 100%;
  max-width: 480px;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-top: 16px;
  text-transform: uppercase;
}

/* ---------------- Accessibility ---------------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
body.reduced-motion * { animation: none !important; transition: none !important; }

/* ---------------- Responsive ---------------- */
@media (max-width: 420px) {
  .action-btn { min-height: 64px; font-size: 11px; }
  .action-btn .glyph { font-size: 18px; }
  .logo-title { font-size: 38px; }
}
