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

html {
  touch-action: manipulation;
  -ms-touch-action: manipulation;
}

body {
  background: #1a1a2e;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  color: #eee;
}

#game-canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
}

/* Login Screen */
#login-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  padding: 40px 60px;
  border-radius: 12px;
  border: 2px solid #2ecc71;
}

#login-screen h1 {
  font-size: 48px;
  color: #2ecc71;
  margin-bottom: 8px;
}

#login-screen p {
  color: #aaa;
  margin-bottom: 20px;
}

#name-input {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 18px;
  font-family: inherit;
  background: #16213e;
  border: 1px solid #555;
  color: #eee;
  border-radius: 6px;
  margin-bottom: 12px;
  text-align: center;
}

#name-input:focus {
  outline: none;
  border-color: #2ecc71;
}

#play-btn {
  padding: 12px 48px;
  font-size: 20px;
  font-family: inherit;
  background: #2ecc71;
  color: #1a1a2e;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

#play-btn:hover {
  background: #27ae60;
}

.controls-info {
  margin-top: 20px;
  color: #888;
  font-size: 12px;
}

/* Death Screen */
#death-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 90;
  background: rgba(180, 0, 0, 0.8);
  padding: 30px 50px;
  border-radius: 12px;
}

#death-screen h2 {
  font-size: 36px;
  margin-bottom: 10px;
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#hud-top-left {
  position: absolute;
  top: 12px;
  left: 12px;
}

#hp-bar-container, #xp-bar-container {
  width: 200px;
  height: 20px;
  background: #333;
  border-radius: 4px;
  margin-bottom: 6px;
  position: relative;
}

#hp-bar {
  height: 100%;
  background: #e74c3c;
  border-radius: 4px;
  transition: width 0.2s;
}

#xp-bar {
  height: 100%;
  background: #3498db;
  border-radius: 4px;
  transition: width 0.2s;
}

#hp-bar-container span, #xp-bar-container span {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  text-shadow: 1px 1px 2px #000;
}

#level-text {
  font-size: 14px;
  margin-top: 4px;
  color: #f1c40f;
}

#seed-bar-container {
  width: 200px;
  height: 20px;
  background: #333;
  border-radius: 4px;
  margin-top: 6px;
  position: relative;
}

#seed-bar {
  height: 100%;
  background: #2ecc71;
  border-radius: 4px;
  transition: width 0.15s;
}

#seed-bar-container span {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  text-shadow: 1px 1px 2px #000;
}

#blink-bar-container {
  width: 200px;
  height: 16px;
  background: #333;
  border-radius: 4px;
  margin-top: 4px;
  position: relative;
}

#blink-bar {
  height: 100%;
  background: #3498db;
  border-radius: 4px;
  transition: width 0.1s;
}

#blink-bar-container span {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  text-shadow: 1px 1px 2px #000;
}

/* Skill Panel */
#skill-wrapper {
  position: absolute;
  bottom: 12px;
  left: 180px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  border-radius: 8px;
  pointer-events: auto;
  z-index: 70;
}

.skill-row:hover, .skill-row:active {
  background: rgba(255,255,255,0.15);
}

.skill-row.upgradeable:active {
  background: rgba(241,196,15,0.3);
}

/* Mobile skill rows */
.skill-row-mobile {
  display: flex;
  align-items: center;
  height: 22px;
  padding: 1px 4px;
  margin: 0;
  border-radius: 2px;
  opacity: 0.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.skill-row-mobile.upgradeable {
  opacity: 1;
  background: rgba(241,196,15,0.2);
}

.skill-row-mobile:active {
  background: rgba(241,196,15,0.4);
}

.skill-mobile-label {
  font-size: 9px;
  color: #aaa;
  font-weight: 300;
}

.skill-mobile-val {
  font-size: 10px;
  font-weight: bold;
  color: #f1c40f;
  margin-left: 3px;
}

#sp-text {
  font-size: 13px;
  color: #f1c40f;
  font-weight: bold;
  margin-bottom: 4px;
}

