:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #10130f;
  color: #edf1e9;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 22% 18%, rgba(110, 209, 119, 0.18), transparent 30%),
    radial-gradient(circle at 82% 78%, rgba(116, 176, 255, 0.16), transparent 32%),
    linear-gradient(145deg, #11150f 0%, #181b15 52%, #0d1110 100%);
}

button {
  min-height: 40px;
  border: 1px solid rgba(237, 241, 233, 0.24);
  border-radius: 7px;
  padding: 0 14px;
  background: rgba(237, 241, 233, 0.08);
  color: #edf1e9;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: rgba(237, 241, 233, 0.14);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sitePage {
  display: none;
  min-height: 100vh;
  padding: 22px;
}

body[data-route="home"] #homePage,
body[data-route="leaderboard"] #leaderboardPage {
  display: block;
}

body[data-route="game"] #gamePage {
  display: grid;
}

.shell {
  display: none;
  grid-template-rows: auto auto minmax(320px, 1fr) auto auto;
  gap: 14px;
  min-height: 100vh;
  padding: 18px;
}

.siteHero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  align-items: center;
  gap: 24px;
  width: min(1280px, 100%);
  min-height: calc(100vh - 44px);
  margin: 0 auto;
  overflow: hidden;
}

.heroCopy {
  position: relative;
  z-index: 2;
}

.brandLink {
  display: inline-flex;
  color: #edf1e9;
  font-size: 16px;
  font-weight: 760;
  letter-spacing: 0;
  text-decoration: none;
}

.heroCopy h1,
.leaderboardLayout h1 {
  margin: 12px 0 0;
  color: #ffffff;
  font-size: clamp(42px, 8vw, 94px);
  line-height: 0.95;
}

.heroCopy p,
.leaderboardLayout > div:first-child p {
  max-width: 520px;
  margin-top: 14px;
  color: #cbd4c4;
  font-size: 18px;
  line-height: 1.5;
}

.languagePanel {
  display: flex;
  margin-top: 18px;
}

.languagePanel select {
  min-height: 38px;
  min-width: 96px;
  border: 1px solid rgba(237, 241, 233, 0.24);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(237, 241, 233, 0.08);
  color: #edf1e9;
  color-scheme: dark;
  font: inherit;
}

.languagePanel select option {
  background: #171b15;
  color: #edf1e9;
}

.languagePanel select option:checked {
  background: #273027;
  color: #ffffff;
}

.siteActions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.secondaryButton {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid rgba(237, 241, 233, 0.24);
  border-radius: 7px;
  padding: 0 14px;
  color: #edf1e9;
  background: rgba(237, 241, 233, 0.08);
  text-decoration: none;
}

.secondaryButton:hover {
  background: rgba(237, 241, 233, 0.14);
}

.accountPanel {
  display: grid;
  gap: 10px;
  max-width: 560px;
  margin-top: 20px;
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  padding: 12px;
  background: rgba(13, 17, 15, 0.7);
}

.accountStatus {
  color: #dbe3d4;
  font-size: 14px;
  font-weight: 650;
}

.accountFields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 8px;
}

.accountFields input {
  min-height: 40px;
  min-width: 0;
  border: 1px solid rgba(237, 241, 233, 0.24);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(237, 241, 233, 0.08);
  color: #edf1e9;
  font: inherit;
}

.accountFields input::placeholder {
  color: #899184;
}

#logoutButton {
  display: none;
  justify-self: start;
}

.accountPanel.signedIn .accountFields {
  display: none;
}

.accountPanel.signedIn #logoutButton {
  display: inline-flex;
}

.quickHelp {
  max-width: 560px;
  margin-top: 16px;
  border-left: 3px solid rgba(120, 230, 111, 0.72);
  padding: 2px 0 2px 14px;
}

.quickHelp h2 {
  margin: 0;
  color: #edf1e9;
  font-size: 15px;
  font-weight: 760;
}

.quickHelp ol {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: #dbe3d4;
  font-size: 13px;
  line-height: 1.4;
}

.quickHelp li::marker {
  color: #78e66f;
  font-weight: 760;
}

.quickHelp p {
  margin-top: 10px;
  color: #aebdab;
  font-size: 13px;
  line-height: 1.4;
}

.heroScene {
  position: relative;
  min-height: 520px;
}

.heroScene::before {
  position: absolute;
  inset: 8%;
  content: "";
  background-image:
    radial-gradient(circle, rgba(237, 241, 233, 0.72) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(237, 241, 233, 0.34) 0 1px, transparent 1.5px);
  background-position:
    0 0,
    38px 61px;
  background-size:
    92px 88px,
    126px 118px;
  opacity: 0.4;
}

.heroAsteroid,
.heroSeed,
.heroRoute {
  position: absolute;
  display: block;
}

