/* =====================================================================
   Grapple Grove — fixed "firefly forest" theme.
   Same page frame as the other arcade cabinets (full-height app shell,
   frosted top bar, chunky buttons, hard-shadow 16:9 stage, card overlays,
   overlay-scrolled rules modal) but with its own palette: dusk canopy,
   mossy gold keylines, lantern amber and firefly lime.
   Deliberately ignores the center's light/dark mode; no glass.css loaded.
   ===================================================================== */
:root {
  --gg-night: #061615;   /* page bottom */
  --gg-deep:  #0a2422;   /* app body */
  --gg-moss:  #7fdf9a;   /* leaves + keylines */
  --gg-lime:  #b7e86a;   /* fireflies */
  --gg-gold:  #ffcf6e;   /* rings + headings */
  --gg-amber: #ffa94d;   /* primary action */
  --gg-ink:   #eaf4e3;   /* main text */
  --gg-dim:   rgba(215, 236, 213, .66);
  --gg-line:  rgba(132, 214, 152, .42);
}

html, body { height: 100%; }
body.gg-page {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(80% 55% at 18% 0%, rgba(126, 205, 140, .16), transparent 60%),
    radial-gradient(70% 50% at 82% 8%, rgba(255, 207, 110, .10), transparent 65%),
    linear-gradient(180deg, #143c34 0%, #0a2422 48%, var(--gg-night) 100%);
  color: var(--gg-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.gg-page *,
body.gg-page *::before,
body.gg-page *::after { box-sizing: border-box; }

/* ---------- App frame ---------- */
.c-app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.c-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  padding: 12px clamp(12px, 3vw, 28px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(6, 26, 24, .58);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--gg-line);
  z-index: 20;
}
.c-bar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-bar__brand svg { filter: drop-shadow(0 0 7px rgba(255, 207, 110, .45)); }
.c-bar__title {
  margin: 0;
  font-size: clamp(19px, 3.4vw, 26px);
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #f7f1dc;
  text-shadow: 0 0 14px rgba(255, 207, 110, .38), 0 0 30px rgba(127, 223, 154, .22);
}
.c-bar__stats { display: flex; align-items: center; gap: 8px 18px; margin-left: auto; }
.c-bar__controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat { font-size: 14px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; color: var(--gg-dim); }
.stat b { color: var(--gg-gold); font-size: 16px; text-shadow: 0 0 8px rgba(255, 207, 110, .35); }
#flies { color: var(--gg-lime); text-shadow: 0 0 8px rgba(183, 232, 106, .45); }

/* ---------- Buttons (carved forest arcade style) ---------- */
.c-btn {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  padding: 9px 16px;
  border-radius: 12px;
  border: 2px solid var(--gg-line);
  background: rgba(14, 44, 39, .82);
  color: var(--gg-ink);
  box-shadow: 0 3px 0 rgba(2, 12, 11, .7);
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.c-btn:hover { background: rgba(23, 62, 53, .95); border-color: var(--gg-moss); }
.c-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(2, 12, 11, .7); }
.c-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(127, 223, 154, .45); }
/* .c-btn sets display:inline-block, which would beat the UA's [hidden] rule — restore it. */
.c-btn[hidden] { display: none; }
.c-btn--primary {
  background: linear-gradient(140deg, #ffd98a, var(--gg-amber));
  border-color: rgba(255, 235, 190, .7);
  color: #33200a;
  text-shadow: none;
  box-shadow: 0 3px 0 rgba(80, 44, 6, .55);
}
.c-btn--primary:hover { background: linear-gradient(140deg, #ffe3a3, #ffb35f); border-color: #fff1cf; }
.c-btn--icon { padding: 8px 11px; }
.c-btn--icon svg { display: block; }
/* Sound icon: waves hide when muted, slash hides when live. */
.gg-slash { display: none; }
body.gg-muted .gg-wave { opacity: 0; }
body.gg-muted .gg-slash { display: block; }

/* ---------- Table / stage column ---------- */
.c-table {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2.4vh, 22px);
}
.gg-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 16:9 landscape; capped by viewport height minus bar + caption. */
  width: min(96vw, calc((100vh - 178px) * 1.7778));
  width: min(96vw, calc((100dvh - 178px) * 1.7778));
}
.gg-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: var(--gg-night);
  border: 3px solid rgba(255, 207, 110, .28);
  box-shadow: 0 10px 0 rgba(2, 12, 11, .5), 0 22px 48px rgba(2, 12, 11, .6), 0 0 42px rgba(127, 223, 154, .18);
  touch-action: manipulation;
  cursor: crosshair;
}
#board {
  display: block;
  width: 100%; height: 100%;
  touch-action: none;                  /* capture taps without page scroll */
  -webkit-user-select: none; user-select: none;
}

