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

body {
  background: #000;
  overflow: hidden;
  font-family: Orbitron, monospace;
}

#app {
  position: fixed;
  width: 800px;
  height: 600px;
  transform-origin: top left;
  overflow: hidden;
  user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 800px;
  height: 600px;
  display: block;
}

.hidden { display: none !important; }

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(4, 2, 20, 0.9);
  padding: 12px;
}

/* ── Title ── */
.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.game-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  margin-bottom: 4px;
}
.logo-top {
  font-size: 3.8rem;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 14px;
  text-shadow: 0 0 20px #f59e0b, 0 0 50px #d97706, 4px 4px 0 #7c3aed;
  animation: logoGlow 2s ease-in-out infinite;
}
.logo-bot {
  font-size: 5rem;
  font-weight: 900;
  color: #a78bfa;
  letter-spacing: 20px;
  text-shadow: 0 0 30px #7c3aed, 0 0 60px #4c1d95, 4px 4px 0 #fbbf24;
  animation: logoGlow 2s ease-in-out infinite reverse;
}
@keyframes logoGlow {
  0%,100% { filter: brightness(1); }
  50%     { filter: brightness(1.3); }
}
.title-btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid #7c3aed;
  color: #c4b5fd;
  font-family: Orbitron, monospace;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: rgba(124,58,237,0.35); box-shadow: 0 0 12px #7c3aed; }