.heroAsteroid {
  width: 112px;
  height: 112px;
  border: 1px solid rgba(237, 241, 233, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 38%, rgba(120, 230, 111, 0.42), transparent 28%),
    #273027;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.heroAsteroid i {
  position: absolute;
  width: 13px;
  height: 36px;
  left: 48%;
  top: 28%;
  border-radius: 8px;
  background: #d6d1a3;
}

.heroAsteroid i::after {
  position: absolute;
  width: 28px;
  height: 28px;
  left: -8px;
  top: -17px;
  border-radius: 50%;
  background: #78e66f;
  content: "";
}

.heroAsteroidA {
  left: 8%;
  top: 34%;
}

.heroAsteroidB {
  right: 14%;
  top: 16%;
  background:
    radial-gradient(circle at 42% 38%, rgba(240, 122, 98, 0.42), transparent 28%),
    #273027;
}

.heroAsteroidB i::after {
  background: #f07a62;
}

.heroAsteroidC {
  right: 24%;
  bottom: 15%;
  background:
    radial-gradient(circle at 42% 38%, rgba(116, 185, 255, 0.42), transparent 28%),
    #273027;
}

.heroAsteroidC i::after {
  background: #74b9ff;
}

.heroRoute {
  height: 2px;
  background: rgba(237, 241, 233, 0.14);
  transform-origin: left center;
}

.heroRouteA {
  left: 21%;
  top: 42%;
  width: 46%;
  transform: rotate(-18deg);
}

.heroRouteB {
  left: 28%;
  top: 52%;
  width: 42%;
  transform: rotate(24deg);
}

.heroSeed {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f3d35b;
  box-shadow: 0 0 22px #f3d35b;
}

.heroSeedA {
  left: 43%;
  top: 34%;
}

.heroSeedB {
  left: 50%;
  top: 54%;
}

.heroSeedC {
  right: 20%;
  bottom: 32%;
  background: #62b7ff;
  box-shadow: 0 0 22px #62b7ff;
}

.siteHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1040px, 100%);
  margin: 0 auto 28px;
}

.leaderboardLayout {
  display: grid;
  gap: 18px;
  width: min(1040px, 100%);
  margin: 0 auto;
}

.sectionLabel {
  color: #78e66f;
  font-size: 13px;
  font-weight: 760;
  text-transform: uppercase;
}

.profileSummary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(237, 241, 233, 0.14);
  border-bottom: 1px solid rgba(237, 241, 233, 0.14);
}

.profileRank {
  color: #ffffff;
  font-size: 18px;
  font-weight: 760;
}

.profileStats {
  color: #cbd4c4;
  font-size: 14px;
}

.leaderboardTable {
  display: grid;
  gap: 8px;
}

.leaderboardRow {
  display: grid;
  grid-template-columns: 44px minmax(120px, 1fr) minmax(110px, auto) minmax(160px, auto);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(13, 17, 15, 0.72);
}

.leaderboardPlace,
.leaderboardRank,
.leaderboardScore {
  color: #cbd4c4;
  font-size: 13px;
}

.leaderboardName {
  color: #ffffff;
  font-weight: 720;
}

.leaderboardScore {
  text-align: right;
}

.leaderboardEmpty {
  min-height: 90px;
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  padding: 28px 12px;
  color: #cbd4c4;
  text-align: center;
  background: rgba(13, 17, 15, 0.72);
}

.topbar,
.lobbyPanel,
.resultPanel,
.selectedPanel,
.hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(1280px, 100%);
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 720;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: #bac5b5;
  font-size: 14px;
}

.roomLine {
  color: #d7decf;
}

.profileLine {
  color: #aebdab;
  font-size: 13px;
}

.accountGameLine {
  color: #d7decf;
  font-size: 13px;
}

.roomLine strong {
  color: #ffffff;
  letter-spacing: 0.08em;
}

.controlPanel {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.actions,
.treePicker,
.cameraControls,
.lobbyControls,
.roomControls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.treePicker {
  gap: 6px;
}

.cameraControls {
  gap: 6px;
}

.roomControls {
  gap: 6px;
}

.shell.is-lobby .treePicker,
.shell.is-lobby #plantButton {
  display: none;
}

.lobbyControls {
  gap: 6px;
}

.lobbyControls input {
  min-height: 34px;
  border: 1px solid rgba(237, 241, 233, 0.24);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(237, 241, 233, 0.08);
  color: #edf1e9;
  font: inherit;
}

.lobbyControls input {
  width: 170px;
}

.cameraControls button {
  width: 42px;
  min-height: 34px;
  padding: 0;
  font-weight: 720;
}

.roomControls button {
  min-height: 34px;
}

