@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Dxx78j6PP2D_kU2muijPEe1n2vVbfJRklWgzORc.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Dxx78j6PP2D_kU2muijPEe1n2vVbfJRklY80ORc.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #07111f;
  --panel: #0f172a;
  --line: rgba(148, 163, 184, 0.22);
  --gold: #d9a441;
  --gold-bright: #f0c46a;
  --paper: #e8edf5;
  --muted: #94a3b8;
  --accent: #3b82f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 18%, #1e293b 0%, #0f172a 52%, #07111f 100%);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  color: var(--paper);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 18%, #1e293b 0%, #0f172a 52%, #07111f 100%);
  transition: opacity 0.35s ease;
}
#boot.is-gone {
  opacity: 0;
  pointer-events: none;
}
.boot-card { text-align: center; color: var(--muted); }
.boot-spin {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid rgba(217, 164, 65, 0.2);
  border-top-color: var(--gold);
  animation: boot-spin 0.8s linear infinite;
}
.boot-card p { font-size: 0.85rem; }
@keyframes boot-spin { to { transform: rotate(360deg); } }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; cursor: grab; }
#scene canvas.is-drag { cursor: grabbing; }

.hud { position: fixed; pointer-events: none; z-index: 3; }

#title { top: 16px; right: 18px; left: 18px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
#title .eyebrow { font-size: 11px; letter-spacing: 0.18em; color: var(--gold); opacity: 0.9; margin-bottom: 4px; }
#title h1 { font-size: clamp(18px, 3vw, 24px); font-weight: 700; }
#statusBox { text-align: left; background: rgba(15, 23, 42, 0.72); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; backdrop-filter: blur(8px); min-width: 140px; }
#statusBox .turn { font-weight: 700; color: var(--gold-bright); font-size: 0.92rem; }
#statusBox .note { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

#views { position: fixed; bottom: 18px; right: 18px; display: flex; gap: 8px; z-index: 4; flex-wrap: wrap; max-width: 58vw; }
.vbtn, .ctrl-btn {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 8px 12px;
  font-size: 11px;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
}
.vbtn:hover, .ctrl-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.vbtn.active { background: var(--gold); color: #1a140d; border-color: var(--gold); }

#gizmo { position: fixed; bottom: 18px; left: 18px; width: 84px; height: 84px; pointer-events: none; z-index: 3; }

.panel-toggle {
  position: fixed;
  top: 78px;
  right: 18px;
  z-index: 6;
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  border-radius: 10px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.panel-toggle:hover { border-color: var(--gold); color: var(--gold-bright); }
.panel-toggle[hidden] { display: none !important; }

#panel {
  position: fixed;
  top: 78px;
  right: 18px;
  z-index: 5;
  width: min(280px, calc(100vw - 28px));
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(10px);
  pointer-events: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
#panel.is-closed { display: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
#panel h2 { font-size: 0.95rem; margin: 0; }
.panel-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper);
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.panel-close:hover { border-color: var(--gold); color: var(--gold-bright); }
.modes { display: flex; gap: 8px; margin-bottom: 12px; }
.modebtn {
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper);
  border-radius: 8px;
  padding: 8px;
  font-family: inherit;
  cursor: pointer;
}
.modebtn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.level-wrap { margin-bottom: 12px; }
.level-wrap label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.level-wrap b { color: var(--gold-bright); }
input[type="range"] { width: 100%; accent-color: var(--gold); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { flex: 1; min-width: 110px; }

#overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(7, 17, 31, 0.72);
  z-index: 8;
}
#overlay.show { display: flex; }
#overlay .card {
  background: #0f172a;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: min(360px, calc(100vw - 32px));
  text-align: center;
}
#overlay h2 { margin-bottom: 8px; }
#overlay p { color: var(--muted); margin-bottom: 16px; font-size: 0.9rem; }

.hint-on { box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45); }

@media (max-width: 720px) {
  #title { flex-direction: column; }
  #statusBox { text-align: right; }
  #panel { top: auto; bottom: 70px; right: 12px; left: 12px; width: auto; }
  .panel-toggle { top: auto; bottom: 70px; right: 12px; }
  #views { right: 12px; left: 110px; max-width: none; }
  #gizmo { left: 10px; bottom: 12px; }
}
