/*
 * Gameplay screen.
 *
 * Landscape-first: the canvas fills the viewport and the HUD sits in the safe
 * area over it. In portrait the same layout still works - the gauges move to
 * the bottom edge and the pitch letterboxes.
 */

.play {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--ink-900);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.play__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.play__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 48%, rgba(5, 7, 12, 0.6) 100%);
}

/* The whole pitch is the button. It sits under the HUD so controls stay live. */
.play__surface {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
  border: 0;
  color: transparent;
  font-size: 0;
}

.play__surface:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: -4px;
}

/* -------------------------------------------------------------------- hud -- */

.play__hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-4);
  padding:
    calc(var(--safe-top) + var(--s-3))
    calc(var(--safe-right) + var(--s-4))
    0
    calc(var(--safe-left) + var(--s-4));
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.hud__left { display: grid; gap: 1px; }
.hud__right { display: grid; justify-items: end; gap: 4px; text-align: right; }

.hud__label {
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-600);
}

.hud__score {
  font-size: var(--fs-2xl);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.hud__chain {
  font-size: var(--fs-sm);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--slate-400);
  transition: color var(--dur) var(--ease);
}

.hud__chain.is-hot {
  color: var(--gold-400);
  text-shadow: 0 0 16px rgba(245, 182, 60, 0.6);
}

.hud__objective {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--bone-100);
  max-width: 44vw;
}

.hud__counter,
.hud__clock {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.hud__clock {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--bone-100);
}

.hud__clock.is-low { color: var(--alert-500); }

.hud__misses { display: flex; gap: 5px; }

.hud__miss-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--turf-500);
  box-shadow: 0 0 8px rgba(79, 191, 123, 0.5);
}

.hud__miss-dot.is-spent {
  background: var(--ink-400);
  box-shadow: none;
}

.hud--large .hud__objective,
.hud--large .hud__counter { font-size: var(--fs-sm); }

/* ----------------------------------------------------------------- pause -- */

.play__pause {
  position: absolute;
  z-index: 3;
  top: calc(var(--safe-top) + var(--s-3));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  background: rgba(11, 15, 24, 0.78);
  border: 1px solid var(--border-strong);
  color: var(--bone-100);
  backdrop-filter: blur(8px);
}

/* ---------------------------------------------------------------- gauges -- */

.play__gauges {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "aim power"
    "contact power";
  gap: var(--s-2) var(--s-3);
  padding:
    var(--s-5)
    calc(var(--safe-right) + var(--s-4))
    calc(var(--safe-bottom) + var(--s-3))
    calc(var(--safe-left) + var(--s-4));
  pointer-events: none;
  /* Separates the controls from the pitch without hiding the strike point. */
  background: linear-gradient(180deg, rgba(5, 7, 12, 0) 0%, rgba(5, 7, 12, 0.72) 42%, rgba(5, 7, 12, 0.92) 100%);
}

.play__gauges.is-left {
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "power aim"
    "power contact";
}

.gauge {
  display: grid;
  gap: 5px;
  opacity: 0.55;
  transition: opacity var(--dur) var(--ease);
}

.gauge.is-active { opacity: 1; }
.gauge.is-locked { opacity: 0.85; }

.gauge__title {
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--slate-400);
}

.gauge.is-active .gauge__title { color: var(--gold-400); }

.gauge__track {
  position: relative;
  display: block;
  border-radius: var(--r-pill);
  background: rgba(5, 7, 12, 0.72);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(6px);
  overflow: hidden;
}

.gauge--aim { grid-area: aim; }
.gauge--contact { grid-area: contact; }

.gauge--aim .gauge__track,
.gauge--contact .gauge__track,
.gauge--lab .gauge__track {
  height: 26px;
}

.gauge--power {
  grid-area: power;
  align-content: end;
  justify-items: center;
}

.gauge--power .gauge__track {
  width: 26px;
  height: 128px;
  border-radius: var(--r-md);
}

.gauge__mid {
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: rgba(247, 244, 236, 0.22);
}

.gauge__marker {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 5px;
  margin-left: -2.5px;
  border-radius: var(--r-pill);
  background: var(--bone-100);
  box-shadow: 0 0 14px rgba(247, 244, 236, 0.7);
}

.gauge--power .gauge__marker {
  top: auto;
  left: 3px;
  right: 3px;
  width: auto;
  height: 5px;
  margin-left: 0;
  margin-bottom: -2.5px;
}

.gauge__lock {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1.5px;
  background: var(--gold-500);
  box-shadow: 0 0 14px rgba(245, 182, 60, 0.85);
}

.gauge--power .gauge__lock {
  top: auto;
  left: 0;
  right: 0;
  width: auto;
  height: 3px;
  margin-left: 0;
  margin-bottom: -1.5px;
}

.gauge__zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(245, 182, 60, 0.22);
}

.gauge__zone-core {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(245, 182, 60, 0.5);
}

.gauge__scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--slate-500);
}

.gauge--lab {
  opacity: 1;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.gauge--lab.is-active { border-color: rgba(245, 182, 60, 0.4); }

/* --------------------------------------------------------------- banners -- */

.play__banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -6px);
  z-index: 2;
  padding: 9px 20px;
  border-radius: var(--r-pill);
  background: rgba(5, 7, 12, 0.82);
  border: 1px solid var(--border-strong);
  font-size: var(--fs-lg);
  font-weight: 850;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}

.play__banner.is-on {
  opacity: 1;
  transform: translate(-50%, -18px);
}

.play__banner[data-tone="perfect"],
.play__banner[data-tone="hit"] { color: var(--turf-500); border-color: rgba(79, 191, 123, 0.5); }
.play__banner[data-tone="bar"] { color: var(--gold-400); border-color: rgba(245, 182, 60, 0.6); }
.play__banner[data-tone="post"] { color: var(--bone-100); }
.play__banner[data-tone="chain"] { color: var(--gold-300); border-color: rgba(245, 182, 60, 0.6); }
.play__banner[data-tone="wave"] { color: var(--sky-500); border-color: rgba(127, 215, 240, 0.5); }
.play__banner[data-tone="miss"],
.play__banner[data-tone="scuffed"] { color: var(--alert-500); border-color: rgba(224, 72, 60, 0.45); }

.play__countdown {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 5.5rem;
  font-weight: 900;
  color: var(--gold-400);
  text-shadow: 0 0 40px rgba(245, 182, 60, 0.5);
  pointer-events: none;
  opacity: 0;
}

.play__countdown.is-pop {
  animation: countdown-pop 700ms var(--ease-out);
}

@keyframes countdown-pop {
  0% { opacity: 0; transform: scale(1.5); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9); }
}

.reduce-motion .play__countdown.is-pop {
  animation-duration: 300ms;
}

/* ------------------------------------------------------------- landscape -- */

@media (orientation: landscape) and (max-height: 520px) {
  .play__hud { padding-top: calc(var(--safe-top) + var(--s-2)); }
  .hud__score { font-size: var(--fs-xl); }
  .gauge--power .gauge__track { height: 96px; }
  .play__countdown { font-size: 4rem; }
}

@media (orientation: portrait) {
  .play__gauges {
    grid-template-columns: 1fr auto;
    padding-bottom: calc(var(--safe-bottom) + var(--s-5));
  }
}
