@import "../css/tokens.css";

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: #0b0f19;
  color: #f8fafc;
  font-family: var(--font-body, "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Hub Navigation Header */
.hub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
}

.hub-bar a {
  color: #818cf8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.hub-bar a:hover {
  color: #a5b4fc;
}

.hub-bar a:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
  border-radius: 4px;
}

.hub-bar span {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
}

.hub-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hub-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.hub-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.hub-btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.hub-btn.is-muted {
  color: #94a3b8;
  opacity: 0.85;
}

/* Ad Rails & Wells */
.playyard-ad {
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  padding: 6px 12px;
  background: transparent;
}

.ad-well {
  min-height: 50px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.4);
  overflow: hidden;
}

.ad-empty {
  margin: 0;
  padding: 6px;
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
  text-align: center;
}

/* Main Game Container */
.game-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Canvas Arena */
.arena-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 480px;
  overflow: hidden;
  background: #0f172a;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* HUD Overlay */
.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.hud-score-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hud-label {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 2px;
}

.score-display {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  transition: transform 0.12s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}

.score-display.score-bump {
  transform: scale(1.15);
}

.hud-best-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.best-display {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Combo Badge */
.combo-badge {
  position: absolute;
  top: 80px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.85), rgba(168, 85, 247, 0.85));
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.4);
  transform: scale(0.8) translateY(-10px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
  z-index: 10;
}

.combo-badge.is-active {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Perfect Toast Indicator */
.perfect-toast {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%) translateY(15px) scale(0.9);
  padding: 8px 18px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.95), rgba(99, 102, 241, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 30px;
  font-family: var(--font-display, "Plus Jakarta Sans", sans-serif);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
  z-index: 15;
}

.perfect-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* Tap Prompt */
.tap-prompt {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: pulse-glow 2s infinite ease-in-out;
  z-index: 10;
}

.tap-prompt.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 16px 4px rgba(99, 102, 241, 0.3);
  }
}

/* Game Over Overlay Sheet */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  text-align: center;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}

.game-overlay.is-open .overlay-card {
  transform: translateY(0) scale(1);
}

.overlay-kicker {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f43f5e;
  margin-bottom: 6px;
}

.overlay-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 8px;
}

.high-badge {
  display: inline-block;
  margin-bottom: 16px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 800;
  border-radius: 999px;
  letter-spacing: 0.05em;
  animation: badge-shine 1.5s infinite;
}

@keyframes badge-shine {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.04); }
}

/* Overlay Stats Grid */
.overlay-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 12px 8px;
}

.stat-box.stat-primary {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  border-color: rgba(99, 102, 241, 0.35);
}

.stat-label {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 4px;
}

.stat-number {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
}

.stat-primary .stat-number {
  font-size: 2.2rem;
  color: #818cf8;
}

/* Overlay Actions */
.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  width: 100%;
  min-height: 50px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-family: var(--font-body, "Plus Jakarta Sans", sans-serif);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:focus-visible {
  outline: 3px solid #818cf8;
  outline-offset: 3px;
}

.btn-secondary {
  width: 100%;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  border-radius: 12px;
  font-family: var(--font-body, "Plus Jakarta Sans", sans-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.btn-secondary:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.overlay-ad {
  margin-top: 16px;
}

/* SEO Article Section */
.game-seo-section {
  width: 100%;
  max-width: 540px;
  margin: 24px auto 36px;
  padding: 0 16px;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.6;
}

.game-seo-section h2 {
  color: #f1f5f9;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 18px 0 8px;
}

.game-seo-section h2:first-child {
  margin-top: 0;
}

.game-seo-section p {
  margin-bottom: 12px;
}

.game-seo-section a {
  color: #818cf8;
  text-decoration: none;
}

.game-seo-section a:hover {
  text-decoration: underline;
}

.game-seo-section code {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: #e2e8f0;
}

/* Responsive adjustments */
@media (max-width: 420px) {
  .hub-bar span {
    display: none;
  }

  .score-display {
    font-size: 2.4rem;
  }

  .overlay-card {
    padding: 22px 18px;
  }

  .stat-primary .stat-number {
    font-size: 1.8rem;
  }
}