/* ---------- Caption under the stage ---------- */
.gg-caption {
  flex: none;
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.9;
  color: var(--gg-dim);
}
.gg-caption b { color: var(--gg-gold); }
.gg-card kbd, .c-modal kbd, .gg-caption kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin: 0 1px;
  font: 700 12px/1.5 ui-monospace, "Segoe UI", monospace;
  text-align: center;
  color: var(--gg-ink);
  background: rgba(12, 38, 33, .9);
  border: 1px solid var(--gg-line);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(2, 12, 11, .6);
}

/* ---------- Title / pause / results overlays ---------- */
.gg-overlay {
  touch-action: manipulation;
  position: absolute; inset: 0; z-index: 8;
  display: flex;
  overflow: auto;                      /* the overlay scrolls, never the card */
  padding: 16px;
  background: rgba(3, 15, 14, .58);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  cursor: default;
}
.gg-overlay[hidden] { display: none; }
.gg-card {
  position: relative;
  margin: auto;                        /* centers AND lets a tall card scroll in */
  width: min(100%, 384px);
  text-align: center;
  padding: 20px 24px 18px;
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 50% -20%, rgba(255, 207, 110, .12), transparent 62%),
    linear-gradient(160deg, #1a4238, #0a201d);
  border: 2px solid var(--gg-line);
  box-shadow: 0 8px 0 rgba(2, 12, 11, .45), 0 22px 50px rgba(2, 12, 11, .6), 0 0 30px rgba(127, 223, 154, .16);
  color: var(--gg-ink);
  animation: ggPop .28s ease;
}
@keyframes ggPop { from { transform: scale(.9); opacity: 0; } }
.gg-mark { display: flex; justify-content: center; margin-bottom: 2px; filter: drop-shadow(0 0 10px rgba(255, 207, 110, .35)); }
.gg-card h2 {
  margin: 4px 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fbf7e6;
  text-shadow: 0 0 14px rgba(255, 207, 110, .3);
}
.gg-card__blurb { margin: 0 0 12px; color: var(--gg-dim); font-size: 13.5px; line-height: 1.55; }
.gg-card__blurb b { color: var(--gg-gold); }
.gg-card__bestline {
  margin: -4px 0 12px;
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 207, 110, .1);
  border: 1px solid rgba(255, 207, 110, .32);
  color: var(--gg-gold);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
}
.gg-card__bestline[hidden] { display: none; }

/* Result stats: compact 2 x 2 block */
.gg-res {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 0 0 12px;
}
.gg-res[hidden] { display: none; }
.gg-res__item {
  padding: 6px 4px 7px;
  border-radius: 10px;
  background: rgba(3, 16, 14, .38);
  border: 1px solid rgba(132, 214, 152, .18);
}
.gg-res__item span {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gg-dim);
}
.gg-res__item b { font-size: 17px; color: var(--gg-gold); }
.gg-res__item:nth-child(2) b { color: var(--gg-lime); }

