:root {
  --bg: #0a0014;
  --text: #fff;
  --muted: #c0a0d0;
  --neon: #ff2d9b;
  --neon-dim: #99005f;
  --neon-glow: rgba(255, 45, 155, 0.45);
  --panel: rgba(10, 0, 20, 0.92);
  --grid: #3a1050;
}

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

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
}

.wrap {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.wrap:fullscreen, .wrap:-webkit-full-screen { width: 100vw; height: 100vh; }

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--grid);
}
.bar h1 { font-size: 17px; font-weight: 800; letter-spacing: 0.3px; color: var(--neon); text-shadow: 0 0 10px var(--neon-glow); }

.controls { display: flex; align-items: center; gap: 10px; }
.level { font-size: 13px; color: var(--muted); }
.level strong { color: var(--text); }

.icon {
  background: transparent;
  border: 1px solid var(--grid);
  border-radius: 7px;
  color: var(--text);
  font-size: 15px;
  width: 32px;
  height: 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon:active { background: var(--grid); }

.board {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#game { display: block; width: 100%; height: 100%; touch-action: none; }

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 14px;
  padding: 20px 24px;
  text-align: center;
  background: var(--panel);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  z-index: 10;
}
.overlay.hidden { display: none; }

.overlay-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--neon);
  text-shadow: 0 0 18px var(--neon-glow), 0 2px 0 rgba(0,0,0,0.4);
}
.overlay-sub { font-size: 14px; color: var(--muted); max-width: 320px; }

.chars { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--grid);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.char:hover { transform: translateY(-2px); }
.char.selected { border-color: var(--neon); background: rgba(255,45,155,0.15); }
.char-canvas { image-rendering: pixelated; }
.char-name { font-size: 15px; font-weight: 800; }
.char-blurb { font-size: 11px; color: var(--muted); }

.nick-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  width: 100%;
  max-width: 240px;
}
.nick-input {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--grid);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
  text-align: center;
}
.nick-input:focus { border-color: var(--neon); }

.play-btn {
  background: var(--neon);
  border: none;
  border-radius: 12px;
  color: #1a0030;
  font-size: 17px;
  font-weight: 900;
  padding: 12px 36px;
  cursor: pointer;
  box-shadow: 0 0 18px var(--neon-glow), 0 4px 0 var(--neon-dim);
  transition: transform .08s;
}
.play-btn:active { transform: translateY(3px); box-shadow: 0 0 8px var(--neon-glow), 0 1px 0 var(--neon-dim); }

/* Touch d-pad */
.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.touch.hidden { display: none; }
.dpad {
  position: absolute;
  left: clamp(10px, 3vw, 24px);
  bottom: clamp(10px, 3vh, 24px);
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 14px);
  pointer-events: none;
}
.dpad-vert {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vw, 8px);
  pointer-events: none;
}
.dpad-vert .tbtn {
  height: clamp(44px, 10vmin, 64px);
}
.tbtn {
  pointer-events: auto;
  width: clamp(56px, 13vmin, 82px);
  height: clamp(56px, 13vmin, 82px);
  border-radius: 50%;
  border: 2px solid rgba(255,45,155,0.5);
  background: rgba(10, 0, 20, 0.55);
  color: var(--neon);
  font-size: clamp(20px, 4.5vmin, 30px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  backdrop-filter: blur(2px);
}
.tbtn:active { background: rgba(255,45,155,0.4); }

.hint {
  flex: 0 0 auto;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 3px 8px;
}
.foot { flex: 0 0 auto; text-align: center; font-size: 10px; color: var(--grid); padding-bottom: 3px; }
