:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg2: #11151c;
  --panel: rgba(12, 15, 20, 0.75);
  --line: rgba(255, 255, 255, 0.15);
  --text: #eef2f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(157, 36, 48, 0.2), transparent 35%),
    radial-gradient(circle at 80% 60%, rgba(143, 37, 21, 0.15), transparent 40%),
    linear-gradient(150deg, var(--bg), var(--bg2));
}

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

#game.hidden {
  display: none;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  z-index: 41;
}

#top-center-hud {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  pointer-events: none;
}

#top-center-hud.hidden {
  display: none;
}

#top-center-hud .top-center-row {
  background: rgba(8, 13, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #e2e8f0;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

#top-center-hud .top-sep {
  opacity: 0.55;
  margin: 0 6px;
}

#bottom-hud {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 11;
  pointer-events: none;
  width: min(760px, calc(100vw - 20px));
}

#bottom-hud.hidden {
  display: none;
}

#fps-corner {
  position: fixed;
  left: 12px;
  bottom: 10px;
  z-index: 12;
  pointer-events: none;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(7, 12, 20, 0.8);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  backdrop-filter: blur(6px);
}

#fps-corner.hidden {
  display: none;
}

#skill-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.skill-chip {
  min-width: 86px;
  max-width: 130px;
  background: rgba(10, 14, 20, 0.78);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 5px 8px;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.skill-chip .cd {
  color: #fcd34d;
  font-weight: 700;
}

#xp-wrap {
  background: rgba(8, 13, 20, 0.85);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 10px;
  padding: 6px 8px;
}

#xp-level {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #d1fae5;
}

#xp-bar {
  height: 12px;
  border-radius: 8px;
  background: rgba(20, 30, 42, 0.95);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}

#xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #34d399);
}

#xp-text {
  margin-top: 4px;
  font-size: 11px;
  color: #bfdbfe;
  text-align: right;
}

#levelup-overlay {
  position: fixed;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  z-index: 25;
  pointer-events: auto;
  width: min(920px, calc(100vw - 24px));
  background: rgba(5, 8, 14, 0.92);
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(10px);
}

#levelup-overlay.hidden {
  display: none;
}

.levelup-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 10px;
}

.levelup-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.skill-option {
  background: rgba(14, 20, 32, 0.95);
  border: 1px solid rgba(148,163,184,0.35);
  border-radius: 10px;
  padding: 10px;
  color: #e5e7eb;
  cursor: pointer;
}

.skill-option:hover {
  border-color: rgba(52,211,153,0.9);
  background: rgba(15, 35, 32, 0.95);
}

.skill-option .nm {
  font-size: 17px;
  font-weight: 700;
}

.skill-option .meta {
  margin-top: 4px;
  font-size: 12px;
  color: #93c5fd;
}

.skill-option .desc {
  margin-top: 6px;
  font-size: 13px;
  color: #cbd5e1;
}

.panel {
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(8px);
}

.panel h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.panel p {
  margin: 6px 0 0;
  opacity: 0.9;
}

#scoreboard {
  max-width: 360px;
  min-width: 260px;
  max-height: min(52vh, 420px);
  overflow: auto;
  text-align: left;
}

#scoreboard.is-minimized {
  min-width: 0;
  width: auto;
  max-width: 220px;
  max-height: none;
  overflow: visible;
}

#scoreboard .score-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#scoreboard .score-title {
  font-weight: 700;
  letter-spacing: 0.4px;
}

#scoreboard:not(.is-minimized) .score-head {
  margin-bottom: 6px;
}

.scoreboard-toggle {
  flex: 0 0 auto;
}

#scoreboard .score-row {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#scoreboard .score-player-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#scoreboard .score-row.me {
  font-weight: 700;
  color: #f8fafc;
}

.conn-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.conn-meta {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1;
}
.conn-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.2);
}

