/* =========================================================
   Giggles & Grooves | Note Catcher
   Full-page, responsive. Canvas draws the scene; this file
   styles the HUD, menus and placeholder buttons.
   ========================================================= */

:root {
  --gg-font: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --gg-navy: #0b0f5c;
  --gg-ink: #10145a;
  --gg-yellow: #ffd52e;
  --gg-gap: clamp(6px, 1.6vmin, 18px);
  --gg-safe-t: env(safe-area-inset-top, 0px);
  --gg-safe-r: env(safe-area-inset-right, 0px);
  --gg-safe-b: env(safe-area-inset-bottom, 0px);
  --gg-safe-l: env(safe-area-inset-left, 0px);
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--gg-navy);
  overflow: hidden;
  overscroll-behavior: none;
}

.gg {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--gg-font);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--gg-navy);
}

#gg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.gg.is-playing #gg-canvas { cursor: pointer; }

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

.gg-hud {
  position: absolute;
  top: calc(var(--gg-safe-t) + var(--gg-gap));
  left: calc(var(--gg-safe-l) + var(--gg-gap));
  right: calc(var(--gg-safe-r) + var(--gg-gap));
  display: flex;
  align-items: center;
  gap: var(--gg-gap);
  pointer-events: none;     /* taps fall through to the canvas... */
  z-index: 5;
}

.gg-hud .gg-box { opacity: 0; transform: translateY(-120%); transition: opacity .3s, transform .45s cubic-bezier(.3,1.6,.5,1); }
.gg.is-playing .gg-hud .gg-box,
.gg.is-paused  .gg-hud .gg-box { opacity: 1; transform: none; }
.gg-hud .gg-box--score { margin-left: auto; }

.gg-hud__buttons {
  display: flex;
  gap: var(--gg-gap);
  margin-left: auto;
  pointer-events: auto;     /* ...except on the buttons */
}
.gg-hud .gg-box--score + .gg-hud__buttons { margin-left: 0; }

.gg .gg-round--pause { display: none; }
.gg.is-playing .gg-round--pause { display: grid; }

/* Score / time boxes (real graphics) */
.gg-box {
  position: relative;
  width: clamp(130px, 22vw, 300px);
  flex: 0 0 auto;
}
.gg-box__img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.45));
}

/* Area inside each box where the number sprites sit */
.gg-digits {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}
.gg-box--time  .gg-digits { left: 36%; right: 7%;  top: 41%; bottom: 14%; }
.gg-box--score .gg-digits { left: 30%; right: 8%;  top: 40%; bottom: 12%; }

.gg-digits img {
  height: calc(100% * var(--fit, 1));
  width: auto;
  margin-inline: -3.5cqh;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.gg-digits img.is-colon { margin-inline: -18cqh; }

.gg-box.is-urgent { animation: gg-throb .5s ease-in-out infinite alternate; }
@keyframes gg-throb { to { transform: scale(1.07); } }
.gg-digits.is-bump { animation: gg-bump .3s ease-out; }
@keyframes gg-bump { 40% { transform: scale(1.25); } }

/* ---------- Round buttons (PLACEHOLDERS for pause / mute art) ---------- */

.gg-round {
  width: clamp(44px, 7vmin, 78px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: clamp(3px, .6vmin, 5px) solid #fff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 8px 18px rgba(0,0,0,.4), inset 0 -6px 0 rgba(0,0,0,.18), inset 0 6px 0 rgba(255,255,255,.35);
  transition: transform .1s;
}
.gg-round:active { transform: translateY(3px) scale(.96); }
.gg-round svg { width: 56%; height: 56%; fill: #fff; stroke: #fff; }
.gg-round--pause { background: radial-gradient(circle at 35% 30%, #ff6b7a, #e0102e 70%); }
.gg-round--mute  { background: radial-gradient(circle at 35% 30%, #6fc4ff, #1265e6 70%); }
.gg-round--mute .icon-off { display: none; }
.gg-round--mute[aria-pressed="true"] .icon-on  { display: none; }
.gg-round--mute[aria-pressed="true"] .icon-off { display: block; }

/* ---------------- Screens ---------------- */

.gg-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--gg-safe-t) + var(--gg-gap)) calc(var(--gg-safe-r) + var(--gg-gap)) calc(var(--gg-safe-b) + var(--gg-gap)) calc(var(--gg-safe-l) + var(--gg-gap));
  background: radial-gradient(ellipse at center, rgba(10,12,70,.35), rgba(5,6,40,.78));
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility 0s .3s;
  z-index: 10;
  overflow-y: auto;
}
.gg-screen--menu { background: radial-gradient(ellipse at center, rgba(10,12,70,.1), rgba(5,6,40,.55)); }

.gg[data-state="menu"]   .gg-screen--menu,
.gg[data-state="paused"] .gg-screen--pause,
.gg[data-state="over"]   .gg-screen--over {
  opacity: 1;
  visibility: visible;
  transition: opacity .3s;
}

.gg-panel {
  width: min(92vw, 560px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2.2vmin, 22px);
  text-align: center;
}
.gg[data-state="menu"] .gg-screen--menu .gg-panel,
.gg[data-state="paused"] .gg-screen--pause .gg-panel,
.gg[data-state="over"] .gg-screen--over .gg-panel { animation: gg-pop .5s cubic-bezier(.3,1.5,.5,1) both; }
@keyframes gg-pop { from { transform: scale(.7); opacity: 0; } }

.gg-logo {
  width: min(100%, 560px);
  max-height: 34vh;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.55));
  animation: gg-float 2.6s ease-in-out infinite;
}
.gg-logo--small { width: min(70%, 340px); max-height: 20vh; }
@keyframes gg-float { 50% { transform: translateY(-6px) rotate(-1deg); } }

.gg-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(28px, 7vmin, 56px);
  line-height: 1;
  color: var(--gg-yellow);
  -webkit-text-stroke: clamp(1.5px, .35vmin, 3px) var(--gg-ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--gg-ink), 0 10px 20px rgba(0,0,0,.5);
  letter-spacing: .02em;
}
.gg-title--big { font-size: clamp(36px, 10vmin, 84px); }

.gg-menu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(8px, 1.8vmin, 16px);
  width: min(100%, 360px);
}

