@font-face {
  font-family: Vazirmatn;
  src: url("fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b1210;
  --ivory: #f4efe6;
  --muted: #b7c0b6;
  --gold: #e4c78a;
  --gold-dim: rgba(228, 199, 138, 0.22);
  --jade: #9ddec0;
  --ink: #16130e;
  --danger: #e7b5a0;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
html { overflow-x: clip; }

body {
  margin: 0 auto;
  width: min(480px, 100%);
  max-width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(228, 199, 138, 0.08), transparent 60%),
    var(--bg);
  color: var(--ivory);
  font-family: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  font-weight: 450;
  line-height: 1.45;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  padding:
    calc(10px + env(safe-area-inset-top))
    calc(14px + env(safe-area-inset-right))
    calc(10px + env(safe-area-inset-bottom))
    calc(14px + env(safe-area-inset-left));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><g fill='none' stroke='%23e4c78a' stroke-width='1.2'><path d='M70 8 L86 54 L132 70 L86 86 L70 132 L54 86 L8 70 L54 54 Z'/><path d='M70 28 L82 70 L70 112 L58 70 Z'/></g></svg>");
  background-size: 148px 148px;
}

.lamp {
  position: fixed;
  left: 50%;
  top: -8vh;
  width: min(80vw, 640px);
  height: 42vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(228, 199, 138, 0.16), transparent 70%);
  pointer-events: none;
}

.top, main, dialog { position: relative; z-index: 1; min-width: 0; max-width: 100%; }

.top {
  width: 100%;
  margin: 0 0 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  flex: 0 0 auto;
}

.brand { min-width: 0; max-width: 100%; flex: 1 1 11rem; }

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: 0.82rem;
}

.latin .kicker {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

h1 {
  margin: 0;
  font-size: clamp(1rem, 4.2vw, 1.22rem);
  font-weight: 680;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.langs { display: flex; gap: 6px; flex: 0 0 auto; margin-inline-start: auto; }

.langs button,
button {
  font: inherit;
  color: var(--ivory);
  background: rgba(228, 199, 138, 0.06);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
}

.langs button { min-height: 34px; padding: 0 10px; font-size: 0.86rem; white-space: nowrap; }

.langs button[aria-pressed="true"],
button.primary {
  background: linear-gradient(#f0ddb4, #c6a15c);
  color: var(--ink);
  border-color: transparent;
  font-weight: 650;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

main {
  width: 100%;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instrument {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: auto;
}

.turn, .warn, .stats { flex: 0 0 auto; }

.turn {
  width: 100%;
  margin: 2px 0 4px;
  text-align: center;
  font-size: clamp(0.98rem, 3.6vw, 1.15rem);
  font-weight: 700;
  line-height: 1.25;
}

.turn.locked { color: var(--jade); }

.warn {
  margin: 0 auto 8px;
  max-width: 36rem;
  text-align: center;
  color: var(--danger);
  font-size: 0.95rem;
}

.dial {
  position: relative;
  flex: 1 1 auto;
  align-self: center;
  min-height: 0;
  min-width: 0;
  width: min(100%, 42dvh);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
}

.dial svg { width: 100%; height: 100%; display: block; }

.dial.locked svg {
  filter: drop-shadow(0 0 14px rgba(157, 222, 192, 0.45));
}

.lubber {
  position: absolute;
  top: 1.5%;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 16px solid var(--gold);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.hub {
  position: absolute;
  inset: 33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #2a3832, #101816 72%);
  box-shadow: inset 0 0 0 1px rgba(228, 199, 138, 0.38);
}

.hub-value {
  font-size: clamp(1.7rem, 5vw, 2.35rem);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  direction: ltr;
  unicode-bidi: isolate;
}

.hub-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px auto 0;
  width: 100%;
}

.stats div {
  min-width: 0;
  padding: 8px 6px 6px;
  text-align: center;
  border: 1px solid var(--gold-dim);
  border-radius: 16px;
  background: rgba(8, 14, 12, 0.45);
}

.stats dt {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stats dd {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.place, .phone-heading, .privacy, .help p {
  margin: 0 0 12px;
  color: var(--muted);
}

.place { color: var(--ivory); font-size: 0.95rem; overflow-wrap: anywhere; }

.ios-note {
  margin: 0 0 8px;
  text-align: center;
  color: var(--gold);
  font-size: 0.92rem;
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.actions button {
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.95rem;
  white-space: normal;
  line-height: 1.15;
}

#compass {
  grid-column: 1 / -1;
  min-height: 52px;
}

.offset {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--muted);
}

.offset input { grid-column: 1 / -1; width: 100%; accent-color: #c6a15c; }

.offset b {
  color: var(--gold);
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.help summary {
  cursor: pointer;
  color: var(--gold);
  list-style: none;
}

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

.privacy { font-size: 0.86rem; }

dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: min(86dvh, 760px);
  padding: 16px;
  border: 1px solid var(--gold-dim);
  border-radius: 22px;
  background: #121a17;
  color: var(--ivory);
}

dialog::backdrop { background: rgba(4, 8, 7, 0.72); }

.dialog-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-top h2 { margin: 0; font-size: 1.2rem; }

.ghost { min-width: 44px; }

input, select, textarea { font-size: 16px; }

#city-search,
.manual input {
  width: 100%;
  margin-top: 10px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--gold-dim);
  background: #0c1412;
  color: var(--ivory);
  font: inherit;
  font-size: 16px;
}

.city-list {
  margin-top: 10px;
  max-height: 38dvh;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.city-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  text-align: start;
}

.city-list b { font-weight: 650; }

.city-list span {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.manual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.manual button { grid-column: 1 / -1; }

.manual span { display: block; color: var(--muted); font-size: 0.8rem; }

.noscript {
  width: min(640px, 100%);
  margin: 16px auto;
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  .dial.locked svg { filter: none; }
}
