:root {
  --bg: #04050c;
  --panel: rgba(8, 10, 24, 0.78);
  --line: rgba(120, 255, 210, 0.22);
  --text: #e9f1ff;
  --muted: #8a94b8;
  --accent: #39ffb0;
  --accent-2: #ff3d8b;
  --easy: #39ff6a;
  --normal: #2ad4ff;
  --hard: #ff3d8b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

button { touch-action: manipulation; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

/* ------------------------------------------------ HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  /* Çentikli ekranlarda kenar boşluğu */
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 18px max(22px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-score .big {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(36px, 7vw, 64px);
  line-height: 1;
  text-shadow: 0 0 18px rgba(57, 255, 176, 0.55);
}

.hud-score .label {
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.3em;
  font-size: 12px;
  color: var(--muted);
}

.hud-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.hud-stat {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
}

.hud-stat small { color: var(--muted); font-size: 12px; }
.hud-stat.small { font-family: 'Rajdhani', sans-serif; font-size: 15px; color: var(--muted); }

.hud-buttons { display: flex; gap: 8px; pointer-events: auto; }

.chip {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  text-transform: uppercase;
}

.chip[data-diff="easy"] { color: var(--easy); }
.chip[data-diff="normal"] { color: var(--normal); }
.chip[data-diff="hard"] { color: var(--hard); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 30, 0.7);
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: border-color 0.15s, transform 0.1s;
}

.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }

/* ------------------------------------------------ Katmanlar */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(4, 5, 12, 0.35), rgba(4, 5, 12, 0.8));
  overflow-y: auto;
}

.overlay.menu {
  justify-content: flex-start;
  padding-left: max(16px, 5vw);
  background: linear-gradient(90deg, rgba(4, 5, 12, 0.85) 0%, rgba(4, 5, 12, 0.35) 55%, rgba(4, 5, 12, 0) 100%);
}

