/* Game layer (public/game.js): player card, level map, HUD, celebrations.
   Uses the design tokens from styles.css when present, with fallbacks. */

/* ---------- player card ---------- */
.gm-player {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "buddy rank goal" "chips chips chips";
  align-items: center;
  gap: 12px 16px;
  margin: 16px 0 6px;
  padding: 16px 18px;
  border-radius: var(--r-lg, 24px);
  background: var(--glass, rgba(255, 255, 255, .8));
  box-shadow: var(--glass-shadow, 0 8px 24px rgba(22, 33, 62, .12));
  -webkit-backdrop-filter: var(--blur, none);
  backdrop-filter: var(--blur, none);
}
.gm-buddy {
  grid-area: buddy;
  width: 72px; height: 72px;
  border: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7d6, #ffd36b 70%, #ffb800);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .8), 0 6px 14px -4px rgba(255, 150, 0, .55);
  font-size: 42px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent;
}
.gm-buddy span { display: block; animation: gm-bob 2.6s ease-in-out infinite; }
.gm-buddy:active { transform: scale(.92); }
.gm-rank { grid-area: rank; min-width: 0; }
.gm-rank-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gm-rank-top b { font-family: var(--font-round, ui-rounded, system-ui); font-size: 24px; font-weight: 800; color: var(--ink, #16213e); }
.gm-rank-top span { font-size: 16px; font-weight: 700; color: var(--purple, #8e5cf0); }
.gm-xpbar { margin: 8px 0 6px; height: 14px; border-radius: 99px; background: rgba(22, 33, 62, .09); overflow: hidden; box-shadow: inset 0 1px 2px rgba(22, 33, 62, .12); }
.gm-xpbar span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #a77bff, #8e5cf0 55%, #6d3fe0);
  background-size: 200% 100%;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45);
  animation: gm-shine 3s linear infinite;
  transition: width .8s var(--spring, ease);
}
.gm-xpnote { font-size: 14px; font-weight: 700; color: var(--muted, #5d6888); font-variant-numeric: tabular-nums; }

.gm-goal {
  grid-area: goal;
  position: relative;
  width: 84px; height: 92px;
  border: 0; background: none; padding: 0; cursor: pointer;
  display: grid; justify-items: center; align-content: start;
  -webkit-tap-highlight-color: transparent;
}
.gm-goal .ring { display: block; }
.gm-goal .ring circle:last-child { transition: stroke-dashoffset 1s var(--ease-out, ease); }
.gm-goal-n { position: absolute; top: 0; height: 74px; display: grid; place-items: center; font-family: var(--font-round, ui-rounded, system-ui); font-weight: 800; font-size: 19px; color: var(--ink, #16213e); font-variant-numeric: tabular-nums; }
.gm-goal.met .gm-goal-n { color: var(--green-ink, #1c7a3a); font-size: 30px; }
.gm-goal-l { font-size: 12px; font-weight: 800; color: var(--muted, #5d6888); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

.gm-chips { grid-area: chips; display: flex; flex-wrap: wrap; gap: 8px; }
.gm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px; border-radius: 99px; border: 0;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 1px 0 #fff, 0 1px 3px rgba(22, 33, 62, .08);
  font: 700 15px/1 var(--font, system-ui); color: var(--ink-2, #3a4566);
}
.gm-btn { cursor: pointer; color: var(--blue-ink, #0a5bd6); }
.gm-btn:active { transform: scale(.95); }

/* ---------- level map ---------- */
.gm-map {
  --step: min(30vw, 150px);
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 24px;
}
.gm-region {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 14px; padding: 10px 20px 10px 12px;
  border-radius: 99px;
  background: var(--glass-strong, rgba(255, 255, 255, .9));
  box-shadow: var(--glass-shadow, 0 6px 18px rgba(22, 33, 62, .12));
  -webkit-backdrop-filter: var(--blur, none);
  backdrop-filter: var(--blur, none);
}
.gm-region:first-child { margin-top: 8px; }
.gm-region-ico { font-size: 28px; }
.gm-region b { font-family: var(--font-round, ui-rounded, system-ui); font-size: 20px; font-weight: 800; color: var(--ink, #16213e); }
.gm-region small { font-size: 14px; font-weight: 700; color: var(--muted, #5d6888); }

.gm-row, .gm-dots { transform: translateX(calc(var(--x) * var(--step))); }
.gm-row { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gm-row:has(.gm-stop.current) { padding-top: 34px; }
.gm-dots { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 6px 0; }
.gm-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(22, 33, 62, .16); }

.gm-stop {
  position: relative;
  width: 104px; height: 104px;
  border: 0; padding: 0; border-radius: 50%;
  background: none; cursor: pointer;
  display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform .35s var(--spring, ease);
}
.gm-stop .ring { position: absolute; inset: 0; }
.gm-stop .ring circle:last-child { transition: stroke-dashoffset 1s var(--ease-out, ease); }
.gm-disc {
  position: relative;
  width: 80px; height: 80px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-round, ui-rounded, system-ui); font-size: 32px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #5ee08a, var(--green, #34c759) 60%, #23a447);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -5px 0 rgba(0, 0, 0, .14), 0 7px 0 #1c8a3c, 0 12px 20px -6px rgba(28, 122, 58, .55);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .15);
}
.gm-stop:active:not(:disabled) { transform: translateY(4px) scale(.97); }
.gm-stop:active:not(:disabled) .gm-disc { box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .14), 0 3px 0 #1c8a3c; }
.gm-stop.done .gm-disc {
  background: linear-gradient(180deg, #ffe07a, var(--gold, #ffb800) 60%, #f09a00);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .5), inset 0 -5px 0 rgba(0, 0, 0, .12), 0 7px 0 #c97f00, 0 12px 20px -6px rgba(201, 127, 0, .55);
  font-size: 38px;
}
.gm-stop.locked { cursor: not-allowed; }
.gm-stop.locked .gm-disc {
  background: linear-gradient(180deg, #eef0f6, #d9dde8);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .7), 0 6px 0 #bcc2d2;
  font-size: 28px; text-shadow: none;
}
.gm-stop.detective:not(.locked) .gm-disc {
  background: linear-gradient(180deg, #b597ff, var(--purple, #8e5cf0) 60%, #6d3fe0);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -5px 0 rgba(0, 0, 0, .14), 0 7px 0 #5a2fc4, 0 12px 20px -6px rgba(90, 47, 196, .5);
}
.gm-stop.current .gm-disc { animation: gm-pulse 2s ease-in-out infinite; }
.gm-here {
  position: absolute; top: -34px; left: 50%;
  font-size: 40px; line-height: 1;
  transform: translateX(-50%);
  animation: gm-hop 1.6s var(--spring, ease) infinite;
  filter: drop-shadow(0 4px 4px rgba(22, 33, 62, .25));
}
.gm-go {
  position: absolute; right: -54px; top: 30px;
  padding: 6px 11px; border-radius: 12px;
  background: #fff; color: var(--green-ink, #1c7a3a);
  font: 800 14px/1 var(--font-round, ui-rounded, system-ui); letter-spacing: .04em;
  box-shadow: 0 4px 12px rgba(22, 33, 62, .18);
  animation: gm-bob 1.8s ease-in-out infinite;
}
.gm-go::before { content: ""; position: absolute; left: -6px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left: 0; border-right-color: #fff; }
.gm-cap { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 220px; }
.gm-cap b { font-size: 16px; font-weight: 800; color: var(--ink, #16213e); }
.gm-cap span { font-size: 13px; font-weight: 700; color: var(--muted, #5d6888); font-variant-numeric: tabular-nums; }

/* ---------- in-level HUD ---------- */
.gm-hud { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: nowrap; }
.topbar:has(.gm-hud) { grid-template-columns: auto 1fr auto; }
.topbar .gm-hud { grid-row: 1; grid-column: 3; }
.gm-combo, .gm-mini, .gm-today {
  display: inline-flex; align-items: center; gap: 5px;
  height: 38px; padding: 0 12px; border-radius: 99px;
  background: rgba(255, 255, 255, .78);
  box-shadow: inset 0 1px 0 #fff, 0 1px 3px rgba(22, 33, 62, .1);
  font: 800 16px/1 var(--font-round, ui-rounded, system-ui); color: var(--ink-2, #3a4566);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.gm-combo { filter: grayscale(1); opacity: .7; transition: filter .3s, opacity .3s; }
.gm-combo small { font-size: 12px; margin-left: -2px; }
.gm-combo.hot { filter: none; opacity: 1; color: #c2410c; background: linear-gradient(180deg, #fff3e0, #ffe0b8); }
.gm-combo.blaze { color: #fff; background: linear-gradient(180deg, #ffa53a, var(--orange-2, #ff5e3a)); box-shadow: 0 4px 14px -4px rgba(255, 94, 58, .8); }
.gm-combo.bump { animation: gm-bump .5s var(--spring, ease); }
.gm-mini b { color: var(--purple, #8e5cf0); }
.gm-minibar { width: 52px; height: 8px; border-radius: 99px; background: rgba(22, 33, 62, .1); overflow: hidden; }
.gm-minibar span { display: block; height: 100%; background: linear-gradient(90deg, #a77bff, #8e5cf0); border-radius: 99px; transition: width .8s var(--spring, ease); }

/* ---------- celebrations ---------- */
.gm-float {
  position: fixed; z-index: 60; pointer-events: none;
  transform: translate(-50%, -50%);
  font: 900 30px/1 var(--font-round, ui-rounded, system-ui);
  color: var(--purple, #8e5cf0);
  text-shadow: 0 2px 0 #fff, 0 0 18px rgba(255, 255, 255, .9);
  animation: gm-float 1.3s var(--ease-out, ease) forwards;
}
.gm-burst {
  position: fixed; z-index: 61; left: 50%; top: 38%; pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -50%);
  animation: gm-burst 1.4s var(--spring, ease) forwards;
}
.gm-burst b { font: 900 84px/1 var(--font-round, ui-rounded, system-ui); color: #ff7a1a; text-shadow: 0 4px 0 #fff, 0 10px 30px rgba(255, 94, 58, .5); }
.gm-burst span { font: 900 28px/1 var(--font-round, ui-rounded, system-ui); color: #c2410c; letter-spacing: .06em; text-shadow: 0 2px 0 #fff; }

.gm-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 24px;
  background: rgba(22, 33, 62, .28);
  animation: gm-dim .25s ease both;
  overflow: hidden;
}
.gm-overlay.out { animation: gm-dim .25s ease reverse both; }
.gm-overlay.out .gm-pop { transition: transform .25s ease; transform: scale(.85); }
.gm-pop {
  position: relative; z-index: 2;
  width: min(440px, 100%); padding: 28px 26px 24px; text-align: center;
  border-radius: var(--r-xl, 30px);
  background: var(--glass-strong, rgba(255, 255, 255, .95));
  box-shadow: var(--glass-shadow, 0 20px 50px rgba(22, 33, 62, .3));
  -webkit-backdrop-filter: var(--blur, none);
  backdrop-filter: var(--blur, none);
  animation: gm-pop .6s var(--spring, ease) both;
}
.gm-pop h2 { margin: 6px 0 8px; font: 900 34px/1.1 var(--font-round, ui-rounded, system-ui); color: var(--ink, #16213e); }
.gm-pop p { margin: 0 0 12px; font-size: 18px; color: var(--ink-2, #3a4566); }
.gm-pop .btn { margin-top: 8px; min-width: 160px; }
.gm-pop-big { font-size: 76px; line-height: 1; animation: gm-hop 1.4s var(--spring, ease) infinite; }
.gm-unlock { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 12px; border-radius: 16px; background: rgba(255, 184, 0, .14); }
.gm-unlock span { font-size: 40px; }
.gm-rays {
  position: absolute; left: 50%; top: 50%; width: 160vmax; height: 160vmax; z-index: 1;
  margin: -80vmax 0 0 -80vmax; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 220, 120, .28) 0 9deg, transparent 9deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 55%);
  mask: radial-gradient(circle, #000 0, transparent 55%);
  animation: gm-spin 14s linear infinite;
}

.gm-toast {
  position: fixed; z-index: 65; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px 12px 14px; border-radius: 22px;
  background: var(--glass-strong, rgba(255, 255, 255, .95));
  box-shadow: var(--glass-shadow, 0 12px 30px rgba(22, 33, 62, .25)), 0 0 0 3px rgba(255, 184, 0, .6);
  -webkit-backdrop-filter: var(--blur, none);
  backdrop-filter: var(--blur, none);
  transform: translateX(-50%);
  animation: gm-toast-in .6s var(--spring, ease) both;
  cursor: pointer;
}
.gm-toast.out { animation: gm-toast-out .4s ease both; }
.gm-toast-ico { font-size: 40px; animation: gm-bump .8s var(--spring, ease) .2s both; }
.gm-toast small { display: block; font-size: 13px; font-weight: 800; color: #b07800; text-transform: uppercase; letter-spacing: .06em; }
.gm-toast b { font: 800 20px/1.2 var(--font-round, ui-rounded, system-ui); color: var(--ink, #16213e); }

/* ---------- trophy room ---------- */
.gm-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; }
.gm-badge {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 14px 10px; border-radius: 18px;
  background: rgba(22, 33, 62, .05);
  color: var(--muted, #5d6888);
}
.gm-badge-ico { font-size: 38px; line-height: 1.1; filter: grayscale(1); opacity: .5; }
.gm-badge b { font-size: 15px; color: var(--ink-2, #3a4566); }
.gm-badge small { font-size: 12.5px; line-height: 1.3; }
.gm-badge.got { background: linear-gradient(180deg, #fff8dc, #ffeeb0); box-shadow: inset 0 1px 0 #fff, 0 2px 8px rgba(201, 127, 0, .2); }
.gm-badge.got .gm-badge-ico { filter: none; opacity: 1; }
.gm-badge.got b { color: var(--ink, #16213e); }
.gm-buddies { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.gm-pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; border-radius: 18px; border: 3px solid transparent;
  background: rgba(255, 255, 255, .75); cursor: pointer;
  font: 700 13px/1.2 var(--font, system-ui); color: var(--ink-2, #3a4566);
}
.gm-pick span { font-size: 40px; line-height: 1.1; }
.gm-pick.on { border-color: var(--gold, #ffb800); background: #fff8dc; }
.gm-pick:disabled { opacity: .5; cursor: not-allowed; }
.gm-pick:disabled span { filter: grayscale(1); font-size: 30px; padding: 5px 0; }

/* ---------- sizes ---------- */
@media (min-width: 700px) {
  .gm-player { grid-template-columns: auto 1fr auto auto; grid-template-areas: "buddy rank chips goal"; padding: 18px 22px; }
  .gm-chips { max-width: 330px; justify-content: flex-end; }
  .gm-map { --step: 150px; }
  .gm-stop { width: 120px; height: 120px; }
  .gm-stop .ring { width: 120px; height: 120px; }
  .gm-disc { width: 92px; height: 92px; font-size: 36px; }
}
@media (max-width: 520px) {
  .gm-player { grid-template-columns: auto 1fr; grid-template-areas: "buddy rank" "goal chips"; }
  .gm-buddy { width: 60px; height: 60px; font-size: 34px; }
  .gm-hud .gm-mini, .gm-hud .gm-today { display: none; }
  .gm-map { --step: 22vw; }
  .gm-go { display: none; }
}

/* ---------- motion ---------- */
@keyframes gm-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes gm-hop { 0%, 100% { transform: translate(-50%, 0); } 40% { transform: translate(-50%, -10px); } }
.gm-pop .gm-pop-big { animation-name: gm-hop-c; }
@keyframes gm-hop-c { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-10px) scale(1.08); } }
@keyframes gm-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes gm-shine { from { background-position: 200% 0; } to { background-position: 0 0; } }
@keyframes gm-bump { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-6deg); } 100% { transform: scale(1); } }
@keyframes gm-float { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
@keyframes gm-burst { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-12deg); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(3deg); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(.9); } }
@keyframes gm-dim { from { background-color: rgba(22, 33, 62, 0); } to { background-color: rgba(22, 33, 62, .28); } }
@keyframes gm-pop { from { transform: scale(.6) translateY(30px); } to { transform: none; } }
@keyframes gm-spin { to { transform: rotate(360deg); } }
@keyframes gm-toast-in { from { transform: translate(-50%, calc(100% + 60px)) scale(.8); } to { transform: translate(-50%, 0); } }
@keyframes gm-toast-out { to { transform: translate(-50%, calc(100% + 60px)) scale(.9); } }

@media (prefers-reduced-motion: reduce) {
  .gm-buddy span, .gm-here, .gm-go, .gm-stop.current .gm-disc, .gm-xpbar span, .gm-pop-big, .gm-rays, .gm-toast-ico { animation: none !important; }
  .gm-here { transform: translateX(-50%); }
}
