* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

/* Clears native button chrome (a white/gray rounded control) that some
   browsers, notably Safari/WebKit, render underneath custom styling
   unless appearance is explicitly reset — was showing as a white box
   peeking out from behind the pill-shaped buttons. */
button {
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #1b2733;
  font-family: 'Patrick Hand SC', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: absolute;
  top: 0;
  left: 0;
  width: 400px;
  height: 750px;
  transform-origin: top left;
  overflow: hidden;
  background: #7ec8e3;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
  touch-action: none;
}

canvas#scene {
  position: absolute;
  top: 0; left: 0;
  width: 400px;
  height: 750px;
  z-index: 1;
}

canvas#swipeFeedback {
  position: absolute;
  top: 0; left: 0;
  width: 400px;
  height: 750px;
  z-index: 35;
  pointer-events: none;
}

canvas#confettiCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 400px;
  height: 750px;
  z-index: 50;
  pointer-events: none;
}

/* ---------------- Score bug ---------------- */
/* Pause button sits to the score bug's left, per the user's reference —
   reuses .icon-btn's shared round-button look but overrides its default
   corner position to sit inline with the (now shifted-over) score bug. */
#pauseBtn {
  top: 14px;
  left: 10px;
  width: 56px;
  height: 56px;
  z-index: 21;
}

#scoreBug {
  position: absolute;
  top: 10px; left: 76px; right: 10px;
  z-index: 20;
  display: flex;
  align-items: stretch;
  height: 64px;
}
.score-box {
  flex: none;
  width: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid #000;
  border-radius: 10px;
  z-index: 2;
}
.cpu-box { background: #7052F3; margin-right: -8px; }
.you-box { background: #F35252; margin-left: -8px; }
.score-value {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}
.score-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 4px solid #000;
  border-radius: 10px;
  margin: 7px 0;
  z-index: 1;
}
.score-static-label {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: #222;
  letter-spacing: 1px;
}
.score-divider {
  width: 4px;
  align-self: stretch;
  margin: 9px 0;
  background: #000;
}

/* ---------------- Overlay screens ---------------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(10, 14, 20, 0.45);
  text-align: center;
  padding: 20px;
}
.overlay-screen.hidden { display: none; }

/* Pause screen: starts below the top bar (not inset:0 like the shared
   .overlay-screen) so the score bug and pause button stay fully bright
   on top, per the user's reference, instead of getting dimmed along with
   everything else. z-index is above every other in-match control panel
   so it fully blocks interaction with whatever was on screen underneath. */
#pauseScreen {
  position: absolute;
  top: 84px; left: 0; right: 0; bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(10, 14, 20, 0.55);
}
#pauseScreen.hidden { display: none; }

/* Tutorial: Power Swipe popup. Dims the whole screen (unlike the pause
   screen, this includes the top bar — no score bug/pause button exist
   during the tutorial to protect), blocking interaction with the real
   swipe controls until the player taps CONTINUE. z-index above every
   real control panel but still below the global confetti layer, which
   never fires during a no-stakes tutorial anyway. */
#tutorialSwipePopup,
#tutorialTimingPopup,
#tutorialCatchPopup,
#tutorialFifaPopup,
#tutorialFinishScreen {
  position: absolute;
  inset: 0;
  z-index: 65;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px;
  background: rgba(10, 14, 20, 0.45);
}
#tutorialSwipePopup.hidden,
#tutorialTimingPopup.hidden,
#tutorialCatchPopup.hidden,
#tutorialFifaPopup.hidden,
#tutorialFinishScreen.hidden { display: none; }

