/* ==========================================================================
   Uçan Behzat 3 — HUD, menüler, dokunmatik kontroller
   3B görüntü sahneyi kaplar; buradaki her şey onun üstünde bir katman.
   ========================================================================== */

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

:root {
  --ink: #f2f6fb;
  --dim: rgba(242, 246, 251, 0.62);
  --faint: rgba(242, 246, 251, 0.34);
  --accent: #ffd23f;
  --good: #6bf0a8;
  --bad: #ff5a5a;
  --shield: #5fd8ff;
  --boost: #ffab4d;
  --panel: rgba(10, 16, 28, 0.86);
  --stroke: rgba(255, 255, 255, 0.14);

  --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);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070d;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#stage { position: fixed; inset: 0; overflow: hidden; }

#game { display: block; width: 100%; height: 100%; }

/* hasar flaşı --------------------------------------------------------------- */
#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center,
    rgba(255, 40, 40, 0) 38%, rgba(255, 30, 30, 0.62) 100%);
}
#flash.on { animation: flashOut 0.5s ease-out; }
@keyframes flashOut { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ==========================================================================
   HUD
   ========================================================================== */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: clamp(10px, 1.05vw, 17px);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}
#hud.hidden { display: none; }

.hud-corner { position: absolute; padding: 1.5em; }
.hud-tl { top: var(--safe-t); left: var(--safe-l); }
.hud-tr { top: var(--safe-t); right: var(--safe-r); text-align: right; }
.hud-bl { bottom: var(--safe-b); left: var(--safe-l); }
.hud-br { bottom: var(--safe-b); right: var(--safe-r); text-align: right; }

.label {
  font-size: 0.72em;
  letter-spacing: 0.2em;
  color: var(--faint);
  font-weight: 700;
}

