@font-face {
  font-family: 'HT Kurdish';
  src: url('../assets/fonts/kurdish-bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #070812;
  --panel: rgba(10, 12, 22, 0.88);
  --line: rgba(62, 240, 255, 0.45);
  --cyan: #3ef0ff;
  --magenta: #ff3ec8;
  --lime: #c6ff4a;
  --text: #e8f4f8;
  --muted: #9aa8b8;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'HT Kurdish', 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}
textarea, input { user-select: text; -webkit-user-select: text; touch-action: manipulation; }
button, a { touch-action: manipulation; }
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
[hidden] { display: none !important; }
.en, .en-title { font-family: 'Segoe UI', Tahoma, sans-serif; }
.en { color: var(--muted); margin: 0 0 8px; font-size: 0.92rem; }
.en-title { letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78rem; color: var(--cyan); margin: 0 0 8px; }

#help, #feedback, #leave { z-index: 8; }
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
  background: rgba(5, 6, 12, 0.82);
}
.panel {
  width: min(440px, 100%);
  margin: 0 auto;
  background: rgba(7, 9, 16, 0.97);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 14px;
  box-shadow: 0 0 0 1px rgba(255, 62, 200, 0.18), 0 18px 50px rgba(0, 0, 0, 0.35);
  max-height: calc(100vh - 16px - var(--safe-t) - var(--safe-b));
  max-height: calc(100dvh - 16px - var(--safe-t) - var(--safe-b));
  max-height: calc(var(--app-h, 100dvh) - 16px - var(--safe-t) - var(--safe-b));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.panel.wide { width: min(640px, 100%); }
h1, h2, h3, h4 { margin: 0 0 6px; font-weight: 700; }
h1 { font-size: 2.4rem; line-height: 1.05; }
h2 { font-size: 1.45rem; }
h3 { margin-top: 14px; color: var(--cyan); font-size: 1.05rem; }
h4 { margin: 10px 0 2px; font-size: 0.98rem; }
p { margin: 0 0 8px; line-height: 1.45; }
.studio { margin: 0; color: var(--magenta); font-size: 0.82rem; letter-spacing: 0.04em; }
.tag { color: var(--text); }
.age {
  display: inline-block;
  border: 1px solid var(--lime);
  color: var(--lime);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.btn, .chip, .stars button {
  font: inherit;
  color: var(--bg);
  background: var(--cyan);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}
.btn { display: block; width: 100%; margin: 8px 0; font-size: 1.05rem; }
.btn.alt { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:focus-visible, .chip:focus-visible, .stars button:focus-visible, a:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }
.row.tight { gap: 6px; }
.row.wrap { flex-wrap: wrap; max-width: 280px; justify-content: flex-end; }
.records {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.records b { color: var(--text); }
.settings { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; }
.chip { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 6px 10px; }
.chip.on { background: var(--cyan); color: var(--bg); }
.swatches { display: flex; gap: 6px; }
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}
.swatch.on { border-color: #fff; }
.swatch:disabled { opacity: 0.35; cursor: default; }
.ai { color: var(--muted); font-size: 0.82rem; margin-top: 10px; }
.legal { color: #7f8b99; font-size: 0.75rem; margin: 8px 0 0; font-family: 'Segoe UI', Tahoma, sans-serif; direction: ltr; unicode-bidi: isolate; text-align: center; }
.owner { color: #8b93a3; font-size: 0.72rem; margin: 6px 0 0; font-family: 'Segoe UI', Tahoma, sans-serif; direction: ltr; unicode-bidi: isolate; text-align: center; }
.banner, .notice, .warn {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.92rem;
}
.banner { border: 1px solid var(--lime); background: rgba(198, 255, 74, 0.08); }
.ios-line {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--lime);
  border-radius: 10px;
  padding: 4px 8px;
  margin: 0 0 6px;
  background: rgba(198, 255, 74, 0.08);
  font-size: 0.75rem;
  line-height: 1.25;
}
.ios-line p {
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 420px) {
  .ios-line p {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
}
.ios-line button {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--lime);
  background: transparent;
  color: var(--lime);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.notice { border: 1px solid var(--line); background: rgba(62, 240, 255, 0.06); }
.warn { border: 1px solid var(--magenta); color: #ffd6f4; background: rgba(255, 62, 200, 0.08); }
a { color: var(--cyan); }
#community { list-style: none; padding: 0; margin: 8px 0; }
#community li { margin: 6px 0; }
#community a {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
}
label { display: block; margin-top: 8px; }
textarea {
  width: 100%;
  margin-top: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0c1018;
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
  resize: vertical;
}
.stars { display: flex; gap: 6px; margin: 8px 0; }
.stars button { flex: 1; background: transparent; color: var(--text); border: 1px solid var(--line); }
.stars button.on { background: var(--magenta); color: #1a0614; border-color: var(--magenta); }
#fbCount { color: var(--muted); font-size: 0.8rem; text-align: end; }
#fbStatus { min-height: 1.2em; color: var(--lime); }
.url { font-family: 'Segoe UI', Tahoma, sans-serif; font-size: 0.8rem; color: var(--cyan); word-break: break-all; }

#hud {
  position: fixed;
  z-index: 3;
  inset: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) auto calc(8px + var(--safe-l));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
#hud button { pointer-events: auto; }
.hud-top { display: flex; gap: 16px; align-items: flex-start; }
#floorLabel { font-size: 1.15rem; }
#floorName, #timerLabel { color: var(--muted); font-size: 0.78rem; }
#placeRow { color: var(--lime); font-size: 0.95rem; margin-top: 2px; }
#placeNum { font-weight: 700; }
#raceResults { list-style: none; padding: 0; margin: 8px 0 12px; }
#raceResults li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
#raceResults .who { display: flex; align-items: center; gap: 8px; }
#raceResults i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
#raceResults .me { color: var(--cyan); }
#timer, #floorNum { font-variant-numeric: tabular-nums; font-family: 'Segoe UI', Tahoma, sans-serif; unicode-bidi: isolate; }
#timer { font-size: 1.25rem; color: var(--cyan); }
#floorNum { font-weight: 700; }
.hud-actions { display: flex; gap: 6px; }
.hud-actions button, #jumpBtn {
  font: inherit;
  background: rgba(8, 10, 18, 0.72);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 44px;
  min-height: 44px;
}
#touch { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#stickZone, #lookZone {
  pointer-events: auto;
  position: absolute;
  width: var(--stick, 120px);
  height: var(--stick, 120px);
  touch-action: none;
}
#stickZone {
  --stick: 120px;
  left: calc(16px + var(--safe-l));
  bottom: calc(16px + var(--safe-b));
}
#lookZone {
  --stick: 112px;
  --jump-w: 84px;
  --jump-b: 28px;
  --jump-r: 18px;
  right: calc(var(--jump-r) + (var(--jump-w) - var(--stick)) / 2 + var(--safe-r));
  bottom: calc(var(--jump-b) + var(--jump-w) + 14px + var(--safe-b));
}
#stick, #lookStick {
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  border: 2px solid rgba(62, 240, 255, 0.8);
  background: rgba(8, 10, 18, 0.88);
}
#lookStick { border-color: rgba(255, 62, 200, 0.85); }
#knob, #lookKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: rgba(62, 240, 255, 0.85);
}
#lookKnob { background: rgba(255, 62, 200, 0.9); }
#jumpBtn {
  pointer-events: auto;
  position: absolute;
  right: calc(18px + var(--safe-r));
  bottom: calc(28px + var(--safe-b));
  width: 84px;
  height: 84px;
  border-radius: 50%;
  color: var(--bg);
  background: rgba(198, 255, 74, 0.92);
  border-color: var(--lime);
  font-size: 0.95rem;
}
#rotate {
  display: none;
  position: fixed;
  z-index: 4;
  top: calc(58px + var(--safe-t));
  left: calc(8px + var(--safe-l));
  right: calc(8px + var(--safe-r));
  width: auto;
  max-width: 420px;
  margin: 0 auto;
  pointer-events: none;
  background: rgba(7, 8, 18, 0.92);
  border: 1px solid var(--cyan);
  border-radius: 12px;
  padding: 4px 6px 4px 8px;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  line-height: 1.2;
}
#rotate.show { display: flex; }
#rotate .rotate-copy { flex: 1; min-width: 0; }
#rotate p { margin: 0; }
#rotate button {
  pointer-events: auto;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--cyan);
  background: transparent;
  color: var(--cyan);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