.conn-lvl-0 { background: #6b7280; }
.conn-lvl-1 { background: #991b1b; }
.conn-lvl-2 { background: #b91c1c; }
.conn-lvl-3 { background: #dc2626; }
.conn-lvl-4 { background: #ea580c; }
.conn-lvl-5 { background: #f97316; }
.conn-lvl-6 { background: #ca8a04; }
.conn-lvl-7 { background: #84cc16; }
.conn-lvl-8 { background: #22c55e; }
.conn-lvl-9 { background: #16a34a; }
.conn-lvl-10 { background: #15803d; }

#hud.menu-hidden {
  display: none;
}

#join-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(128, 4, 18, 0.35), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(109, 10, 22, 0.25), transparent 42%),
    linear-gradient(160deg, rgba(9, 2, 5, 0.92), rgba(25, 4, 8, 0.9));
  z-index: 20;
  overflow: hidden;
}

#join-overlay::before,
#join-overlay::after {
  content: '';
  position: absolute;
  inset: -20%;
  pointer-events: none;
}

#join-overlay::before {
  background:
    radial-gradient(circle at 12% 20%, rgba(220, 30, 40, 0.23) 0 10%, transparent 35%),
    radial-gradient(circle at 78% 14%, rgba(170, 16, 36, 0.2) 0 9%, transparent 33%),
    radial-gradient(circle at 65% 82%, rgba(200, 18, 34, 0.16) 0 8%, transparent 32%);
  animation: bloodPulse 6.5s ease-in-out infinite;
}

#join-overlay::after {
  background: repeating-linear-gradient(
    118deg,
    rgba(120, 16, 22, 0.06) 0 14px,
    rgba(30, 5, 8, 0.02) 14px 28px
  );
  mix-blend-mode: screen;
  animation: bloodDrift 14s linear infinite;
}

@keyframes bloodPulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.07); opacity: 1; }
}

@keyframes bloodDrift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-8%, -6%, 0); }
}

#join-form {
  position: relative;
  z-index: 1;
  background: #10151d;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 18px;
  display: grid;
  gap: 8px;
  width: min(640px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow: auto;
}
#join-form input,
#join-form button {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

#join-form input {
  background: #0b0f15;
  color: var(--text);
}

.auth-card {
  display: grid;
  gap: 10px;
  margin-bottom: 4px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(8, 12, 18, 0.72);
}

.auth-card:not([open]) {
  gap: 0;
  padding-bottom: 8px;
}

.auth-card-summary {
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
}

.auth-card-summary::-webkit-details-marker {
  display: none;
}

