/* ============================================================
   EGGFART v9 — GUT RUNNER
   A dark, warm, slightly damp arcade cabinet of a stylesheet.
   ============================================================ */

:root {
  --gut-900: #0d0409;
  --gut-800: #160810;
  --gut-700: #240d18;
  --gut-600: #3a1424;
  --flesh-500: #a33b52;
  --flesh-400: #c25a6d;
  --flesh-700: #6d2233;
  --cream: #f7ead8;
  --cream-dim: #d9c3ae;
  --yolk: #ffb703;
  --gas: #a8d68a;
  --gas-deep: #6f9e56;
  --chili: #e23b3b;
  --soda: #7fd1e8;
  --spike: #d9c2ff;
  --ink: #f7e7d8;
  --muted: #c08e99;
  --line: rgba(247, 234, 216, 0.16);
  --panel: rgba(28, 10, 18, 0.92);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --pad: clamp(0.75rem, 2.4vw, 1.5rem);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--gut-900);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- shell ---------- */

#game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 45%, rgba(6, 2, 5, 0.55) 100%),
    linear-gradient(to bottom, rgba(6, 2, 5, 0.35), transparent 22%, transparent 78%, rgba(6, 2, 5, 0.45));
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--pad) + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right))
            calc(var(--pad) + env(safe-area-inset-bottom)) calc(var(--pad) + env(safe-area-inset-left));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.hud.is-visible { opacity: 1; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dist {
  font-family: var(--font-mono);
  font-size: clamp(2.1rem, 7vw, 3.4rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--cream);
  text-shadow: 0 0 18px rgba(255, 183, 3, 0.35), 0 3px 0 rgba(0, 0, 0, 0.45);
}

.dist .unit {
  font-size: 0.4em;
  margin-left: 0.15em;
  color: var(--yolk);
}

.stat-sub, .score {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* Small HUD text can end up over the wall band — give it a legibility pill. */
.stat-sub, .score, .pressure-label {
  padding: 0.15rem 0.45rem;
  border-radius: 0.4rem;
  background: rgba(10, 4, 8, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.hud-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.score-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score {
  font-size: clamp(1rem, 3.4vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--cream);
}

.mult {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: var(--gut-900);
  background: var(--yolk);
  box-shadow: 0 0 14px rgba(255, 183, 3, 0.55);
  animation: pop 0.25s ease;
}

.mult[hidden] { display: none; }

.icon-row { display: flex; gap: 0.4rem; }

.icon-btn {
  pointer-events: auto;
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--cream);
  background: rgba(28, 10, 18, 0.72);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.icon-btn:hover { background: rgba(58, 20, 36, 0.9); border-color: rgba(247, 234, 216, 0.35); }
.icon-btn:active { transform: scale(0.93); }

.hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(0.5rem, 2vw, 1.25rem);
}

.left-stack {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  font-family: var(--font-mono);
  background: rgba(10, 4, 8, 0.55);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
}

.lives { display: flex; gap: 0.25rem; font-size: 1.05rem; }

.life { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); transition: opacity 0.2s ease, filter 0.2s ease, transform 0.2s ease; }
.life.is-lost { opacity: 0.22; filter: grayscale(1); transform: scale(0.82) rotate(-14deg); }

.bean-count {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--cream-dim);
}

.bean-icon { font-size: 1em; }

.pressure-wrap {
  flex: 1 1 auto;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pressure-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.pressure-label #pressure-state { color: var(--gas); }
.pressure-wrap.is-ready #pressure-state { color: var(--yolk); }
.pressure-wrap.is-fizz #pressure-state { color: var(--soda); }

.pressure-track {
  position: relative;
  height: 0.85rem;
  border-radius: 999px;
  background: rgba(10, 4, 8, 0.75);
  border: 1px solid var(--line);
  overflow: hidden;
}

.pressure-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gas-deep), var(--gas) 60%, #e6ff9c);
  box-shadow: 0 0 12px rgba(168, 214, 138, 0.55);
  transition: width 0.09s linear;
}

.pressure-wrap.is-ready .pressure-fill {
  background: linear-gradient(90deg, var(--gas), var(--yolk));
  box-shadow: 0 0 16px rgba(255, 183, 3, 0.7);
  animation: throb 0.85s ease-in-out infinite;
}

.pressure-wrap.is-fizz .pressure-fill {
  background: linear-gradient(90deg, #4fb6d9, var(--soda), #ffffff);
  box-shadow: 0 0 18px rgba(127, 209, 232, 0.8);
}

/* the 30% "fart cost" tick */
.pressure-cap {
  position: absolute;
  top: 0; bottom: 0;
  left: 30%;
  width: 2px;
  background: rgba(247, 234, 216, 0.55);
}

.fart-btn {
  pointer-events: auto;
  flex: 0 0 auto;
  width: clamp(4.4rem, 17vw, 5.6rem);
  height: clamp(4.4rem, 17vw, 5.6rem);
  border-radius: 50%;
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 3vw, 1.05rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #1d2b12;
  background: radial-gradient(circle at 35% 30%, #d3f0a8, var(--gas) 55%, var(--gas-deep));
  border: 2px solid rgba(247, 234, 216, 0.5);
  box-shadow: 0 6px 0 #3f5c30, 0 10px 24px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
  filter: saturate(0.45) brightness(0.7);
}

.fart-btn:hover { filter: saturate(0.7) brightness(0.85); }
.fart-btn.is-ready { filter: none; animation: fart-pulse 1.1s ease-in-out infinite; }
.fart-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #3f5c30, 0 4px 12px rgba(0, 0, 0, 0.5); }

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--pad);
  /* Deliberately opaque: a backdrop blur here would re-composite the
     animating canvas underneath on every frame. */
  background:
    radial-gradient(90% 70% at 50% 40%, rgba(58, 20, 36, 0.88), rgba(8, 3, 6, 0.97) 75%);
  z-index: 5;
  animation: fade-in 0.28s ease;
  overflow-y: auto;
}

