:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color: #f8f9ff;
  background: #02030a;
  font-synthesis: none;
  --cyan: #49f6ff;
  --violet: #a86bff;
  --danger: #ff4675;
  --panel: rgba(7, 10, 29, 0.88);
  --muted: #929bc0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(circle at 50% 42%, #11183b 0%, #050716 48%, #02030a 100%);
}

body {
  display: grid;
  place-items: center;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16), 520px);
  height: min(100dvh, calc(100vw * 16 / 9), 924px);
  min-width: min(100vw, 320px);
  overflow: hidden;
  isolation: isolate;
  background: #07091a;
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.62);
}

#game-shell::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 20%),
    radial-gradient(circle at 50% 54%, transparent 34%, rgba(0, 0, 0, 0.32));
}

#game-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(24px, env(safe-area-inset-top))
    24px
    max(24px, env(safe-area-inset-bottom));
  text-align: center;
  background:
    radial-gradient(circle at 50% 44%, rgba(25, 34, 80, 0.18), transparent 48%),
    linear-gradient(180deg, rgba(3, 5, 17, 0.3), rgba(3, 5, 17, 0.86));
  transition: opacity 160ms ease, visibility 160ms ease;
}

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

h1,
h2 {
  margin: 0;
  text-transform: uppercase;
  line-height: 0.9;
  letter-spacing: -0.055em;
  text-shadow: 0 0 24px rgba(73, 246, 255, 0.28);
}

h1 {
  font-size: clamp(3.4rem, 15vw, 5.8rem);
}

h2 {
  font-size: clamp(2.45rem, 11vw, 4rem);
}

.subcopy {
  max-width: 280px;
  margin: 18px 0 0;
  color: #a2abc9;
  font-size: 0.98rem;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.start-content {
  width: min(330px, 92%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-2%);
}

.start-best {
  position: absolute;
  top: max(18px, calc(env(safe-area-inset-top) + 10px));
  left: 18px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(7, 10, 28, 0.58);
}

.start-best span,
.score-block span,
.results span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 0 0 30px;
  padding: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 0 18px rgba(73, 246, 255, 0.2));
}

.brand-orbit {
  position: absolute;
  border: 1px solid rgba(138, 224, 255, 0.38);
  border-radius: 50%;
}

.brand-orbit-outer {
  inset: 0;
}

.brand-orbit-inner {
  inset: 20px;
  border-color: rgba(168, 107, 255, 0.46);
}

.brand-orb {
  position: absolute;
  top: 36px;
  right: -5px;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan), 0 0 26px var(--cyan);
  animation: brand-pulse 1.5s ease-in-out infinite;
}

@keyframes brand-pulse {
  50% {
    transform: scale(1.14);
    box-shadow: 0 0 15px var(--cyan), 0 0 38px var(--cyan);
  }
}

