/* Bug-Bug's Pie Spinner — DataCruise Arcade #3.
   Bright orange + black arcade palette, matching Block City / Mountain Climb. */

* { box-sizing: border-box; }

:root {
  --bg-top: #FFE9A8;
  --bg-bot: #FFB347;
  --ink: #1A1A1A;
  --paper: #FFF7E2;
  --orange: #FF6A1A;
  --orange-deep: #D44A00;
  --gold: #FFC500;
  --green: #2BB673;
  --sky: #5DC1E8;
  --sky-deep: #2E9DC9;
  --shadow: 0 6px 0 0 #1A1A1A;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Fredoka", "Quicksand", "Avenir Next", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bot) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--orange);
  color: var(--ink);
  font-weight: 800;
  padding: 12px 22px;
  font-size: 18px;
  box-shadow: 0 4px 0 0 var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease, background 120ms ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 5px 0 0 var(--ink); }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--ink); }
button[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 0 var(--ink); }
button.ghost { background: var(--paper); color: var(--ink); }

/* ============== TITLE / END SCREENS ============== */

.screen { display: grid; place-items: center; min-height: 80vh; }

.card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px 38px;
  max-width: 640px;
  text-align: center;
}
.card h1 { font-size: 38px; margin: 12px 0 6px; letter-spacing: 1px; line-height: 1.05; }
.card .subtitle { margin: 0 0 22px; font-weight: 600; color: #5C2A0F; font-size: 15px; }
.card .big-bug { width: 130px; height: 110px; display: block; margin: 0 auto 4px; }

.howto {
  text-align: left;
  background: #FFF;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.5;
}
.howto p { margin: 0 0 6px; }
.howto p:last-child { margin-bottom: 0; }
.howto strong { color: var(--orange-deep); }

.prompt { font-weight: 800; letter-spacing: 1.5px; font-size: 13px; color: var(--orange-deep); margin: 0 0 12px; }

.stars { font-size: 46px; letter-spacing: 6px; margin: 12px 0 8px; }
.stars .dim { opacity: 0.25; }

.end-chart {
  display: block;
  margin: 8px auto 8px;
  background: #FFF;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 3px 0 0 var(--ink);
}

.chart-trophy {
  margin: 6px 0;
  color: var(--orange-deep);
  font-weight: 900;
  letter-spacing: 1.5px;
  font-size: 15px;
}

.new-best {
  margin: 0 0 12px;
  color: var(--orange-deep);
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 16px;
  animation: bounce-best 0.6s ease;
}
@keyframes bounce-best {
  0% { transform: scale(0); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.stats { font-size: 15px; line-height: 1.6; margin: 0 0 16px; }
.stats b { color: var(--orange-deep); }

.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ============== GAME SCREEN ============== */

.game { display: grid; grid-template-columns: 1fr; gap: 14px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--ink);
  color: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 14px;
  font-weight: 800;
  flex-wrap: wrap;
}
.topbar .title { font-size: 16px; letter-spacing: 1px; }

.sound-toggle {
  font-size: 20px;
  line-height: 1;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2A2A2A;
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
}
.sound-toggle:hover { background: #3A3A3A; }
.sound-toggle:active { transform: scale(0.94); }

.spin-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #2A2A2A;
  border: 2px solid var(--paper);
  border-radius: 14px;
  padding: 6px 14px;
  font-size: 13px;
  letter-spacing: 1px;
  transition: background 160ms ease, transform 120ms ease;
}
.spin-label { opacity: 0.85; font-weight: 800; }
.spin-num { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 50px; }
.spin-dots { display: inline-flex; gap: 4px; }
.spin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  background: transparent;
  transition: background 140ms ease;
}
.spin-dot.used { background: var(--orange); border-color: var(--orange-deep); }
.spin-pill.warn { background: linear-gradient(180deg, #7A4A00 0%, #4A2A00 100%); }
.spin-pill.danger {
  background: linear-gradient(180deg, #B33000 0%, #7E1F00 100%);
  animation: pulse-pill 0.7s ease-in-out infinite;
}
@keyframes pulse-pill {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.stage {
  background: #FFFFFF;
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.stage svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 110px);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ============== PIE SLICES ============== */

.slice .slice-path {
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linejoin: round;
  transition: fill 350ms ease;
  transform-box: fill-box;
  transform-origin: center;
}
.slice.dim .slice-path { fill: #DDD2B5; }
.slice.lit .slice-path { fill: var(--slice-color, #FF6A1A); }

.slice .slice-label {
  font: 900 22px "Fredoka", sans-serif;
  fill: var(--ink);
  pointer-events: none;
  transition: fill 200ms ease;
}
.slice.dim .slice-label { fill: #6F5C2E; }
.slice.lit .slice-label { fill: var(--ink); }

/* Just-lit pop: scale the whole slice group briefly. */
.slice {
  transform-box: fill-box;
  transform-origin: 290px 320px;
}
.slice.just-lit { animation: slice-pop 700ms ease; }
@keyframes slice-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  70%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

/* ============== SPINNER WHEEL ============== */

#wheel { cursor: pointer; pointer-events: bounding-box; }
#wheel > * { pointer-events: none; }
#wheel-hub { cursor: pointer; pointer-events: bounding-box; }
#wheel-hub > * { pointer-events: none; }
#wheel-hub:hover circle:first-of-type { fill: #FF8035; }
#wheel-hub:active { transform-origin: center; }

.wedge-num {
  font: 900 28px "Fredoka", sans-serif;
  fill: var(--ink);
  pointer-events: none;
}

#wheel-pointer { pointer-events: none; }

/* ============== BUG-BUG ============== */

/* Bug-Bug pose is positioned and bobbed by JS (patchGame). CSS only handles fills/strokes. */
.bug-group { pointer-events: none; }
.bug-body { fill: var(--orange-deep); stroke: var(--ink); stroke-width: 3; }
.bug-spot { fill: var(--ink); }
.bug-head { fill: var(--ink); stroke: var(--ink); stroke-width: 2; }
.bug-eye { fill: #FFF; }
.bug-pupil { fill: var(--ink); }

/* Result chip fade */
#result-chip { transition: opacity 220ms ease; }