.score-line { display: flex; align-items: baseline; gap: 0.6em; }
.value.big {
  font-size: 2.5em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sub-line {
  margin-top: 0.45em;
  font-size: 0.9em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.sub-line .sep { margin: 0 0.5em; color: var(--faint); }
.sub-line.dim { color: var(--faint); font-size: 0.75em; letter-spacing: 0.06em; }
.unit { color: var(--faint); margin-left: 0.15em; }

.lives { font-size: 1.9em; letter-spacing: 0.08em; line-height: 1; }
.heart { color: #ff4d6d; filter: drop-shadow(0 0 8px rgba(255, 77, 109, 0.55)); }
.heart.spent { color: rgba(255, 255, 255, 0.16); filter: none; }

/* göstergeler --------------------------------------------------------------- */
.meter-row { display: flex; align-items: center; gap: 0.7em; margin-top: 0.55em; }
.meter-label {
  width: 5.4em;
  font-size: 0.72em;
  letter-spacing: 0.16em;
  color: var(--faint);
  font-weight: 700;
}
.meter {
  width: 13em;
  height: 0.72em;
  border-radius: 1em;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--stroke);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 100%;
  border-radius: 1em;
  transition: width 0.08s linear, filter 0.15s ease;
}
.meter-fill.shield { background: linear-gradient(90deg, #2a8fb8, var(--shield)); }
.meter-fill.boost { background: linear-gradient(90deg, #c76a1e, var(--boost)); }
.meter-fill.active { filter: brightness(1.5) saturate(1.3); }
.key-hint { font-size: 0.62em; letter-spacing: 0.1em; color: var(--faint); }

.mode-badge {
  display: inline-block;
  padding: 0.35em 0.9em;
  border: 1px solid var(--stroke);
  border-radius: 0.4em;
  font-size: 0.76em;
  letter-spacing: 0.18em;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  color: var(--dim);
}
.mode-badge.camera { color: #0b1220; background: var(--accent); border-color: var(--accent); }

/* kombo --------------------------------------------------------------------- */
.combo { position: absolute; top: 15%; left: 50%; transform: translateX(-50%); text-align: center; }
.combo.hidden { display: none; }
#combo-x {
  display: block;
  font-size: 2.4em;
  font-weight: 800;
  color: var(--accent);
  filter: drop-shadow(0 0 14px rgba(255, 210, 63, 0.45));
}
.combo-bar {
  margin-top: 0.3em;
  width: 7em;
  height: 0.24em;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 1em;
  overflow: hidden;
}
#combo-fill { height: 100%; background: var(--accent); border-radius: 1em; }
.combo.pop { animation: comboPop 0.28s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes comboPop {
  0% { transform: translateX(-50%) scale(0.7); }
  60% { transform: translateX(-50%) scale(1.18); }
  100% { transform: translateX(-50%) scale(1); }
}

/* bildirim ------------------------------------------------------------------ */
.toast {
  position: absolute;
  bottom: 24%;
  left: 50%;
  transform: translateX(-50%) translateY(0.6em);
  font-size: 1.2em;
  font-weight: 800;
  letter-spacing: 0.14em;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.good { color: var(--good); }
.toast.bad { color: var(--bad); }
.toast.gold { color: var(--accent); }

/* ==========================================================================
   Kamera önizlemesi (el takibi)
   ========================================================================== */
.cam-panel {
  position: absolute;
  top: calc(var(--safe-t) + 1.5em);
  left: 50%;
  transform: translateX(-50%);
  width: 14em;
  padding: 0.45em;
  background: rgba(6, 12, 22, 0.72);
  border: 1px solid var(--stroke);
  border-radius: 0.6em;
  text-align: center;
}
.cam-panel.hidden { display: none; }
#cam-preview {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.35em;
  background: #06101c;
}
.cam-status {
  margin-top: 0.4em;
  font-size: 0.68em;
  letter-spacing: 0.08em;
  color: var(--dim);
  min-height: 1.2em;
}
.cam-calbar {
  margin-top: 0.3em;
  height: 0.3em;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 1em;
  overflow: hidden;
}
.cam-calbar.hidden { display: none; }
#cam-calfill { height: 100%; width: 0%; background: var(--accent); border-radius: 1em; }

/* ==========================================================================
   Dokunmatik kontroller
   ========================================================================== */
#touch-controls { position: absolute; inset: 0; z-index: 6; }
#touch-controls.hidden { display: none; }

#stick-zone {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 55%;
  touch-action: none;
}

#stick-base {
  position: absolute;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  left: 0; top: 0;
}
#stick-base.active { opacity: 1; }
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.30);
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

#touch-buttons {
  position: absolute;
  right: calc(var(--safe-r) + 18px);
  bottom: calc(var(--safe-b) + 18px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-end;
}
.touch-btn {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--ink);
  border: 2px solid var(--stroke);
  background: rgba(0, 0, 0, 0.3);
  touch-action: none;
  transition: transform 0.08s ease, background 0.08s ease;
}
.touch-btn.shield { border-color: rgba(95, 216, 255, 0.55); }
.touch-btn.boost { width: 86px; height: 86px; border-color: rgba(255, 171, 77, 0.55); font-size: 11px; }
.touch-btn.shield.active { background: rgba(95, 216, 255, 0.4); transform: scale(0.93); }
.touch-btn.boost.active { background: rgba(255, 171, 77, 0.4); transform: scale(0.93); }

/* ==========================================================================
   Menüler
   ========================================================================== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 10px)
           calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
  background: radial-gradient(ellipse at center,
    rgba(4, 8, 16, 0.55) 0%, rgba(4, 8, 16, 0.9) 100%);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.overlay.hidden { display: none; }

.panel {
  width: min(46em, 92vw);
  max-height: 100%;
  padding: 2.2em 2.4em;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 1.1em;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  text-align: center;
  font-size: clamp(12px, 1.05vw, 17px);
}
.panel.scrollable { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.panel.small { width: min(24em, 86vw); }

.title { font-size: 2.6em; font-weight: 800; letter-spacing: 0.05em; line-height: 1.1; }
.title .accent { color: var(--accent); }
.title .accent-bad { color: var(--bad); }
.title .ver { font-size: 0.5em; vertical-align: super; color: var(--faint); }

.tagline { margin-top: 0.7em; color: var(--dim); font-size: 1em; }

.controls-grid {
  margin: 1.6em 0 1.2em;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7em 1.5em;
  text-align: left;
}
.controls-grid.hidden { display: none; }
.ctrl { display: flex; align-items: center; gap: 0.7em; color: var(--dim); font-size: 0.93em; }
.ctrl .keys { display: inline-flex; gap: 0.25em; flex: 0 0 auto; min-width: 6.4em; }
.ctrl .keys.tag {
  font-size: 0.72em;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--accent);
  min-width: 3.4em;
}

kbd {
  display: inline-block;
  min-width: 2em;
  padding: 0.28em 0.55em;
  font: inherit;
  font-size: 0.8em;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
  border-bottom-width: 2px;
  border-radius: 0.35em;
}

/* kamera kutusu ------------------------------------------------------------- */
.cam-box {
  margin: 0 0 1.4em;
  padding: 0.9em 1.1em;
  border: 1px solid var(--stroke);
  border-radius: 0.6em;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}
.cam-box-row { display: flex; align-items: center; gap: 0.7em; font-size: 0.9em; color: var(--dim); }
.cam-dot {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}
.cam-dot.on { background: var(--good); box-shadow: 0 0 10px var(--good); }
.cam-dot.off { background: var(--bad); }
.cam-help {
  margin-top: 0.7em;
  font-size: 0.82em;
  line-height: 1.7;
  color: var(--faint);
}
.cam-help.hidden { display: none; }
.cam-help b { color: var(--dim); }

.btn {
  display: block;
  width: 100%;
  margin-top: 0.7em;
  padding: 0.9em 1.4em;
  font: inherit;
  font-size: 1em;
  font-weight: 800;
  letter-spacing: 0.16em;
  border-radius: 0.6em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.hidden { display: none; }
.btn.primary { color: #10141d; background: linear-gradient(180deg, #ffe07a, var(--accent)); }
.btn.ghost { color: var(--dim); background: transparent; border-color: var(--stroke); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.footnote { margin-top: 1.2em; font-size: 0.78em; color: var(--faint); line-height: 1.6; }
.footnote code { font-family: ui-monospace, Consolas, monospace; color: var(--dim); }
.footnote kbd { font-size: 0.75em; padding: 0.15em 0.4em; }

/* sonuçlar ------------------------------------------------------------------ */
.results { margin: 1.8em 0 1.1em; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1em; }
.result {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 0.85em;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 0.6em;
}
.r-label { font-size: 0.68em; letter-spacing: 0.18em; color: var(--faint); font-weight: 700; }
.r-value { font-size: 1.6em; font-weight: 800; font-variant-numeric: tabular-nums; }

.new-best {
  margin-bottom: 0.9em;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
.new-best.hidden { display: none; }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* yatay çevirme uyarısı ----------------------------------------------------- */
.rotate-hint {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1em;
  padding: 2em;
  text-align: center;
  background: rgba(4, 8, 16, 0.94);
  font-size: 15px;
  color: var(--dim);
}
.rotate-icon { font-size: 3.4em; color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }

/* ==========================================================================
   Duyarlı düzen
   ========================================================================== */

/* dar ekranlar: HUD sıkışır, göstergeler kısalır */
@media (max-width: 900px) {
  .hud-corner { padding: 0.9em; }
  .meter { width: 8.5em; }
  .meter-label { width: 4.6em; }
  .value.big { font-size: 2em; }
  .lives { font-size: 1.5em; }
  .cam-panel { width: 10.5em; top: calc(var(--safe-t) + 0.6em); }
  .controls-grid, .results { grid-template-columns: 1fr; }
  .panel { padding: 1.6em 1.4em; }
  .title { font-size: 2.1em; }
}

/* alçak ekranlar (yatay telefon): dikey alan çok kısıtlı */
@media (max-height: 520px) {
  #hud { font-size: 11px; }
  .hud-corner { padding: 0.7em; }
  .value.big { font-size: 1.7em; }
  .lives { font-size: 1.25em; }
  .meter { width: 7em; height: 0.62em; }
  .combo { top: 8%; }
  #combo-x { font-size: 1.7em; }
  .toast { bottom: 30%; font-size: 1em; }
  .panel { padding: 1.2em 1.3em; font-size: 12px; }
  .title { font-size: 1.7em; }
  .tagline { font-size: 0.9em; }
  .controls-grid { margin: 0.9em 0 0.8em; gap: 0.4em 1em; }
  .results { margin: 0.9em 0 0.7em; gap: 0.6em; }
  .r-value { font-size: 1.25em; }
  .btn { padding: 0.7em 1.2em; margin-top: 0.5em; }
  .footnote { margin-top: 0.7em; }
  .cam-panel { width: 9em; }
  .touch-btn { width: 78px; height: 78px; font-size: 10px; }
  .touch-btn.boost { width: 64px; height: 64px; font-size: 9px; }
  #stick-base { width: 104px; height: 104px; margin: -52px 0 0 -52px; }
  #stick-knob { width: 46px; height: 46px; }
}

/* Dokunmatik cihazda klavyeye özel HUD parçaları yer kaplamasın — üstelik
   KALKAN düğmesi tam o köşeye geliyor. */
body.is-touch .hud-br { display: none; }
body.is-touch .key-hint { display: none; }
body.is-touch .meter { width: 7.5em; }

/* EĞİM modu: yön hem telefonu çevirerek HEM de soldaki analog çubukla
   verilebilir — ikisi birlikte çalışır, panel gizlenmez. */

/* dokunmatik cihazda dikey yön: yan çevir uyarısı */
@media (pointer: coarse) and (orientation: portrait) and (max-width: 820px) {
  .rotate-hint { display: flex; }
}

/* fare olmayan cihazlarda hover efektlerini kapat */
@media (hover: none) {
  .btn:hover { transform: none; filter: none; }
}
