/* ═══════════════════════════════════════════════════════════════════
 * MKP Gamification v1.1 · 2026-06-01 · RPG/Game style
 * Vibe: Stardew Valley + Octopath Traveler · pixel-art chunky borders
 * Boss + Hia Gem dual sign-off · vibe locked
 * ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Palette */
  --gm-bg-primary: #1a1a2e;
  --gm-bg-card: #252543;
  --gm-bg-card-deep: #14142b;
  --gm-text: #f0f0ff;
  --gm-text-muted: #a0a0c0;
  --gm-border-gold: #ffd700;
  --gm-border-silver: #c0c0c0;
  --gm-border-bronze: #cd7f32;
  --gm-border-diamond: #5af;
  --gm-border-founder-1: #ff00ff;
  --gm-border-founder-2: #ffd700;
  --gm-border-founder-3: #00ffff;
  --gm-xp-fill: linear-gradient(90deg, #ffd700, #ff9500);
  --gm-streak-fire: #ff6b00;
  --gm-quest-pending: #ffd700;
  --gm-quest-done: #00cc66;
  /* Timing */
  --gm-anim-instant: 150ms;
  --gm-anim-bounce: cubic-bezier(.34, 1.56, .64, 1);
}

/* ═══ Dashboard Widget (sticky top of dashboard) ═══ */
.gm-widget {
  background: var(--gm-bg-primary);
  border: 3px solid var(--gm-border-gold);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  color: var(--gm-text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.gm-widget::before {
  /* subtle gold shimmer overlay */
  content: '';
  position: absolute; top: 0; left: -100%;
  width: 200%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.04), transparent);
  animation: gmShimmer 8s linear infinite;
  pointer-events: none;
}
@keyframes gmShimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.gm-widget-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.gm-widget-avatar {
  font-size: 28px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gm-bg-card-deep);
  border: 2px solid var(--gm-border-gold);
  border-radius: 8px;
}
.gm-widget-name {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
}
.gm-widget-level-pill {
  background: var(--gm-bg-card-deep);
  border: 2px solid var(--gm-border-gold);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gm-border-gold);
}

/* XP bar */
.gm-xp-bar-wrap {
  background: var(--gm-bg-card-deep);
  border-radius: 10px;
  height: 18px;
  position: relative;
  overflow: hidden;
  margin: 8px 0 6px;
  border: 1px solid #333;
}
.gm-xp-bar-fill {
  background: var(--gm-xp-fill);
  height: 100%;
  border-radius: 10px;
  transition: width 600ms var(--gm-anim-bounce);
  animation: gmXpPulse 2.5s ease infinite;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5) inset;
}
@keyframes gmXpPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
.gm-xp-bar-text {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.gm-widget-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px;
  color: var(--gm-text-muted);
}
.gm-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.gm-meta-fire { color: var(--gm-streak-fire); animation: gmFlicker 1.5s ease infinite; }
@keyframes gmFlicker {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.08); }
}

/* ═══ Quests Section ═══ */
.gm-quests {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 215, 0, 0.2);
}
.gm-quests-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--gm-border-gold);
  margin-bottom: 8px;
  display: flex; justify-content: space-between;
}
.gm-quest-list { display: flex; flex-direction: column; gap: 6px; }
.gm-quest {
  background: var(--gm-bg-card);
  border: 1px solid #333;
  border-left: 4px solid var(--gm-quest-pending);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  transition: all 200ms;
}
.gm-quest.done {
  border-left-color: var(--gm-quest-done);
  opacity: 0.6;
  text-decoration: line-through;
}
.gm-quest-icon { font-size: 14px; }
.gm-quest-label { flex: 1; }
.gm-quest-progress {
  font-size: 11px;
  color: var(--gm-text-muted);
}
.gm-quest-reward {
  background: var(--gm-bg-card-deep);
  border: 1px solid var(--gm-border-gold);
  color: var(--gm-border-gold);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

/* ═══ Mini Toast (XP gain · bottom-right) ═══ */
.gm-toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9998;
  display: flex; flex-direction: column-reverse; gap: 6px;
  pointer-events: none;
}
.gm-toast {
  background: var(--gm-bg-primary);
  border: 2px solid var(--gm-border-gold);
  border-left: 6px solid var(--gm-border-gold);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--gm-text);
  font-size: 13px;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: gmToastIn 350ms var(--gm-anim-bounce), gmToastOut 350ms ease 1700ms forwards;
}
@keyframes gmToastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes gmToastOut {
  to { transform: translateX(120%); opacity: 0; }
}
.gm-toast-xp {
  font-size: 17px;
  font-weight: 700;
  color: var(--gm-border-gold);
}
.gm-toast-source { font-size: 11px; color: var(--gm-text-muted); margin-top: 2px; }

