:root {
  color-scheme: dark;
  --bg: #08040f;
  --bg-deep: #12051f;
  --panel: rgba(12, 8, 24, 0.82);
  --panel-strong: rgba(19, 12, 34, 0.94);
  --ink: #f7f4ff;
  --muted: #b3a9cf;
  --accent: #ffd84d;
  --accent-strong: #fff06a;
  --violet: #a24dff;
  --cyan: #7af7ff;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 216, 77, 0.34);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Orbitron", "Rajdhani", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(162, 77, 255, 0.24), transparent 28%),
    radial-gradient(circle at top right, rgba(122, 247, 255, 0.12), transparent 24%),
    radial-gradient(circle at bottom center, rgba(255, 216, 77, 0.08), transparent 34%),
    linear-gradient(180deg, #05030a 0%, var(--bg) 42%, var(--bg-deep) 100%);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 100% 3px, 3px 100%;
  opacity: 0.28;
  mix-blend-mode: screen;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(130deg, transparent 0 64%, rgba(255, 216, 77, 0.08) 64% 67%, transparent 67% 100%),
    linear-gradient(180deg, transparent 0 88%, rgba(162, 77, 255, 0.12) 88% 100%);
  opacity: 0.85;
}

.app {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    linear-gradient(145deg, rgba(162, 77, 255, 0.08), rgba(255, 216, 77, 0.03)),
    var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.panel::before {
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
}

.panel::after {
  top: 16px;
  right: 18px;
  width: 88px;
  height: 10px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 8px,
      rgba(255, 216, 77, 0.9) 8px 16px
    );
  opacity: 0.75;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subhead {
  margin-top: 8px;
  color: var(--muted);
  max-width: 32ch;
}

.subhead.compact {
  margin-top: 4px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.field span {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04)),
    rgba(5, 4, 10, 0.88);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

input::placeholder {
  color: rgba(179, 169, 207, 0.72);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

button {
  border: 1px solid rgba(255, 216, 77, 0.42);
  border-radius: 14px;
  padding: 12px 18px;
  background:
    linear-gradient(135deg, rgba(255, 216, 77, 0.24), rgba(162, 77, 255, 0.14)),
    rgba(18, 12, 31, 0.96);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 24px rgba(255, 216, 77, 0.08);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

button.secondary {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(122, 247, 255, 0.08)),
    rgba(11, 8, 22, 0.9);
  border-color: rgba(255, 255, 255, 0.14);
}

button:hover,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(255, 216, 77, 0.18),
    0 0 30px rgba(255, 216, 77, 0.14);
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 77, 0.22);
  background: rgba(255, 216, 77, 0.08);
  color: var(--accent-strong);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill.muted {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.08);
}

.tap-panel,
.log-panel {
  margin-top: 22px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 30%),
    var(--panel-strong);
}

.game-panel {
  margin-top: 18px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.status-card {
  margin-top: 22px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    rgba(14, 10, 26, 0.86);
}

.status-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.game-topbar,
.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hud-row {
  margin-top: 16px;
  flex-wrap: wrap;
}

.tap-header,
.log-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.pointer-preview {
  color: var(--accent);
  font-size: 0.92rem;
  letter-spacing: 0.06em;
}

.tap-pad {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 360px;
  margin-top: 14px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 34%),
    radial-gradient(circle at 15% 22%, rgba(255, 216, 77, 0.18), transparent 28%),
    radial-gradient(circle at 80% 18%, rgba(122, 247, 255, 0.16), transparent 24%),
    linear-gradient(145deg, rgba(36, 12, 64, 0.96), rgba(5, 5, 10, 0.98) 62%);
  touch-action: manipulation;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 0 48px rgba(162, 77, 255, 0.12),
    0 18px 34px rgba(0, 0, 0, 0.34);
}

.tap-pad::before,
.tap-pad::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.tap-pad::before {
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.tap-pad::after {
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 12px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 216, 77, 0.95) 0 14px,
      transparent 14px 20px
    );
  opacity: 0.75;
}

.tap-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, transparent 0 88%, rgba(255, 216, 77, 0.08) 88% 100%);
  background-size: 20% 100%, 100% 20%;
  pointer-events: none;
}

.beat-wave {
  position: absolute;
  inset: -12%;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at center, rgba(255, 240, 106, 0.58) 0%, rgba(255, 240, 106, 0.16) 30%, transparent 54%),
    linear-gradient(180deg, rgba(162, 77, 255, 0.16), transparent 38%, rgba(255, 214, 111, 0.18) 100%);
  transform: scale(0.82);
}

