/* Home Run — Game CMB (gamecmb.com) */

:root {
  --navy: #0a1330;
  --navy-2: #0f2447;
  --green: #0c4d2e;
  --gold: #ffd54a;
  --orange: #ff6b3d;
  --cyan: #4fd6ff;
  --white: #ffffff;
  --card-bg: rgba(10, 19, 48, 0.92);
  --font-display: 'Poppins', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-display);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

a { color: var(--cyan); }

.site-header, .seo-content, .site-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
}

.site-header h1 {
  font-size: clamp(28px, 5vw, 40px);
  margin: 0 0 6px;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-header p { color: #b9c6e6; margin: 0; }

/* --- Game shell ---------------------------------------------------- */

.game-shell {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: #000;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 720 / 1280;
  overflow: hidden;
  background: #0a1330;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
  cursor: pointer;
}

/* Top controls: always above every overlay (z-index lesson learned the
   hard way on this project's earlier games — Penalty King round 1). */
.top-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 45;
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 19, 48, 0.65);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(3px);
}
.icon-btn:active { transform: scale(0.92); }

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 60px;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}
.hud .hud-item { display: flex; flex-direction: column; line-height: 1.05; }
.hud .hud-label { font-size: 9px; letter-spacing: 1px; color: #9fb3dd; font-weight: 700; }
.hud .hud-value { font-size: 18px; }
#hudCombo { color: var(--gold); }

.strikes-indicator {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 30;
  font-size: 22px;
  letter-spacing: 6px;
  color: #ff5555;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* --- Overlays -------------------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 9, 22, 0.72);
  backdrop-filter: blur(2px);
}

.overlay-card {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 26px 22px;
  width: 100%;
  max-width: 380px;
  max-height: 92%;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.logo-mark {
  width: 84px;
  margin: 0 auto 10px;
  display: block;
}

.game-title {
  font-size: 34px;
  font-weight: 900;
  margin: 0;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 1px;
}

.tagline {
  color: #a9bade;
  font-size: 13px;
  margin: 4px 0 18px;
}

.stat-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 18px;
}
.stat-row .stat { display: flex; flex-direction: column; }
.stat-row .stat-label { font-size: 10px; letter-spacing: 1px; color: #9fb3dd; }
.stat-row .stat-value { font-size: 22px; font-weight: 800; color: var(--gold); }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(90deg, #ffb84a, var(--orange));
  color: #24140a;
}
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 10px; }

.countdown-text {
  font-size: 90px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

/* Game over screen: score/HR/longest/combo, nickname form, action
   buttons ALL visible from the moment the screen appears — submitting a
   score is optional and never gates Try Again (this project's established
   lesson, built in from round 1). */
.go-score {
  font-size: 44px;
  font-weight: 900;
  color: var(--gold);
  margin: 4px 0 2px;
}
.go-new-record {
  display: inline-block;
  background: var(--orange);
  color: #2a1000;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.nickname-form { margin-top: 16px; }
.nickname-form input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 15px;
  text-align: center;
}
.form-error { color: #ff7676; font-size: 12px; margin-top: 6px; min-height: 14px; }

.rank-banner {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(79, 214, 255, 0.12);
  font-size: 13px;
}
.rank-banner .rank-value, .rank-banner .rank-today { color: var(--cyan); font-weight: 800; }

.submit-confirmed { margin-top: 12px; font-size: 13px; color: #8fe0a0; }

/* --- Leaderboard ------------------------------------------------------ */

.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; justify-content: center; }
.lb-tab {
  background: rgba(255,255,255,0.06);
  color: #cdd8f2;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 6px 16px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.lb-tab.active { background: var(--gold); color: #241800; border-color: transparent; }

.lb-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; text-align: left; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 14px; }
.lb-rank { width: 34px; color: #9fb3dd; font-weight: 700; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: var(--gold); }
.lb-loading, .lb-empty { text-align: center; color: #9fb3dd; padding: 20px 0; }

/* --- Achievements ------------------------------------------------------ */

.achievements-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.ach-card { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px; opacity: 0.55; }
.ach-card.unlocked { opacity: 1; background: rgba(255, 213, 74, 0.12); border: 1px solid rgba(255,213,74,0.3); }
.ach-card-label { font-weight: 800; font-size: 13px; }
.ach-card-desc { font-size: 11px; color: #a9bade; margin-top: 2px; }

/* --- Toasts ------------------------------------------------------------ */

.achievement-toast, .generic-toast {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 60px;
  z-index: 46;
  background: rgba(10, 19, 48, 0.95);
  border: 1px solid rgba(255,213,74,0.4);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
}
.ach-label { font-weight: 800; color: var(--gold); }
.ach-desc { color: #cdd8f2; }
.generic-toast { text-align: center; color: #fff; border-color: rgba(255,255,255,0.2); }

.connecting-hint {
  position: absolute;
  bottom: 12px;
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  color: #9fb3dd;
  z-index: 46;
}

/* --- SEO content below the game ---------------------------------------- */

.seo-content h2 { color: var(--gold); font-size: 22px; margin-top: 34px; }
.seo-content p, .seo-content li { color: #cdd8f2; line-height: 1.7; font-size: 15px; }
.seo-content ul { padding-left: 20px; }

.faq-item { border-bottom: 1px solid rgba(255,255,255,0.08); padding: 12px 0; }
.faq-item summary { cursor: pointer; font-weight: 700; color: #fff; }
.faq-item p { margin: 8px 0 0; }

.related-games { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.related-games a {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  text-decoration: none;
  color: #dbe8ff;
}

.ad-slot {
  max-width: 900px;
  margin: 20px auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #55618a;
  font-size: 12px;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 8px;
}

.site-footer { text-align: center; color: #6c7aa3; font-size: 12px; }
.site-footer a { color: #8fa8e0; }

@media (min-width: 700px) {
  .game-shell { max-width: 520px; }
}
