/* Selip - tokens by intent. Base styles are the phone layout. */

:root {
  --deep: #080b0d;
  --deep-2: #0e1418;
  --line: #1d2a31;
  --line-soft: #16212700;

  --chalk: #eef3f4;
  --chalk-dim: #9aabb3;
  --chalk-faint: #7d8f97;

  --ice: #6fe3ff;
  --ice-deep: #2aa8c8;
  --shard: #ff8a6b;
  --shard-deep: #c9543a;
  --gain: #8ef0a8;

  --sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', 'Instrument Sans', sans-serif;

  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 140ms;
  --mid: 300ms;

  --pad: clamp(14px, 4vw, 28px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--deep);
  color: var(--chalk);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.field {
  position: relative;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* --------------------------------------------------------------------- hud */

.hud {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad) 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--s4);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--mid) var(--ease);
}

.field[data-phase='playing'] .hud {
  opacity: 1;
}

.hud-block {
  display: grid;
  gap: 2px;
}

.hud-block-right {
  justify-items: end;
}

.hud-label {
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--chalk-faint);
}

.hud-value {
  font-family: var(--display);
  font-size: clamp(1.6rem, 6.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--chalk);
  transition: color var(--fast) var(--ease);
}

.hud-value.is-gain {
  color: var(--gain);
}

.hud-value-sm {
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  color: var(--chalk-dim);
  font-weight: 500;
}

.charge {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding-top: 3px;
  opacity: 0;
  transition: opacity var(--mid) var(--ease);
}

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

.charge-label {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ice);
}

.charge-track {
  width: clamp(70px, 26vw, 130px);
  height: 3px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.charge-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ice);
  border-radius: 99px;
  transition: width 180ms linear;
}

.slow-banner {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ice);
  opacity: 0.9;
  animation: slowPulse 2.4s var(--ease) infinite;
  pointer-events: none;
  white-space: nowrap;
}

.slow-banner[hidden] {
  display: none;
}

@keyframes slowPulse {
  50% {
    opacity: 0.45;
  }
}

/* ------------------------------------------------------------------ panels */

.panel {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 100% - (var(--pad) * 2));
  text-align: center;
  animation: panelIn 420ms var(--ease) both;
}

.panel[hidden] {
  display: none;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.kicker {
  margin: 0 0 var(--s3);
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--chalk-faint);
}

.title {
  margin: 0 0 var(--s4);
  font-family: var(--display);
  font-size: clamp(3rem, 18vw, 5.2rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.85;
  color: var(--chalk);
}

.pitch {
  margin: 0 auto var(--s6);
  max-width: 32ch;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--chalk-dim);
}

.final-label,
.stats dt {
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--chalk-faint);
}

.final-label {
  margin: 0 0 2px;
}

.final {
  margin: 0 0 var(--s2);
  font-family: var(--display);
  font-size: clamp(3.2rem, 19vw, 5.6rem);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
  color: var(--ice);
}

.verdict {
  margin: 0 0 var(--s5);
  font-size: 0.92rem;
  color: var(--chalk-dim);
  min-height: 1.4em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 0 var(--s5);
  padding: 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.stats > div {
  background: var(--deep);
  padding: var(--s3) var(--s2);
  display: grid;
  gap: 3px;
}

.stats dd {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--chalk);
}

.record {
  margin: 0 0 var(--s4);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gain);
}

.record[hidden] {
  display: none;
}

.best {
  margin: var(--s5) 0 0;
  font-size: 12px;
  color: var(--chalk-faint);
}

.best[hidden] {
  display: none;
}

.best strong {
  color: var(--chalk);
  font-weight: 500;
}

.hint {
  margin: var(--s5) 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--chalk-faint);
}

.actions {
  display: flex;
  justify-content: center;
  gap: var(--s3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 50px;
  padding: 0 var(--s6);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--fast) var(--ease), gap var(--mid) var(--ease), transform var(--fast) var(--ease);
}

.btn-primary {
  background: var(--ice);
  color: #04202a;
}

.btn-primary:hover {
  background: #96ecff;
  gap: var(--s3);
}

.btn-primary:active {
  transform: translateY(1px);
}

:where(button):focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

/* -------------------------------------------------------------- responsive */

@media (max-height: 600px) {
  .title {
    font-size: clamp(2.4rem, 12vw, 3.4rem);
  }

  .pitch {
    margin-bottom: var(--s5);
    font-size: 0.88rem;
  }

  .hint {
    margin-top: var(--s4);
  }

  .final {
    font-size: clamp(2.6rem, 13vw, 3.8rem);
  }
}

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