/* =========================================================
   Bulut Basamak: tasarım değerleri (Nikhil Rana, ISC; bkz. LICENSE)
   ========================================================= */
:root {
  --night: #120d33;
  --ink: #1b1446;
  --ink-2: #2c2170;
  --gold: #ffc04d;
  --gold-hi: #ffe08a;
  --gold-lo: #c76a12;
  --orange: #ff8a3d;
  --pink: #ff6fae;
  --mint: #5ef2c2;
  --sky: #8cc4ff;
  --violet: #9b6bff;

  --text: #ffffff;
  --muted: rgba(255, 255, 255, .72);
  --glass: rgba(255, 255, 255, .13);
  --glass-strong: rgba(255, 255, 255, .2);
  --glass-brd: rgba(255, 255, 255, .28);

  /* type scale */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 42px;
  --fs-display: 72px;

  /* spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-14: 56px;

  /* radius scale */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 999px;

  --font-display: system-ui, -apple-system, sans-serif;
  --font-body: system-ui, -apple-system, sans-serif;

  --ease-pop: cubic-bezier(.2, 1.5, .4, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 3px; }

/* =========================================================
   App shell
   ========================================================= */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--night);
}

/* Oyun alanı 5:8 oranını korur; dikey ve yatayda sığar, kenarlarda boşluk kalabilir. */
#stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: min(100vw, calc(100dvh * .625));
  overflow: hidden;
  background: #60b0ff;
  isolation: isolate;
}

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

/* =========================================================
   HUD
   ========================================================= */
.hud {
  position: absolute;
  top: calc(12px + var(--safe-t));
  left: calc(64px + env(safe-area-inset-left, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity .35s, transform .45s var(--ease-pop);
}
.hud.show { opacity: 1; transform: none; }

.hud-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-3xl);
  line-height: 1;
  text-shadow: 0 3px 0 rgba(27, 20, 70, .35), 0 0 18px rgba(255, 255, 255, .35);
  transform-origin: left center;
}
.hud-score.bump { animation: bump .35s var(--ease-pop); }
@keyframes bump { 0% { transform: scale(1.25); color: var(--gold-hi); } 100% { transform: scale(1); } }

.hud-best { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; opacity: .85; margin-top: var(--sp-1); text-shadow: 0 1px 2px rgba(0,0,0,.35); }

.hud-right { display: flex; gap: var(--sp-2); align-items: center; }

.chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  background: rgba(27, 20, 70, .32);
  border: 1px solid rgba(255, 255, 255, .25);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-lg);
}

.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(27, 20, 70, .32);
  border: 1px solid rgba(255, 255, 255, .25);
  transition: transform .15s var(--ease-pop);
}
.icon-btn:active { transform: scale(.88); }
.pause-ico { width: 14px; height: 16px; border-left: 5px solid #fff; border-right: 5px solid #fff; }

.star-ico {
  width: 16px;
  height: 16px;
  display: inline-block;
  background: linear-gradient(135deg, #fff3a6, var(--gold));
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%);
}

.power, .shield-chip {
  position: absolute;
  top: 70px;
  left: 0;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity .25s, transform .35s var(--ease-pop);
}
.power.show, .shield-chip.show { opacity: 1; transform: none; }
.power span { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-xs); letter-spacing: .1em; }
.power-track { width: 120px; height: 8px; border-radius: var(--r-pill); background: rgba(0, 0, 0, .25); overflow: hidden; margin-top: var(--sp-1); }
.power-fill { height: 100%; width: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--orange), var(--gold-hi)); transform-origin: left; }
.shield-chip {
  top: 108px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  background: rgba(94, 242, 194, .25);
  border: 1px solid rgba(94, 242, 194, .7);
}

/* Toast (zone change etc.) */
.toast {
  position: absolute;
  left: 50%;
  top: 22%;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-md);
  background: rgba(27, 20, 70, .45);
  border: 1px solid rgba(255, 255, 255, .3);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -20px) scale(.9);
  transition: opacity .3s, transform .5s var(--ease-pop);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast small { font-size: var(--fs-xs); letter-spacing: .25em; font-weight: 800; color: var(--gold-hi); }
.toast strong { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; white-space: nowrap; }

.touch-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(26px + var(--safe-b));
  display: flex;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity .5s;
}
.touch-hint.show { opacity: .9; }
.touch-hint span { padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill); background: rgba(27, 20, 70, .35); animation: nudge 1.2s ease-in-out infinite; }
.touch-hint span:last-child { animation-delay: .6s; }
@keyframes nudge { 50% { transform: translateY(-5px); } }

/* =========================================================
   Screens (menu / pause / game over)
   ========================================================= */
.screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: calc(20px + var(--safe-t)) 18px calc(20px + var(--safe-b));
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  transition: opacity .35s, transform .5s var(--ease-out), visibility 0s linear .35s;
  overflow-y: auto;
}
.screen.show { opacity: 1; visibility: visible; transform: none; transition: opacity .35s, transform .5s var(--ease-out), visibility 0s; }
.screen.dim { background: rgba(18, 13, 51, .5); -webkit- }

.screen.show > * { animation: rise .6s var(--ease-pop) both; }
.screen.show > *:nth-child(2) { animation-delay: .06s; }
.screen.show > *:nth-child(3) { animation-delay: .12s; }
.screen.show > *:nth-child(4) { animation-delay: .18s; }
.screen.show > *:nth-child(5) { animation-delay: .24s; }
.screen.show > *:nth-child(6) { animation-delay: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.96); } }

/* Paneller */
.panel {
  width: min(360px, 100%);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: rgba(27, 20, 70, .38);
  border: 1px solid var(--glass-brd);
  box-shadow: 0 20px 50px rgba(18, 13, 51, .35);
}
.panel.center { display: grid; gap: var(--sp-3); justify-items: stretch; text-align: center; position: relative; }

/* Game over */
.over-card { padding-top: var(--sp-6); }
.over-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-display);
  line-height: 1;
  color: #fff;
  text-shadow: 0 5px 0 var(--ink), 0 0 30px rgba(255, 192, 77, .5);
}
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-1); }
.stats div { padding: var(--sp-3) var(--sp-1); border-radius: var(--r-sm); background: rgba(255, 255, 255, .09); display: grid; gap: var(--sp-1); }
.stats small { font-size: var(--fs-xs); letter-spacing: .14em; font-weight: 800; color: var(--muted); }
.stats b { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ribbon {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg) scale(0);
  padding: var(--sp-2) var(--sp-6);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--ink);
  background: linear-gradient(110deg, var(--pink), var(--gold-hi) 45%, #fff 50%, var(--gold-hi) 55%, var(--mint));
  background-size: 250% 100%;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
  white-space: nowrap;
}
.ribbon.show { animation: ribbonIn .6s var(--ease-pop) .35s forwards, shine 2.2s linear infinite 1s; }
@keyframes ribbonIn { to { transform: translateX(-50%) rotate(-3deg) scale(1); } }
@keyframes shine { from { background-position: 120% 0; } to { background-position: -120% 0; } }

@media (max-height: 520px) {
  .over-score { font-size: var(--fs-3xl); }
  .stats b { font-size: var(--fs-sm); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
