:root {
  --bg: #070b1f;
  --ink: #fdf6e3;
  --muted: #aab3d9;
  --gold: #ffcf6e;
  --panel: rgba(9, 13, 36, 0.82);
  --font: 'Fredoka', ui-rounded, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 50% 0%, #17204d 0%, var(--bg) 65%) fixed var(--bg);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- game area ---------- */
#game {
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
}

#stage {
  position: relative;
  height: 100%;
  width: 100%;
  max-width: min(520px, 82vh);
  max-width: min(520px, 82dvh);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.65);
}

#cv {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#stage[data-state="play"] #cv { cursor: none; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(7, 11, 31, 0.15), rgba(7, 11, 31, 0.72));
  touch-action: pan-y;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }

.logo {
  margin: 0 0 4px;
  display: flex;
  flex-direction: column;
  font-size: clamp(52px, 15vw, 78px);
  line-height: 0.92;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 26px rgba(255, 190, 110, 0.55), 0 4px 0 rgba(0, 0, 0, 0.25);
  animation: float 2.4s ease-in-out infinite alternate;
}
.logo span { color: var(--gold); }

.tag { margin: 0 0 6px; color: var(--muted); font-size: 18px; max-width: 26ch; }
.best, .hint { margin: 0; color: var(--muted); }
.best { font-size: 17px; }
.best b { color: var(--gold); }
.hint { font-size: 14px; opacity: 0.85; max-width: 30ch; }
.more { color: var(--muted); font-size: 14px; text-decoration: none; margin-top: 6px; opacity: 0.8; }
.more:hover { color: #fff; }

.over-title { margin: 0; font-size: 30px; font-weight: 600; color: #fff; }
.big-score {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 22px rgba(255, 200, 120, 0.55);
}
.record {
  margin: 0;
  color: var(--gold);
  font-weight: 700;
  font-size: 20px;
  animation: pulse 0.7s ease-in-out infinite alternate;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px 24px;
  margin: 2px 0 10px;
}
.stats div { display: flex; flex-direction: column; }
.stats dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stats dd { margin: 0; font-size: 21px; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  font: 600 21px var(--font);
  min-width: 230px;
  padding: 14px 34px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #3a1a05;
  background: linear-gradient(180deg, #ffe09a, #ff9f4a);
  box-shadow: 0 6px 0 #c4621f, 0 12px 30px rgba(255, 150, 60, 0.35);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c4621f, 0 6px 18px rgba(255, 150, 60, 0.3); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn[hidden] { display: none; }

.btn.reward {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
  line-height: 1.1;
  color: #062a1b;
  background: linear-gradient(180deg, #b6f7d6, #3fcf93);
  box-shadow: 0 6px 0 #1f8a5e, 0 12px 30px rgba(60, 220, 150, 0.3);
}
.btn.reward:active { box-shadow: 0 2px 0 #1f8a5e; }
.btn.reward small { display: block; font-size: 13px; font-weight: 500; opacity: 0.8; }
.play-ico { font-size: 18px; }

.btn.ghost {
  min-width: 0;
  padding: 10px 24px;
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
}
.btn.ghost:active { transform: translateY(1px); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4); }

.hud-btns {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  z-index: 5;
  display: flex;
  gap: 8px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.22); }
.icon-btn svg { width: 20px; height: 20px; }
#btn-pause { display: none; }
#stage[data-state="play"] #btn-pause { display: grid; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 6;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 15px;
  animation: fade 1.8s forwards;
}

/* ---------- content below the game ---------- */
.info {
  max-width: 640px;
  margin: 0 auto;
  padding: 36px 20px 30px;
  line-height: 1.6;
  color: #d9def3;
  font-size: 17px;
}
.info h2 { margin: 1.4em 0 0.4em; font-size: 25px; color: #fff; }
.info ul { padding-left: 1.2em; margin: 0; }
.info li { margin: 0.25em 0; }
.info strong { color: var(--gold); font-weight: 600; }
.info footer { margin-top: 36px; font-size: 14px; color: var(--muted); text-align: center; }
.info a { color: var(--gold); }

/* ---------- ad slots (filled by site-config.js) ---------- */
.ad-slot[hidden] { display: none; }
.ad-content { width: 100%; min-height: 100px; margin: 32px auto 0; text-align: center; }
.ad-side {
  position: fixed;
  top: 50%;
  right: 24px;
  width: 160px;
  height: 600px;
  transform: translateY(-50%);
}
@media (max-width: 1279px) { .ad-side { display: none !important; } }

.ad-slot.demo {
  display: grid;
  place-items: center;
  border: 1.5px dashed rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ad-demo-ov {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.88);
}
.ad-demo-box {
  width: min(88vw, 360px);
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed #888;
  border-radius: 14px;
  background: #1c1c22;
  color: #ddd;
  font-family: var(--font);
}
.ad-demo-box strong { font-size: 34px; letter-spacing: 0.15em; }
.ad-demo-box em { font-style: normal; font-size: 22px; color: var(--gold); }

/* ---------- motion ---------- */
@keyframes float { from { transform: translateY(0); } to { transform: translateY(-7px); } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
@keyframes fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .logo, .record { animation: none; }
  html { scroll-behavior: auto; }
}
