/* ============================================================
   Flick Shot — Cloud9 Aim Trainer
   Original art only. System fonts, no external requests.
   ============================================================ */

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

:root {
  --sky-top: #0b5cff;
  --sky-mid: #2f8cff;
  --sky-bottom: #aee3ff;
  --cloud-white: #ffffff;
  --ink: #0a2540;
  --panel: rgba(255, 255, 255, 0.94);
  --accent: #0b5cff;
  --accent-dark: #0848c8;
  --gold: #ffc93c;
  --gold-dark: #e0a800;
  --danger: #ff4757;
  --good: #2ed573;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 100%);
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Animated sky ---------- */
.sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.sun {
  position: absolute;
  top: 6%;
  right: 8%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe6 0%, #ffe98a 55%, rgba(255, 233, 138, 0) 75%);
  opacity: 0.95;
}

.cloud {
  position: absolute;
  background: var(--cloud-white);
  border-radius: 999px;
  opacity: 0.85;
  filter: blur(1px);
  animation: drift linear infinite;
}

/* Puffy cloud built from one div + two pseudo-blobs */
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: var(--cloud-white);
  border-radius: 50%;
}
.cloud::before { width: 55%; height: 160%; left: 12%; top: -80%; }
.cloud::after  { width: 40%; height: 120%; right: 10%; top: -55%; }

.cloud.c1 { width: 180px; height: 52px; top: 12%; animation-duration: 75s; }
.cloud.c2 { width: 120px; height: 38px; top: 26%; animation-duration: 55s; animation-delay: -20s; opacity: 0.7; }
.cloud.c3 { width: 240px; height: 64px; top: 48%; animation-duration: 95s; animation-delay: -45s; opacity: 0.6; }
.cloud.c4 { width: 150px; height: 44px; top: 68%; animation-duration: 65s; animation-delay: -30s; opacity: 0.75; }
.cloud.c5 { width: 100px; height: 32px; top: 84%; animation-duration: 50s; animation-delay: -10s; opacity: 0.55; }

@keyframes drift {
  from { left: -260px; }
  to   { left: 110%; }
}

/* ---------- Birds crossing the sky (random, JS-spawned) ---------- */
#birds { position: absolute; inset: 0; overflow: hidden; }
.bird {
  position: absolute;
  top: var(--top, 15%);
  left: 0;
  width: calc(38px * var(--scale, 1));
  height: calc(20px * var(--scale, 1));
  opacity: 0.7;
  animation: fly var(--dur, 12s) linear forwards;
}
.bird svg { display: block; width: 100%; height: 100%; overflow: visible; }
.bird.rtl svg { transform: scaleX(-1); }  /* flies right-to-left, facing left */
.bird .wing {
  transform-box: fill-box;
  animation: flap 0.55s ease-in-out infinite alternate;
}
.bird .wing.left  { transform-origin: 100% 100%; }
.bird .wing.right { transform-origin: 0% 100%; animation-delay: -0.27s; }
@keyframes flap { from { transform: rotate(16deg); } to { transform: rotate(-20deg); } }
@keyframes fly {
  0%   { transform: translate(-60px, 0); }
  25%  { transform: translate(25vw, -14px); }
  50%  { transform: translate(50vw, 6px); }
  75%  { transform: translate(75vw, -10px); }
  100% { transform: translate(110vw, 0); }
}

/* ---------- Top bar ---------- */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-size: 22px; }
.brand-name { font-weight: 900; font-size: 22px; letter-spacing: 2px; }
.brand-sub { font-size: 13px; font-weight: 600; opacity: 0.9; }

.icon-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 18px;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.35); }

/* ---------- Screens ---------- */
.screen {
  position: relative;
  z-index: 2;
  flex: 1;
  display: none;
  min-height: 0;
}
.screen.active { display: flex; flex-direction: column; }

/* ---------- Panels (start / end) ---------- */
.panel {
  margin: auto;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--panel);
  border-radius: 20px;
  padding: 28px 28px 22px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(4, 30, 80, 0.35);
}

.game-title {
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(11, 92, 255, 0.15);
}
.tagline { margin-top: 6px; font-weight: 700; font-size: 15px; color: #33507a; }
.howto { margin: 14px auto 0; font-size: 14.5px; line-height: 1.55; color: #40597c; max-width: 460px; }

.name-label {
  display: block;
  margin-top: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #5b7398;
}
#player-name {
  margin-top: 6px;
  width: min(320px, 100%);
  padding: 11px 14px;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  border: 2px solid #bcd6ff;
  border-radius: 12px;
  background: #fff;
  outline: none;
}
#player-name:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 92, 255, 0.2); }

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  background: var(--accent);
  border-radius: 14px;
  box-shadow: 0 6px 0 var(--accent-dark), 0 10px 22px rgba(11, 92, 255, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark); }
.btn-big { margin-top: 20px; padding: 15px 46px; font-size: 21px; }

