/* Misket — arayüz stilleri.
   Oyun alanı canvas'ta çiziliyor; buradaki her şey onun üstünde duran katman. */

:root {
  --ink: #16211f;
  --ink-soft: #4d5f5c;
  --line: rgba(22, 33, 31, 0.12);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --accent: #1b4d48;
  --accent-soft: rgba(27, 77, 72, 0.1);
  --shadow: 0 8px 30px rgba(20, 35, 33, 0.12);
  --radius: 14px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

/* hidden özniteliği tarayıcı stilinde display:none veriyor ama aşağıdaki
   .help-backdrop, .controls gibi kurallar display'i geri açıyor. O yüzden
   gizli elemanları burada kesin olarak kapatıyoruz — yoksa görünmez paneller
   ekranı kaplayıp tıklamaları yutuyor. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: #fbfbfb;
  /* Mobilde sürükleyerek nişan alırken sayfa kaymasın. */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

#playfield {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* pointer olayları tarayıcı jestlerine yenilmesin */
}

/* --- Üst çubuk ------------------------------------------------------------ */

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none; /* boşlukları tıklanabilir bırakma, altta oyun var */
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  /* Küçük bir cam misket: parlaklık sol üstte. */
  background:
    radial-gradient(circle at 33% 28%, #ffffff 0%, rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 62% 68%, #3fa89b 0%, #1b4d48 78%);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.25);
}

.mode-switcher {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
}

.mode-switcher button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 15px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.mode-switcher button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.top-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 8px;
}

/* --- Düğmeler ------------------------------------------------------------- */

button {
  font-family: inherit;
}

.icon-button,
.compact-button,
.game-hud button,
.controls button,
.result-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap; /* dar ekranda "Sonucu paylaş" iki satıra düşüyordu */
  transition: background 0.16s, border-color 0.16s, transform 0.1s;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
}

.icon-button:hover,
.compact-button:hover,
.game-hud button:hover,
.controls button:hover,
.result-actions button:hover {
  background: var(--panel-solid);
  border-color: rgba(22, 33, 31, 0.2);
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: #143b37;
  border-color: #143b37;
}

.compact-button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: rgba(27, 77, 72, 0.28);
}

.button-icon {
  font-size: 12px;
  line-height: 1;
}

/* --- Oyun durumu ---------------------------------------------------------- */

.game-hud,
.controls {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  max-width: calc(100vw - 24px);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.stat span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.stat strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.divider {
  width: 1px;
  height: 26px;
  background: var(--line);
}

.controls {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.control-row,
.surface-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.surface-switcher > span,
.count-control > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.surface-switcher button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.count-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.count-control input {
  width: 128px;
  accent-color: var(--accent);
}

.count-control output {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  min-width: 2ch;
  text-align: right;
}

/* --- Nişan alma ----------------------------------------------------------- */

.aim-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.aim-layer.visible {
  opacity: 1;
}

.aim-layer line {
  stroke: rgba(27, 77, 72, 0.55);
  stroke-width: 2;
  stroke-dasharray: 7 6;
  stroke-linecap: round;
}

.aim-layer circle {
  fill: rgba(27, 77, 72, 0.75);
}

/* Üstte duruyor çünkü atış misketi ekranın altında ve nişan çizgisi yukarı
   uzanıyor; alt ortada olunca misketin üstüne biniyordu. */
.power-meter {
  position: absolute;
  left: 50%;
  top: max(72px, calc(env(safe-area-inset-top) + 58px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.power-caption {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.power-track {
  width: 116px;
  height: 5px;
  border-radius: 999px;
  background: rgba(22, 33, 31, 0.1);
  overflow: hidden;
}

.power-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #3fa89b, #1b4d48);
  transform-origin: left center;
  transform: scaleX(0);
}

.power-meter strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: right;
}

/* --- Sonuç ---------------------------------------------------------------- */

.result-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 34px 22px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(20, 35, 33, 0.18);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.result-panel.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.result-panel h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.result-stars {
  font-size: 26px;
  letter-spacing: 3px;
  color: #e8b93c;
}

#result-score {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Yardım --------------------------------------------------------------- */

.help-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 28, 27, 0.34);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.help-dialog {
  position: relative;
  width: min(430px, 100%);
  max-height: 84dvh;
  overflow-y: auto;
  padding: 26px 26px 22px;
  background: var(--panel-solid);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(20, 35, 33, 0.24);
}

.help-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(22, 33, 31, 0.06);
  font-size: 18px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}

.help-eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}

.help-dialog h1 {
  margin: 4px 0 18px;
  font-size: 21px;
  font-weight: 600;
}

.help-content section + section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.help-content h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.help-content p {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}

.help-content .note {
  font-size: 12.5px;
  color: var(--ink-soft);
}

#help-confirm {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
}

/* --- Bildirim ------------------------------------------------------------- */

.toast {
  position: absolute;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  padding: 9px 16px;
  background: rgba(22, 33, 31, 0.9);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
}

.error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  text-align: center;
  background: #fbfbfb;
  font-size: 15px;
  color: var(--ink-soft);
}

/* --- Dar ekran ------------------------------------------------------------ */

@media (max-width: 560px) {
  .brand strong {
    display: none;
  }

  .button-label {
    display: none;
  }

  .compact-button,
  .controls button {
    padding: 8px 11px;
  }

  .count-control input {
    width: 92px;
  }

  .game-hud,
  .controls {
    gap: 9px;
    padding: 8px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