#musicButton.active {
  border-color: rgba(120, 230, 111, 0.7);
  box-shadow: inset 0 -2px 0 #78e66f;
}

.treeOption {
  min-height: 34px;
  padding: 0 11px;
  color: #cbd4c4;
}

.treeOption.active {
  border-color: rgba(237, 241, 233, 0.62);
  background: rgba(237, 241, 233, 0.18);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--tree-color, #edf1e9);
}

.treeOption.unavailable {
  opacity: 0.52;
}

canvas {
  display: block;
  width: min(1280px, 100%);
  height: min(760px, calc(100vh - 292px));
  min-height: 320px;
  margin: 0 auto;
  border: 1px solid rgba(237, 241, 233, 0.16);
  border-radius: 8px;
  background: #11160f;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  touch-action: none;
  cursor: grab;
  user-select: none;
}

canvas.dragging {
  cursor: grabbing;
}

.shell.is-playing {
  display: block;
  min-height: 100vh;
  padding: 8px;
}

.shell.is-playing canvas {
  width: 100%;
  max-width: none;
  height: calc(100vh - 16px);
  max-height: none;
  margin: 0;
}

.shell.is-playing .topbar {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 5;
  width: auto;
  pointer-events: none;
}

.shell.is-playing .topbar > div:first-child {
  max-width: min(440px, calc(100vw - 20px));
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(13, 17, 15, 0.72);
  pointer-events: auto;
}

.shell.is-playing .brandLink,
.shell.is-playing .profileLine,
.shell.is-playing .accountGameLine,
.shell.is-playing .hint,
.shell.is-playing .lobbyControls,
.shell.is-playing .cameraControls,
.shell.is-playing .roomControls {
  display: none;
}

.shell.is-playing .roomLine {
  font-size: 12px;
}

.shell.is-playing #status {
  margin-top: 0;
  color: #edf1e9;
  font-size: 13px;
}

.shell.is-playing .controlPanel {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 6;
  display: none;
  width: min(740px, calc(100vw - 20px));
  transform: translateX(-50%);
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  padding: 8px;
  background: rgba(13, 17, 15, 0.82);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  pointer-events: auto;
}

.shell.is-playing.has-selection.controls-open .controlPanel {
  display: grid;
  justify-items: center;
}

.shell.is-playing .treePicker,
.shell.is-playing .actions {
  justify-content: center;
}

.shell.is-playing .selectedPanel {
  position: fixed;
  left: 50%;
  bottom: 58px;
  z-index: 6;
  display: none;
  width: min(740px, calc(100vw - 20px));
  max-height: 28vh;
  margin: 0;
  overflow: auto;
  transform: translateX(-50%);
  background: rgba(13, 17, 15, 0.82);
}

.shell.is-playing.controls-open .selectedPanel {
  bottom: 116px;
}

.shell.is-playing.has-selection .selectedPanel {
  display: flex;
}

.buildToggle {
  display: none;
}

.shell.is-playing.has-selection .buildToggle {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 136px;
  min-height: 40px;
  transform: translateX(-50%);
  border-color: rgba(120, 230, 111, 0.58);
  background: rgba(13, 17, 15, 0.86);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.shell.is-playing.controls-open .buildToggle {
  display: none;
}

.chatToggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 108px;
  min-height: 40px;
  border-color: rgba(116, 185, 255, 0.48);
  background: rgba(13, 17, 15, 0.88);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.34);
  flex: 0 0 auto;
}

.chatBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  padding: 0 6px;
  color: #0d1110;
  background: #74b9ff;
  font-size: 12px;
  font-weight: 760;
}

.chatBadge[hidden] {
  display: none;
}

.chatPanel {
  position: fixed;
  right: 18px;
  bottom: 70px;
  z-index: 8;
  display: none;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  max-height: min(430px, calc(100vh - 110px));
  border: 1px solid rgba(237, 241, 233, 0.16);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(13, 17, 15, 0.92);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

.chatPanel.active {
  display: flex;
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border-bottom: 1px solid rgba(237, 241, 233, 0.12);
  padding: 0 10px 0 12px;
}

.chatTitle {
  color: #edf1e9;
  font-size: 14px;
  font-weight: 720;
}

.chatClose {
  width: 32px;
  min-height: 32px;
  padding: 0;
  color: #cbd4c4;
  flex: 0 0 auto;
}

.chatMessages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  max-height: 310px;
  overflow-y: auto;
  padding: 10px;
}

.chatEmpty {
  display: grid;
  min-height: 96px;
  place-items: center;
  color: #9ea99a;
  font-size: 13px;
  text-align: center;
}

.chatMessage {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--chat-color, #edf1e9);
  border-radius: 7px;
  padding: 8px 9px;
  background: rgba(237, 241, 233, 0.06);
}