/* ═══ Level-Up Modal (full-screen 3s) ═══ */
.gm-levelup-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  animation: gmFadeIn 300ms ease;
  cursor: pointer;
}
@keyframes gmFadeIn { from { opacity: 0; } to { opacity: 1; } }
.gm-levelup-box {
  background: var(--gm-bg-primary);
  border: 4px solid var(--gm-border-gold);
  border-radius: 16px;
  padding: 32px 48px;
  text-align: center;
  color: var(--gm-text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
  animation: gmLevelupPop 500ms var(--gm-anim-bounce);
  min-width: 360px;
  max-width: 90vw;
}
@keyframes gmLevelupPop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.gm-levelup-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--gm-border-gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
  letter-spacing: 2px;
  margin-bottom: 18px;
  animation: gmLevelupWipe 600ms ease;
}
@keyframes gmLevelupWipe {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.gm-levelup-levels {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 20px 0;
  font-size: 22px;
}
.gm-levelup-old {
  background: var(--gm-bg-card-deep);
  border: 2px solid #555;
  border-radius: 10px;
  padding: 8px 18px;
  color: var(--gm-text-muted);
}
.gm-levelup-arrow { font-size: 28px; color: var(--gm-border-gold); }
.gm-levelup-new {
  background: var(--gm-bg-card-deep);
  border: 3px solid var(--gm-border-gold);
  border-radius: 10px;
  padding: 8px 18px;
  color: var(--gm-border-gold);
  font-weight: 800;
  animation: gmLevelupRotate 600ms var(--gm-anim-bounce);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.5);
}
@keyframes gmLevelupRotate {
  from { transform: rotate(-15deg) scale(0.5); }
  to { transform: rotate(0) scale(1); }
}
.gm-levelup-perks-label {
  font-size: 14px;
  color: var(--gm-text-muted);
  margin-top: 18px;
}
.gm-levelup-perks-list {
  margin: 10px 0 16px;
  list-style: none;
  padding: 0;
  font-size: 15px;
}
.gm-levelup-perks-list li {
  padding: 4px 0;
  opacity: 0;
  animation: gmPerkIn 400ms ease forwards;
}
.gm-levelup-perks-list li:nth-child(1) { animation-delay: 1.0s; }
.gm-levelup-perks-list li:nth-child(2) { animation-delay: 1.2s; }
.gm-levelup-perks-list li:nth-child(3) { animation-delay: 1.4s; }
.gm-levelup-perks-list li:nth-child(4) { animation-delay: 1.6s; }
@keyframes gmPerkIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.gm-levelup-hint {
  font-size: 11px;
  color: var(--gm-text-muted);
  margin-top: 14px;
  opacity: 0;
  animation: gmFadeIn 500ms ease 2.5s forwards;
}

/* Confetti particles (JS-spawned) */
.gm-confetti {
  position: fixed;
  width: 8px; height: 8px;
  pointer-events: none;
  z-index: 10001;
  border-radius: 2px;
}

/* ═══ Badges (5 tiers · SVG inline) ═══ */
.gm-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  font-size: 18px;
  vertical-align: middle;
}
.gm-badge.lg { width: 64px; height: 64px; font-size: 48px; }
.gm-badge-bronze { color: var(--gm-border-bronze); filter: drop-shadow(0 0 4px var(--gm-border-bronze)); }
.gm-badge-silver { color: var(--gm-border-silver); filter: drop-shadow(0 0 4px var(--gm-border-silver)); }
.gm-badge-gold {
  color: var(--gm-border-gold);
  filter: drop-shadow(0 0 6px var(--gm-border-gold));
  animation: gmGoldPulse 4s ease infinite;
}
@keyframes gmGoldPulse {
  0%, 100% { filter: drop-shadow(0 0 6px var(--gm-border-gold)); }
  50% { filter: drop-shadow(0 0 14px var(--gm-border-gold)); }
}
.gm-badge-diamond {
  color: var(--gm-border-diamond);
  animation: gmDiamondHue 8s linear infinite;
}
@keyframes gmDiamondHue {
  from { filter: drop-shadow(0 0 8px var(--gm-border-diamond)) hue-rotate(0deg); }
  to { filter: drop-shadow(0 0 8px var(--gm-border-diamond)) hue-rotate(360deg); }
}
.gm-badge-founder {
  background: linear-gradient(45deg, var(--gm-border-founder-1), var(--gm-border-founder-2), var(--gm-border-founder-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gmFounderShimmer 3s linear infinite;
  background-size: 200% 200%;
}
@keyframes gmFounderShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ═══ Profile XP History Section ═══ */
.gm-profile-section {
  background: var(--gm-bg-primary);
  border: 3px solid var(--gm-border-gold);
  border-radius: 12px;
  padding: 20px;
  margin: 16px 0;
  color: var(--gm-text);
}
.gm-profile-section h3 {
  color: var(--gm-border-gold);
  margin: 0 0 12px;
  font-size: 16px;
}
.gm-badge-collection {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center;
  margin: 16px 0;
}
.gm-badge-cell {
  text-align: center;
  background: var(--gm-bg-card);
  padding: 10px;
  border-radius: 8px;
  min-width: 80px;
}
.gm-badge-cell.locked { opacity: 0.35; }
.gm-badge-cell-label {
  font-size: 11px;
  color: var(--gm-text-muted);
  margin-top: 4px;
}
.gm-xp-history-list {
  max-height: 280px;
  overflow-y: auto;
  font-size: 12px;
}
.gm-xp-history-row {
  display: flex; justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid #333;
  font-family: 'SF Mono', Consolas, monospace;
}
.gm-xp-history-row .delta-pos { color: var(--gm-quest-done); font-weight: 700; }
.gm-xp-history-row .delta-neg { color: #f55; font-weight: 700; }

/* ═══ Mobile ═══ */
@media (max-width: 600px) {
  .gm-widget { padding: 10px 12px; }
  .gm-widget-header { gap: 8px; }
  .gm-widget-avatar { width: 32px; height: 32px; font-size: 20px; }
  .gm-widget-name { font-size: 13px; }
  .gm-quest { padding: 5px 8px; font-size: 11px; }
  .gm-levelup-box { padding: 24px; min-width: unset; }
  .gm-levelup-title { font-size: 24px; }
  .gm-toast-container { right: 10px; bottom: 10px; }
  .gm-toast { min-width: 160px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion) {
  .gm-widget::before,
  .gm-xp-bar-fill,
  .gm-meta-fire,
  .gm-badge-gold,
  .gm-badge-diamond,
  .gm-badge-founder { animation: none !important; }
}