.auth-card-summary::after {
  content: 'Hide';
  float: right;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

.auth-card:not([open]) .auth-card-summary::after {
  content: 'Show';
}

.auth-card-body {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.auth-title {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}

.auth-summary {
  margin-top: 4px;
  font-size: 12px;
  color: #cbd5e1;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.auth-tab,
.auth-action,
.provider-btn,
#join-form button.ghost {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.16);
  color: #fff;
}

.auth-tab {
  background: rgba(22, 30, 42, 0.78);
}

.auth-tab.active {
  background: linear-gradient(135deg, #0f766e, #059669);
}

.auth-panel {
  display: none;
  gap: 8px;
}

.auth-panel.active {
  display: grid;
}

.auth-copy {
  font-size: 12px;
  color: #cbd5e1;
}

.auth-action {
  border: none;
  background: linear-gradient(135deg, #dc2626, #be123c);
  cursor: pointer;
}

.providers-card {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.providers-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.providers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.provider-btn {
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
}

.provider-btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.auth-feedback {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
}

.auth-feedback.ok {
  border-color: rgba(34,197,94,0.35);
  background: rgba(20, 83, 45, 0.3);
  color: #bbf7d0;
}

.auth-feedback.err {
  border-color: rgba(244,63,94,0.35);
  background: rgba(127, 29, 29, 0.3);
  color: #fecdd3;
}

.field-hint {
  min-height: 18px;
  font-size: 12px;
  color: #94a3b8;
}

.field-hint.ok {
  color: #86efac;
}

.field-hint.err {
  color: #fda4af;
}

.hidden {
  display: none !important;
}

.character-select {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.char-option {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(8, 12, 18, 0.7);
  border-radius: 8px;
  padding: 6px 4px;
  display: grid;
  justify-items: center;
  gap: 4px;
  cursor: pointer;
  color: #e2e8f0;
}

.char-option.active {
  border-color: rgba(74, 222, 128, 0.98);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.45), 0 0 14px rgba(22, 163, 74, 0.42), inset 0 0 0 1px rgba(74, 222, 128, 0.24);
  background: rgba(9, 36, 20, 0.9);
  color: #dcfce7;
}

.char-preview {
  width: 40px;
  height: 44px;
  image-rendering: pixelated;
}

.char-label {
  font-size: 11px;
  line-height: 1;
}


.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.join-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.35;
  border: 1px solid rgba(244, 63, 94, 0.35);
  background: rgba(127, 29, 29, 0.28);
  color: #fecdd3;
}

#join-form button {
  cursor: pointer;
  background: linear-gradient(135deg, #dc2626, #be123c);
  color: #fff;
  border: none;
}

#join-form button.secondary {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
}

@media (max-width: 720px) {
  #hud {
    flex-direction: column;
    right: auto;
    top: 8px;
  }

  #top-center-hud {
    top: 8px;
    width: calc(100vw - 24px);
    max-width: 560px;
  }

  #top-center-hud .top-center-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 12px;
    padding: 7px 10px;
  }

  .panel {
    min-width: 0;
    width: calc(100vw - 24px);
  }

  #bottom-hud {
    width: calc(100vw - 16px);
    bottom: calc(env(safe-area-inset-bottom) + 8px);
  }

  #fps-corner {
    left: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 56px);
    font-size: 11px;
  }

  #stats-toggle {
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 126px);
    padding: 7px 10px;
    font-size: 12px;
  }

  #stats-panel {
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 168px);
    width: min(300px, calc(100vw - 16px));
    max-height: 40vh;
    padding: 9px;
  }

  .levelup-options {
    grid-template-columns: 1fr;
  }

  #join-form {
    width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
    padding: 12px;
    gap: 7px;
  }

  .auth-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-tabs,
  .providers-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .character-select {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rooms-list {
    max-height: 160px;
  }
}

#quality-select {
  pointer-events: auto;
  background: #0b0f15;
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 2px 6px;
}


.rooms-browser {
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 8px;
  background: rgba(8, 12, 18, 0.55);
}

.rooms-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
  color: #dbeafe;
}

#join-form button.mini {
  padding: 4px 8px;
  font-size: 12px;
  background: #334155;
}

.rooms-list {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
  font-size: 13px;
}

.room-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255,255,255,0.08);
}

.room-code {
  font-weight: 600;
  letter-spacing: 0.4px;
}

.room-meta {
  color: #cbd5e1;
}

.room-join {
  padding: 5px 8px;
  border-radius: 6px;
  border: none;
  background: #0ea5e9;
  color: white;
  cursor: pointer;
}

.room-join:disabled {
  background: #475569;
  cursor: not-allowed;
}

#info-panel.is-hidden {
  display: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h1 {
  margin: 0;
}

.panel-close {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: #e5e7eb;
  font: inherit;
  font-size: 22px;
  line-height: 0.80;
  cursor: pointer;
  padding: 0 0 2px;
}

.panel-close:hover {
  background: rgba(255,255,255,0.12);
}

.panel-close-sm {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  font-size: 18px;
}

#toggle-info {
  pointer-events: auto;
  align-self: flex-start;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(9, 14, 22, 0.8);
  color: #e5e7eb;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#toggle-info:hover {
  background: rgba(20, 29, 43, 0.9);
}

#toggle-info.hidden {
  display: none;
}
.shadow-option {
  pointer-events: auto;
}

.shadow-option label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#shadow-toggle {
  pointer-events: auto;
}
#stats-toggle {
  position: fixed;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 29;
  pointer-events: auto;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(9, 14, 22, 0.86);
  color: #e2e8f0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#stats-toggle.hidden {
  display: none;
}

