:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --bg: #05060f;
  --fg: #eef3ff;
  --muted: #8a93b8;
  --accent: #3de8ff;
  --pink: #ff3d6e;
  --gold: #ffd84d;
  --panel: rgba(16, 20, 44, 0.92);
  --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

canvas#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }

/* ---------- Ekranlar ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(16px + var(--sat)) 16px calc(24px + var(--sab));
  z-index: 5;
}

.bar { width: 100%; display: flex; justify-content: space-between; }

.pill {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.pill.star { color: var(--gold); }

#menu { justify-content: flex-start; }
#menu .menu-bottom { margin-top: auto; }
.menu-top { text-align: center; margin-top: 2.5vh; }
.logo {
  margin: 0;
  font-size: clamp(40px, 13vw, 72px);
  font-weight: 900;
  letter-spacing: 0.12em;
  padding-left: 0.12em;
  background: linear-gradient(90deg, #3de8ff, #9d6bff 55%, #ff3d6e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(61, 232, 255, 0.35));
}
.best-line { margin-top: 6px; color: var(--muted); font-weight: 700; letter-spacing: 0.15em; font-size: 14px; }
.best-line b { color: var(--fg); font-size: 18px; margin-left: 6px; }

.menu-bottom { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; align-items: center; }

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.95); }

.btn.primary {
  width: 100%;
  max-width: 320px;
  padding: 18px 0;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.2em;
  padding-left: 0.2em;
  color: #031018;
  background: linear-gradient(90deg, #3de8ff, #7cf5ff);
  box-shadow: 0 0 28px rgba(61, 232, 255, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 22px rgba(61, 232, 255, 0.35), inset 0 -3px 0 rgba(0,0,0,0.15); }
  50% { box-shadow: 0 0 40px rgba(61, 232, 255, 0.65), inset 0 -3px 0 rgba(0,0,0,0.15); }
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 24px;
  font-size: 16px;
}

.btn-row { display: flex; gap: 10px; width: 100%; justify-content: center; }
.btn.icon {
  position: relative;
  flex: 1;
  max-width: 100px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.btn.icon .ic { font-size: 18px; color: var(--accent); }
.dot {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 8px var(--pink);
}

/* ---------- Oyun sonu ---------- */
#over { justify-content: center; gap: 28px; background: rgba(3, 4, 12, 0.55); animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.over-card {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px 24px 18px;
  width: 100%;
  max-width: 340px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.badge {
  display: inline-block;
  background: linear-gradient(90deg, var(--gold), #ff9f1c);
  color: #1b1000;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 8px;
  animation: wiggle 0.8s ease-in-out infinite;
}
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(3deg) scale(1.08); } }

