* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a1a0a;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #fff;
  touch-action: none;
}

#game-container {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

#game-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

.hidden { display: none !important; }

/* ===== Loading ===== */
#loading {
  position: fixed;
  inset: 0;
  background: #0a1a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #1a3a1a;
  border-top-color: #7cfc00;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Character Select ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #0d2818 0%, #061208 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.panel {
  background: rgba(10, 30, 15, 0.92);
  border: 2px solid #2d6a2d;
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.panel h1 {
  font-size: 1.7rem;
  color: #8fef4a;
  margin-bottom: 4px;
}
.subtitle {
  color: #a0c0a0;
  margin-bottom: 22px;
  font-size: 0.95rem;
}
.avatar-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 20px;
}
.avatar-card {
  background: #142814;
  border: 3px solid #2a4a2a;
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 110px;
}
.avatar-card.selected {
  border-color: #7cfc00;
  background: #1a3a1a;
  box-shadow: 0 0 16px rgba(124,252,0,0.25);
}
.avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  border-radius: 12px;
  image-rendering: pixelated;
  position: relative;
}
.avatar.male {
  background: linear-gradient(180deg, #5ba3e0 0%, #3a7abf 100%);
  box-shadow: inset 0 -8px 0 #2a5a9a;
}
.avatar.male::before {
  content: '';
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 28px;
  background: #f5d0a9;
  border-radius: 50%;
}
.avatar.male::after {
  content: '';
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 12px;
  background: #3b2a1a;
  border-radius: 6px 6px 0 0;
}
.avatar.female {
  background: linear-gradient(180deg, #e88ab8 0%, #c45a90 100%);
  box-shadow: inset 0 -8px 0 #a04070;
}
.avatar.female::before {
  content: '';
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 28px;
  background: #f5d0a9;
  border-radius: 50%;
}
.avatar.female::after {
  content: '';
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 18px;
  background: #5a2a1a;
  border-radius: 10px 10px 0 0;
}
.name-label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: #8ab88a;
  margin-bottom: 6px;
}
#char-name {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid #2a4a2a;
  background: #0d1f0d;
  color: #fff;
  font-size: 1rem;
  margin-bottom: 18px;
  outline: none;
}
#char-name:focus {
  border-color: #7cfc00;
}
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #5cb85c, #3d8b3d);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a5a2a;
}
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #2a5a2a;
}

/* ===== Notification ===== */
#notif {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #8fef4a;
  padding: 12px 20px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 500;
  text-align: center;
  max-width: 90%;
  pointer-events: none;
  border: 1px solid rgba(143,239,74,0.3);
  white-space: pre-line;
}
