html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #08111c;
  color: #f5efe3;
  font-family: "PT Sans Caption", "Segoe UI", sans-serif;
}

body {
  display: grid;
}

#game {
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
}

.hud-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.5);
  transition: opacity 120ms ease, visibility 120ms ease;
}

.hud-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
  width: 286px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(89, 180, 255, 0.12), transparent 40%),
    linear-gradient(180deg, rgba(5, 10, 16, 0.88), rgba(5, 10, 16, 0.72));
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  transition: opacity 120ms ease, visibility 120ms ease;
}

.hud.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.logo {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 12px;
}

.leaderboard {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 340px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: rgba(5, 10, 16, 0.82);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  transition: opacity 120ms ease, visibility 120ms ease;
}

.leaderboard.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.safe-zone-badge {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(110, 255, 168, 0.35);
  border-radius: 999px;
  background: rgba(6, 28, 16, 0.82);
  color: #b9ffd2;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.safe-zone-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(61, 201, 111, 0.2);
  font-size: 14px;
}

.leaderboard-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.leaderboard-brand {
  font-size: 18px;
  font-weight: 700;
}

.leaderboard-time {
  font-size: 20px;
  font-weight: 700;
  color: #f3d889;
}

.leaderboard-meta {
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.4;
  color: #d0d8e2;
}

.leaderboard-columns,
.leaderboard-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 36px 42px 42px;
  gap: 8px;
  align-items: center;
}

.leaderboard-columns {
  padding: 6px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9fb0c2;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-rows {
  margin-top: 6px;
}

.leaderboard-row {
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-row.self {
  color: #7ce8ef;
}

.leaderboard-player {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

input,
button {
  font: inherit;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  padding: 10px 12px;
}

input {
  outline: none;
}

input:focus {
  border-color: rgba(124, 232, 239, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 232, 239, 0.12);
}

.actions {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

#playButton,
#resumeButton,
#respawnButton,
#disconnectButton {
  width: 100%;
  font-weight: 700;
}

#playButton {
  background: linear-gradient(135deg, rgba(124, 240, 231, 0.28), rgba(53, 167, 255, 0.26));
}

.secondary {
  background: rgba(255, 255, 255, 0.06);
}

.hidden {
  display: none !important;
}

.status {
  min-height: 54px;
  font-size: 13px;
  line-height: 1.45;
  color: #d0d8e2;
}

.legend {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #a9b5c4;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  border: none;
  padding: 0;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(124, 232, 239, 0.85);
  cursor: pointer;
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(124, 232, 239, 0.85);
  border: none;
  cursor: pointer;
}

.slider-value {
  min-width: 38px;
  font-size: 12px;
  text-align: right;
  color: #9fb0c2;
}

/* Touch controls */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  touch-action: none;
}

.touch-zone {
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 60%;
  pointer-events: auto;
  touch-action: none;
}

.touch-zone-left {
  left: 0;
}

.touch-zone-right {
  right: 0;
}

.joystick-base {
  position: absolute;
  bottom: 80px;
  left: 60px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
}

.joystick-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(124, 232, 239, 0.35);
  border: 2px solid rgba(124, 232, 239, 0.5);
  transition: none;
}

.touch-jump-btn {
  position: absolute;
  bottom: 90px;
  right: 50px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(124, 240, 231, 0.18);
  border: 2px solid rgba(124, 240, 231, 0.35);
  color: #b0f0e8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: auto;
  touch-action: none;
  display: grid;
  place-items: center;
}

.touch-jump-btn:active {
  background: rgba(124, 240, 231, 0.4);
}

.touch-respawn-btn {
  position: absolute;
  bottom: 190px;
  right: 42px;
  width: 96px;
  height: 48px;
  border-radius: 24px;
  background: rgba(255, 100, 100, 0.2);
  border: 2px solid rgba(255, 100, 100, 0.35);
  color: #ffb0b0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: auto;
  touch-action: none;
  display: grid;
  place-items: center;
}

.touch-respawn-btn:active {
  background: rgba(255, 100, 100, 0.4);
}

/* Clap text overlay */
#clapTextContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.clap-text {
  position: absolute;
  font-weight: bold;
  font-size: 24px;
  color: white;
  text-shadow: 0 0 4px black, 0 0 8px black;
  white-space: nowrap;
  pointer-events: none;
}

/* Preroll countdown overlay */
#prerollOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  font-size: 96px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(124, 232, 239, 0.6), 0 4px 12px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Settings overlay */
#settingsOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#settingsPanel {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

#settingsPanel h2 {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
}

.settings-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.settings-row label {
  font-size: 14px;
  min-width: 120px;
}

.settings-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  border: none;
  padding: 0;
}

.settings-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(124, 232, 239, 0.85);
  cursor: pointer;
}

.settings-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(124, 232, 239, 0.85);
  border: none;
  cursor: pointer;
}

.settings-row span {
  min-width: 32px;
  font-size: 13px;
  text-align: right;
  color: #9fb0c2;
}

.settings-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: rgba(124, 232, 239, 0.85);
  cursor: pointer;
}

/* Chat */
.chat-container {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 12;
  width: 340px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0;
  max-height: 220px;
  overflow: hidden;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.35;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  color: #e8e0d4;
  word-break: break-word;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(4px);
}

.chat-msg-name {
  font-weight: 700;
  margin-right: 6px;
}

.chat-msg.system {
  color: #a0b8d0;
  font-style: italic;
}

.chat-msg.faded {
  opacity: 0;
}

.chat-form {
  pointer-events: auto;
  margin-top: 4px;
}

.chat-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(5, 10, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #f5efe3;
  backdrop-filter: blur(8px);
}

.chat-form input:focus {
  border-color: rgba(124, 232, 239, 0.6);
  outline: none;
}

.hud-button {
  width: 100%;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
}
