* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0b0e1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

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

#joinScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #161d38 0%, #05060c 100%);
  z-index: 10;
}

#joinBox {
  text-align: center;
  color: #eee;
}

#titleArt {
  width: min(320px, 70vw);
  height: auto;
  border-radius: 50%;
  margin-bottom: 1rem;
  box-shadow:
    0 0 0 2px rgba(0,255,249,0.3),
    0 0 40px 4px rgba(0,255,249,0.18),
    0 0 80px 12px rgba(255,32,121,0.12);
}

#nameInput {
  display: block;
  margin: 0 auto 1rem;
  padding: 0.6rem 1rem;
  font-size: 1.1rem;
  border-radius: 8px;
  border: none;
  outline: none;
  width: 240px;
  text-align: center;
}

#playBtn {
  padding: 0.6rem 2rem;
  font-size: 1.1rem;
  border-radius: 8px;
  border: none;
  background: #00fff9;
  color: #05060c;
  font-weight: bold;
  cursor: pointer;
}

#playBtn:hover {
  background: #6dfffb;
}

.hint {
  margin-top: 1.2rem;
  color: #8b93ab;
  font-size: 0.9rem;
  max-width: 360px;
  line-height: 1.5;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  color: #eee;
  font-size: 0.9rem;
  z-index: 5;
  display: none;
  background: rgba(0,0,0,0.4);
  padding: 10px 14px;
  border-radius: 8px;
  min-width: 160px;
}

#hud .hpBar {
  width: 140px;
  height: 10px;
  background: rgba(255,255,255,0.15);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 6px;
}

#hud .hpFill {
  height: 100%;
  background: #e05252;
  transition: width 0.15s;
}

#hud .cdBar {
  width: 140px;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

#hud .cdFill {
  height: 100%;
  background: #f4d33c;
  transition: width 0.05s linear;
}

#hud .coords {
  margin-top: 6px;
  font-size: 0.75rem;
  color: #8b93ab;
}

#hud .playerCount {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #8b93ab;
}

#hud .carrySwatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid rgba(255,255,255,0.5);
}

#mapHint {
  position: fixed;
  bottom: 12px;
  right: 12px;
  color: #9aa4c2;
  font-size: 0.8rem;
  z-index: 5;
  display: none;
  background: rgba(0,0,0,0.35);
  padding: 6px 10px;
  border-radius: 6px;
}

#emoteRadial {
  position: fixed;
  left: 100px;
  bottom: 20px;
  z-index: 8;
  display: none;
}

#emoteToggle {
  position: relative;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
}

#emoteToggle:hover,
#emoteToggle.open {
  background: rgba(0,255,249,0.3);
}

#emoteWheel {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  pointer-events: none;
}

.wheelBtn {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  background: rgba(10,14,26,0.92);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.3);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

#emoteRadial.open .wheelBtn {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(1);
}

.wheelBtn:hover {
  background: rgba(0,255,249,0.35);
}

.wheelBtn:nth-child(1) { --dx: -60px; --dy: 0px; }
.wheelBtn:nth-child(2) { --dx: -42px; --dy: -42px; }
.wheelBtn:nth-child(3) { --dx: 0px; --dy: -60px; }
.wheelBtn:nth-child(4) { --dx: 42px; --dy: -42px; }
.wheelBtn:nth-child(5) { --dx: 60px; --dy: 0px; }

#timelapseBtn {
  position: fixed;
  bottom: 44px;
  right: 12px;
  z-index: 5;
  display: none;
  color: #eee;
  font-size: 0.8rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(0,255,249,0.3);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

#timelapseBtn:hover {
  background: rgba(0,255,249,0.15);
}

#timelapseBtn.active {
  background: rgba(0,255,249,0.3);
  color: #0b0e1a;
  font-weight: bold;
}

#muteBtn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 6;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  color: #eee;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

#muteBtn:hover {
  background: rgba(0,0,0,0.6);
}

#donateBtn {
  position: fixed;
  top: 12px;
  right: 56px;
  z-index: 6;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  color: #eee;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

#donateBtn:hover {
  background: #00fff9;
  color: #05060c;
}

#paletteBar {
  position: fixed;
  left: 12px;
  z-index: 6;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  min-width: 100px;
}

#paletteHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #9aa4c2;
  font-size: 0.75rem;
}

#paletteToggle {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  color: #eee;
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
}

#paletteToggle:hover {
  background: rgba(255,255,255,0.3);
}

#paletteSwatches {
  display: grid;
  grid-template-columns: repeat(4, 18px);
  grid-auto-rows: 18px;
  gap: 4px;
}

#paletteBar.collapsed #paletteSwatches {
  display: none;
}

#paletteBar .swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.15);
  box-sizing: border-box;
}

#paletteBar .swatch:hover {
  border-color: rgba(255,255,255,0.5);
}

#paletteBar .swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
}

#settingsMenu {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
}

#settingsBox {
  background: #12172a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 24px 28px;
  width: 340px;
  max-height: 80vh;
  overflow-y: auto;
  color: #eee;
}

#settingsBox h2 {
  margin: 0 0 16px;
  color: #00fff9;
  font-size: 1.4rem;
}

.settingsSection {
  margin-bottom: 20px;
}

.settingsSection h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: #8b93ab;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settingsRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.settingsRow input[type="range"] {
  width: 150px;
}

#keybindList {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.keybindRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  gap: 12px;
}

.keybindRow button {
  min-width: 90px;
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  color: #eee;
  cursor: pointer;
  font-size: 0.85rem;
}

.keybindRow button:hover {
  background: rgba(255,255,255,0.22);
}

.keybindRow button.rebinding {
  background: #00fff9;
  color: #05060c;
}

#settingsBox .secondaryBtn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: #eee;
  cursor: pointer;
  font-size: 0.85rem;
}

#settingsBox .secondaryBtn:hover {
  background: rgba(255,255,255,0.2);
}

#closeSettings {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #00fff9;
  color: #05060c;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.95rem;
}

#closeSettings:hover {
  background: #6dfffb;
}

#settingsBox {
  max-width: 92vw;
}

#touchControls {
  display: none;
}

#aimZone {
  position: fixed;
  top: 0;
  right: 0;
  width: 55vw;
  height: 100vh;
  z-index: 3;
  touch-action: none;
}

#joystickZone {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.2);
  touch-action: none;
  z-index: 5;
}

#joystickThumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  pointer-events: none;
  transition: none;
}

#touchControls .actionBtn {
  position: fixed;
  z-index: 7;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(0,255,249,0.25);
  color: #fff;
  font-size: 0.85rem;
  font-weight: bold;
  touch-action: none;
}

#placeTouchBtn {
  right: 24px;
  bottom: 100px;
}

#dropTouchBtn {
  right: 110px;
  bottom: 40px;
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.12);
}

#touchControls .iconTouchBtn {
  position: fixed;
  top: 12px;
  z-index: 7;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  color: #eee;
  font-size: 1rem;
  touch-action: none;
}

#mapTouchBtn {
  right: 100px;
}

#settingsTouchBtn {
  right: 144px;
}