#stats-panel {
  position: fixed;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 58px);
  z-index: 29;
  width: min(320px, calc(100vw - 24px));
  max-height: min(52vh, 420px);
  overflow: auto;
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  background: rgba(8, 13, 20, 0.9);
  backdrop-filter: blur(10px);
  padding: 10px;
}

#stats-panel.hidden {
  display: none;
}

#stats-panel .panel-head {
  align-items: center;
  margin-bottom: 12px;
}

.stats-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 0;
  color: #dbeafe;
}

#stats-content {
  display: grid;
  gap: 5px;
  font-size: 13px;
  color: #d1d5db;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.stats-row b {
  color: #f8fafc;
  font-weight: 700;
}

#mobile-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  padding: 0 12px;
  display: none;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  z-index: 30;
}

#mobile-controls.active {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
}

#mobile-controls .stick {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(8, 12, 18, 0.38);
  backdrop-filter: blur(4px);
  position: relative;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

#move-stick {
  grid-column: 1;
  justify-self: start;
}

#aim-stick {
  grid-column: 3;
  justify-self: end;
}

#mobile-controls .stick-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(236, 241, 249, 0.4);
  border: 1px solid rgba(255,255,255,0.45);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#mobile-controls .stick-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -16px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.8px;
  color: rgba(226,232,240,0.9);
  pointer-events: none;
}

#jump-btn {
  --jump-progress: 1;
  pointer-events: auto;
  grid-column: 3;
  justify-self: end;
  align-self: end;
  margin-bottom: 124px;
  min-width: 104px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.34);
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(37,99,235,0.72) 0 calc(var(--jump-progress) * 100%), rgba(120, 8, 8, 0.78) calc(var(--jump-progress) * 100%) 100%);
  color: #fee2e2;
  font-weight: 700;
  letter-spacing: 0.6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

#jump-btn:active {
  transform: translateY(1px) scale(0.98);
  background: rgba(160, 16, 16, 0.82);
}


@media (pointer: coarse) {
  #game {
    touch-action: none;
  }
}
.records-browser .rooms-list {
  max-height: 170px;
}

.record-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(255,255,255,0.08);
}

.record-rank {
  width: 24px;
  color: #facc15;
  font-weight: 700;
}

.record-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.record-meta {
  color: #cbd5e1;
  font-size: 12px;
}
.records-pager {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.records-pager #records-page {
  font-size: 12px;
  color: #cbd5e1;
}

.records-pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.death-result {
  display: none;
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(25, 10, 12, 0.55);
  color: #fecaca;
  font-size: 12px;
  line-height: 1.35;
}

#join-overlay.death-mode .death-result {
  display: block;
}

#join-overlay.death-cinematic-active #join-form {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

.death-cinematic {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: auto;
  overflow: hidden;
}

#join-overlay.death-cinematic-active .death-cinematic {
  display: flex;
}

.death-text {
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(52px, 11vw, 156px);
  letter-spacing: 2px;
  color: #ffd4d4;
  text-shadow: 0 2px 0 #5c0000, 0 10px 36px rgba(180,0,0,0.75);
  transform: translateZ(0) scale(0.06);
  opacity: 0;
}

#join-overlay.death-cinematic-active .death-text {
  animation: deathSlam 1.2s cubic-bezier(0.08, 0.78, 0.12, 1) forwards;
}

.death-impact {
  position: absolute;
  width: min(80vw, 900px);
  height: min(42vw, 520px);
  background: radial-gradient(circle at center, rgba(190, 10, 16, 0.65) 0%, rgba(70, 6, 10, 0.45) 48%, rgba(16, 4, 8, 0) 74%);
  filter: blur(0.5px);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.2);
}

#join-overlay.death-cinematic-active .death-impact {
  animation: deathImpact 1.4s ease-out forwards;
}