.label { color: var(--muted); font-weight: 800; letter-spacing: 0.25em; font-size: 13px; }
.big-score { font-size: 76px; font-weight: 900; line-height: 1.05; }
.sub { color: var(--accent); font-weight: 700; min-height: 22px; margin-bottom: 14px; }
.stats { display: flex; justify-content: space-around; border-top: 1px solid var(--line); padding-top: 14px; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; font-weight: 700; }
.over-actions { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.over-actions .btn.primary[disabled] { opacity: 0.5; }

/* ---------- Alt paneller ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.sheet-panel {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  touch-action: pan-y;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(24px + var(--sab));
  animation: slideUp 0.28s cubic-bezier(0.2, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(40%); } to { transform: translateY(0); } }

.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 22px; }
.close {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.skin {
  appearance: none;
  font: inherit;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 14px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.skin.selected { border-color: var(--accent); background: rgba(61, 232, 255, 0.1); }
.skin.locked .ball { filter: grayscale(0.6) brightness(0.6); }
.skin .ball { width: 36px; height: 36px; border-radius: 50%; }
.skin .ball.rainbow { background: conic-gradient(#ff3d6e, #ffd84d, #b6ff3d, #3de8ff, #9d6bff, #ff3d6e) !important; }
.skin .name { font-weight: 700; font-size: 14px; }
.skin .price { font-size: 13px; font-weight: 800; color: var(--gold); }
.skin .price.cant { color: var(--muted); }
.skin .price.ok { color: var(--accent); }

.streak-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(90deg, rgba(255, 159, 28, 0.18), rgba(255, 61, 110, 0.12));
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-weight: 700;
}
.streak-box small { color: var(--muted); font-weight: 500; }
.streak-num { font-size: 32px; font-weight: 900; }

.mission-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mission { background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 12px 14px; }
.mission.done { background: rgba(61, 232, 255, 0.1); }
.mission .row { display: flex; justify-content: space-between; font-weight: 700; gap: 8px; }
.mission .reward { color: var(--gold); white-space: nowrap; }
.mission.done .reward { color: var(--accent); }
.bar-bg { margin-top: 8px; height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3de8ff, #9d6bff); border-radius: 99px; }
.mission .prog { font-size: 12px; color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Bildirimler ---------- */
#toasts {
  position: fixed;
  top: calc(60px + var(--sat));
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid rgba(61, 232, 255, 0.4);
  box-shadow: 0 0 20px rgba(61, 232, 255, 0.25);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  max-width: calc(100% - 32px);
  text-align: center;
  animation: toastIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1), toastOut 0.3s ease 2.4s forwards;
}
.toast b { color: var(--gold); }
@keyframes toastIn { from { transform: translateY(-20px) scale(0.9); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

/* ---------- Devam et ---------- */
#revive { justify-content: center; background: rgba(3, 4, 12, 0.6); animation: fadeIn 0.2s ease; }
.revive-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(107, 224, 255, 0.35);
  border-radius: 24px;
  padding: 22px 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.revive-card .big-score { font-size: 60px; }
.revive-text { margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.revive-card .btn.primary { font-size: 18px; letter-spacing: 0.08em; padding-left: 0; }
.revive-timer { width: 80%; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; }
#reviveBar { height: 100%; background: #6be0ff; transform-origin: left; animation: drain 4s linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Güçler ---------- */
.sheet-note { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0 0 14px; }
.upg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upg {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 12px;
}
.upg-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900;
  color: #0a0c1c;
  background: var(--c);
  box-shadow: 0 0 14px var(--c);
}
.upg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.upg-body b { font-size: 15px; }
.upg-info { font-size: 13px; color: var(--fg); }
.upg-next { font-size: 12px; color: var(--muted); }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips i { width: 14px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--c); }
.upg-buy {
  flex: none;
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--gold);
  color: #1b1000;
  cursor: pointer;
}
.upg-buy.cant { background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.upg-buy[disabled] { background: rgba(61, 232, 255, 0.15); color: var(--accent); }

/* ---------- Menü: üst çubuk, meydan okuma, güçlü başla ---------- */
.bar-right { display: flex; gap: 8px; align-items: center; }
.pill-btn { appearance: none; color: var(--fg); font: inherit; cursor: pointer; line-height: 1; padding: 6px 10px; }
#menu .menu-bottom { gap: 10px; }

.btn.challenge {
  width: 100%;
  max-width: 320px;
  border-radius: 18px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(255, 216, 77, 0.16), rgba(255, 159, 28, 0.1));
  border: 1px solid rgba(255, 216, 77, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ch-title { font-weight: 900; font-size: 16px; color: var(--gold); }
.ch-sub { font-size: 12px; color: var(--fg); opacity: 0.8; font-weight: 600; }

.btn.boost {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 16px;
  border-radius: 14px;
  background: rgba(107, 224, 255, 0.1);
  border: 1px dashed rgba(107, 224, 255, 0.5);
  color: #6be0ff;
  font-weight: 800;
  font-size: 14px;
}
.btn.boost small { font-size: 11px; color: var(--muted); font-weight: 600; }
.btn.boost.ready { border-style: solid; background: rgba(107, 224, 255, 0.2); }
.btn.boost.small { margin-top: 4px; }

.btn.reward {
  width: 100%;
  max-width: 320px;
  padding: 13px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  color: #1b1000;
  background: linear-gradient(90deg, #ffd84d, #ffb13d);
  box-shadow: 0 0 20px rgba(255, 216, 77, 0.35);
}
.btn.reward.primary { font-size: 17px; }
.btn.reward b { margin-left: 4px; }

/* ---------- Günlük hediye ---------- */
#gift { justify-content: center; background: rgba(3, 4, 12, 0.7); z-index: 12; animation: fadeIn 0.2s ease; }
.gift-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(255, 159, 28, 0.45);
  border-radius: 24px;
  padding: 22px 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.gift-flame { font-size: 46px; line-height: 1; }
.gift-amt { font-size: 48px; font-weight: 900; color: var(--gold); }

/* ---------- Sıralama ---------- */
.tabs { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.05); padding: 4px; border-radius: 14px; margin-bottom: 12px; }
.tab {
  flex: 1;
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
  padding: 9px 6px;
  border-radius: 10px;
  cursor: pointer;
}
.tab.active { background: rgba(61, 232, 255, 0.15); color: var(--accent); }
.name-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.name-row label { font-weight: 700; font-size: 13px; color: var(--muted); }
.name-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 700;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}
.name-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.name-row button {
  appearance: none; border: 0; font: inherit; font-weight: 800; font-size: 13px;
  padding: 10px 12px; border-radius: 10px; background: var(--accent); color: #031018; cursor: pointer;
}
.board-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}
.board-row.me { background: rgba(61, 232, 255, 0.14); outline: 1px solid rgba(61, 232, 255, 0.4); }
.board-row .rank { font-weight: 900; text-align: center; color: var(--muted); }
.board-row .pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .pscore { font-weight: 900; font-size: 17px; }
.board-row.top1 .pscore { color: var(--gold); }
.board-empty { text-align: center; color: var(--muted); padding: 18px 0; }

