:root {
  --teal: #27bfbd;
  --gold: #efac00;
  --bg: #f6f8f8;
  --text-primary: #57636c;
  --text-secondary: rgba(20, 32, 32, 0.48);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: Outfit, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  cursor: none;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(
      ellipse 70% 50% at 50% 28%,
      rgba(39, 191, 189, 0.12),
      transparent 60%
    ),
    radial-gradient(
      ellipse 50% 40% at 70% 75%,
      rgba(239, 172, 0, 0.09),
      transparent 55%
    ),
    var(--bg);
}

.screen {
  width: 100%;
  height: 100%;
  padding: 7vh 8vw 6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.logo {
  width: min(32vw, 580px);
  height: auto;
  display: block;
}

.stats {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  width: 100%;
  max-width: 1400px;
}

.stat-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3.2vh 2vw;
}

.stat-values {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 1.2rem;
}

.stat-value {
  flex: 1;
  font-weight: 700;
  font-size: clamp(3.2rem, 6.5vw, 7.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-value + .stat-value {
  border-left: 1px solid transparent;
  border-image: linear-gradient(
      to bottom,
      transparent,
      var(--teal) 20%,
      var(--gold) 80%,
      transparent
    )
    1;
}

.stat-value .unit {
  font-size: 0.38em;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-left: 0.18em;
  vertical-align: 0.18em;
}

.stat-value--count {
  color: var(--teal);
}

.stat-value--power {
  color: var(--gold);
}

.stat-label {
  font-weight: 300;
  font-size: clamp(0.95rem, 1.4vw, 1.55rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.dash-footer {
  display: flex;
  justify-content: center;
}

.footer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.85rem 0.6rem;
  border-radius: 1.1rem;
  background: rgba(20, 32, 32, 0.06);
  box-shadow: inset 0 0 0 1px rgba(26, 36, 36, 0.05);
}

.footer-hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  font-weight: 300;
  font-size: clamp(0.8rem, 1.05vw, 1.1rem);
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.footer-hint {
  display: flex;
  align-items: center;
  padding: 0 1.15rem;
  white-space: nowrap;
}

.footer-hint + .footer-hint {
  border-left: 1px solid rgba(26, 36, 36, 0.1);
}

.footer-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.7em;
  margin-right: 0.55em;
  border-radius: 0.38em;
  background: #fff;
  color: var(--teal);
  font-weight: 500;
  font-size: 0.95em;
  letter-spacing: 0;
  box-shadow:
    0 1px 2px rgba(16, 26, 26, 0.08),
    0 0 0 1px rgba(26, 36, 36, 0.06);
}

.start-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

html[data-view="dashboard"] .start-prompt:not(.is-done):not(.is-covered) {
  display: flex;
}

.start-prompt-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 1.8rem 2.2rem 1.7rem;
  border-radius: 1.3rem;
  background: rgba(22, 28, 28, 0.82);
  color: #fff;
  box-shadow:
    0 18px 50px rgba(16, 26, 26, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  animation: start-prompt-blink 1.35s ease-in-out infinite;
}

.start-prompt-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 0.7rem;
  background: #fff;
  color: var(--teal);
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: 0;
  box-shadow: 0 8px 20px rgba(16, 26, 26, 0.18);
}

.start-prompt-text {
  font-weight: 500;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  letter-spacing: 0.04em;
  text-align: center;
}

@keyframes start-prompt-blink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.38;
    transform: scale(0.985);
  }
}

.key-hud {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.key-hud.is-open {
  display: flex !important;
}

.key-hud-value {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 5.4rem;
  height: 5.4rem;
  padding: 0 1.1rem;
  border-radius: 1.2rem;
  background: rgba(22, 28, 28, 0.78);
  color: #fff;
  font-weight: 700;
  font-size: clamp(2.2rem, 4.2vw, 3.1rem);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  box-shadow:
    0 18px 50px rgba(16, 26, 26, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  animation: key-hud-in 0.16s ease;
}

.key-hud.is-leaving .key-hud-value {
  animation: key-hud-out 0.22s ease forwards;
}

@keyframes key-hud-in {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes key-hud-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

.status-pill {
  display: none;
  position: fixed;
  top: max(1.6vh, 12px);
  z-index: 60;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: rgba(246, 248, 248, 0.92);
  box-shadow:
    0 8px 24px rgba(16, 26, 26, 0.08),
    inset 0 0 0 1px rgba(26, 36, 36, 0.06);
  font-weight: 500;
  font-size: clamp(0.75rem, 1vw, 0.95rem);
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.update-status {
  left: max(1.6vw, 12px);
}

.sound-status {
  right: max(1.6vw, 12px);
  padding-left: 0.7rem;
}

html[data-view="dashboard"] .status-pill {
  display: flex;
}

.sound-status.is-on {
  color: var(--teal);
}

.sound-status-icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
}

.sound-status.is-on .sound-status-icon--off,
.sound-status:not(.is-on) .sound-status-icon--on {
  display: none;
}

#dashboard {
  display: none;
}

html[data-view="dashboard"] #gate {
  display: none !important;
}

html[data-view="dashboard"] #dashboard {
  display: flex;
}

.screen.gate {
  justify-content: space-between;
}