.primary-button {
  width: 100%;
  min-height: 60px;
  margin-top: 28px;
  padding: 17px 30px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  color: #061018;
  background: linear-gradient(135deg, #efffff, var(--cyan) 50%, #78a8ff);
  box-shadow:
    0 0 30px rgba(73, 246, 255, 0.35),
    inset 0 1px rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.primary-button:active {
  transform: scale(0.97);
}

.link-button {
  margin-top: 14px;
  padding: 4px;
  border: 0;
  color: #b7eefe;
  background: transparent;
  font-size: 0.76rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.replay-link {
  margin-top: 7px;
  color: #808bae;
  font-size: 0.68rem;
}

.player-name-details {
  width: min(250px, 84vw);
  margin-top: 22px;
  color: #8e98bb;
  font-size: 0.7rem;
}

.player-name-details summary {
  cursor: pointer;
  list-style-position: inside;
}

.player-name-details[open] summary {
  margin-bottom: 8px;
}

.player-name-details small {
  display: block;
  margin-top: 6px;
  color: #697497;
  font-size: 0.61rem;
}

.player-name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.player-name-row input,
.improve-panel input,
.improve-panel select {
  min-width: 0;
  height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  outline: none;
  color: #fff;
  background: rgba(3, 5, 17, 0.92);
  user-select: text;
}

.player-name-row input {
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.player-name-row button,
.small-action,
.improve-actions button,
.leaderboard-tabs button {
  min-height: 38px;
  border: 1px solid rgba(73, 246, 255, 0.3);
  border-radius: 9px;
  color: #c5f3ff;
  background: rgba(15, 24, 53, 0.9);
  font-size: 0.68rem;
  font-weight: 850;
}

.player-name-row button {
  padding: 0 13px;
}

.icon-button {
  position: absolute;
  z-index: 9;
  top: max(16px, calc(env(safe-area-inset-top) + 8px));
  right: 15px;
  width: 46px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #dce4ff;
  background: rgba(10, 13, 35, 0.68);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.sound-off {
  display: none;
}

.icon-button[aria-pressed="true"] .sound-on {
  display: none;
}

.icon-button[aria-pressed="true"] .sound-off {
  display: inline;
}

.hud {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: max(20px, calc(env(safe-area-inset-top) + 10px)) 22px 0;
  pointer-events: none;
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.score-block-right {
  align-items: flex-end;
  padding-right: 48px;
}

.score-block strong {
  font-size: 2.1rem;
  line-height: 1;
  text-shadow: 0 0 16px rgba(73, 246, 255, 0.36);
}

.tutorial-overlay {
  position: absolute;
  z-index: 8;
  inset: max(78px, calc(env(safe-area-inset-top) + 64px)) 20px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.tutorial-overlay p {
  margin: 0;
  padding: 11px 18px;
  border: 1px solid rgba(73, 246, 255, 0.28);
  border-radius: 999px;
  color: #fff;
  background: rgba(5, 8, 25, 0.82);
  box-shadow: 0 0 24px rgba(73, 246, 255, 0.12);
  font-size: 0.88rem;
  font-weight: 850;
}

.tutorial-overlay button {
  margin-top: 10px;
  padding: 5px;
  border: 0;
  color: #8d97b9;
  background: transparent;
  font-size: 0.66rem;
  text-decoration: underline;
  pointer-events: auto;
}

.game-over-card,
.leaderboard-card {
  width: min(342px, 94vw);
  max-height: calc(100% - 24px);
  padding: 28px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  overflow: auto;
  scrollbar-width: none;
}

.game-over-card::-webkit-scrollbar,
.leaderboard-card::-webkit-scrollbar {
  display: none;
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 24px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 19px;
  overflow: hidden;
}

.results > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 17px;
}

.results > div + div {
  border-left: 1px solid rgba(255, 255, 255, 0.09);
}

.results strong {
  font-size: 2.35rem;
}

.game-over-card .primary-button {
  margin-top: 18px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
}

.result-actions .link-button {
  margin-top: 12px;
}

.score-pass-panel {
  margin-top: 17px;
  padding: 14px;
  border: 1px solid rgba(73, 246, 255, 0.24);
  border-radius: 15px;
  background: rgba(10, 18, 42, 0.8);
}

.score-pass-panel strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-pass-panel p {
  margin: 6px 0 10px;
  color: #99a4c8;
  font-size: 0.7rem;
}

.score-pass-panel button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(73, 246, 255, 0.5);
  border-radius: 10px;
  color: #071017;
  background: var(--cyan);
  font-size: 0.72rem;
  font-weight: 950;
}

.score-pass-panel small {
  display: block;
  margin-top: 7px;
  color: #ffb2c5;
  font-size: 0.62rem;
}

.improve-panel {
  margin-top: 16px;
  padding: 0 4px;
  color: #929dc1;
  text-align: left;
}

.improve-panel summary {
  cursor: pointer;
  font-size: 0.7rem;
  text-align: center;
}

.improve-panel > p {
  margin: 13px 0 8px;
  font-size: 0.7rem;
  text-align: center;
}

.feedback-buttons {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.feedback-buttons button {
  min-height: 35px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  color: #bac3e0;
  background: rgba(13, 17, 43, 0.9);
  font-size: 0.68rem;
}

.feedback-buttons button.is-selected {
  color: #071017;
  border-color: var(--cyan);
  background: var(--cyan);
}

.improve-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 9px;
}

.improve-panel label span {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.small-action {
  width: 100%;
  margin-top: 10px;
}

.improve-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 7px;
}

.action-status,
.global-status {
  min-height: 1em;
  color: var(--cyan);
  font-size: 0.68rem;
}

.action-status {
  margin: 8px 0 0;
}

.global-status {
  position: absolute;
  z-index: 12;
  right: 18px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 18px;
  margin: 0;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 8px #000;
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 20px;
}

.leaderboard-tabs button.is-selected {
  color: #071017;
  background: var(--cyan);
}

.leaderboard-list {
  min-height: 160px;
  max-height: 350px;
  margin: 12px 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 39px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #9ca7ca;
  font-size: 0.75rem;
}

.leaderboard-list li strong {
  color: #fff;
  letter-spacing: 0.14em;
}

.leaderboard-list li b {
  color: var(--cyan);
}

#leaderboard-status {
  color: #8e98bc;
  font-size: 0.76rem;
}

.leaderboard-card .primary-button {
  margin-top: 16px;
}

.debug-panel {
  position: absolute;
  z-index: 20;
  inset: auto 12px max(12px, env(safe-area-inset-bottom));
  max-height: 62%;
  padding: 14px;
  border: 1px solid rgba(73, 246, 255, 0.35);
  border-radius: 14px;
  background: rgba(3, 5, 17, 0.96);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.52);
  font-size: 0.68rem;
}

.debug-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.debug-heading button {
  border: 0;
  color: #a9faff;
  background: transparent;
  font-size: 0.65rem;
}

.debug-panel pre {
  max-height: 45vh;
  margin: 9px 0 0;
  overflow: auto;
  color: #a9faff;
  user-select: text;
  white-space: pre-wrap;
}

.captcha-host {
  position: absolute;
  z-index: 30;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}

@media (min-width: 600px) {
  #game-shell {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
  }
}

@media (max-height: 720px) {
  .brand-mark {
    width: 68px;
    height: 68px;
    margin-bottom: 20px;
  }

  .brand-orbit-inner {
    inset: 15px;
  }

  .brand-orb {
    top: 26px;
    width: 15px;
    height: 15px;
  }

  h1 {
    font-size: 3.35rem;
  }

  .subcopy {
    margin-top: 12px;
  }

  .player-name-details {
    margin-top: 14px;
  }

  .primary-button {
    min-height: 52px;
    margin-top: 17px;
  }

  .game-over-card {
    padding: 19px 18px 15px;
  }

  .results {
    margin-top: 15px;
  }

  .results > div {
    padding: 11px;
  }

  .results strong {
    font-size: 2rem;
  }
}