.overlay[hidden] { display: none; }

.panel {
  width: min(40rem, 100%);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  text-align: center;
  background: rgba(28, 10, 18, 0.97);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(247, 234, 216, 0.08);
}

.panel-small { width: min(30rem, 100%); }
.panel-credits { width: min(44rem, 100%); text-align: left; }

.kicker {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  color: var(--yolk);
}

.kicker .dot { color: var(--flesh-400); }

.title {
  margin: 0;
  font-size: clamp(2.9rem, 13vw, 5.2rem);
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fffaf0 10%, var(--yolk) 55%, #e2603f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 18px rgba(226, 96, 63, 0.35));
}

.title-thin {
  display: block;
  font-weight: 300;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #ffe9c9, var(--flesh-400));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0.9rem auto 1.4rem;
  max-width: 30rem;
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  line-height: 1.55;
  color: var(--cream-dim);
}

.panel-heading {
  margin: 0 0 0.6rem;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--cream);
}

.quip {
  margin: 0 0 1.2rem;
  font-style: italic;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.8rem 1.6rem;
  font-family: var(--font-body);
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2a1206;
  background: linear-gradient(180deg, #ffd166, var(--yolk) 60%, #e8930c);
  border: none;
  border-radius: 999px;
  box-shadow: 0 5px 0 #a35c05, 0 12px 26px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #a35c05, 0 5px 14px rgba(0, 0, 0, 0.45); }

.btn-big { min-height: 3.6rem; padding: 1rem 2.4rem; font-size: clamp(1rem, 3.4vw, 1.2rem); }

.btn-ghost {
  color: var(--cream);
  background: rgba(247, 234, 216, 0.06);
  border: 1px solid var(--line);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.btn-ghost:hover { background: rgba(247, 234, 216, 0.12); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.link-btn {
  pointer-events: auto;
  margin-top: 1.1rem;
  padding: 0.5rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  background: none;
  border: 1px dashed var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.link-btn:hover { color: var(--cream); border-color: var(--flesh-400); }

:where(.btn, .icon-btn, .fart-btn, .link-btn):focus-visible {
  outline: 3px solid var(--soda);
  outline-offset: 3px;
}

/* ---------- title extras ---------- */

.howto, .legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.9rem;
  margin: 1.4rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: var(--cream-dim);
}

.legend {
  margin-top: 0.7rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.howto li, .legend li { display: flex; align-items: center; gap: 0.35rem; }

.how-key {
  padding: 0.15rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--cream);
  background: rgba(247, 234, 216, 0.08);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 0.35rem;
}

.glyph {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.25);
}

.glyph-bean { background: radial-gradient(circle at 32% 30%, #b07a4e, #5f3a20); border-radius: 60% 40% 55% 45%; }
.glyph-soda { background: radial-gradient(circle at 32% 30%, #d8f4ff, #4fb6d9); }
.glyph-chili { background: radial-gradient(circle at 32% 30%, #ff8a8a, var(--chili)); border-radius: 55% 45% 60% 40%; }
.glyph-spike { background: var(--spike); border-radius: 2px; transform: rotate(45deg); }

.best-line {
  margin: 1.3rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.best-line strong { color: var(--cream); }

/* ---------- results ---------- */

.results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0 0 1.4rem;
}

.results > div {
  padding: 0.7rem 0.5rem;
  background: rgba(247, 234, 216, 0.05);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.results dt {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}

.results dd {
  margin: 0.25rem 0 0;
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 700;
  color: var(--cream);
}

/* ---------- credits ---------- */

.credits-scroll {
  max-height: min(46vh, 22rem);
  margin: 1.2rem 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.credits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.credits-table th, .credits-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid rgba(247, 234, 216, 0.08);
}

.credits-table th {
  position: sticky;
  top: 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  background: #1d0a14;
}

.credits-table td:first-child { font-family: var(--font-mono); color: var(--gas); }
.credits-table tr:last-child td { border-bottom: none; }

/* ---------- animations ---------- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes throb {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

@keyframes fart-pulse {
  0%, 100% { box-shadow: 0 6px 0 #3f5c30, 0 10px 24px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(168, 214, 138, 0.55); }
  50% { box-shadow: 0 6px 0 #3f5c30, 0 10px 24px rgba(0, 0, 0, 0.5), 0 0 0 12px rgba(168, 214, 138, 0); }
}

/* ---------- small / landscape phones ---------- */

@media (max-height: 560px) {
  .hud-bottom { align-items: center; }
  .left-stack { flex-direction: row; align-items: center; gap: 0.7rem; }
  .dist { font-size: clamp(1.6rem, 5vh, 2.2rem); }
  .pressure-wrap { max-width: 18rem; }
  .pressure-label { font-size: 0.55rem; }
  .fart-btn {
    width: clamp(3.4rem, 13vh, 4.4rem);
    height: clamp(3.4rem, 13vh, 4.4rem);
    font-size: 0.75rem;
  }
  .icon-btn { width: 2rem; height: 2rem; font-size: 0.8rem; }
  .howto, .legend { display: none; }
  .panel { padding: 1rem 1.2rem; }
  .title { font-size: clamp(2.2rem, 9vh, 3.2rem); }
  .tagline { margin: 0.5rem auto 0.9rem; font-size: 0.85rem; }
  .results { gap: 0.4rem; }
  .results > div { padding: 0.5rem 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