.tutorial-popup-title {
  margin: 0;
  font-size: 44px;
  font-weight: normal;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.tutorial-popup-card {
  width: 320px;
  max-width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 25px;
  padding: 26px 20px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.tutorial-hand-stage {
  position: relative;
  width: 100%;
  height: 210px;
}
.tutorial-hand-stage img {
  position: absolute;
  pointer-events: none;
}
.tutorial-hand-ring {
  top: 0;
  left: 50%;
  width: 92px;
  transform: translateX(-50%);
}
.tutorial-hand-diamond {
  bottom: 14px;
  left: 50%;
  width: 38px;
  transform: translateX(-50%);
}
.tutorial-hand {
  bottom: 30px;
  left: 52%;
  width: 84px;
  transform: translateX(-50%);
  animation: tutorialHandSwipe 1400ms infinite;
}
/* Same looping shape as the reference recording (ease up-and-right
   toward the ring, fade out, snap back, fade in) but slowed down from
   the measured ~900ms to a more readable 1400ms per the user's request. */
@keyframes tutorialHandSwipe {
  0%   { transform: translate(-50%, 0); opacity: 1; animation-timing-function: ease-out; }
  78%  { transform: translate(calc(-50% + 34px), -128px); opacity: 1; }
  83%  { transform: translate(calc(-50% + 34px), -128px); opacity: 0; }
  86%  { transform: translate(-50%, 0); opacity: 0; }
  92%  { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

.tutorial-popup-text {
  margin: 0;
  color: #fff;
  font-size: 18px;
  text-align: center;
  line-height: 1.35;
}

/* Accuracy Timer popup: a tapping hand (with a ripple at the fingertip)
   over a mini copy of the timing bar, per the user's Figma + reference
   recording — hand presses down with a ripple, lifts up-and-right, loops. */
.tutorial-tap-stage {
  position: relative;
  width: 100px;
  height: 100px;
}
.tutorial-tap-hand {
  position: absolute;
  top: 0;
  left: 0;
  width: 100px;
  pointer-events: none;
  animation: tutorialHandTap 1400ms infinite;
}
.tutorial-ripple {
  position: absolute;
  top: 24px;
  left: 12px;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  border: 3px solid #fff;
  border-radius: 50%;
  opacity: 0;
  animation: tutorialRipple 1400ms infinite;
}
.tutorial-ripple::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 3px solid #fff;
  border-radius: 50%;
}
@keyframes tutorialHandTap {
  0%   { transform: translate(18px, -16px); animation-timing-function: ease-in; }
  25%  { transform: translate(0, 0); }
  60%  { transform: translate(0, 0); animation-timing-function: ease-out; }
  80%  { transform: translate(18px, -16px); }
  100% { transform: translate(18px, -16px); }
}
@keyframes tutorialRipple {
  0%, 22% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  30%     { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
  58%     { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  66%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

/* Catch popup: same tapping hand but slower (~2.1s a tap, per the
   reference), over "big black ring -> small white circle" showing the
   ring closing down. */
.tutorial-tap-stage.slow .tutorial-tap-hand,
.tutorial-tap-stage.slow .tutorial-ripple {
  animation-duration: 2100ms;
}
.tutorial-catch-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}
.tutorial-catch-demo img {
  display: block;
  flex: none;
  pointer-events: none;
}
.tutorial-catch-big { width: 107px; height: 107px; }
.tutorial-catch-arrow { width: 40px; height: 26px; }
.tutorial-catch-small { width: 64px; height: 64px; }

.tutorial-bar {
  position: relative;
  width: 100%;
  height: 58px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 25px;
}
.tutorial-bar-target,
.tutorial-bar-mover {
  position: absolute;
  top: 4px;
  width: 9px;
  height: 50px;
  border-radius: 10px;
}
.tutorial-bar-target { left: 48%; background: #898989; }
.tutorial-bar-mover { left: 80%; background: #fff; }

/* Title screen shows the flat sky/grass canvas cleanly underneath (logo +
   button only) instead of a darkened scrim over the game scene. */
#titleScreen { background: transparent; }

/* .big-btn has no fixed width by default (sized to its own text via
   padding), so PLAY and TUTORIAL render at different natural widths —
   swapped here so PLAY is the wider one and TUTORIAL the narrower one. */
#playBtn,
#tutorialFinishBtn { width: 171px; }
#tutorialBtn,
#tutorialRestartBtn {
  width: 127px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* .big-btn's shared 12px/20px top/bottom padding was tuned for its
     22px font — asymmetric enough to read off-center at this button's
     smaller 15px text. Same total (32px) so the height matches PLAY,
     just split evenly; flex centering on top makes it exact regardless
     of font-metric quirks. */
  padding-top: 16px;
  padding-bottom: 16px;
}

.game-title {
  font-size: 54px;
  font-weight: 900;
  color: #ffd75e;
  margin: 0;
  text-shadow: 0 4px 0 #b5470f, 0 6px 12px rgba(0,0,0,0.4);
  letter-spacing: 2px;
}
.game-subtitle {
  font-size: 18px;
  color: #fff;
  margin: 0;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.title-logo {
  width: 210px;
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.4));
}

.big-btn {
  font-family: inherit;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #4a2600;
  background-image: url('../assets/btn_pill.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: none;
  border-radius: 40px;
  padding: 12px 42px 20px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.06s ease;
  filter: drop-shadow(0 6px 6px rgba(0,0,0,0.3));
}
.big-btn:active {
  transform: translateY(4px);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
}

.small-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 20px;
  padding: 8px 18px;
  cursor: pointer;
}
.small-btn:active { transform: translateY(2px); }

/* Round icon button (e.g. the back arrow), pinned to a screen corner */
.icon-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 52px;
  height: 52px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.4));
  transition: transform 0.06s ease;
}
.icon-btn img { width: 100%; height: 100%; pointer-events: none; }
.icon-btn:active { transform: translateY(2px); }

/* ---------------- Skin select screen ---------------- */
/* This screen isn't the usual centered-flex overlay: the card panel needs
   to run edge-to-edge and flush to the bottom, so it's laid out manually
   instead of relying on .overlay-screen's flex centering. */
#skinScreen {
  display: block;
  padding: 0;
}
.skin-title {
  color: #fff;
  font-size: 22px;
  margin: 32px 0 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Live preview of the currently selected character, above the grid,
   standing on a small pedestal platform. Anchored by its BOTTOM edge
   (not stacked in normal flow) so the platform + name stay put at a
   constant spot when switching characters — only the character art
   above grows/shrinks upward with each skin's own image height,
   matching #skinGridPanel's fixed top (318px): 750 - 318 + 25 = 457. */
#skinPedestal {
  position: absolute;
  left: 50%;
  bottom: 457px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  gap: 2px;
}
#skinPedestalImg {
  position: relative;
  z-index: 2;
  height: 110px;
  width: auto;
  max-width: 130px;
  margin-bottom: -16px;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.3));
}
#skinPedestalBase {
  width: 128px;
  height: auto;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.45));
}
#skinPedestalName {
  color: #ffd75e;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 3px rgba(0,0,0,0.5);
}