.death-drips {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(92, 6, 10, 0) 0 56%, rgba(130, 8, 14, 0.38) 74%, rgba(96, 5, 11, 0) 100%);
  opacity: 0;
  transform: translateY(-16%);
  filter: blur(0.35px);
  overflow: hidden;
}

.death-drips::before,
.death-drips::after {
  content: '';
  position: absolute;
  inset: -8% 0 0 0;
  pointer-events: none;
  opacity: 0;
}

.death-drips::before {
  background:
    radial-gradient(8px 16px at 8% 6%, rgba(178, 10, 16, 0.92) 0 56%, rgba(178, 10, 16, 0) 75%),
    radial-gradient(9px 18px at 17% 8%, rgba(198, 15, 22, 0.88) 0 55%, rgba(198, 15, 22, 0) 74%),
    radial-gradient(7px 14px at 29% 7%, rgba(162, 8, 14, 0.9) 0 58%, rgba(162, 8, 14, 0) 76%),
    radial-gradient(10px 20px at 42% 9%, rgba(188, 13, 20, 0.88) 0 54%, rgba(188, 13, 20, 0) 74%),
    radial-gradient(8px 16px at 56% 7%, rgba(172, 10, 16, 0.9) 0 57%, rgba(172, 10, 16, 0) 76%),
    radial-gradient(9px 18px at 72% 8%, rgba(192, 16, 22, 0.86) 0 54%, rgba(192, 16, 22, 0) 74%),
    radial-gradient(8px 16px at 86% 6%, rgba(165, 9, 15, 0.88) 0 56%, rgba(165, 9, 15, 0) 76%),
    radial-gradient(7px 14px at 95% 9%, rgba(142, 7, 12, 0.85) 0 58%, rgba(142, 7, 12, 0) 76%);
}

.death-drips::after {
  background:
    radial-gradient(7px 14px at 12% 4%, rgba(150, 8, 13, 0.82) 0 58%, rgba(150, 8, 13, 0) 78%),
    radial-gradient(8px 16px at 24% 5%, rgba(175, 11, 17, 0.8) 0 56%, rgba(175, 11, 17, 0) 76%),
    radial-gradient(6px 12px at 38% 4%, rgba(138, 7, 12, 0.8) 0 60%, rgba(138, 7, 12, 0) 79%),
    radial-gradient(8px 16px at 51% 6%, rgba(170, 10, 16, 0.8) 0 56%, rgba(170, 10, 16, 0) 76%),
    radial-gradient(7px 14px at 66% 4%, rgba(146, 8, 13, 0.78) 0 58%, rgba(146, 8, 13, 0) 78%),
    radial-gradient(9px 17px at 81% 6%, rgba(176, 11, 17, 0.8) 0 55%, rgba(176, 11, 17, 0) 75%),
    radial-gradient(7px 14px at 92% 5%, rgba(140, 8, 12, 0.78) 0 58%, rgba(140, 8, 12, 0) 78%);
}

#join-overlay.death-cinematic-active .death-drips {
  animation: deathDrips 2s ease-out 0.7s forwards;
}

#join-overlay.death-cinematic-active .death-drips::before {
  animation: deathDripsFlowA 2.3s linear 0.7s forwards;
}

#join-overlay.death-cinematic-active .death-drips::after {
  animation: deathDripsFlowB 2.8s linear 0.8s forwards;
}

.death-continue {
  position: absolute;
  bottom: 14vh;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(10, 16, 24, 0.88);
  color: #f8fafc;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

#join-overlay.death-cinematic-active .death-continue {
  animation: deathContinueIn 0.35s ease-out 1.55s forwards;
  pointer-events: auto;
}

@keyframes deathSlam {
  0% { opacity: 0; transform: perspective(900px) translateZ(-1000px) scale(0.05); }
  62% { opacity: 1; transform: perspective(900px) translateZ(0) scale(1.14); }
  76% { transform: perspective(900px) translateZ(0) scale(0.96) rotate(-1.1deg); }
  100% { opacity: 1; transform: perspective(900px) translateZ(0) scale(1) rotate(0deg); }
}