.beat-wave.is-pulsing {
  animation: beat-wave-pulse 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes beat-wave-pulse {
  0% {
    opacity: 0.02;
    transform: scale(0.82);
  }

  20% {
    opacity: 0.88;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

.defender-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition:
    left 120ms linear,
    top 120ms linear,
    opacity 120ms linear;
  z-index: 3;
}

.defender-marker.hidden {
  opacity: 0;
}

.defender-marker.head {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.2), transparent 24%),
    linear-gradient(180deg, rgba(255, 216, 77, 0.12), rgba(162, 77, 255, 0.36));
  box-shadow:
    0 0 0 8px rgba(162, 77, 255, 0.14),
    0 0 22px rgba(162, 77, 255, 0.18);
}

.defender-marker.hand {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 24%),
    linear-gradient(180deg, rgba(255, 216, 77, 0.26), rgba(255, 216, 77, 0.08));
  box-shadow:
    0 0 0 6px rgba(255, 216, 77, 0.14),
    0 0 18px rgba(255, 216, 77, 0.14);
  transform: translate(-50%, -50%) rotate(45deg);
}

.defender-marker.head::before,
.defender-marker.head::after,
.defender-marker.hand::before,
.defender-marker.hand::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.defender-marker.head::before {
  left: 7px;
  right: 7px;
  top: 12px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(122, 247, 255, 0.82), rgba(255, 255, 255, 0.95), rgba(122, 247, 255, 0.82));
  box-shadow: 0 0 10px rgba(122, 247, 255, 0.4);
}

.defender-marker.head::after {
  left: 14px;
  right: 14px;
  bottom: 8px;
  height: 10px;
  border-top: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 0 0 999px 999px;
}

.defender-marker.hand::before {
  inset: 6px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 4px;
}

.defender-marker.hand::after {
  left: 50%;
  top: 50%;
  width: 14px;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 -5px 0 rgba(255, 255, 255, 0.72),
    0 5px 0 rgba(255, 255, 255, 0.72);
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cube-ghost {
  position: absolute;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  margin-top: -16px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 216, 77, 0.84));
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 30px rgba(255, 216, 77, 0.22);
  opacity: 1;
  transform: scale(1.6);
  transition:
    transform var(--travel-ms, 6000ms) linear,
    opacity var(--travel-ms, 6000ms) linear,
    background 220ms ease;
  pointer-events: none;
}

.cube-ghost.is-traveling {
  opacity: 0.5;
  transform: scale(0.02);
}

.cube-ghost.is-missed {
  opacity: 1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(162, 77, 255, 0.9));
  box-shadow: 0 10px 26px rgba(162, 77, 255, 0.3);
  transform: scale(0.08);
}

.cube-particle {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 216, 77, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.72);
  pointer-events: none;
  animation: cube-particle-burst 700ms ease-out forwards;
}

@keyframes cube-particle-burst {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform:
      translate3d(var(--particle-x), var(--particle-y), 0)
      scale(0.25)
      rotate(var(--particle-rot));
  }
}

.log-output {
  min-height: 120px;
  margin-top: 14px;
  padding: 14px;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #06050a;
  color: #fff4b5;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.log-panel.compact,
.compact-button {
  margin-top: 18px;
}

@media (max-width: 640px) {
  .app {
    padding: 12px 10px 28px;
  }

  .panel {
    padding: 16px;
    border-radius: 22px;
  }

  .panel::after {
    top: 14px;
    right: 14px;
    width: 68px;
  }

  h1 {
    font-size: 1.45rem;
    line-height: 1.05;
  }

  .subhead {
    font-size: 0.94rem;
  }

  .row,
  .game-topbar,
  .tap-header,
  .log-header {
    align-items: flex-start;
  }

  .row button,
  .game-topbar button {
    width: 100%;
  }

  .game-topbar {
    flex-direction: column;
  }

  .tap-panel,
  .status-card,
  .log-panel {
    padding: 14px;
    border-radius: 18px;
  }

  .status-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tap-pad {
    min-height: 300px;
    border-radius: 20px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 32%),
      repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.04) 0 8px,
        transparent 8px 18px
      ),
      radial-gradient(circle at 18% 20%, rgba(255, 216, 77, 0.18), transparent 26%),
      radial-gradient(circle at 82% 16%, rgba(162, 77, 255, 0.24), transparent 28%),
      linear-gradient(145deg, rgba(29, 10, 55, 0.98), rgba(4, 4, 8, 1) 68%);
  }

  .tap-pad::after {
    left: 12px;
    right: 12px;
    bottom: 12px;
    height: 10px;
  }

  .pointer-preview,
  .pill,
  .field span,
  button {
    font-size: 0.82rem;
  }

  .log-output {
    min-height: 96px;
    font-size: 0.8rem;
  }
}
