:root {
  --bg: #0b1218;
  --bg-soft: #131f2a;
  --surface: rgba(17, 27, 37, 0.88);
  --surface-border: rgba(120, 166, 209, 0.35);
  --text: #e8f3ff;
  --muted: #a7bfd6;
  --accent: #2fe89e;
  --accent-press: #26ca89;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at 20% 20%, #173754 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, #0f3b33 0%, transparent 40%),
    linear-gradient(140deg, var(--bg) 0%, #060b10 100%);
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.welcomeTitle {
  text-align: center;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.auth-glow {
  position: absolute;
  width: 34vmax;
  height: 34vmax;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.auth-glow-left {
  left: -10vmax;
  top: -8vmax;
  background: rgba(56, 142, 255, 0.22);
}

.auth-glow-right {
  right: -10vmax;
  bottom: -8vmax;
  background: rgba(47, 232, 158, 0.19);
}

.auth-card {
  position: relative;
  width: min(100%, 430px);
  padding: 28px;
  border-radius: 18px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
}

h1 {
  margin: 8px 0 6px;
  font-size: 30px;
}

.subtitle {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  background: rgba(10, 16, 23, 0.55);
  border-radius: 12px;
  padding: 5px;
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.18s ease;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  background: rgba(62, 116, 166, 0.45);
  color: var(--text);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

label {
  display: block;
  margin: 11px 0 6px;
  color: #d0e7fc;
  font-size: 14px;
}

input {
  width: 100%;
  border: 1px solid rgba(132, 173, 209, 0.35);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(7, 12, 17, 0.65);
  outline: none;
}

input:focus {
  border-color: #54b4ff;
  box-shadow: 0 0 0 3px rgba(84, 180, 255, 0.2);
}

.remember-login {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.remember-login input {
  width: auto;
  margin: 0;
  accent-color: #5efec0;
}

.primary-btn {
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #042213;
  cursor: pointer;
  background: linear-gradient(130deg, #5efec0 0%, var(--accent) 100%);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(47, 232, 158, 0.35);
}

.primary-btn:active {
  transform: translateY(0);
  background: var(--accent-press);
}

.auth-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-message.error {
  color: var(--danger);
}

.auth-message.success {
  color: var(--accent);
}

#game {
  position: fixed;
  inset: 0;
  display: none;
  width: 100dvw;
  height: 100dvh;
  touch-action: none;
}

#inventoryUI {
  position: absolute;
  right: 20px;
  top: 20px;
  width: min(340px, calc(100vw - 24px));
  display: none;
  z-index: 10;
}

.chat-ui {
  position: absolute;
  left: 18px;
  top: 18px;
  width: min(420px, calc(100vw - 36px));
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(125, 170, 209, 0.25);
  background: rgba(8, 14, 20, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 12;
}

.chat-ui.visible {
  opacity: 1;
  transform: translateY(0);
}

.chat-ui.active {
  pointer-events: auto;
}

.chat-messages {
  max-height: 180px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}

.chat-line {
  background: rgba(30, 49, 66, 0.55);
  border: 1px solid rgba(115, 160, 202, 0.22);
  border-radius: 8px;
  padding: 6px 8px;
}

.chat-name {
  color: #a8d8ff;
  font-weight: 700;
  margin-right: 6px;
}

.chat-input {
  width: 100%;
  border: 1px solid rgba(115, 160, 202, 0.35);
  border-radius: 9px;
  padding: 9px 10px;
  background: rgba(12, 21, 31, 0.85);
  color: var(--text);
}

.chat-emote-select {
  width: 100%;
  border: 1px solid rgba(115, 160, 202, 0.35);
  border-radius: 9px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(12, 21, 31, 0.85);
  color: var(--text);
}

.online-users {
  position: absolute;
  top: 210px;
  left: 14px;
  min-width: 180px;
  max-width: 280px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(125, 170, 209, 0.3);
  background: rgba(10, 16, 23, 0.85);
  backdrop-filter: blur(4px);
  font-size: 12px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 14;
}

.online-users.visible {
  opacity: 1;
  transform: translateY(0);
}

.online-users-title {
  margin-bottom: 6px;
  color: #a9d8ff;
  font-weight: 700;
}

.online-user-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.online-user-typing {
  color: #7fffc7;
}

.ride-hud-label {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(128, 173, 211, 0.35);
  background: rgba(9, 16, 24, 0.7);
  color: #dff2ff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 16;
}

.ride-hud-label.visible {
  opacity: 1;
}

.ride-hud-controls {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  display: inline-flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 16;
}

.ride-hud-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

.ride-hud-btn {
  border: 1px solid rgba(145, 191, 228, 0.45);
  background: rgba(12, 24, 35, 0.82);
  color: #e4f4ff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ride-hud-btn.active {
  background: rgba(39, 73, 103, 0.9);
  border-color: rgba(188, 225, 255, 0.8);
}

.ride-jump-charge {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(220px, calc(100vw - 28px));
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(145, 191, 228, 0.4);
  background: rgba(12, 24, 35, 0.72);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
  z-index: 16;
}

.ride-jump-charge.visible {
  opacity: 1;
}

.ride-jump-charge-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #56d2ff 0%, #7cffbf 62%, #fff18c 100%);
  box-shadow: 0 0 12px rgba(124, 255, 191, 0.45);
  transition: width 0.06s linear;
}

.inventory-panel {
  background: linear-gradient(165deg, rgba(11, 20, 29, 0.95), rgba(15, 28, 39, 0.92));
  border: 1px solid rgba(137, 177, 213, 0.35);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

.inventory-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.inventory-subtitle {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.inventory-grid {
  display: grid;
  gap: 8px;
}

.inventory-item {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(32, 52, 71, 0.45);
  border: 1px solid rgba(128, 173, 211, 0.28);
  border-radius: 10px;
  padding: 10px 12px;
}

.inventory-item.equipped {
  border-color: rgba(126, 245, 189, 0.75);
  box-shadow: 0 0 0 1px rgba(126, 245, 189, 0.4) inset;
}

.inventory-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inventory-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(87, 138, 184, 0.25);
  border: 1px solid rgba(128, 173, 211, 0.32);
}

.inventory-item-icon.has-asset-icon,
.craft-slot.has-asset-icon {
  background: rgba(115, 185, 231, 0.15);
}

.inventory-item-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
}

.craft-slot .inventory-item-icon-img {
  width: 42px;
  height: 42px;
}

.inventory-item-name {
  text-transform: capitalize;
}

.inventory-item-count {
  color: #a8ffd8;
  font-weight: 700;
}

.inventory-empty {
  color: var(--muted);
  background: rgba(24, 37, 51, 0.45);
  border: 1px dashed rgba(128, 173, 211, 0.35);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.craft-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(128, 173, 211, 0.22);
}

.craft-title {
  margin: 0 0 10px;
  font-size: 14px;
  color: #d9ebff;
}

.craft-grid {
  display: grid;
  gap: 7px;
}

.craft-grid-2 {
  grid-template-columns: repeat(2, 1fr);
  max-width: 140px;
}

.craft-grid-3 {
  grid-template-columns: repeat(3, 1fr);
  max-width: 210px;
}

.craft-slot {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 1px dashed rgba(138, 184, 221, 0.4);
  background: rgba(26, 41, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  user-select: none;
}

.craft-slot.filled {
  border-style: solid;
  border-color: rgba(164, 214, 255, 0.55);
}

.craft-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.craft-result {
  color: var(--muted);
  font-size: 12px;
}

.craft-btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  color: #062515;
  background: linear-gradient(130deg, #63ffca, #2fe89e);
  font-weight: 700;
  cursor: pointer;
}

.craft-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.workbench-section {
  margin-top: 16px;
}

.workbench-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.craft-close-btn {
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(50, 78, 104, 0.7);
  color: var(--text);
  cursor: pointer;
}

.inventory-item-menu {
  position: absolute;
  right: 10px;
  top: calc(100% + 6px);
  width: min(220px, 92%);
  background: rgba(9, 15, 22, 0.97);
  border: 1px solid rgba(128, 173, 211, 0.35);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  z-index: 3;
}

.inventory-item-menu-btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  color: var(--text);
  background: rgba(43, 69, 93, 0.65);
  cursor: pointer;
}

.inventory-item-menu-btn:hover {
  background: rgba(67, 106, 140, 0.72);
}

.chest-actions {
  display: inline-flex;
  gap: 6px;
}

.chest-actions .inventory-item-menu-btn {
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
}

#pauseMenu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(12, 17, 23, 0.95);
  border: 1px solid rgba(137, 177, 213, 0.35);
  border-radius: 12px;
  padding: 22px;
  display: none;
}

#pauseMenu button {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 0;
  border-radius: 9px;
  background: #244058;
  color: #eaf4ff;
  cursor: pointer;
}

#pauseMenu .pause-menu-logout {
  margin-top: 18px;
  background: #8b2f2f;
}

.admin-window {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 12, 0.6);
}

.admin-panel {
  width: min(460px, calc(100vw - 24px));
  background: rgba(10, 17, 24, 0.96);
  border: 1px solid rgba(137, 177, 213, 0.35);
  border-radius: 12px;
  padding: 14px;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.admin-head h3 {
  margin: 0;
}

.admin-close {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(60, 84, 106, 0.8);
  color: #eaf4ff;
  cursor: pointer;
}

.admin-panel input,
.admin-panel select {
  width: 100%;
  margin: 6px 0 10px;
}

.admin-panel button {
  width: 100%;
  margin-top: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 6px 0 12px;
}

.admin-row button {
  margin-top: 0;
}

.admin-note {
  margin: 0 0 8px;
  color: var(--muted);
}

.admin-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: #a9d8ff;
  font-size: 13px;
}

.mobile-controls {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: none;
  justify-content: space-between;
  align-items: stretch;
  padding: 14px 16px 18px;
  z-index: 20;
  pointer-events: none;
}

.mobile-controls.active {
  display: flex;
}

.mobile-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: flex-end;
  pointer-events: auto;
}