@keyframes deathImpact {
  0% { opacity: 0; transform: scale(0.12); }
  58% { opacity: 0.75; transform: scale(1.08); }
  100% { opacity: 0.2; transform: scale(1.42); }
}

@keyframes deathDrips {
  0% { opacity: 0; transform: translateY(-18%); }
  22% { opacity: 0.84; }
  70% { opacity: 0.52; }
  100% { opacity: 0; transform: translateY(8%); }
}

@keyframes deathDripsFlowA {
  0% { opacity: 0; transform: translate3d(0,-24%,0) scaleY(0.92); }
  18% { opacity: 0.92; }
  72% { opacity: 0.58; }
  100% { opacity: 0; transform: translate3d(6%,72%,0) scaleY(1.06); }
}

@keyframes deathDripsFlowB {
  0% { opacity: 0; transform: translate3d(0,-30%,0) scaleY(0.9); }
  24% { opacity: 0.78; }
  70% { opacity: 0.46; }
  100% { opacity: 0; transform: translate3d(-4%,90%,0) scaleY(1.08); }
}

@keyframes deathContinueIn {
  0% { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}


#join-form select {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: #0b0f15;
  color: var(--text);
}

.sync-settings {
  margin-top: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px;
  background: rgba(8, 12, 18, 0.45);
}

.sync-settings > summary {
  cursor: pointer;
  color: #dbeafe;
  font-size: 13px;
  margin-bottom: 8px;
  user-select: none;
}

.sync-settings .sync-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.sync-settings label {
  font-size: 12px;
  color: #cbd5e1;
}

.sync-settings input {
  margin-top: 2px;
}

#records-total {
  color: #cbd5e1;
  font-weight: 500;
}

.presence-meta {
  margin-bottom: 6px;
  font-size: 12px;
  color: #cbd5e1;
}



/* Keep mobile HUD layout overrides at the very end so base rules above don't override them. */
@media (max-width: 720px) {
  #bottom-hud {
    width: calc(100vw - 14px);
    bottom: calc(env(safe-area-inset-bottom) + 6px);
  }

  #fps-corner {
    left: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 82px);
    font-size: 12px;
  }

  #stats-toggle {
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 146px);
    padding: 7px 10px;
    font-size: 12px;
  }

  #stats-panel {
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 188px);
    width: min(300px, calc(100vw - 16px));
    max-height: 42vh;
    padding: 9px;
  }

  #mobile-controls {
    bottom: calc(env(safe-area-inset-bottom) + 120px);
    padding: 0 10px;
  }

  #mobile-controls .stick {
    width: 108px;
    height: 108px;
  }

  #jump-btn {
    min-width: 98px;
    height: 44px;
    margin-bottom: 128px;
    font-size: 14px;
  }

  #levelup-overlay {
    width: calc(100vw - 12px);
    left: 6px;
    right: 6px;
    top: 56%;
    transform: translateY(-50%);
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 210px);
    overflow: auto;
    padding: 10px;
  }

  .levelup-title {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .skill-option {
    padding: 8px;
  }

  .skill-option .nm {
    font-size: 14px;
  }

  .skill-option .meta,
  .skill-option .desc {
    font-size: 12px;
  }

  body.levelup-open #bottom-hud,
  body.levelup-open #stats-toggle,
  body.levelup-open #fps-corner {
    display: none !important;
  }

  body.levelup-open #mobile-controls.active {
    opacity: 0;
  }
}

/* Mobile HUD and records details overlay fixes */
#stats-toggle {
  z-index: 35;
}

#stats-panel {
  z-index: 36;
}

.record-row {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.55);
  padding: 6px;
}

.record-row:hover {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(30, 58, 110, 0.35);
}

.record-details-modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 8;
  background: rgba(2, 6, 14, 0.64);
  backdrop-filter: blur(5px);
}

.record-details-modal.hidden {
  display: none;
}

.record-details-card {
  width: min(560px, calc(100vw - 24px));
  max-height: min(78vh, 760px);
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  background: rgba(8, 14, 24, 0.96);
  padding: 10px;
}

