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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #0b1020;
  font-family: "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* real visible height on mobile, ignored (falls back to vh) where unsupported */
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  font-weight: 600;
}

.hud-label {
  font-size: 12px;
  letter-spacing: 2px;
  opacity: 0.8;
  margin-bottom: 4px;
}

#weight-bar-wrap {
  width: 220px;
}

#weight-kg-value {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
}

#weight-bar-bg {
  width: 100%;
  height: 18px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

#weight-bar-fill {
  height: 100%;
  width: 70%;
  background: linear-gradient(90deg, #ffb703, #fb5607);
  transition: width 0.25s ease, background 0.25s ease;
}

#score-wrap {
  text-align: right;
}

#score-value {
  font-size: 28px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(11, 16, 32, 0.75);
  color: #fff;
  gap: 14px;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: 42px;
  letter-spacing: 1px;
}

.overlay p {
  font-size: 16px;
  opacity: 0.9;
  max-width: 480px;
}

.controls-hint {
  opacity: 0.7;
  font-size: 14px;
}

#end-stats {
  font-size: 18px;
  opacity: 0.95;
  margin-top: 4px;
}

button {
  margin-top: 10px;
  padding: 12px 32px;
  font-size: 18px;
  font-weight: 700;
  color: #0b1020;
  background: #ffb703;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
  background: #ffd166;
  transform: scale(1.05);
}

button:active {
  transform: scale(0.97);
}

.secondary-btn {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  padding: 8px 24px;
  font-size: 14px;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

#character-grid {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 760px;
}

.character-card {
  width: 170px;
  padding: 16px 12px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 3px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.character-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.14);
}

.character-card.selected {
  border-color: #ffb703;
  background: rgba(255, 183, 3, 0.16);
}

.character-card .avatar {
  position: relative;
  width: 84px;
  height: 100px;
  margin: 0 auto 10px;
}

.character-card .avatar-head {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--skin);
  transform: translateX(-50%);
}

.character-card .avatar-hair {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 46px;
  height: 26px;
  border-radius: 50% 50% 0 0;
  background: var(--hair);
  transform: translateX(-50%);
}

.character-card .avatar-body {
  position: absolute;
  left: 50%;
  top: 48px;
  width: 66px;
  height: 52px;
  border-radius: 30px 30px 14px 14px;
  background: var(--shirt);
  transform: translateX(-50%);
}

.character-card .avatar-legs {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 50px;
  height: 18px;
  border-radius: 6px;
  background: var(--pants);
  transform: translateX(-50%);
}

.character-card .char-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

.character-card .char-tagline {
  font-size: 12px;
  opacity: 0.75;
  min-height: 30px;
}

.character-card .char-stats {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 6px;
  letter-spacing: 0.5px;
}

/* On-screen touch controls — hidden by default, shown via JS on
   touch-capable devices so mobile players get visible buttons instead
   of having to guess where the invisible tap zones are. */
#touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 18px 22px;
  pointer-events: none;
  z-index: 5;
}

#touch-controls.hidden {
  display: none;
}

.touch-side {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
}

.touch-btn {
  margin: 0;
  padding: 0;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
  background: rgba(255, 183, 3, 0.45);
  border-color: #ffb703;
}

.touch-btn-action {
  width: 68px;
  height: 68px;
  background: rgba(255, 183, 3, 0.18);
}

@media (max-width: 480px), (max-height: 480px) {
  #hud {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .hud-label {
    font-size: 10px;
  }

  #weight-bar-wrap {
    width: 150px;
  }

  #weight-bar-bg {
    height: 14px;
  }

  #score-value {
    font-size: 22px;
  }

  .overlay {
    padding: 16px;
    gap: 10px;
  }

  .overlay h1 {
    font-size: 28px;
  }

  .overlay p {
    font-size: 13px;
    max-width: 90vw;
  }

  #character-grid {
    gap: 10px;
  }

  .character-card {
    width: 128px;
    padding: 10px 8px 12px;
  }

  .character-card .avatar {
    width: 64px;
    height: 76px;
  }

  .character-card .avatar-head {
    width: 34px;
    height: 34px;
    top: 6px;
  }

  .character-card .avatar-hair {
    width: 36px;
    height: 20px;
    top: 2px;
  }

  .character-card .avatar-body {
    width: 50px;
    height: 40px;
    top: 36px;
  }

  .character-card .avatar-legs {
    width: 38px;
    height: 14px;
  }

  .character-card .char-name {
    font-size: 13px;
  }

  .character-card .char-tagline {
    font-size: 10.5px;
    min-height: 24px;
  }

  button {
    padding: 10px 24px;
    font-size: 15px;
  }

  .touch-btn {
    width: 54px;
    height: 54px;
    font-size: 20px;
  }

  .touch-btn-action {
    width: 58px;
    height: 58px;
  }
}
