:root {
  color-scheme: dark;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #111411;
  color: #f7f4ea;
  --panel: rgba(18, 20, 18, 0.72);
  --panel-strong: rgba(18, 20, 18, 0.9);
  --line: rgba(247, 244, 234, 0.16);
  --amber: #f3b23c;
  --mint: #87d8b7;
  --steel: #9fc8df;
  --danger: #d96a62;
  --shadow: rgba(0, 0, 0, 0.36);
  --radius: 18px;
  --soft-glow: 0 0 38px rgba(243, 178, 60, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
}

body.is-aiming {
  cursor: crosshair;
}

body.is-orbiting,
body.is-orbiting #site-scene {
  cursor: grabbing;
}

#site-scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #151812;
  touch-action: manipulation;
}

.ambient-halo {
  position: fixed;
  inset: auto auto 8vh 56vw;
  z-index: 1;
  width: min(42vw, 520px);
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(243, 178, 60, 0.14), rgba(135, 216, 183, 0.05), rgba(110, 231, 183, 0));
  filter: blur(24px);
  pointer-events: none;
  transform: translate3d(var(--pointer-x, 0px), var(--pointer-y, 0px), 0);
}

.game-shell {
  position: fixed;
  inset: 0;
  z-index: 3;
  min-height: 0;
  display: block;
  padding: 0;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero,
.leaderboard-panel,
.game-over-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 18% 0%, rgba(243, 178, 60, 0.1), transparent 30%),
    linear-gradient(135deg, rgba(16, 18, 16, 0.9), rgba(16, 18, 16, 0.52)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0));
  box-shadow: 0 24px 80px var(--shadow), var(--soft-glow);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 3vw, 30px);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 54px);
  opacity: 0.48;
  transform: translateX(calc(-42% + var(--scan-x, 0%) * 0.16));
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--amber);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 10em;
  font-size: clamp(2.25rem, 4.6vw, 4rem);
  line-height: 1.08;
  padding-bottom: 0.04em;
}

h2 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.05;
}

.lead {
  max-width: 520px;
  margin: 18px 0 0;
  color: rgba(247, 244, 234, 0.82);
  font-size: clamp(0.98rem, 1.6vw, 1.08rem);
  line-height: 1.72;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.score-card {
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(243, 178, 60, 0.09), rgba(255, 255, 255, 0.045)),
    rgba(255, 255, 255, 0.04);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.score-card span {
  display: block;
  color: var(--steel);
  font-size: 0.82rem;
}

.score-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.45rem, 3.2vw, 2rem);
  line-height: 1;
}

.leaderboard-panel {
  position: fixed;
  left: 18px;
  top: 50%;
  z-index: 5;
  width: min(314px, calc(100vw - 76px));
  max-height: min(520px, calc(100svh - 120px));
  padding: 16px;
  transform: translateY(-50%);
  transition:
    transform 220ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.panel-title > span {
  white-space: nowrap;
}

#refresh-scores,
.panel-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(247, 244, 234, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f7f4ea;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

#leaderboard-toggle {
  position: absolute;
  top: 18px;
  right: -48px;
  width: 42px;
  height: 48px;
  border-radius: 0 12px 12px 0;
  background:
    linear-gradient(135deg, rgba(18, 20, 18, 0.92), rgba(18, 20, 18, 0.68)),
    rgba(255, 255, 255, 0.08);
  border-left: 0;
  box-shadow: 12px 16px 34px rgba(0, 0, 0, 0.24);
}

.collapse-icon {
  position: relative;
  width: 18px;
  height: 16px;
  display: block;
  transform: rotate(0deg);
  transition: transform 180ms ease;
}

.collapse-icon::before,
.collapse-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 999px;
}

.collapse-icon::before,
.collapse-icon::after {
  width: 11px;
  height: 3px;
  left: 4px;
  top: 6px;
  transform-origin: 2px 50%;
}

.collapse-icon::before {
  transform: rotate(45deg);
}

.collapse-icon::after {
  transform: rotate(-45deg);
}

.leaderboard {
  display: grid;
  gap: 8px;
  max-height: 320px;
  margin: 14px 0 0;
  padding: 0;
  overflow: auto;
  list-style-position: inside;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid rgba(247, 244, 234, 0.12);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.045));
  color: rgba(247, 244, 234, 0.86);
  font-size: 0.92rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.leaderboard .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .score {
  color: var(--mint);
  font-weight: 800;
}

.leaderboard-panel.is-collapsed {
  transform: translate(calc(-100% - 18px), -50%);
  background: rgba(12, 14, 12, 0.58);
}

.leaderboard-panel.is-collapsed .collapse-icon {
  transform: rotate(180deg);
}

.control-dock {
  position: fixed;
  right: clamp(16px, 3vw, 34px);
  bottom: clamp(18px, 4vw, 34px);
  z-index: 4;
  display: flex;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(12, 14, 12, 0.72);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28), 0 0 24px rgba(110, 231, 183, 0.1);
  backdrop-filter: blur(12px);
}

.tool-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(247, 244, 234, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f7f4ea;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.tool-button:hover,
.tool-button:focus-visible,
#refresh-scores:hover,
#refresh-scores:focus-visible,
.panel-button:hover,
.panel-button:focus-visible {
  border-color: rgba(243, 178, 60, 0.56);
  background: rgba(243, 178, 60, 0.12);
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(243, 178, 60, 0.14);
}

.tool-button.is-active {
  border-color: rgba(110, 231, 183, 0.62);
  background: rgba(110, 231, 183, 0.14);
}

.pause-icon,
.pause-icon::after {
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
}

.pause-icon {
  position: relative;
  display: block;
  transform: translateX(-4px);
}

.pause-icon::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 0;
}