.record-details-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#record-details-title {
  color: #e2e8f0;
  font-size: 14px;
}

.record-details-body {
  display: grid;
  gap: 8px;
  color: #d1d5db;
  font-size: 13px;
}

.rd-summary {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(15, 23, 42, 0.45);
}

.rd-grid {
  display: grid;
  gap: 5px;
}

.rd-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.rd-row b {
  color: #f8fafc;
  text-align: right;
}

.rd-subtitle {
  margin-top: 3px;
  font-weight: 700;
  color: #cbd5e1;
}

.rd-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rd-skill {
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(30, 41, 59, 0.55);
  color: #e2e8f0;
  font-size: 12px;
}

.record-details-empty {
  color: #94a3b8;
  font-size: 12px;
}

@media (max-width: 720px) {
  #toggle-info {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 8px);
    left: 8px;
    z-index: 42;
  }

  #scoreboard {
    margin-top: 44px;
  }

  #stats-panel {
    bottom: calc(env(safe-area-inset-bottom) + 190px);
  }

  .record-details-card {
    width: calc(100vw - 16px);
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 18px);
  }
}

@media (max-width: 720px) {
  #toggle-info {
    top: calc(env(safe-area-inset-top) + 52px);
    left: 8px;
  }

  #stats-toggle {
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 82px);
  }

  #stats-panel {
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 126px);
  }

  #mobile-controls {
    bottom: calc(env(safe-area-inset-bottom) + 86px);
  }

  #jump-btn {
    margin-bottom: 96px;
  }
}

@media (max-width: 720px) {
  #toggle-info {
    top: calc(env(safe-area-inset-top) + 10px);
    left: 12px;
    width: 32px;
    height: 30px;
    padding: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    z-index: 44;
  }

  #mobile-controls {
    bottom: calc(env(safe-area-inset-bottom) + 82px);
  }

  #jump-btn {
    margin-bottom: 82px;
    margin-top: 15px;
  }
}


#levelup-overlay {
  z-index: 50;
}


#dev-console {
  position: fixed;
  left: 14px;
  bottom: 52px;
  width: min(620px, calc(100vw - 24px));
  max-height: min(42vh, 340px);
  z-index: 60;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 12px;
  background: rgba(6, 10, 16, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#dev-console.hidden {
  display: none;
}

.dev-console-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(20, 28, 40, 0.8);
  border-bottom: 1px solid rgba(255,255,255,0.16);
  font-size: 13px;
}

.dev-console-hint {
  color: #93c5fd;
  font-size: 12px;
}

#dev-console-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  font-family: Consolas, Menlo, Monaco, monospace;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.dev-console-line {
  margin-bottom: 4px;
  color: #dbeafe;
}

.dev-console-line.err {
  color: #fda4af;
}

.dev-console-line.ok {
  color: #86efac;
}

#dev-console-form {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding: 8px;
}

#dev-console-input {
  width: 100%;
  border: 1px solid rgba(148,163,184,0.4);
  border-radius: 8px;
  background: rgba(2, 6, 14, 0.9);
  color: #f8fafc;
  font-family: Consolas, Menlo, Monaco, monospace;
  font-size: 13px;
  padding: 8px 10px;
}

#dev-console-input:focus {
  outline: none;
  border-color: rgba(59,130,246,0.85);
}

#dev-console-toggle {
  position: fixed;
  right: 12px;
  bottom: 62px;
  z-index: 61;
  min-width: 44px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.45);
  background: rgba(6, 10, 16, 0.88);
  color: #bfdbfe;
  font-weight: 700;
  letter-spacing: 0.5px;
}

#dev-console-toggle.hidden {
  display: none;
}

@media (max-width: 720px) {
  #dev-console-toggle {
    top: calc(env(safe-area-inset-top) + 10px);
    right: 12px;
    bottom: auto;
    width: 32px;
    min-width: 32px;
    height: 30px;
    padding: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    z-index: 44;
  }
}