/* ---------- Leaderboard ---------- */
.board-wrap { margin-top: 24px; text-align: left; }
.board-title { font-size: 15px; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.board { list-style: none; }
.board li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 14.5px;
  font-weight: 600;
}
.board li:nth-child(odd) { background: rgba(11, 92, 255, 0.07); }
.board li.me { background: rgba(255, 201, 60, 0.35); outline: 2px solid var(--gold); }
.board .b-rank { width: 26px; font-weight: 900; color: var(--accent); }
.board .b-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .b-score { font-weight: 900; }
.board-empty { font-size: 13.5px; color: #6b829f; text-align: center; padding: 6px 0; }

.foot-note { margin-top: 18px; font-size: 12.5px; color: #7b90ad; }

/* ---------- HUD ---------- */
.hud {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 10px;
  padding: 4px 16px 10px;
  flex-wrap: wrap;
}
.hud-item {
  flex: 1;
  min-width: 110px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(4, 30, 80, 0.25);
}
.hud-label { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: 1.5px; color: #5b7398; }
.hud-value { font-size: 26px; font-weight: 900; color: var(--ink); line-height: 1.1; }
.hud-time .hud-value { color: var(--accent); }
.hud-time.low .hud-value { color: var(--danger); animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
.hud-combo .hud-value { color: #b87700; }

/* ---------- Play field ---------- */
.field {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  margin: 0 16px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.10) 100%);
  border: 2px solid rgba(255, 255, 255, 0.55);
  overflow: hidden;
  cursor: crosshair;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Targets ---------- */
.target {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(11, 92, 255, 0.35), 0 6px 18px rgba(4, 30, 80, 0.4);
  background: radial-gradient(circle at 35% 30%, #7db4ff 0%, var(--accent) 55%, #0848c8 100%);
  animation: spawn-pop 0.16s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}
.target::after {
  content: "";
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}
.target.small {
  background: radial-gradient(circle at 35% 30%, #9be7ff 0%, #00b8d9 55%, #007a99 100%);
  box-shadow: 0 0 0 4px rgba(0, 184, 217, 0.4), 0 6px 18px rgba(4, 30, 80, 0.4);
}
.target.golden {
  background: radial-gradient(circle at 35% 30%, #fff3b0 0%, var(--gold) 55%, var(--gold-dark) 100%);
  box-shadow: 0 0 0 4px rgba(255, 201, 60, 0.55), 0 0 26px 6px rgba(255, 201, 60, 0.65), 0 6px 18px rgba(4, 30, 80, 0.4);
  animation: spawn-pop 0.16s ease-out, gold-glow 0.7s ease-in-out infinite alternate;
}
@keyframes gold-glow { from { filter: brightness(1); } to { filter: brightness(1.25); } }
@keyframes spawn-pop {
  from { transform: scale(1.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Drifting targets slide across the field using CSS vars set from JS */
.target.moving { animation: spawn-pop 0.16s ease-out, drift-target 1.4s ease-in-out infinite alternate; }
@keyframes drift-target {
  from { translate: calc(var(--dx, 20px) * -1) calc(var(--dy, 14px) * -1); }
  to   { translate: var(--dx, 20px) var(--dy, 14px); }
}

/* Shrinking targets decay over their lifetime (duration set inline) */
.target.shrinking { animation: spawn-pop 0.16s ease-out, shrink-out var(--life, 1.1s) linear forwards; }
@keyframes shrink-out {
  from { scale: 1; opacity: 1; }
  to   { scale: 0.25; opacity: 0.55; }
}

/* ---------- Particles & score popups ---------- */
.particle {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  pointer-events: none;
  animation: burst 0.55s ease-out forwards;
}
@keyframes burst {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to   { transform: translate(var(--px, 0px), var(--py, 0px)) scale(0.2); opacity: 0; }
}

.score-pop {
  position: absolute;
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(4, 30, 80, 0.6);
  pointer-events: none;
  animation: float-up 0.8s ease-out forwards;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}
.score-pop.gold { color: var(--gold); font-size: 27px; }
@keyframes float-up {
  from { opacity: 1; margin-top: 0; }
  to   { opacity: 0; margin-top: -56px; }
}

.miss-pop {
  position: absolute;
  font-weight: 900;
  font-size: 15px;
  color: #ffd2d6;
  text-shadow: 0 2px 6px rgba(120, 0, 10, 0.6);
  pointer-events: none;
  animation: float-up 0.6s ease-out forwards;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

/* ---------- Countdown ---------- */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(72px, 18vw, 150px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 24px rgba(4, 30, 80, 0.55);
  pointer-events: none;
  z-index: 10;
  animation: count-zoom 0.9s ease-out forwards;
}
/* display:flex above beats the browser's [hidden]{display:none} — without
   this rule the GO! text could never actually disappear. */
.countdown[hidden] { display: none; }
@keyframes count-zoom {
  0% { transform: scale(1.8); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0; }
}

/* ---------- Screen shake (golden hit) ---------- */
#app.shake { animation: shake 0.28s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -3px); }
  80% { transform: translate(4px, 3px); }
}

/* ---------- End screen ---------- */
.rank-label { font-size: 12px; font-weight: 800; letter-spacing: 3px; color: #5b7398; }
.rank-title {
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 900;
  line-height: 1.05;
  color: var(--accent);
  margin-top: 2px;
}
.end-score-line { margin-top: 8px; font-size: 17px; font-weight: 700; color: #33507a; }
.end-score-line span { font-size: 24px; font-weight: 900; color: var(--ink); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.stat {
  background: rgba(11, 92, 255, 0.07);
  border-radius: 12px;
  padding: 10px 6px;
}
.stat-value { display: block; font-size: 21px; font-weight: 900; }
.stat-label { display: block; margin-top: 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: #5b7398; }

.end-panel .board-wrap { margin-top: 20px; }
.end-panel .btn-big { margin-top: 22px; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 18px; }
  .panel { padding: 22px 18px 18px; }
  .hud-value { font-size: 21px; }
  .hud-item { min-width: 84px; padding: 6px 8px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