.noads {
  width: 100%;
  margin-top: 14px;
  appearance: none;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
}
.noads[disabled] { color: var(--accent); cursor: default; }

/* ---------- Yasal bağlantılar ---------- */
.legal { display: flex; justify-content: center; gap: 18px; margin-top: 6px; }
.linkish { appearance: none; background: none; border: 0; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px 2px; }

/* ---------- Test reklamı ---------- */
.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.ad-box {
  width: 100%;
  max-width: 360px;
  background: #f4f6fb;
  color: #111;
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.ad-tag { align-self: flex-start; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; background: #111; color: #fff; padding: 4px 8px; border-radius: 6px; }
.ad-visual {
  aspect-ratio: 16 / 10;
  max-width: 100%;
  border-radius: 12px;
  background: repeating-linear-gradient(45deg, #dfe4f0, #dfe4f0 12px, #e9edf6 12px, #e9edf6 24px);
  display: grid;
  place-items: center;
  color: #556;
  font-weight: 700;
}
.ad-count { font-weight: 700; color: #334; }
.ad-text { margin: 0; color: #334; line-height: 1.4; }
.ad-actions { display: flex; gap: 8px; }
.ad-btn {
  flex: 1;
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 800;
  padding: 12px;
  border-radius: 12px;
  background: #1a73e8;
  color: #fff;
  cursor: pointer;
}
.ad-btn[disabled] { opacity: 0.45; cursor: default; }
.ad-btn.ghost { background: #e3e7f0; color: #334; }

@media (max-height: 720px) {
  .menu-top { margin-top: 0; }
  .logo { font-size: clamp(34px, 11vw, 56px); }
  #menu .menu-bottom { gap: 8px; }
  .btn.primary { padding: 14px 0; font-size: 20px; }
  .btn.boost small { display: none; }
  .btn.challenge { padding: 8px 14px; }
  .btn.icon { padding: 8px 4px; }
}

/* ---------- Ayarlar ---------- */
.sheet-sub { margin: 4px 0 10px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt {
  appearance: none;
  font: inherit;
  color: var(--fg);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  cursor: pointer;
}
.opt b { font-size: 16px; }
.opt span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.opt.selected { border-color: var(--accent); background: rgba(61, 232, 255, 0.1); }
.opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Kaldığın yerden başla ---------- */
.btn.skip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  max-width: 320px;
  margin-top: 6px;
  padding: 9px 16px;
  border-radius: 14px;
  background: rgba(157, 107, 255, 0.14);
  border: 1px solid rgba(157, 107, 255, 0.55);
  color: #c9b3ff;
  font-weight: 800;
  font-size: 15px;
}
.btn.skip small { font-size: 11px; color: var(--muted); font-weight: 600; }