.skill-row {
  display: flex;
  align-items: center;
  height: 32px;
  margin: 2px 0;
  opacity: 0.6;
  padding: 2px 6px;
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.skill-row.upgradeable {
  opacity: 1;
}

.skill-key {
  width: 20px;
  font-size: 13px;
  color: #f1c40f;
  text-align: center;
}

.skill-row.upgradeable .skill-key {
  color: #fff;
  text-shadow: 0 0 6px #f1c40f;
}

.skill-label {
  width: 70px;
  font-size: 12px;
  color: #ccc;
  margin-left: 6px;
}

.skill-blocks {
  display: flex;
  gap: 2px;
  margin-left: 4px;
}

.skill-block {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.skill-block.filled {
  background: #f1c40f;
}

.skill-block.empty {
  background: #444;
}

.skill-row.upgradeable .skill-block.empty {
  background: #665;
}

/* Leaderboard */
#leaderboard {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 16px;
  border-radius: 8px;
  min-width: 180px;
}

#leaderboard h3 {
  font-size: 14px;
  margin-bottom: 6px;
  color: #f1c40f;
}

#lb-list {
  list-style: none;
  padding: 0;
  font-size: 12px;
}

#lb-list li {
  padding: 2px 0;
}

/* Killfeed */
#killfeed {
  position: absolute;
  bottom: 12px;
  left: 12px;
  font-size: 13px;
}

#killfeed .kill-msg {
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 8px;
  margin-top: 3px;
  border-radius: 4px;
  animation: fadeout 4s forwards;
}

@keyframes fadeout {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* Seed Selector */
#seed-selector {
  position: absolute;
  bottom: 200px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 14px;
  border-radius: 6px;
  text-align: center;
  border: 2px solid #555;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

#seed-selector:hover {
  background: rgba(0, 0, 0, 0.85);
}

#seed-selector-label {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 2px;
}

#seed-selector-hint {
  font-size: 10px;
  color: #888;
}

/* Volume Control */
#volume-control {
  position: absolute;
  bottom: 170px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

#volume-icon {
  font-size: 16px;
  color: #aaa;
  cursor: pointer;
  user-select: none;
}

#volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #555;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2ecc71;
  cursor: pointer;
}

#volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2ecc71;
  border: none;
  cursor: pointer;
}

/* Minimap */
#minimap-container {
  position: absolute;
  bottom: 12px;
  right: 12px;
  border: 2px solid #555;
  border-radius: 4px;
  overflow: hidden;
}

#minimap {
  display: block;
  background: #0f3d0f;
}

/* Evolution Panel */
#evolve-panel {
  position: absolute;
  top: 60px;
  left: 12px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}

.evolve-btn {
  display: block;
  background: rgba(40, 40, 80, 0.9);
  border: 2px solid #f1c40f;
  color: #eee;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  pointer-events: auto;
}

.evolve-btn:hover {
  background: rgba(60, 60, 120, 0.95);
  border-color: #fff;
}

.evolve-btn strong {
  color: #f1c40f;
  font-size: 14px;
}

.evolve-btn span {
  color: #aaa;
  font-size: 11px;
}

.hidden {
  display: none !important;
}

/* ── Mobile Touch UI ─────────────────────────── */
#mobile-ui {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  pointer-events: none;
}

#joystick-zone {
  position: absolute;
  left: 0; bottom: 0;
  width: 45%;
  height: 50%;
  pointer-events: auto;
}

#attack-zone {
  position: absolute;
  right: 0; top: 0;
  width: 55%;
  height: 70%;
  pointer-events: auto;
}

#mobile-plant-btn {
  position: absolute;
  right: 20px; bottom: 100px;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(34,139,34,0.7);
  color: #fff;
  font-size: 14px; font-weight: bold;
  border: 2px solid rgba(255,255,255,0.5);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

#mobile-dash-btn {
  position: absolute;
  right: 100px; bottom: 100px;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(52,152,219,0.7);
  color: #fff;
  font-size: 14px; font-weight: bold;
  border: 2px solid rgba(255,255,255,0.5);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

#mobile-plant-btn:active { background: rgba(34,139,34,0.9); }
#mobile-dash-btn:active { background: rgba(52,152,219,0.9); }
