:root {
  --panel: rgba(12, 18, 32, 0.8);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f5f7fb;
  --muted: #b8c2d6;
  --accent: #f5b544;
  --focus: #7cc4ff;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cfe6f5;
  font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
}

/* حلقة التركيز لمستخدمي لوحة المفاتيح */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}

.title svg {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  outline: none;
}

.hidden {
  display: none !important;
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.top {
  top: 0;
}

.bottom {
  bottom: 0;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 13px;
  padding-bottom: 14px;
}

.bottom span {
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 8px;
}

.title {
  font-weight: 700;
  font-size: 18px;
  background: var(--panel);
  padding: 8px 14px;
  border-radius: 10px;
}

.btn {
  background: var(--accent);
  color: #1b1b1b;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.btn:hover {
  filter: brightness(1.07);
}

.panel {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 270px;
  max-height: 70vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 14px;
  padding: 12px;
  z-index: 5;
}

.panel h2 {
  font-size: 16px;
  margin: 4px 6px 10px;
}

.panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.panel button.shop {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-family: inherit;
}

.panel button.shop:hover {
  background: rgba(255, 255, 255, 0.16);
}

.panel button.shop small {
  opacity: 0.7;
}

.prompt {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 4;
  white-space: nowrap;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  transform: translate(-50%, -140%);
  z-index: 6;
  white-space: nowrap;
}

.floor-badge {
  position: fixed;
  top: 64px;
  left: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 4;
  pointer-events: none;
}

.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 7;
}

#loading {
  position: fixed;
  inset: 0;
  background: #0b1220;
  display: grid;
  place-items: center;
  z-index: 20;
  transition: opacity 0.6s;
}

#loading.done {
  opacity: 0;
  pointer-events: none;
}

.box {
  text-align: center;
  width: min(360px, 80vw);
}

.bar {
  height: 8px;
  background: #1d2a44;
  border-radius: 6px;
  overflow: hidden;
  margin: 16px 0 10px;
}

#bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

/* عصا التحكم للجوال */
.joy {
  position: fixed;
  left: 20px;
  bottom: 24px;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
  touch-action: none;
  z-index: 8;
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

@media (max-width: 900px), (orientation: portrait) {
  .panel {
    width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
    max-height: 45vh;
  }
  .bottom {
    display: none;
  }
  .prompt {
    bottom: 170px;
    font-size: 14px;
  }
  .title {
    font-size: 15px;
  }
}