/* ── Shared screen header ── */
.screen-title {
  color: #fbbf24;
  font-size: 1.35rem;
  letter-spacing: 6px;
  margin-bottom: 14px;
  text-shadow: 0 0 12px #f59e0b;
  flex-shrink: 0;
}
.section-label {
  color: #7c3aed;
  font-size: 0.62rem;
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Battle Setup ── */
/* Map grid: 4 cards in a row */
.map-grid {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.map-card {
  width: 162px;
  cursor: pointer;
  border-radius: 8px;
  border: 2px solid #4c1d95;
  overflow: hidden;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
}
.map-card:hover { transform: scale(1.05); }
.map-card.map-active { border-width: 3px; }
.map-card canvas { display: block; }
.map-card-label {
  font-size: 0.56rem;
  letter-spacing: 2px;
  text-align: center;
  padding: 5px 4px;
  background: rgba(0,0,0,0.7);
  color: #c4b5fd;
}
.map-card.map-active .map-card-label { color: #fbbf24; }

/* Difficulty row */
.diff-row {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}
.diff-btn {
  padding: 9px 22px;
  border-radius: 6px;
  border: 2px solid #4c1d95;
  background: transparent;
  color: #6b7280;
  font-family: Orbitron, monospace;
  font-size: 0.72rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.18s;
}
.diff-btn:hover   { border-color: #7c3aed; color: #c4b5fd; }
.diff-btn.diff-active { border-color: #fbbf24; color: #fbbf24; background: rgba(251,191,36,0.1); }
.diff-desc {
  font-size: 0.6rem;
  letter-spacing: 1px;
  color: #6b7280;
  margin-top: 6px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

/* ── Character Select — 4-column ── */
.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  flex-shrink: 0;
}
.char-card {
  width: 162px;
  background: rgba(15, 10, 40, 0.95);
  border: 2px solid #4c1d95;
  border-radius: 10px;
  padding: 10px 12px 12px;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.char-card:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 0 22px currentColor;
}
.char-card canvas {
  border-radius: 5px;
  background: rgba(255,255,255,0.04);
  display: block;
}
.char-card-name {
  font-size: 1.1rem;
  letter-spacing: 3px;
  font-weight: 900;
}
.char-card-title {
  font-size: 0.55rem;
  letter-spacing: 2px;
  color: #9ca3af;
  text-align: center;
}
.char-card-special {
  font-size: 0.55rem;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid currentColor;
  opacity: 0.85;
  text-align: center;
}
.char-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.52rem;
  letter-spacing: 1px;
  color: #9ca3af;
}
.stat-bar  { flex: 1; height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 2px; }

/* ── VS Screen ── */
.vs-wrap { display: flex; align-items: center; gap: 30px; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vs-side canvas {
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(139,92,246,0.5);
}
.vs-char-name  { font-size: 1.3rem; letter-spacing: 4px; color: #fbbf24; text-shadow: 0 0 10px #f59e0b; }
.vs-char-title { font-size: 0.62rem; letter-spacing: 2px; color: #9ca3af; }
.vs-mid {
  font-size: 4rem;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 0 0 20px #dc2626;
  letter-spacing: 4px;
  animation: vsFlash 0.7s ease-in-out infinite;
}
@keyframes vsFlash {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.1); }
}
.vs-round-text {
  margin-top: 24px;
  font-size: 1.1rem;
  letter-spacing: 6px;
  color: #c4b5fd;
  animation: fadeInUp 0.4s ease-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.overlay-box {
  background: rgba(5,2,20,0.97);
  border: 2px solid #7c3aed;
  border-radius: 16px;
  padding: 26px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
  min-width: 240px;
  animation: popIn 0.2s ease-out;
  box-shadow: 0 0 40px rgba(124,58,237,0.4);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.82); }
  to   { opacity: 1; transform: scale(1); }
}
.overlay-box h2 { font-size: 1.8rem; letter-spacing: 4px; color: #fbbf24; text-shadow: 0 0 14px #f59e0b; }
.stat-line  { color: #c4b5fd; font-size: 0.9rem; letter-spacing: 2px; }
.best-label { color: #fbbf24; font-size: 0.78rem; }

/* ── How To Play overlay ── */
.howto-box { min-width: 560px; padding: 22px 32px; }
.howto-cols {
  display: flex;
  gap: 0;
  width: 100%;
}
.howto-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0 16px;
}
.howto-divider {
  width: 1px;
  background: rgba(139,92,246,0.35);
  margin: 0 4px;
  align-self: stretch;
}
.howto-sub {
  font-size: 0.75rem;
  letter-spacing: 3px;
  color: #a78bfa;
  margin-bottom: 4px;
  width: 100%;
  text-align: left;
}
.ctrl-list  { display: flex; flex-direction: column; gap: 5px; width: 100%; }
.ctrl-row   { display: flex; align-items: center; gap: 10px; font-size: 0.62rem; letter-spacing: 1px; color: #9ca3af; }
.ctrl-key {
  min-width: 60px;
  text-align: center;
  padding: 2px 6px;
  border: 1px solid rgba(139,92,246,0.5);
  border-radius: 4px;
  color: #c4b5fd;
  font-size: 0.6rem;
  background: rgba(124,58,237,0.1);
  flex-shrink: 0;
}
/* Match touch button colors inside how-to */
.ctrl-key.tch-p { border-color: rgba(251,191,36,0.6);  color: #fbbf24; }
.ctrl-key.tch-k { border-color: rgba(239,68,68,0.6);   color: #f87171; }
.ctrl-key.tch-s { border-color: rgba(139,92,246,0.9);  color: #a78bfa; }
.ctrl-key.tch-b { border-color: rgba(34,197,94,0.6);   color: #86efac; }
.howto-tip {
  font-size: 0.55rem;
  letter-spacing: 0.5px;
  color: #4b5563;
  line-height: 1.6;
  margin-top: 6px;
}

/* ── Buttons ── */
.btn-primary {
  background: #7c3aed;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: Orbitron, monospace;
  font-size: 0.9rem;
  letter-spacing: 3px;
  padding: 11px 30px;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}
.btn-primary:hover { background: #8b5cf6; box-shadow: 0 0 16px #7c3aed; transform: scale(1.04); }
.btn-secondary {
  background: transparent;
  border: 1px solid #4c1d95;
  border-radius: 6px;
  color: #9ca3af;
  font-family: Orbitron, monospace;
  font-size: 0.68rem;
  letter-spacing: 2px;
  padding: 7px 20px;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}
.btn-secondary:hover { background: #1f1235; color: #c4b5fd; }

/* ── Pause Button ── */
#btn-pause {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: 1px solid rgba(139,92,246,0.5);
  border-radius: 4px;
  color: #a78bfa;
  font-size: 0.85rem;
  width: 28px;
  height: 24px;
  cursor: pointer;
  padding: 0;
  font-family: Orbitron, monospace;
  z-index: 20;
  transition: all 0.15s;
}
#btn-pause:hover { background: rgba(139,92,246,0.3); }

/* ── Touch Controls ── */
#touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 110px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px 10px;
  z-index: 20;
  pointer-events: none;
}
#touch-left, #touch-right {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: all;
}
.tch {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(30, 20, 60, 0.75);
  border: 2px solid rgba(139,92,246,0.6);
  color: #c4b5fd;
  font-family: Orbitron, monospace;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tch:active { background: rgba(124,58,237,0.5); transform: scale(0.93); }
.tch-p { border-color: rgba(251,191,36,0.7);  color: #fbbf24; }
.tch-k { border-color: rgba(239,68,68,0.7);   color: #f87171; }
.tch-s { border-color: rgba(139,92,246,0.9);  color: #a78bfa; font-size: 1.1rem; }
.tch-b { border-color: rgba(34,197,94,0.7);   color: #86efac; font-size: 1rem; }