@media (max-width: 430px) {
  #hud { align-items: center; flex-wrap: nowrap; }
  .hud-top { flex-direction: row; align-items: center; gap: 6px; min-width: 0; }
  .hud-top > div:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; }
  #floorName, #timerLabel { display: none; }
  #floorLabel, #placeRow, #timer { font-size: 0.78rem; white-space: nowrap; }
  #placeRow { margin: 0; }
  #timer { font-size: 0.78rem; }
  .hud-actions { gap: 3px; flex: none; }
  .hud-actions button, #gemBtn { min-width: 32px; min-height: 32px; padding: 0 4px; font-size: 0.85rem; }
  #stickZone { --stick: 104px; left: calc(10px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); }
  #lookZone { --stick: 96px; --jump-w: 72px; --jump-b: 18px; --jump-r: 12px; }
  #jumpBtn { width: 72px; height: 72px; right: calc(12px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); font-size: 0.82rem; }
  #dashBtn { width: 54px; height: 54px; right: calc(90px + var(--safe-r)); bottom: calc(24px + var(--safe-b)); }
}
@media (max-height: 420px) {
  #lookZone { --stick: 88px; }
  #stickZone { --stick: 100px; }
}
#flash {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: rgba(255, 40, 80, 0);
}
#flash.on { background: rgba(255, 40, 80, 0.28); }
#toast {
  position: fixed;
  z-index: 7;
  top: calc(64px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 10, 18, 0.9);
  border: 1px solid var(--lime);
  color: var(--lime);
  border-radius: 999px;
  padding: 6px 14px;
  pointer-events: none;
  opacity: 0;
}
#toast.on { opacity: 1; }
#glLost {
  position: fixed;
  z-index: 30;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px));
  background: rgba(7, 9, 16, 0.96);
  border: 1px solid var(--cyan);
  border-radius: 16px;
  padding: 16px 18px;
  text-align: center;
}

