html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color: rgba(255,255,255,0.9);
  background: radial-gradient(circle at 40% 30%, #1a0a2e 0%, #16213e 35%, #0f3460 100%);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#c {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

#hud {
  position: fixed;
  inset: 14px 14px auto 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 10;
  flex-wrap: wrap;
}

#hud .left {
  pointer-events: none;
  user-select: none;
  min-width: 200px;
}
.title {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: clamp(14px, 4vw, 18px);
}
.subtitle {
  margin-top: 4px;
  font-size: clamp(10px, 2.5vw, 12px);
  opacity: 0.75;
  max-width: 280px;
}

.stats-row {
  display: flex;
  gap: clamp(12px, 3vw, 16px);
  margin-top: 8px;
  flex-wrap: wrap;
}

.stat {
  font-size: clamp(10px, 2vw, 11px);
  opacity: 0.7;
  font-weight: 500;
}

#hud .right {
  display: flex;
  align-items: center;
  gap: clamp(6px, 2vw, 10px);
  pointer-events: auto;
  flex-wrap: wrap;
}

.pill {
  padding: clamp(6px, 2vw, 8px) clamp(8px, 2.5vw, 10px);
  border-radius: 999px;
  background: rgba(255,182,193,0.12);
  border: 1px solid rgba(255,182,193,0.25);
  backdrop-filter: blur(6px);
  font-size: clamp(10px, 2vw, 12px);
  user-select: none;
  transition: all 120ms ease;
  white-space: nowrap;
}

/* Mobile adjustments */
@media (max-width: 700px) {
  #hud { inset: 8px 8px auto 8px; gap: 8px; }
  .subtitle { display: none; }
  .title { font-size: 14px; }
  .stats-row { gap: 8px; }
  .pill { padding: 6px 8px; font-size: 11px; }
  .overlay-card { padding: 14px; max-width: 92vw; }
  .overlay-card .achievement { font-size: 14px; }
  .btn { padding: 6px 8px; font-size: 13px; }
}

@media (max-width: 420px) {
  .title { font-size: 13px; }
  .pill { font-size: 10px; padding: 4px 6px; }
  .overlay-card { padding: 10px; }
  .overlay-card .achievement { font-size: 13px; }
  .btn { font-size: 12px; padding: 6px 8px; }
}

.pill:hover {
  background: rgba(255,182,193,0.18);
  border-color: rgba(255,182,193,0.35);
}

.btn {
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid rgba(255,182,193,0.25);
  background: rgba(255,182,193,0.12);
  color: rgba(255,255,255,0.92);
  border-radius: 12px;
  padding: clamp(6px, 2vw, 8px) clamp(8px, 2.5vw, 10px);
  font-size: clamp(10px, 2vw, 12px);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
  font-weight: 500;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { 
  background: rgba(255,182,193,0.18);
  border-color: rgba(255,182,193,0.35);
}
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(135deg, rgba(255,100,180,0.25), rgba(255,200,220,0.15));
  border-color: rgba(255,182,193,0.4);
  font-weight: 600;
}

.btn.primary:hover {
  background: linear-gradient(135deg, rgba(255,100,180,0.35), rgba(255,200,220,0.25));
  border-color: rgba(255,182,193,0.5);
}

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(26, 10, 46, 0.65);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 20;
}
#overlay.show {
  opacity: 1;
  pointer-events: auto;
}
#overlay .overlay-card {
  box-sizing: border-box;
  width: min(520px, calc(100vw - 40px));
  padding: 28px 20px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255,182,193,0.18), rgba(255,200,220,0.12));
  border: 1px solid rgba(255,182,193,0.35);
  box-shadow: 0 20px 80px rgba(26,10,46,0.4), inset 0 1px 0 rgba(255,255,255,0.12);
}

#overlay .overlay-card > *:not(:last-child) {
  margin-bottom: 12px;
}

.overlay-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.big {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #ff69b4, #ffb6d9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.medium {
  font-size: 16px;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 12px;
  color: rgba(255,182,193,0.95);
}

.small {
  font-size: 13px;
  opacity: 0.85;
  line-height: 1.5;
  margin-bottom: 16px;
  color: rgba(255,255,255,0.8);
}

.achievement-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,182,193,0.8);
  margin: 8px 0 4px 0;
}

.achievement {
  font-size: 12px;
  padding: 6px 0;
  color: rgba(255,255,255,0.8);
}

/* Ensure long text inside overlay wraps and buttons don't overflow */
#overlay .overlay-card, #overlay .overlay-card * {
  overflow-wrap: break-word;
}

#overlay .overlay-card .overlay-actions .btn {
  min-width: 0;
  white-space: normal;
}

@media (max-width: 420px) {
  #overlay .overlay-card {
    width: calc(100vw - 24px);
    padding: 14px;
    border-radius: 16px;
  }
  #overlay .overlay-card .overlay-actions {
    flex-direction: column;
    gap: 8px;
  }
  #overlay .overlay-card .overlay-actions .btn {
    width: 100%;
    font-size: 13px;
    padding: 10px 12px;
  }
  #overlay .overlay-card .achievement {
    font-size: 13px;
  }
}

.achievement:before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background: rgba(255,182,193,0.8);
  border-radius: 50%;
  margin-right: 8px;
}
@media (max-width: 480px) {
  #hud {
    inset: 10px 10px auto 10px;
    gap: 8px;
  }
  
  #hud .left {
    min-width: auto;
  }
  
  .subtitle {
    max-width: 200px;
  }
  
  #overlay .card {
    width: calc(100vw - 24px);
    padding: 20px 16px;
  }
  
  .big {
    font-size: 18px;
  }
  
  .medium {
    font-size: 14px;
  }
  
  .small {
    font-size: 12px;
  }
}