.mobile-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  align-self: flex-end;
  pointer-events: auto;
}

.mobile-top-right {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  margin-left: auto;
  pointer-events: auto;
}

.touch-btn {
  border: 1px solid rgba(145, 191, 228, 0.4);
  background: rgba(12, 24, 35, 0.75);
  color: #e4f4ff;
  border-radius: 999px;
  padding: 13px 18px;
  min-width: 118px;
  font-size: 14px;
  backdrop-filter: blur(4px);
  touch-action: none;
}

.touch-btn:active {
  background: rgba(39, 73, 103, 0.86);
}

.touch-btn.active {
  background: rgba(39, 73, 103, 0.86);
  border-color: rgba(188, 225, 255, 0.65);
}

.touch-btn-small {
  min-width: 92px;
  padding: 10px 15px;
  font-size: 13px;
}

.touch-dismount {
  display: none;
}

.touch-dismount.active {
  display: inline-block;
}

.touch-mount {
  display: none;
}

.touch-mount.active {
  display: inline-block;
}

.touch-pad {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  border: 1px solid rgba(145, 191, 228, 0.4);
  background: rgba(12, 24, 35, 0.62);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.touch-knob {
  position: absolute;
  width: 54px;
  height: 54px;
  left: 41px;
  top: 41px;
  border-radius: 50%;
  background: rgba(119, 194, 255, 0.8);
  border: 1px solid rgba(190, 229, 255, 0.85);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

@media (max-width: 520px) {
  .auth-card {
    padding: 20px;
    border-radius: 14px;
  }

  h1 {
    font-size: 24px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .mobile-controls {
    position: fixed;
    inset: 0;
    padding: 0;
  }

  .mobile-top-right {
    position: absolute;
    right: max(8px, env(safe-area-inset-right));
    top: max(8px, env(safe-area-inset-top));
    z-index: 22;
  }

  .mobile-left {
    position: absolute;
    left: 0;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 8px;
    z-index: 22;
  }

  .mobile-left .touch-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .mobile-right {
    position: absolute;
    right: max(14vw, 56px);
    bottom: max(10px, env(safe-area-inset-bottom));
    align-items: flex-end;
    z-index: 22;
  }

  .chat-ui {
    left: auto;
    right: max(8px, env(safe-area-inset-right));
    top: calc(max(8px, env(safe-area-inset-top)) + 52px);
    width: min(360px, calc(100vw - 16px - env(safe-area-inset-right)));
    background: rgba(8, 14, 20, 0.48);
    border-color: rgba(125, 170, 209, 0.2);
  }

  .chat-line {
    background: rgba(30, 49, 66, 0.4);
  }

  .mobile-controls.active {
    display: flex;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .ride-hud-label {
    top: calc(max(8px, env(safe-area-inset-top)) + 56px);
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
    text-align: center;
    z-index: 23;
  }

  .ride-hud-controls {
    top: calc(max(8px, env(safe-area-inset-top)) + 96px);
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    z-index: 23;
  }

  .ride-jump-charge {
    top: calc(max(8px, env(safe-area-inset-top)) + 138px);
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    z-index: 23;
  }

  .ride-hud-btn {
    font-size: 13px;
    padding: 9px 13px;
  }
}