.screen.gate::after {
  content: "";
  min-height: 7.2vh;
}

.logo--gate {
  width: min(22vw, 380px);
}

.gate-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gate-title {
  font-weight: 500;
  font-size: clamp(1.4rem, 2.2vw, 2.4rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.gate-hint {
  margin-top: 0.7rem;
  font-weight: 300;
  font-size: clamp(0.95rem, 1.3vw, 1.35rem);
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.pin {
  display: flex;
  gap: 1.4vw;
  margin: 3.2vh 0 3.8vh;
}

.pin-dot {
  width: clamp(1.4rem, 2.1vw, 2.2rem);
  height: clamp(1.4rem, 2.1vw, 2.2rem);
  border-radius: 50%;
  border: 2px solid rgba(26, 36, 36, 0.18);
  background: transparent;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.pin-dot.is-filled {
  background: var(--teal);
  border-color: var(--teal);
}

.pin.is-wrong .pin-dot {
  border-color: var(--gold);
  animation: pin-shake 0.4s ease;
}

@keyframes pin-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-0.5vw);
  }
  75% {
    transform: translateX(0.5vw);
  }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1vh 1.1vw;
  width: min(28vw, 420px);
}

.key {
  appearance: none;
  border: 1px solid rgba(26, 36, 36, 0.12);
  background: rgba(255, 255, 255, 0.55);
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 500;
  font-size: clamp(1.4rem, 2.4vw, 2.5rem);
  height: clamp(3.4rem, 8vh, 5.4rem);
  border-radius: 0.7rem;
  cursor: none;
  outline: none;
}

.key--action {
  font-size: clamp(1.1rem, 1.6vw, 1.6rem);
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.key:focus {
  background: #fff;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(39, 191, 189, 0.28);
  color: var(--teal);
}

@media (max-aspect-ratio: 4/5) {
  .stat-row {
    padding: 4.5vh 0;
  }

  .stat-values {
    flex-direction: column;
    gap: 3.2vh;
  }

  .stat-value + .stat-value {
    border-left: 0;
    border-image: none;
    border-top: 1px solid transparent;
    border-image: linear-gradient(
        to right,
        transparent,
        var(--teal) 20%,
        var(--gold) 80%,
        transparent
      )
      1;
    padding-top: 3.2vh;
    width: 100%;
  }
}

.signature {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6vh 6vw;
  background: rgba(16, 26, 26, 0.46);
  backdrop-filter: blur(14px);
}

.signature.is-open {
  display: flex !important;
}

.signature-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.signature-card {
  position: relative;
  z-index: 1;
  width: min(78vw, 1040px);
  padding: 6.5vh 5vw 4.2vh;
  border-radius: 1.4rem;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 24px 80px rgba(16, 26, 26, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.6);
  text-align: center;
}

.signature.is-open .signature-card {
  animation: signature-in 0.45s ease;
}

@keyframes signature-in {
  from {
    opacity: 0;
    transform: translateY(1.4vh) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.signature-kicker {
  font-weight: 300;
  font-size: clamp(0.95rem, 1.4vw, 1.55rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.signature-title {
  margin-top: 1.4vh;
  font-weight: 700;
  font-size: clamp(2.2rem, 4.6vw, 5.2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--teal);
}

.signature-agent {
  margin-top: 1.6vh;
  font-weight: 500;
  font-size: clamp(1.15rem, 2vw, 2rem);
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.signature-offer {
  display: flex;
  flex-direction: column;
  gap: 2.4vh;
  margin-top: 4.2vh;
}

.signature-offer-row:not([hidden]) {
  display: flex;
  justify-content: center;
}

.signature-fact {
  flex: 1;
  min-width: 0;
  padding: 0 1.6vw;
}

.signature-fact:not([hidden]) ~ .signature-fact:not([hidden]) {
  border-left: 1px solid transparent;
  border-image: linear-gradient(
      to bottom,
      transparent,
      var(--teal) 20%,
      var(--gold) 80%,
      transparent
    )
    1;
}

.signature-fact dt {
  font-weight: 300;
  font-size: clamp(0.8rem, 1.1vw, 1.15rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.signature-fact dd {
  margin-top: 0.7rem;
  font-weight: 700;
  font-size: clamp(1.25rem, 2.1vw, 2.15rem);
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

#signature-power dd {
  color: var(--gold);
}

.signature-timer {
  margin-top: 5vh;
  height: 0.45rem;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(26, 36, 36, 0.08);
}

.signature-timer-bar {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--teal);
}

.signature.is-open .signature-timer-bar {
  animation: signature-countdown var(--signature-duration, 15s) linear forwards;
}

@keyframes signature-countdown {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (max-aspect-ratio: 4/5) {
  .signature-offer-row:not([hidden]) {
    flex-direction: column;
    gap: 2.4vh;
  }

  .signature-fact:not([hidden]) ~ .signature-fact:not([hidden]) {
    border-left: 0;
    border-image: none;
    border-top: 1px solid transparent;
    border-image: linear-gradient(
        to right,
        transparent,
        var(--teal) 20%,
        var(--gold) 80%,
        transparent
      )
      1;
    padding-top: 2.4vh;
  }
}