/* Chunky cartoon buttons (PLACEHOLDERS until menu art arrives) */
.gg-btn {
  --c1: #4fb4ff; --c2: #1559e0; --c3: #0a2f8a;
  display: block;
  font: 700 clamp(19px, 4.4vmin, 32px)/1 var(--gg-font);
  color: #fff;
  text-decoration: none;
  letter-spacing: .02em;
  padding: .55em 1.2em .6em;
  border-radius: 999px;
  border: clamp(3px, .55vmin, 5px) solid #fff;
  background: linear-gradient(to bottom, var(--c1), var(--c2));
  box-shadow: 0 6px 0 var(--c3), 0 12px 22px rgba(0,0,0,.45), inset 0 3px 0 rgba(255,255,255,.45);
  text-shadow: 0 2px 0 var(--c3);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.gg-btn:hover { filter: brightness(1.08); transform: translateY(-2px); }
.gg-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--c3), 0 4px 10px rgba(0,0,0,.4), inset 0 3px 0 rgba(255,255,255,.45); }
.gg-btn:focus-visible, .gg-round:focus-visible { outline: 4px solid var(--gg-yellow); outline-offset: 4px; }

.gg-btn--play   { --c1: #ffe75a; --c2: #ffb800; --c3: #b86e00; color: #6a2c00; text-shadow: 0 2px 0 rgba(255,255,255,.5); font-size: clamp(24px, 5.6vmin, 42px); }
.gg-btn--orange { --c1: #ffb35a; --c2: #ff6a00; --c3: #a83a00; }
.gg-btn--blue   { --c1: #5cc2ff; --c2: #1867e8; --c3: #0b3591; }
.gg-btn--purple { --c1: #c27bff; --c2: #7a2ee0; --c3: #45138f; }

.gg-hint {
  margin: 0;
  font-weight: 500;
  font-size: clamp(14px, 2.6vmin, 20px);
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}

/* End-screen results */
.gg-results {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gg-gap) calc(var(--gg-gap) * 2);
}
.gg-result { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gg-result .gg-box { width: clamp(170px, 26vw, 300px); }
.gg-result__label {
  font-weight: 700;
  font-size: clamp(13px, 2.3vmin, 18px);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}
.gg-screen--over .gg-panel { width: min(94vw, 720px); }

/* Short landscape screens (phones turned sideways): go wide, not tall */
@media (orientation: landscape) and (max-height: 520px) {
  .gg-logo { max-height: 30vh; }
  .gg-logo--small { max-height: 16vh; }
  .gg-menu { flex-direction: row; flex-wrap: wrap; justify-content: center; width: min(100%, 720px); }
  .gg-btn { font-size: clamp(15px, 4.6vh, 22px); padding: .5em 1em .55em; }
  .gg-btn--play { font-size: clamp(17px, 5.4vh, 26px); }
  .gg-panel { gap: 2.4vh; width: min(94vw, 760px); }
  .gg-result .gg-box { width: clamp(150px, 22vw, 240px); }
  .gg-title--big { font-size: clamp(28px, 10vh, 48px); }
  .gg-hint { display: none; }
}

/* Narrow phones in portrait: tighten the HUD so both boxes + buttons fit */
@media (max-width: 520px) and (orientation: portrait) {
  .gg-hud .gg-box { width: 34vw; }
  .gg-round { width: 10.5vw; }
}

/* ---------------- Loading ---------------- */
.gg-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--gg-navy);
  z-index: 20;
  transition: opacity .4s, visibility 0s .4s;
  font-weight: 700;
  font-size: clamp(18px, 3.5vmin, 26px);
}
.gg-loading p { margin: 0; }
.gg:not(.is-loading) .gg-loading { opacity: 0; visibility: hidden; }
.gg-loading__bar { width: min(60vw, 320px); height: 14px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; border: 2px solid #fff; }
.gg-loading__bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd52e, #ff7a00); transition: width .2s; }

@media (prefers-reduced-motion: reduce) {
  .gg-logo, .gg-box.is-urgent { animation: none; }
}