/* Card grid panel: full screen width, flush to the bottom edge (rounded
   top corners only), scrollable once it grows past what's visible. */
#skinGridPanel {
  position: absolute;
  top: 318px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.82);
  border-radius: 28px 28px 0 0;
  padding: 18px 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#skinGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 360px;
  margin: 0 auto;
}
.skin-card {
  background: transparent;
  border: 4px solid rgba(255, 223, 14, 0.3);
  border-radius: 18px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.skin-card img { width: 92px; height: auto; pointer-events: none; }
.skin-card .skin-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  text-align: center;
}
.skin-card.selected { border-color: #FFDF0E; }

/* ---------------- Aim screen ---------------- */
#aimScreen {
  justify-content: flex-end;
  padding-bottom: 40px;
  background: transparent;
  pointer-events: none;
}
#aimScreen.hidden { display: none; }
#aimScreen .hint-banner { pointer-events: none; }
#aimScreen #throwBtn { pointer-events: auto; }

/* Restyled with the Figma instruction-banner art — one shared class since
   every step reuses the exact same background shape, just with its own
   text. Applied on top of .hint-banner (which still carries the shared
   base positioning/margins) for whichever steps have their own art so
   far; others keep .hint-banner's plain look until theirs arrives. */
.hint-banner.instruction-banner {
  background: transparent;
  background-image: url('../assets/instruction_banner.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  width: 366px;
  max-width: 94%;
  height: 101px;
  box-sizing: border-box;
  padding: 8px 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 35px;
  font-weight: 400;
  line-height: 1.15;
}

/* Longer copy than the others — at the shared 35px it wraps to 3 lines,
   which doesn't fit the fixed 101px box height. Box stays the same size
   (per the user) so the text shrinks instead. */
#readyHint {
  font-size: 24px;
  line-height: 1.1;
}

.hint-banner {
  background: rgba(10,14,20,0.72);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 14px;
  max-width: 320px;
  line-height: 1.35;
}

