/* Higher or Lower — Game CMB
   Modern Premium Arcade Card Game: dark gradient background, glassmorphism
   panels, glowing neon accents, large typography, HTML/CSS-rendered cards
   (no third-party card art, per concept section 13). System font stack
   only — no external web font, avoiding this project's own diagnosed
   GDPR pre-consent Google Fonts issue entirely. */

:root {
  --bg-0: #0a0e1a;
  --bg-1: #10152a;
  --bg-2: #171d3a;
  --accent-cyan: #4fd8ff;
  --accent-violet: #b17bff;
  --accent-gold: #ffd166;
  --accent-red: #ff5c7a;
  --accent-green: #4ade80;
  --text-0: #f4f6ff;
  --text-1: #b9c0e0;
  --text-2: #7c84ac;
  --card-face: #f7f8fc;
  --card-ink: #1a1d2e;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-glow-cyan: 0 0 32px rgba(79, 216, 255, 0.35);
  --shadow-glow-violet: 0 0 32px rgba(177, 123, 255, 0.3);
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-stack);
  color: var(--text-0);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(177, 123, 255, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(79, 216, 255, 0.12), transparent),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 40%, var(--bg-2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-1);
  text-decoration: none;
  font-size: 14px;
}
.brand img { width: 28px; height: 28px; border-radius: 8px; }

.game-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 20px 40px;
}

.glass {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-lg);
}

/* ---- Home screen ---- */

.screen-home {
  text-align: center;
  padding: 48px 24px 40px;
  margin-top: 16px;
}

.game-logo {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text-2);
  text-transform: uppercase;
  margin-bottom: 18px;
}

.game-title {
  font-size: clamp(34px, 8vw, 56px);
  font-weight: 900;
  margin: 0;
  line-height: 1.05;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: var(--shadow-glow-cyan);
}

.game-subtitle {
  color: var(--text-1);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 10px 0 30px;
}

.stat-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-1);
}
.stat-pill strong {
  color: var(--text-0);
  font-size: 16px;
  margin-left: 6px;
}

.btn {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  min-height: 56px;
  min-width: 44px;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  color: #0a0e1a;
  font-size: 18px;
  padding: 16px 48px;
  box-shadow: 0 8px 30px rgba(79, 216, 255, 0.25);
}
.btn-primary:hover { box-shadow: 0 10px 36px rgba(79, 216, 255, 0.4); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-0);
  padding: 12px 22px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

.home-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ---- Game screen ---- */

.screen-game { margin-top: 10px; }

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
}

.hud-score-block { text-align: left; }
.hud-label { font-size: 11px; letter-spacing: 0.12em; color: var(--text-2); text-transform: uppercase; }
.hud-value { font-size: 26px; font-weight: 800; color: var(--text-0); }

.sound-toggles { display: flex; gap: 8px; }
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-0);
}

.streak-block {
  text-align: center;
  margin: 8px 0 6px;
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  padding: 6px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.streak-badge.tier-warm { background: rgba(255, 209, 102, 0.12); }
.streak-badge.tier-hot { background: rgba(255, 209, 102, 0.2); box-shadow: 0 0 22px rgba(255, 209, 102, 0.25); animation: pulse 1.1s ease-in-out infinite; }
.streak-badge.tier-insane { background: rgba(255, 92, 122, 0.22); box-shadow: 0 0 28px rgba(255, 92, 122, 0.35); animation: pulse 0.8s ease-in-out infinite; }
.streak-badge.tier-legendary { background: rgba(177, 123, 255, 0.28); box-shadow: 0 0 32px rgba(177, 123, 255, 0.45); animation: pulse 0.6s ease-in-out infinite; }
.streak-badge.tier-unstoppable { background: linear-gradient(135deg, rgba(255, 92, 122, 0.3), rgba(177, 123, 255, 0.35)); box-shadow: 0 0 40px rgba(255, 92, 122, 0.5); animation: pulse 0.45s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.streak-tier-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent-gold);
  margin-top: 4px;
}

.card-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px 20px;
  min-height: 320px;
}

#particle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.playing-card {
  position: relative;
  width: 168px;
  height: 236px;
  background: var(--card-face);
  border-radius: 16px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  color: var(--card-ink);
  transform: scale(0.85);
  animation: card-pop 0.32s ease forwards;
  z-index: 2;
}
@keyframes card-pop {
  from { transform: scale(0.85); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.playing-card[data-color="red"] { color: var(--accent-red); }
.playing-card[data-color="black"] { color: var(--card-ink); }

.pc-rank {
  position: absolute;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pc-rank-tl { top: 14px; left: 14px; }
.pc-rank-br { bottom: 14px; right: 14px; transform: rotate(180deg); }
.pc-suit-mini { font-size: 15px; margin-top: 2px; }
.pc-suit-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  line-height: 1;
}

.card-slide-out { animation: card-slide-out 0.18s ease forwards; }
.card-slide-in { animation: card-slide-in 0.26s ease forwards; }
@keyframes card-slide-out {
  to { transform: translateX(-40px) scale(0.9); opacity: 0; }
}
@keyframes card-slide-in {
  from { transform: translateX(40px) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

.card-stage.glow-correct .playing-card { box-shadow: 0 0 0 3px var(--accent-cyan), 0 20px 50px rgba(79, 216, 255, 0.4); }
.card-stage.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.card-stage.flash-wrong::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 92, 122, 0.18);
  border-radius: var(--radius-lg);
  animation: flash-fade 0.5s ease forwards;
  pointer-events: none;
}
@keyframes flash-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

.floating-text {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 20px;
  pointer-events: none;
  animation: float-up 0.9s ease forwards;
  z-index: 3;
}
.floating-good { color: var(--accent-cyan); }
.floating-same { color: var(--accent-gold); }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50px); }
}