#dashBtn {
  pointer-events: auto;
  position: absolute;
  right: calc(112px + var(--safe-r));
  bottom: calc(42px + var(--safe-b));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font: inherit;
  color: var(--text);
  background: rgba(8, 10, 18, 0.82);
  border: 1px solid var(--magenta);
}
#gemBtn {
  pointer-events: auto;
  font: inherit;
  background: rgba(8, 10, 18, 0.82);
  color: var(--lime);
  border: 1px solid var(--lime);
  border-radius: 12px;
  min-height: 44px;
  padding: 0 10px;
}
.upgrade {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 8px 0;
}
.upgrade .sub { color: var(--muted); font-size: 0.88rem; margin: 2px 0 8px; }
.upgrade .btn { margin: 0; }
@media (max-height: 420px) {
  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.15rem; }
  .panel { padding: 8px 10px; }
  .btn { padding: 8px 12px; margin: 4px 0; }
  #menu .studio, #menu .en-title, #menu .tag { font-size: 0.75rem; margin-bottom: 2px; }
  #menu .age { margin-bottom: 4px; font-size: 0.72rem; }
  #menu .tag { display: none; }
  #leave p { margin-bottom: 4px; font-size: 0.8rem; line-height: 1.25; }
  #leave h2 { margin-bottom: 4px; }
}