.chatMessage.own {
  background: rgba(116, 185, 255, 0.1);
}

.chatMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #9ea99a;
  font-size: 11px;
}

.chatName {
  min-width: 0;
  overflow: hidden;
  color: #edf1e9;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatText {
  overflow-wrap: anywhere;
  color: #dbe3d4;
  font-size: 13px;
  line-height: 1.35;
}

.chatForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid rgba(237, 241, 233, 0.12);
  padding: 10px;
}

.chatForm input {
  min-height: 36px;
  min-width: 0;
  border: 1px solid rgba(237, 241, 233, 0.24);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(237, 241, 233, 0.08);
  color: #edf1e9;
  font: inherit;
}

.chatForm button {
  min-height: 36px;
  flex: 0 0 auto;
}

.lobbyPanel {
  display: none;
  align-items: stretch;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  background: rgba(13, 17, 15, 0.78);
}

.lobbyPanel.active {
  display: flex;
}

.resultPanel {
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  background: rgba(13, 17, 15, 0.82);
}

.resultPanel.active {
  display: flex;
}

.resultTitle {
  color: #edf1e9;
  font-weight: 720;
  font-size: 15px;
}

.resultText {
  margin-top: 4px;
  color: #bac5b5;
  font-size: 13px;
}

.resultProgress {
  margin-top: 6px;
  color: #d7decf;
  font-size: 13px;
  font-weight: 650;
}

.winnerLine {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  color: #edf1e9;
  font-size: 13px;
  font-weight: 650;
}

.winnerSwatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--winner-color, #edf1e9);
  box-shadow: 0 0 12px var(--winner-color, #edf1e9);
}

.lobbyHeader {
  display: grid;
  gap: 4px;
}

.lobbyTitle {
  color: #edf1e9;
  font-weight: 720;
  font-size: 14px;
}

.lobbyHint {
  color: #bac5b5;
  font-size: 13px;
}

.playerList {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.playerBadge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid rgba(237, 241, 233, 0.16);
  border-radius: 7px;
  padding: 0 9px;
  color: #dbe3d4;
  background: rgba(237, 241, 233, 0.06);
  font-size: 13px;
}

.playerBadge.ready {
  border-color: rgba(120, 230, 111, 0.48);
}

.playerSwatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--player-color, #edf1e9);
}

.selectedPanel {
  min-height: 44px;
  justify-content: flex-start;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid rgba(237, 241, 233, 0.14);
  border-radius: 8px;
  background: rgba(13, 17, 15, 0.7);
}

.selectedTitle {
  color: #edf1e9;
  font-weight: 720;
  font-size: 14px;
}

.selectedStats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.statChip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  border: 1px solid rgba(237, 241, 233, 0.16);
  border-radius: 7px;
  padding: 0 8px;
  color: #dbe3d4;
  background: rgba(237, 241, 233, 0.06);
  font-size: 12px;
  white-space: nowrap;
}

.statDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color, #edf1e9);
}

.hint {
  justify-content: center;
  flex-wrap: wrap;
  color: #cbd4c4;
  font-size: 13px;
}

.hint span {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .sitePage {
    padding: 14px;
  }

  .siteHero {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 28px);
  }

  .heroCopy h1,
  .leaderboardLayout h1 {
    font-size: 48px;
  }

  .heroScene {
    min-height: 300px;
  }

  .accountFields {
    grid-template-columns: 1fr;
  }

  .heroAsteroid {
    width: 84px;
    height: 84px;
  }

  .leaderboardRow {
    grid-template-columns: 34px minmax(0, 1fr);
    min-height: 64px;
    padding: 8px 10px;
  }

  .leaderboardRank,
  .leaderboardScore {
    grid-column: 2;
    text-align: left;
  }

  .profileSummary {
    align-items: flex-start;
    flex-direction: column;
  }

  .siteHeader button {
    flex: 0 0 auto;
  }

  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .controlPanel,
  .actions,
  .treePicker,
  .cameraControls,
  .lobbyControls,
  .roomControls {
    width: 100%;
    justify-content: stretch;
    justify-items: stretch;
  }

  .cameraControls button,
  .lobbyControls input,
  .lobbyControls button,
  .roomControls button {
    flex: 1;
  }

  .chatToggle {
    right: 12px;
    bottom: 12px;
    min-width: 94px;
  }

  .chatPanel {
    right: 12px;
    bottom: 62px;
    width: calc(100vw - 24px);
    max-height: min(420px, calc(100vh - 82px));
  }

  .chatMessages {
    max-height: min(300px, calc(100vh - 176px));
  }

  button {
    flex: 1;
  }

  .chatToggle,
  .chatClose,
  .chatForm button {
    flex: 0 0 auto;
  }
}