#aimTarget {
  position: absolute;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  margin-top: -23px;
  z-index: 15;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
  cursor: grab;
}
#aimTarget img {
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#aimTarget.hidden { display: none; }

#turnToast {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(10,14,20,0.8);
  color: #ffd75e;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 8px 20px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
#turnToast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
#turnToast.hidden { display: none; }

/* ---------------- Control panels (swipe / timing / fifa) ---------------- */
.control-panel {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 30px;
  background: linear-gradient(180deg, rgba(10,14,20,0), rgba(10,14,20,0.85) 30%);
}
.control-panel.hidden { display: none; }

/* Backdrop card behind the swipe control panel, matched exactly to the
   user's Figma reference (node 254:392 — the box plus the ring and
   diamond already used in-game, laid out together at fixed offsets).
   Rather than resizing the box to fit some other reference point, this
   solves for the one uniform scale + position that keeps the box's own
   ring/diamond spacing from that composite exact while leaving
   Game.SWIPE.ring/start (the actual swipe-drag anchors) untouched —
   only their drawn SIZE grows slightly to match, which is purely
   cosmetic (scoring is distance-based, not tied to how big they look). */
#swipeBox {
  position: absolute;
  left: 50%;
  top: 328.28px;
  transform: translateX(-50%);
  width: 215.58px;
  height: 316.63px;
  z-index: 34;
  pointer-events: none;
}
#swipeBox.hidden { display: none; }

#swipeHandle {
  position: absolute;
  width: 36.75px;
  height: 36.75px;
  margin-left: -18.38px;
  margin-top: -18.38px;
  z-index: 36;
  pointer-events: auto;
  touch-action: none;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.5));
  cursor: grab;
}
#swipeHandle img {
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#swipeHandle.hidden { display: none; }

/* Shared by the throw-timing meter and both Fifa stages (kick + catch) so
   they're visually identical, per design: dark pill track, static gray
   target line, white moving line. */
.meter-track {
  position: relative;
  width: 300px;
  height: 70px;
  background: rgba(0,0,0,0.75);
  border-radius: 35px;
}
.meter-target {
  position: absolute;
  top: 6px; bottom: 6px;
  width: 10px;
  background: #898989;
  border-radius: 5px;
  transform: translateX(-50%);
}
.meter-mover {
  position: absolute;
  top: 6px; bottom: 6px;
  width: 10px;
  background: #ffffff;
  border-radius: 5px;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
}
#fifaTrack.meter-track { width: 260px; }

/* ---------------- Quality banner ---------------- */
.quality-banner {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  z-index: 40;
  width: 240px;
  height: 166px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
  padding: 10px 20px;
  border-radius: 16px;
  color: #000;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.25s ease;
}
.quality-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.quality-banner.hidden { display: none; }
.quality-perfect { background: linear-gradient(180deg,#ffe27a,#ff9c1a); }
.quality-great {
  background-image: url('../assets/banner_green.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.quality-good    { background: linear-gradient(180deg,#8fd3ff,#2f9be8); }
.quality-ok      { background: linear-gradient(180deg,#d9d9d9,#9a9a9a); }
.quality-bad {
  background-image: url('../assets/banner_red.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.quality-slightly {
  background-image: url('../assets/banner_yellow.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* ---------------- Catch button (defense) ---------------- */
#catchBtn {
  position: absolute;
  width: 84px;
  height: 84px;
  margin-left: -42px;
  margin-top: -42px;
  border-radius: 50%;
  z-index: 36;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
#catchIcon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.5));
  pointer-events: none;
}

/* ---------------- Popup / confetti ---------------- */
#popupLayer {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#popupLayer.hidden { display: none; }
#popupCard {
  background: rgba(255,255,255,0.96);
  border-radius: 26px;
  padding: 22px 46px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  transform: scale(0.5);
  opacity: 0;
  animation: popIn 0.45s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes popIn {
  to { transform: scale(1); opacity: 1; }
}
#popupText {
  font-size: 52px;
  font-weight: 900;
  color: #2fb84f;
  line-height: 1;
}
#popupSub {
  font-size: 16px;
  font-weight: 800;
  color: #444;
  letter-spacing: 1px;
  margin-top: 4px;
}

.hidden { display: none !important; }