.tool-button.is-paused .pause-icon {
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 15px solid currentColor;
  border-radius: 0;
  background: transparent;
  transform: translateX(2px);
}

.tool-button.is-paused .pause-icon::after {
  display: none;
}

.light-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 16px rgba(243, 178, 60, 0.58);
}

.light-icon::before,
.light-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid currentColor;
  border-radius: inherit;
  opacity: 0.32;
}

.light-icon::after {
  inset: 4px 1px 4px 10px;
  border: 0;
  background: rgba(12, 14, 12, 0.72);
}

.reset-icon,
.refresh-icon {
  position: relative;
  width: 20px;
  height: 20px;
  display: block;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
}

.reset-icon::after,
.refresh-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -2px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
  transform: rotate(-18deg);
}

.game-over {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(243, 178, 60, 0.13), transparent 28%),
    rgba(0, 0, 0, 0.7);
  pointer-events: auto;
}

.game-over[hidden] {
  display: none;
}

.game-over-card {
  width: min(520px, 100%);
  padding: clamp(24px, 5vw, 38px);
  transform: translateY(0) scale(1);
  animation: card-in 220ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }

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

.game-over-card p {
  color: rgba(247, 244, 234, 0.78);
}

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

label[hidden],
.identity-row[hidden] {
  display: none;
}

label span {
  color: var(--steel);
  font-size: 0.88rem;
}

.identity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(247, 244, 234, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
}

.identity-row span {
  grid-column: 1 / -1;
  color: var(--steel);
  font-size: 0.86rem;
}

.identity-row strong {
  min-width: 0;
  overflow: hidden;
  color: #f7f4ea;
  font-size: 1.2rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-row button {
  min-height: 34px;
  border: 1px solid rgba(247, 244, 234, 0.22);
  border-radius: 10px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f7f4ea;
  font: inherit;
  cursor: pointer;
}

input {
  width: 100%;
  min-height: 52px;
  position: relative;
  z-index: 12;
  border: 1px solid rgba(247, 244, 234, 0.32);
  border-radius: 12px;
  padding: 0 15px;
  background: rgba(0, 0, 0, 0.34);
  color: #f7f4ea;
  font: inherit;
  pointer-events: auto !important;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}

label small {
  color: rgba(247, 244, 234, 0.58);
  font-size: 0.78rem;
  line-height: 1.45;
}

input:focus-visible,
button:focus-visible {
  border-color: rgba(243, 178, 60, 0.62);
  outline: none;
  box-shadow: 0 0 0 3px rgba(243, 178, 60, 0.16);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.form-actions button {
  min-height: 44px;
  border: 1px solid rgba(247, 244, 234, 0.22);
  border-radius: 12px;
  padding: 0 18px;
  background: linear-gradient(135deg, rgba(243, 178, 60, 0.22), rgba(243, 178, 60, 0.1));
  color: #f7f4ea;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.form-actions button:nth-child(2) {
  background: rgba(255, 255, 255, 0.08);
}

.form-note {
  min-height: 1.2em;
  margin-bottom: 0;
  color: var(--mint);
}

.site-footer {
  position: relative;
  z-index: 2;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(20px, 6vw, 88px);
  padding-right: max(clamp(20px, 6vw, 88px), 170px);
  color: rgba(247, 244, 234, 0.68);
  font-size: 0.9rem;
  pointer-events: none;
}

body.is-gameover #site-scene {
  touch-action: none;
}

body.is-night .ambient-halo {
  background: radial-gradient(circle, rgba(143, 211, 255, 0.2), rgba(143, 211, 255, 0));
}

@media (max-width: 920px) {
  .leaderboard-panel {
    max-width: 520px;
  }
}

@media (max-width: 720px) {
  .game-shell {
    padding: 0;
  }

  h1 {
    max-width: 10em;
    font-size: clamp(1.95rem, 10vw, 2.8rem);
  }

  .lead {
    margin-top: 12px;
    font-size: 0.96rem;
    line-height: 1.62;
  }

  .score-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
  }

  .score-card {
    min-height: 68px;
    padding: 10px;
  }

  .score-card span {
    font-size: 0.76rem;
  }

  .score-card strong {
    font-size: clamp(1.32rem, 7vw, 1.8rem);
  }

  .leaderboard-panel {
    position: fixed;
    top: 50%;
    left: 12px;
    right: auto;
    z-index: 5;
    width: min(284px, calc(100vw - 70px));
    padding: 12px;
  }

  .leaderboard-panel.is-collapsed {
    transform: translate(calc(-100% - 12px), -50%);
  }

  .leaderboard {
    max-height: 118px;
    overflow: auto;
  }

  .control-dock {
    right: 20px;
    bottom: 18px;
  }

  .tool-button {
    width: 44px;
    height: 44px;
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding-right: clamp(20px, 6vw, 88px);
  }

  .game-over {
    padding: 16px;
  }

  .game-over-card {
    padding: 22px;
  }

  .form-actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero {
    backdrop-filter: none;
  }

  .hero::before {
    display: none;
  }
}