.panel {
  position: relative;
  width: min(480px, 100%);
  margin: auto 0;
  padding: 26px 26px 22px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 0 40px rgba(57, 255, 176, 0.08), inset 0 0 30px rgba(57, 255, 176, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel.small {
  width: min(380px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.logo {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(34px, 8vw, 48px);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(57, 255, 176, 0.6);
}

.logo span {
  display: block;
  font-size: 0.55em;
  letter-spacing: 0.55em;
  color: var(--accent-2);
  text-shadow: 0 0 18px rgba(255, 61, 139, 0.6);
  margin-top: 6px;
}

.tagline { color: var(--muted); margin: 10px 0 18px; font-size: 16px; }

h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 10px;
  display: flex;
  justify-content: space-between;
}

.ball-name { color: var(--text); letter-spacing: 0.1em; }

.title {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  margin: 0 0 4px;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(57, 255, 176, 0.5);
}

/* Zorluk */
.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.diff-btn {
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s;
  --c: var(--normal);
}

.diff-btn[data-diff="easy"] { --c: var(--easy); }
.diff-btn[data-diff="hard"] { --c: var(--hard); }
.diff-btn b { font-family: 'Orbitron', sans-serif; font-size: 14px; color: var(--c); }
.diff-btn small { color: var(--muted); font-size: 13px; }
.diff-btn:hover { border-color: var(--c); }

.diff-btn.selected {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c) 35%, transparent);
}

/* Top seçimi */
.ball-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.ball-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.ball-card canvas { width: 48px; height: 48px; transition: transform 0.2s; }
.ball-card .ball-label { font-size: 12px; line-height: 1.1; color: var(--muted); text-align: center; }
.ball-card:hover { border-color: var(--accent); }
.ball-card:hover canvas { transform: rotate(-12deg) scale(1.06); }

.ball-card.selected {
  border-color: var(--accent);
  background: rgba(57, 255, 176, 0.1);
  box-shadow: 0 0 16px rgba(57, 255, 176, 0.25);
}

.ball-card.selected .ball-label { color: var(--text); }

/* Butonlar */
.primary {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.2em;
  color: #031a10;
  background: linear-gradient(90deg, var(--accent), #2ad4ff);
  box-shadow: 0 0 24px rgba(57, 255, 176, 0.45);
  transition: transform 0.1s, box-shadow 0.15s;
}

.panel.small .primary { margin-top: 6px; font-size: 16px; }
.primary small, .secondary small { font-family: 'Rajdhani', sans-serif; letter-spacing: 0; opacity: 0.7; font-size: 13px; }
.primary:hover { box-shadow: 0 0 34px rgba(57, 255, 176, 0.7); }
.primary:active { transform: scale(0.98); }

.secondary {
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 16px;
  font-weight: 600;
}

.secondary:hover { border-color: var(--accent); }

.controls {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 14px;
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin-right: 2px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  text-align: center;
  color: var(--text);
}

.credit {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.credit b {
  display: block;
  margin-top: 4px;
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(57, 255, 176, 0.5);
}

.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-only { display: inline; }
  #jump-btn.touch-only { display: grid; place-items: center; }
}

.corner { position: absolute; top: 14px; right: 14px; }
.corner-2 { right: 62px; }

/* Oyun bitti */
.reason { margin: 0; color: var(--accent-2); font-size: 18px; font-weight: 600; }

.record {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: #ffe066;
  text-shadow: 0 0 18px rgba(255, 224, 102, 0.7);
  animation: pulse 0.8s ease-in-out infinite alternate;
}

@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

.go-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.go-stats > div { padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.go-stats .big { display: block; font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 34px; }
.go-stats .dim { color: var(--muted); }
.go-stats label { color: var(--muted); font-size: 14px; }

/* ------------------------------------------------ Jeton */
.coin {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.3em;
  vertical-align: -0.12em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c4 0%, #ffc93c 45%, #c97f00 100%);
  box-shadow: 0 0 8px rgba(255, 201, 60, 0.6), inset 0 0 0 2px rgba(150, 90, 0, 0.35);
}

.hud-coins {
  margin-top: 8px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: #ffd34d;
  text-shadow: 0 0 12px rgba(255, 201, 60, 0.5);
}

.wallet {
  position: absolute;
  top: 18px;
  right: 112px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 201, 60, 0.35);
  background: rgba(255, 201, 60, 0.08);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #ffd34d;
}

/* Kilitli toplar */
.ball-card { position: relative; }

.ball-card .price {
  display: none;
  font-family: 'Orbitron', sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  color: #ffd34d;
}

.ball-card.locked .price { display: block; }
.ball-card.locked canvas { filter: grayscale(0.85) brightness(0.55); }
.ball-card.locked .ball-label { opacity: 0.6; }
.ball-card.locked.affordable { border-color: rgba(255, 201, 60, 0.45); }
.ball-card.locked.affordable canvas { filter: grayscale(0.3) brightness(0.85); }
.ball-card.locked.selected canvas { filter: none; }

/* Ana buton durumları */
.primary.buy {
  color: #2a1a00;
  background: linear-gradient(90deg, #ffd34d, #ff9f1c);
  box-shadow: 0 0 24px rgba(255, 201, 60, 0.5);
}

.primary.cant {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.primary.shake { animation: shake 0.35s; }

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Ayarlar */
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 15px;
  font-weight: 600;
}

.toggle b {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.toggle.on { border-color: rgba(57, 255, 176, 0.5); }
.toggle.on b { color: #031a10; background: var(--accent); }

.music-btn.off { opacity: 0.4; text-decoration: line-through; }

/* Güçlendirici çubuğu */
#powerbar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.pw {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--c);
  background: rgba(6, 8, 20, 0.75);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent);
}

.pw-icon { font-size: 20px; line-height: 1; }
.pw-track { width: 64px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.pw-track i { display: block; height: 100%; background: var(--c); }
.pw.ending { animation: blink 0.25s steps(2) infinite; }

@keyframes blink { 50% { opacity: 0.35; } }

/* Zıplama butonu (dokunmatik) */
#jump-btn {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(124, 255, 79, 0.45);
  background: rgba(10, 14, 30, 0.55);
  color: #b8ff9c;
  font-size: 30px;
  pointer-events: auto;
  touch-action: none;
  transition: transform 0.08s, background 0.08s;
}

#jump-btn.pressed { transform: scale(0.92); background: rgba(124, 255, 79, 0.25); }

/* Butonlar modunda zıplama butonu sağ yön butonunun üstünde */
html.ctl-buttons #jump-btn { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 120px); }

/* Sol / sağ butonları (yalnızca görsel; asıl dokunma alanı ekranın yarısı) */
#touch-controls { display: none; position: absolute; inset: 0; pointer-events: none; }

html.touch.ctl-buttons #touch-controls { display: block; }

.tc-btn {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 34px;
  color: rgba(233, 241, 255, 0.85);
  border: 2px solid var(--line);
  background: rgba(10, 14, 30, 0.45);
  transition: transform 0.08s, background 0.08s, border-color 0.08s;
}

#tc-left { left: max(18px, env(safe-area-inset-left)); }
#tc-right { right: max(18px, env(safe-area-inset-right)); }

.tc-btn.pressed {
  transform: scale(0.92);
  border-color: var(--accent);
  background: rgba(57, 255, 176, 0.22);
  box-shadow: 0 0 20px rgba(57, 255, 176, 0.35);
}

/* Oyun başındaki dokunmatik ipucu */
#touch-hint {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  width: min(86vw, 420px);
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(6, 8, 20, 0.72);
  border: 1px solid var(--line);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#touch-hint b { font-family: 'Orbitron', sans-serif; font-size: 16px; color: var(--accent); }
#touch-hint span { font-size: 15px; color: var(--text); }
#touch-hint.show { animation: hint 4.2s ease-out; }

@keyframes hint {
  0% { opacity: 0; }
  8%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Ekran efektleri */
.fx { position: fixed; inset: 0; pointer-events: none; opacity: 0; }

#fx-slow {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(46, 230, 214, 0.28) 100%);
  transition: opacity 0.4s;
}

body.slowmo #fx-slow { opacity: 1; }
#fx-flash.show { animation: flash 0.45s ease-out; }

@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

#toast {
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  white-space: nowrap;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(18px, 4vw, 30px);
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px currentColor;
  opacity: 0;
  z-index: 5;
}

#toast.show { animation: toast 1.4s ease-out; }

@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* Dokunmatik kontrol ayarları (yalnızca telefon / tablette görünür) */
.touch-block { display: none; }
html.touch .touch-block { display: block; }
html.touch .kbd-only { display: none; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.seg button {
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

.seg button i { font-style: normal; font-size: 18px; color: var(--text); }

.seg-4 { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg-4 button { font-size: 13px; padding: 9px 2px; line-height: 1.1; text-align: center; }
.seg-4 button i { font-size: 16px; white-space: nowrap; }

.seg button.selected {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(57, 255, 176, 0.1);
  box-shadow: 0 0 14px rgba(57, 255, 176, 0.2);
}

.seg-small {
  margin-top: 8px;
  grid-template-columns: auto repeat(3, 1fr);
  align-items: center;
}

.seg-small button { padding: 7px 4px; font-size: 14px; }
.seg-label { font-size: 14px; color: var(--muted); padding-right: 4px; }

/* Telefonda güçlendirici çubuğu sola, skorun altına (başparmakların altında kalmasın) */
html.touch #powerbar {
  left: max(16px, env(safe-area-inset-left));
  top: calc(max(18px, env(safe-area-inset-top)) + 128px);
  bottom: auto;
  transform: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

html.touch .pw-track { width: 44px; }

/* Gündüz modu: açık gökyüzünde gösterge yazıları koyu renk olsun */
html.day .hud-score .big,
html.day .hud-stat { color: #0d1733; }
html.day .hud-score .big { text-shadow: 0 0 16px rgba(255, 255, 255, 0.7); }
html.day .hud-score .label,
html.day .hud-stat small,
html.day .hud-stat.small { color: #2b3a5e; }
html.day .hud-coins { color: #8a5600; text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); }
html.day .chip { background: rgba(8, 12, 30, 0.75); }
html.day #toast { text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 18px currentColor; }

.go-coins { font-size: 18px; color: #ffd34d; font-weight: 600; }
.go-coins .dim { color: var(--muted); }

/* Mobil */
@media (max-width: 900px) {
  .overlay.menu {
    justify-content: center;
    padding-left: 16px;
    background: rgba(4, 5, 12, 0.6);
  }
}

@media (max-width: 420px) {
  .panel { padding: 20px 16px 18px; }
  .ball-grid { grid-template-columns: repeat(4, 1fr); }
  .ball-card canvas { width: 46px; height: 46px; }
  .ball-card .ball-label { font-size: 11px; }
  #powerbar { bottom: 16px; gap: 6px; }
  .pw-track { width: 40px; }
  #hud { padding: 12px 16px; }
}