/* Medal chip */
.gg-medal {
  display: inline-block;
  margin: 0 0 12px;
  padding: 4px 16px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #3a2706;
  background: linear-gradient(140deg, #ffe6a6, #e3aa33);
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 2px 0 rgba(2, 12, 11, .35);
}
.gg-medal[hidden] { display: none; }
.gg-medal--silver { background: linear-gradient(140deg, #f2f8f7, #a9bfc2); color: #243234; }
.gg-medal--bronze { background: linear-gradient(140deg, #f0c69b, #b5743f); color: #3a2210; }

/* ---------- Level select grid ---------- */
.gg-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 4px;
}
.gg-lvl {
  appearance: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 9px;
  border-radius: 11px;
  border: 2px solid rgba(132, 214, 152, .26);
  background: rgba(7, 28, 24, .6);
  color: var(--gg-ink);
  transition: border-color .15s ease, background .15s ease, transform .06s ease;
}
.gg-lvl:hover:not(:disabled) { border-color: var(--gg-moss); background: rgba(18, 52, 44, .85); }
.gg-lvl:active:not(:disabled) { transform: translateY(1px); }
.gg-lvl:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(127, 223, 154, .4); }
.gg-lvl__no {
  flex: none;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(255, 207, 110, .14);
  border: 1px solid rgba(255, 207, 110, .34);
  color: var(--gg-gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}
.gg-lvl__txt { min-width: 0; display: flex; flex-direction: column; }
.gg-lvl__name {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gg-lvl__meta {
  font-size: 10px;
  font-weight: 600;
  color: var(--gg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gg-lvl__dot {
  flex: none;
  width: 7px; height: 7px;
  margin-left: auto;
  border-radius: 999px;
  background: rgba(132, 214, 152, .22);
}
.gg-lvl__dot--gold { background: #ffd259; box-shadow: 0 0 8px rgba(255, 210, 89, .8); }
.gg-lvl__dot--silver { background: #dfe9ea; box-shadow: 0 0 8px rgba(223, 233, 234, .7); }
.gg-lvl__dot--bronze { background: #d08b4f; box-shadow: 0 0 8px rgba(208, 139, 79, .7); }
.gg-lvl.is-locked { opacity: .4; cursor: not-allowed; }
.gg-lvl.is-next { border-color: rgba(255, 207, 110, .58); box-shadow: inset 0 0 0 1px rgba(255, 207, 110, .16); }
.gg-lvl.is-here .gg-lvl__no { background: rgba(255, 207, 110, .3); }

/* Card buttons: full-width stacked blocks */
.gg-card .c-btn { display: block; width: 100%; margin-top: 8px; font-size: 14px; }
.gg-card .c-btn[hidden] { display: none; }
.gg-card__hint {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--gg-dim);
}
.gg-card__hint kbd { font-size: 11px; }

/* ---------- Toast ---------- */
.gg-toast {
  position: absolute;
  left: 50%; top: 14px;
  z-index: 9;
  transform: translate(-50%, -6px);
  max-width: 92%;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(4, 20, 17, .9);
  border: 1px solid rgba(255, 207, 110, .42);
  box-shadow: 0 6px 20px rgba(2, 12, 11, .5);
  color: #fff3cf;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
}
.gg-toast[hidden] { display: none; }
.gg-toast.is-in { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Touch pad (coarse pointers / narrow screens) ---------- */
.gg-touch {
  display: none;
  position: absolute;
  left: 8px; right: 8px; bottom: 8px;
  z-index: 7;
  gap: 7px;
  align-items: flex-end;
  pointer-events: none;
}
.gg-tbtn {
  appearance: none;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  width: 48px; height: 48px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 999px;
  border: 2px solid rgba(207, 236, 200, .38);
  background: rgba(4, 22, 19, .5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: var(--gg-ink);
  font: 800 8.5px/1 system-ui, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: 0 2px 0 rgba(2, 12, 11, .45);
}
.gg-tbtn:active, .gg-tbtn.is-down { transform: translateY(1px) scale(.96); background: rgba(22, 64, 52, .8); }
.gg-tbtn--jump { margin-left: auto; border-color: rgba(127, 223, 154, .62); }
.gg-tbtn--hook { border-color: rgba(255, 207, 110, .62); color: #ffe7b2; }
.gg-tbtn svg { pointer-events: none; }
@media (hover: none), (pointer: coarse), (max-width: 820px) {
  .gg-touch { display: flex; }
}

/* ---------- Rules modal (overlay scrolls; panel never does) ---------- */
.c-modal { position: fixed; inset: 0; z-index: 50; display: flex; overflow: auto; padding: 14px; }
.c-modal[hidden] { display: none; }
.c-modal__backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 12, 11, .66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.c-modal__panel {
  position: relative;
  margin: auto;
  width: min(92vw, 500px);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 207, 110, .09), transparent 60%),
    linear-gradient(160deg, #1a4238, #081d1a);
  color: #e6f1e2;
  border-radius: 16px;
  border: 2px solid var(--gg-line);
  box-shadow: 0 8px 0 rgba(2, 12, 11, .45), 0 24px 60px rgba(2, 12, 11, .7), 0 0 34px rgba(127, 223, 154, .18);
}
.c-modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(132, 214, 152, .24);
}
.c-modal__head h2 {
  margin: 0; font-size: 18px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  color: #fff8e4; text-shadow: 0 0 10px rgba(255, 207, 110, .4);
}
.c-modal__x {
  appearance: none; border: 0; background: none;
  color: #e6f1e2; font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.c-modal__x:hover { color: var(--gg-gold); }
.c-modal__body { padding: 6px 20px 2px; font-size: 13.5px; line-height: 1.5; }
.c-modal__body h3 {
  margin: 12px 0 5px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--gg-moss);
}
.c-modal__body ul { margin: 0; padding-left: 20px; }
.c-modal__body li { margin: 2.5px 0; }
.c-modal__body b { color: var(--gg-gold); }
.c-modal__lead { margin: 10px 0; }
.c-modal__note {
  margin: 12px 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(127, 223, 154, .08);
  border: 1px solid rgba(127, 223, 154, .26);
  font-size: 13px;
  color: #d3e8cc;
}
.c-modal__foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }
.c-modal .c-btn { border-color: var(--gg-line); box-shadow: 0 3px 0 rgba(2, 12, 11, .6); }

/* ---------- Responsive ---------- */
@media (max-width: 760px), (max-height: 560px) {
  .c-bar { gap: 5px 12px; padding: 7px clamp(10px, 3vw, 18px); padding-top: max(7px, env(safe-area-inset-top)); }
  .c-bar__brand { gap: 8px; }
  .c-bar__title { font-size: 16px; }
  .c-bar__stats { gap: 4px 12px; margin-left: auto; }
  .stat { font-size: 12px; }
  .stat b { font-size: 13px; }
  .c-btn { padding: 8px 10px; font-size: 12px; }
  .c-btn--icon { padding: 7px 9px; }
  .c-bar__controls { gap: 6px; }
  .c-bar__controls .c-btn { padding: 9px 10px; white-space: nowrap; }
  .gg-board { width: min(96vw, calc((100vh - 156px) * 1.7778)); width: min(96vw, calc((100dvh - 156px) * 1.7778)); }
}
/* Narrow screens: controls get their own full-width row, and the overlay
   leaves the tiny 16:9 stage so the card is readable. */
@media (max-width: 700px) {
  .c-bar__controls { flex: 1 1 100%; flex-wrap: nowrap; }
  .c-bar__controls .c-btn { flex: 1 1 auto; min-width: 0; padding: 9px 6px; overflow: hidden; text-overflow: ellipsis; }
  .gg-overlay { position: fixed; z-index: 40; padding: 12px; }
  .gg-card { width: min(100%, 360px); padding: 18px 20px 16px; }
  .gg-card h2 { font-size: 21px; }
  .gg-caption { display: none; }
  .gg-levels { grid-template-columns: 1fr; }
  .gg-touch { left: 6px; right: 6px; bottom: 6px; }
  .gg-tbtn { width: 44px; height: 44px; }
}
/* Smallest phones: labels scale down instead of stacking. */
@media (max-width: 380px) {
  .c-bar { gap: 5px 8px; }
  .c-bar__title { font-size: 15px; }
  .stat { font-size: 11px; }
  .stat b { font-size: 12px; }
  .c-bar__controls { gap: 4px; }
  .c-bar__controls .c-btn { font-size: clamp(10px, 3.2vw, 12px); padding: 9px 4px; letter-spacing: .01em; }
  .gg-tbtn span { display: none; }
  .gg-tbtn { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .c-btn, .gg-card, .gg-toast { transition: none; animation: none; }
}
