:root {
  color-scheme: dark;
  --panel: rgba(16, 18, 18, 0.78);
  --panel-strong: rgba(12, 14, 14, 0.92);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f3f5f1;
  --muted: #9da69b;
  --accent: #e2b14b;
  --accent-2: #4bc2b0;
  --danger: #e15a4f;
  --control: #242827;
  --control-hover: #303633;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #121414;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
.discord-login {
  font: inherit;
}

button,
.discord-login {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  background: var(--control-hover);
}

button:active {
  transform: translateY(1px);
}

.game-shell,
#viewport {
  position: fixed;
  inset: 0;
}

#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.hud-title,
.button-row,
.weapon-panel > div,
.toggle,
.field,
.field-inputs {
  display: flex;
  align-items: center;
}

.hud-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.app-name {
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-link {
  max-width: 150px;
  overflow: hidden;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.state-pill {
  min-width: 72px;
  padding: 4px 8px;
  border: 1px solid rgba(75, 194, 176, 0.45);
  border-radius: 999px;
  color: var(--accent-2);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

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

.stat-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
}

.stat-grid span,
.field > span,
.toggle span,
.weapon-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
  line-height: 1;
}

.button-row {
  gap: 8px;
  margin: 12px 0;
}

.button-row button {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12px;
  font-weight: 800;
}

.primary-btn,
.start-action {
  border-color: rgba(226, 177, 75, 0.7);
  background: #c98f2f;
  color: #15120a;
}

.primary-btn:hover,
.start-action:hover {
  background: #e2b14b;
}

.settings-subtitle {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.settings-subtitle:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.settings-modal.hidden {
  pointer-events: none;
  opacity: 0;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.settings-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: min(82vh, 720px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.settings-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 14px 0;
  border-bottom: 1px solid var(--line);
}

.settings-tab {
  flex: 1 1 0;
  min-width: 120px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.settings-tab.active {
  background: rgba(226, 177, 75, 0.18);
  border-color: rgba(226, 177, 75, 0.55);
  color: var(--accent);
}

.settings-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 22px 22px;
}

.settings-panel {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 22px;
}

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

.settings-panel .settings-subtitle {
  grid-column: 1 / -1;
}

.settings-panel .keybind-grid,
.settings-panel .settings-action,
.settings-panel .gamepad-status,
.settings-panel .settings-note {
  grid-column: 1 / -1;
}

.settings-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

select#responseCurve,
.field-inputs select {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-weight: 700;
}

.field {
  justify-content: space-between;
  gap: 10px;
}

.field > span {
  flex: 0 0 76px;
}

.field-inputs {
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}

input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

input[type="number"] {
  width: 66px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  text-align: right;
}

.toggle {
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.keybind-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bind-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(82px, auto) 30px;
  align-items: center;
  gap: 8px;
}

.bind-field span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bind-field button,
.settings-action {
  min-height: 30px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 900;
}

.bind-field button[data-bind-mode="replace"] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bind-field button[data-bind-mode="add"] {
  width: 30px;
  padding: 0;
  color: var(--accent-2);
}

.bind-field button.binding {
  border-color: rgba(75, 194, 176, 0.85);
  background: var(--accent-2);
  color: #071816;
}

.settings-action {
  width: 100%;
}

.gamepad-status {
  display: block;
  min-height: 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.weapon-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 190px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.weapon-panel > div {
  justify-content: space-between;
  gap: 12px;
}

.weapon-panel strong {
  font-size: 28px;
  line-height: 1;
}

meter {
  width: 100%;
  height: 8px;
  margin-top: 9px;
}

.weapon-actions,
.scope-actions {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

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

.scope-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.weapon-actions button,
.scope-actions button {
  min-width: 0;
  min-height: 30px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 900;
}

.weapon-actions button.active,
.scope-actions button.active {
  border-color: rgba(226, 177, 75, 0.85);
  background: #e2b14b;
  color: #15120a;
}

.weapon-actions .weapon-wide {
  grid-column: 1 / -1;
}

.scope-actions button:disabled {
  cursor: default;
  opacity: 0.35;
}

.weapon-hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.crosshair,
.hit-marker {
  position: fixed;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.crosshair {
  width: 34px;
  height: 34px;
  opacity: 0.9;
}

.crosshair .line,
.crosshair .dot {
  position: absolute;
  background: rgba(245, 248, 242, 0.92);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}

.crosshair .dot {
  left: 16px;
  top: 16px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
}

.line-top,
.line-bottom {
  left: 16px;
  width: 2px;
  height: 9px;
}

.line-left,
.line-right {
  top: 16px;
  width: 9px;
  height: 2px;
}

.line-top {
  top: 0;
}

.line-bottom {
  bottom: 0;
}

.line-left {
  left: 0;
}

.line-right {
  right: 0;
}

.hit-marker {
  width: 42px;
  height: 42px;
  opacity: 0;
  transition: opacity 90ms ease;
}

.hit-marker::before,
.hit-marker::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 4px;
  width: 2px;
  height: 34px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(226, 177, 75, 0.9);
}

.hit-marker::before {
  transform: rotate(45deg);
}

.hit-marker::after {
  transform: rotate(-45deg);
}

.hit-marker.active {
  opacity: 1;
}

.damage-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.damage-number {
  position: absolute;
  min-width: 28px;
  text-align: center;
  color: #f6f0de;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.82), 0 0 10px rgba(0, 0, 0, 0.68);
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.damage-number.headshot {
  color: #ffdf72;
}

.damage-number.kill {
  color: #e15a4f;
}

.reload-indicator {
  position: fixed;
  left: 50%;
  top: calc(50% + 58px);
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 6px 10px;
  min-width: 156px;
  padding: 8px 10px;
  border: 1px solid rgba(226, 177, 75, 0.56);
  border-radius: 6px;
  background: rgba(12, 14, 14, 0.72);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 80ms ease, transform 80ms ease;
}

.reload-indicator.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.reload-indicator span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.reload-indicator strong {
  justify-self: end;
  min-width: 36px;
  text-align: right;
  font-size: 12px;
}

.reload-indicator div {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.reload-indicator i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

.scope-overlay {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(56vw, 520px);
  height: min(56vw, 520px);
  border: 2px solid rgba(245, 248, 242, 0.54);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.54), 0 0 0 9999px rgba(0, 0, 0, 0.26);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.98);
  transition: opacity 100ms ease, transform 100ms ease;
}

.scope-overlay.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.scope-overlay span {
  position: absolute;
  background: rgba(245, 248, 242, 0.48);
}

.scope-overlay span:first-child {
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
}

.scope-overlay span:last-child {
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
}

.start-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.start-overlay > * {
  pointer-events: auto;
}

.start-overlay.hidden {
  opacity: 0;
}

.start-overlay.hidden > * {
  pointer-events: none;
}

.start-action {
  min-width: 148px;
  min-height: 52px;
  padding: 0 24px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.touch-fire {
  position: fixed;
  right: 18px;
  bottom: 98px;
  display: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border-color: rgba(225, 90, 79, 0.7);
  background: rgba(225, 90, 79, 0.82);
  font-size: 12px;
  font-weight: 900;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #121414;
}

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.auth-card h1 {
  margin: 16px 0 8px;
  font-size: 28px;
  line-height: 1.1;
}

.auth-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 600;
}

.auth-error {
  display: grid;
  gap: 4px;
  margin: 16px 0;
  padding: 10px;
  border: 1px solid rgba(225, 90, 79, 0.5);
  border-radius: 6px;
  background: rgba(225, 90, 79, 0.12);
  color: #ffd6d2;
  font-size: 13px;
  font-weight: 700;
}

.discord-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(75, 194, 176, 0.55);
  border-radius: 6px;
  background: var(--accent-2);
  color: #071816;
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 760px) {
  .hud {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 48vh;
    padding: 10px;
  }

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

  .settings-modal {
    padding: 12px;
  }

  .settings-dialog {
    max-height: 92vh;
  }

  .settings-panel {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .settings-tab {
    min-width: 96px;
    font-size: 11px;
  }

  .weapon-panel {
    top: 10px;
    right: 10px;
    bottom: auto;
    width: 140px;
    padding: 10px;
  }

  .weapon-panel strong {
    font-size: 22px;
  }

  .touch-fire {
    display: block;
  }
}
