/* Aim Trainer-specific layout. Shared typography, color tokens, and controls live in style.css. */

main {
  width: min(calc(100% - 40px), 1440px);
}

main > :not(.aim-shell) {
  width: min(100%, var(--max-width));
  margin-inline: auto;
}

.aim-shell {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
}

.aim-card {
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(13, 28, 49, 0.96), rgba(5, 12, 23, 0.98));
}

.aim-card .test-card__topline {
  gap: 24px;
}

.aim-card .latency-label {
  flex: 0 0 auto;
  min-height: 44px;
  padding-inline: 14px;
}

.aim-card .latency-label span {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(73, 231, 165, 0.7);
}

.aim-difficulty-panel {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(18px, 2.1vw, 30px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 13, 25, 0.54);
}

.aim-difficulty-selector {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: rgba(3, 9, 18, 0.72);
  border-radius: 14px;
}

.aim-difficulty-option {
  display: flex;
  min-width: 148px;
  min-height: 50px;
  padding: 7px 14px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  color: #9fb2cb;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.aim-difficulty-option strong {
  color: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.aim-difficulty-option span {
  color: var(--muted);
  font-size: 0.67rem;
}

.aim-difficulty-option[aria-pressed="true"] {
  color: #eaf3ff;
  border-color: rgba(99, 165, 255, 0.38);
  background: rgba(47, 128, 255, 0.16);
}

.aim-difficulty-option--hell[aria-pressed="true"] {
  color: #fff1f3;
  border-color: rgba(255, 64, 87, 0.54);
  background: rgba(255, 64, 87, 0.14);
}

.aim-difficulty-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.aim-difficulty-option:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.aim-difficulty-note {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.aim-card__body {
  display: block;
  min-height: 0;
  padding: clamp(18px, 2.1vw, 30px);
}

.aim-hud {
  display: grid;
  width: min(100%, 1280px);
  margin: 0 auto 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(5, 13, 25, 0.8);
  border-radius: 14px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
}

.aim-hud div {
  display: flex;
  min-width: 0;
  min-height: 64px;
  padding: 10px 18px;
  flex-direction: column;
  justify-content: center;
}

.aim-hud div + div {
  border-left: 1px solid var(--line);
}

.aim-hud span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.aim-hud strong {
  overflow: hidden;
  color: #f6f9ff;
  font-size: clamp(1.05rem, 1.8vw, 1.42rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aim-arena {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 1280px;
  aspect-ratio: 16 / 9;
  margin-inline: auto;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  color: var(--text);
  border: 1px solid rgba(99, 165, 255, 0.32);
  background:
    radial-gradient(circle at 50% 44%, rgba(47, 128, 255, 0.13), transparent 34%),
    linear-gradient(145deg, #071321, #030811 74%);
  border-radius: 18px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    inset 0 0 72px rgba(0, 0, 0, 0.44),
    0 24px 60px rgba(0, 0, 0, 0.3);
  cursor: crosshair;
}

.aim-arena::before,
.aim-arena::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
}

.aim-arena::before {
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(92, 145, 209, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 145, 209, 0.075) 1px, transparent 1px);
  background-size: 4% 7.111%;
  mask-image: radial-gradient(circle at center, black, transparent 83%);
}

.aim-arena::after {
  border: 1px solid rgba(51, 214, 255, 0.08);
  box-shadow: inset 0 0 0 9px rgba(3, 8, 17, 0.2);
}

.aim-idle,
.aim-invalid {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  padding: clamp(18px, 4vw, 54px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.aim-idle h3,
.aim-invalid h3,
.aim-report h3 {
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 3.1vw, 2.65rem);
}

.aim-idle > p:not(.section-label),
.aim-invalid > p:not(.section-label) {
  max-width: 610px;
  margin-bottom: 22px;
  color: #a9b9cf;
  font-size: clamp(0.82rem, 1.35vw, 1rem);
}

.aim-idle .start-orb {
  width: clamp(76px, 10vw, 126px);
  height: clamp(76px, 10vw, 126px);
  margin-bottom: clamp(10px, 1.5vw, 20px);
}

.aim-idle .start-orb span {
  width: clamp(30px, 3.5vw, 45px);
  height: clamp(30px, 3.5vw, 45px);
}

.aim-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.aim-actions .button,
.aim-invalid .button,
.aim-report .button {
  min-width: 164px;
  min-height: 44px;
}

.aim-countdown {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  margin: 0;
  color: #f8fbff;
  font-size: clamp(5rem, 17vw, 11rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.08em;
  text-shadow: 0 0 24px rgba(51, 214, 255, 0.36), 0 0 80px rgba(47, 128, 255, 0.28);
  place-items: center;
  animation: aim-countdown-in 520ms ease-out both;
}

.aim-target {
  position: absolute;
  z-index: 4;
  width: 5%;
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: 1;
  padding: 0;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  border: clamp(2px, 0.24vw, 4px) solid rgba(255, 255, 255, 0.94);
  background:
    radial-gradient(circle, #07101f 0 15%, var(--red-bright) 16% 40%, #f4f8ff 41% 57%, var(--red) 58% 100%);
  border-radius: 50%;
  box-shadow:
    0 0 0 2px rgba(255, 64, 87, 0.46),
    0 0 24px rgba(255, 64, 87, 0.62),
    0 8px 18px rgba(0, 0, 0, 0.45);
}

.aim-target::before,
.aim-target::after {
  position: absolute;
  top: 50%;
  left: 50%;
  content: "";
  pointer-events: none;
  background: rgba(4, 12, 23, 0.72);
  transform: translate(-50%, -50%);
}

.aim-target::before {
  width: 46%;
  height: 2px;
}

.aim-target::after {
  width: 2px;
  height: 46%;
}

.aim-target:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 5px;
}

.aim-target__center {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  width: 18.75%;
  aspect-ratio: 1;
  pointer-events: none;
  background: #ff1f3d;
  border-radius: 1px;
  box-shadow: 0 0 5px rgba(255, 31, 61, 0.94);
  transform: translate(-50%, -50%);
}

body[data-aim-difficulty="hell"] .aim-target {
  width: 2.5%;
  min-width: 24px;
  min-height: 24px;
  border-width: 2px;
  background: radial-gradient(circle, #f7fbff 0 30%, #ff6b7d 31% 64%, #95182b 65% 100%);
  box-shadow:
    0 0 0 2px rgba(255, 64, 87, 0.34),
    0 0 18px rgba(255, 64, 87, 0.54),
    0 6px 14px rgba(0, 0, 0, 0.48);
}

body[data-aim-difficulty="hell"] .aim-target__center {
  display: block;
}

body[data-aim-difficulty="hell"] .aim-target::before,
body[data-aim-difficulty="hell"] .aim-target::after {
  display: none;
}

.aim-report-grid > div.is-hell-metric {
  border-color: rgba(255, 64, 87, 0.28);
  background: rgba(255, 64, 87, 0.08);
}

.aim-invalid {
  background: radial-gradient(circle at 50% 45%, rgba(255, 64, 87, 0.14), rgba(3, 8, 17, 0.88) 56%);
}

.aim-invalid .section-label {
  color: var(--red-bright);
}

.aim-invalid h3 {
  color: #fff5f6;
}

.aim-invalid #aim-invalid-reason {
  margin-bottom: 8px;
  color: #ffd7dc;
  font-weight: 800;
}

.aim-report {
  width: min(100%, 1280px);
  margin-inline: auto;
  padding: clamp(22px, 4vw, 48px);
  text-align: center;
  border: 1px solid rgba(99, 165, 255, 0.24);
  background:
    radial-gradient(circle at 50% 0, rgba(47, 128, 255, 0.2), transparent 40%),
    rgba(5, 13, 25, 0.9);
  border-radius: 18px;
}

.aim-report .section-label {
  margin-bottom: 10px;
}

.aim-report-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 28px 0;
}

.aim-report-grid div {
  min-height: 94px;
  padding: 14px;
  background: rgba(6, 16, 30, 0.82);
}

.aim-report-grid dd {
  overflow-wrap: anywhere;
  font-size: clamp(0.92rem, 1.4vw, 1.08rem);
}

body[data-aim-state="countdown"] .aim-arena {
  border-color: rgba(51, 214, 255, 0.52);
  box-shadow:
    inset 0 0 72px rgba(0, 0, 0, 0.44),
    0 0 44px rgba(47, 128, 255, 0.16);
}

body[data-aim-state="active"] .aim-hud strong {
  color: var(--cyan);
}

body[data-aim-state="invalid"] .aim-arena {
  border-color: rgba(255, 64, 87, 0.52);
}

body[data-aim-state="complete"] .aim-arena {
  display: none;
}

body[data-aim-mode="practice"] .latency-label {
  color: #ffe1a1;
  border-color: rgba(255, 200, 87, 0.42);
  background: rgba(99, 66, 11, 0.34);
}

body[data-aim-mode="practice"] .latency-label span {
  background: var(--yellow);
  box-shadow: 0 0 14px rgba(255, 200, 87, 0.66);
}

body[data-aim-mode="practice"] .aim-card {
  border-color: rgba(255, 200, 87, 0.24);
}

.aim-arena:fullscreen {
  position: fixed;
  inset: 0;
  width: min(100vw, calc(100vh * 16 / 9), 1280px);
  height: auto;
  min-height: 0;
  max-width: 1280px;
  max-height: 720px;
  margin: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 0;
}

.aim-arena:-webkit-full-screen {
  position: fixed;
  inset: 0;
  width: min(100vw, calc(100vh * 16 / 9), 1280px);
  height: auto;
  min-height: 0;
  max-width: 1280px;
  max-height: 720px;
  margin: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 0;
}

.aim-arena::backdrop {
  background: #030811;
}

@keyframes aim-countdown-in {
  from {
    opacity: 0;
    transform: scale(0.82);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 1099px) {
  .aim-card .test-card__topline {
    align-items: flex-start;
  }

  .aim-card .latency-label {
    display: inline-flex;
  }

  body[data-aim-mode="practice"] .aim-card .test-card__topline .section-label::after {
    content: " · Practice Mode";
    color: var(--yellow);
  }

  .aim-card__body {
    padding: 18px;
  }

  .aim-hud div {
    min-height: 58px;
    padding-inline: 12px;
  }

  .aim-report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aim-report-grid div:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  main {
    width: min(calc(100% - 28px), 1440px);
  }

  .aim-difficulty-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .aim-difficulty-selector {
    width: 100%;
  }

  .aim-difficulty-option {
    min-width: 0;
    flex: 1 1 0;
  }

  .aim-difficulty-note {
    max-width: none;
    text-align: left;
  }

  .aim-card .test-card__topline {
    gap: 12px;
    flex-direction: column;
  }

  .aim-card .latency-label {
    min-height: 44px;
  }

  .aim-card__body {
    padding: 10px;
  }

  .aim-hud {
    margin-bottom: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aim-hud div {
    min-height: 52px;
    padding: 7px 10px;
  }

  .aim-hud div:nth-child(3) {
    border-left: 0;
  }

  .aim-hud div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .aim-arena {
    min-height: 310px;
    aspect-ratio: auto;
    border-radius: 13px;
  }

  .aim-idle,
  .aim-invalid {
    padding: 18px 14px;
  }

  .aim-idle .start-orb {
    display: none;
  }

  .aim-idle h3,
  .aim-invalid h3 {
    font-size: 1.4rem;
  }

  .aim-idle > p:not(.section-label),
  .aim-invalid > p:not(.section-label) {
    margin-bottom: 14px;
    font-size: 0.78rem;
  }

  .aim-actions {
    width: 100%;
  }

  .aim-actions .button {
    width: 100%;
    min-height: 44px;
    padding: 9px 14px;
  }

  .aim-report {
    padding: 24px 14px;
    border-radius: 13px;
  }

  .aim-report-grid {
    grid-template-columns: 1fr;
  }

  .aim-report-grid div:last-child {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aim-countdown,
  .aim-card .button {
    animation: none;
    transition: none;
  }
}