.prompt-text {
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--text-1);
  text-transform: uppercase;
  margin: 6px 0 16px;
}

.guess-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 0 18px 22px;
  flex-wrap: wrap;
}

.btn-guess {
  flex: 1 1 200px;
  max-width: 240px;
  font-size: 18px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-higher {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  color: #06240f;
}
.btn-lower {
  background: linear-gradient(135deg, #ff8a8a, #ff5c7a);
  color: #2a0410;
}

.first-time-tip {
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  padding: 0 18px 18px;
}

/* ---- Game over screen ---- */

.screen-gameover {
  text-align: center;
  padding: 40px 24px;
  margin-top: 16px;
}
.go-title {
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--text-2);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.go-score-value {
  font-size: clamp(40px, 10vw, 64px);
  font-weight: 900;
  color: var(--text-0);
  margin: 0 0 18px;
}
.go-new-high {
  color: var(--accent-gold);
  font-weight: 800;
  margin-bottom: 18px;
  animation: pulse 0.8s ease-in-out infinite;
}
.go-stat-row {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.go-stat { text-align: center; }
.go-stat-label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.1em; }
.go-stat-value { font-size: 22px; font-weight: 800; }

.go-actions { display: flex; justify-content: center; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; }

.nickname-form {
  max-width: 360px;
  margin: 0 auto 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.nickname-form input {
  flex: 1 1 200px;
  min-width: 0;
  font-family: inherit;
  font-size: 16px; /* prevents iOS auto-zoom */
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-0);
}
.nickname-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 8px;
}
.nickname-success { color: var(--accent-green); font-size: 14px; margin-bottom: 10px; }
.submit-failed-note { color: var(--text-2); font-size: 13px; margin-bottom: 10px; }

/* ---- Modals ---- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 16, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-panel {
  background: var(--bg-1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  max-height: 84vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-1);
  font-size: 22px;
  cursor: pointer;
  min-height: 36px;
  min-width: 36px;
}
.modal-title { font-size: 18px; font-weight: 800; margin: 0 0 14px; }

.lb-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.lb-tab {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-1);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  min-height: 44px;
}
.lb-tab.active { background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet)); color: #0a0e1a; }

#leaderboard-list { list-style: none; margin: 0; padding: 0; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
}
.lb-top { font-weight: 800; }
.lb-rank { width: 30px; text-align: center; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.lb-score { color: var(--accent-cyan); font-weight: 800; }
.lb-loading, .lb-empty { text-align: center; color: var(--text-2); padding: 20px 0; list-style: none; }

.share-options { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.howtoplay-list { text-align: left; padding-left: 20px; color: var(--text-1); line-height: 1.7; }

/* ---- Below-the-fold SEO content ---- */

.seo-content {
  max-width: 760px;
  margin: 30px auto 0;
  padding: 0 20px 60px;
  color: var(--text-1);
  line-height: 1.7;
}
.seo-content h2 { color: var(--text-0); font-size: 22px; margin-top: 36px; }
.seo-content h3 { color: var(--text-0); font-size: 17px; margin-top: 22px; }
.seo-content ol, .seo-content ul { padding-left: 22px; }
.faq-item { margin-bottom: 16px; }
.faq-q { font-weight: 700; color: var(--text-0); }

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

.ad-slot {
  max-width: 760px;
  margin: 24px auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 24, 44, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-0);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.site-footer {
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
  padding: 20px;
}
.site-footer a { color: var(--text-2); }

/* ---- Responsive breakpoints (concept section 14) ---- */

@media (max-width: 768px) {
  .playing-card { width: 148px; height: 208px; }
  .pc-suit-center { font-size: 60px; }
  .go-stat-row { gap: 20px; }
}

@media (max-width: 576px) {
  .site-header { padding: 14px 16px 0; }
  .game-wrap { padding: 6px 12px 30px; }
  .playing-card { width: 128px; height: 180px; }
  .pc-suit-center { font-size: 50px; }
  .pc-rank { font-size: 19px; }
  .btn-guess { font-size: 16px; padding: 14px 16px; }
  .hud-value { font-size: 21px; }
  .go-score-value { font-size: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
