:root {
  color: #242424;
  font-family: Arial, Helvetica, sans-serif;
  background: #fbfbfa;
  --bg: #fbfbfa;
  --panel: #f4f4f2;
  --panel-strong: #ececea;
  --border: #b9b8b2;
  --border-strong: #8e8c86;
  --text-soft: #62615d;
  --danger: #b3261e;
  --danger-bg: #fff0ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

body.dark-mode {
  color: #eeeeeb;
  --bg: #20211f;
  --panel: #2a2b28;
  --panel-strong: #343530;
  --border: #555650;
  --border-strong: #777870;
  --text-soft: #aaa9a2;
}

button,
input,
select {
  font: inherit;
}

input[type="color"] {
  min-height: 44px;
  padding: 4px;
}

button {
  cursor: pointer;
}

.stage {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.top-bar {
  position: fixed;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.personal-counter,
.global-counter,
.achievement {
  color: #242424;
}

.personal-counter span,
.global-counter span {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.personal-counter strong,
.global-counter strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.tab-button,
.side-drawer button,
.admin-shell button {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: #202020;
  padding: 8px 12px;
}

.dots-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 52px;
  height: 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.dots-trigger span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #777772;
}

.dots-trigger:hover,
.tab-button:hover,
.side-drawer button:hover,
.admin-shell button:hover {
  background: var(--panel-strong);
}

.dots-trigger:hover {
  background: transparent;
}

.dots-trigger:hover span {
  background: #555550;
}

.button-wrap {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.global-button {
  width: clamp(96px, 20vw, 150px);
  aspect-ratio: 1;
  border: 2px solid #77756f;
  border-radius: 50%;
  background: #dededb;
}

.global-button:active {
  background: #d0d0cc;
}

.global-counter {
  min-height: 58px;
  text-align: center;
}

.side-drawer header,
.admin-header,
.inline-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.side-drawer h2,
.admin-card h2,
.admin-header h1 {
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
  background: #ffffff;
  color: #151515;
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle input {
  width: auto;
}

.stat-list {
  display: grid;
  gap: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #deddd8;
  padding-bottom: 10px;
}

.stat-row span {
  color: var(--text-soft);
}

.stats-drawer {
  position: fixed;
  top: 156px;
  left: -304px;
  z-index: 20;
  width: 344px;
  min-height: 260px;
  display: flex;
  transition: left 180ms ease;
}

.stats-drawer:hover,
.stats-drawer:focus-within,
.stats-drawer.is-open {
  left: 0;
}

.stats-handle {
  order: 2;
  align-self: flex-start;
  width: 40px;
  min-height: 94px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: var(--panel);
  color: var(--text-soft);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 13px;
  padding: 0;
  cursor: pointer;
}

.drawer-inner {
  width: 304px;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 18px;
}

.tab-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.account-mode {
  display: flex;
  gap: 8px;
}

.account-mode .tab-button {
  flex: 1;
}

.tab-button {
  flex: 1;
}

.tab-button.is-active {
  border-color: var(--border-strong);
  background: #e7e6e1;
}

.achievement-list {
  display: grid;
  gap: 10px;
}

.achievement-item {
  display: grid;
  gap: 4px;
  border: 1px solid #deddd8;
  border-radius: 6px;
  background: var(--bg);
  padding: 10px;
}

.achievement-item span,
.empty-state,
.field-note,
.small-note {
  color: var(--text-soft);
  font-size: 13px;
}

.field-note {
  margin: -4px 0 2px;
}

.field-note.is-valid {
  color: #276738;
}

.field-note.is-invalid {
  color: var(--danger);
}

.side-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  z-index: 30;
  width: min(360px, calc(100vw - 28px));
  height: 100vh;
  border-left: 1px solid var(--border);
  background: #ffffff;
  transition: right 180ms ease;
  visibility: hidden;
  pointer-events: none;
}

.side-drawer.is-open {
  right: 0;
  visibility: visible;
  pointer-events: auto;
}

.menu-drawer-inner {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 18px;
  width: 100%;
  height: 100%;
  overflow: auto;
}

.menu-section {
  display: grid;
  gap: 12px;
  border-top: 1px solid #deddd8;
  padding-top: 16px;
}

.menu-section h3 {
  margin: 0;
  font-size: 15px;
}

.logout-button {
  align-self: end;
  border-color: #d7a39e !important;
  background: var(--danger-bg) !important;
  color: var(--danger) !important;
}

.toast-stack {
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: min(320px, calc(100vw - 44px));
  pointer-events: none;
}

.achievement-toast {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  padding: 12px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 800ms ease, transform 800ms ease;
}

.achievement-toast span {
  color: var(--text-soft);
  font-size: 13px;
}

.achievement-toast.is-fading {
  opacity: 0;
  transform: translateY(8px);
}

.message,
#adminMessage,
#loginMessage {
  min-height: 20px;
  margin: 0;
  color: #5b5b5b;
}

.is-hidden {
  display: none !important;
}

.dark-mode .personal-counter,
.dark-mode .global-counter {
  color: #eeeeeb;
}

.dark-mode .global-button {
  border-color: #85867f;
  background: #555650;
}

.dark-mode .global-button:active {
  background: #62635d;
}

.dark-mode .drawer-inner,
.dark-mode .side-drawer,
.dark-mode .achievement-toast,
.dark-mode .achievement-item,
.dark-mode input,
.dark-mode select {
  background: #252623;
  color: #eeeeeb;
}

.dark-mode .side-drawer button,
.dark-mode .tab-button {
  color: #eeeeeb;
}

.dark-mode .tab-button.is-active {
  background: #41423d;
}

.dark-mode .dots-trigger span {
  background: #a5a69f;
}

.dark-mode .logout-button {
  background: #3c2422 !important;
  color: #ffb4ac !important;
}

.admin-page {
  background: var(--bg);
}

.admin-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.admin-header {
  margin-bottom: 20px;
  border-bottom: 1px solid #deddd8;
  padding-bottom: 16px;
}

.admin-header p {
  margin: 6px 0 0;
  color: #666666;
}

.admin-header a {
  color: #202020;
}

.admin-login,
.admin-card {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  padding: 18px;
}

.admin-login {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  gap: 12px;
  align-items: center;
}

.admin-login p {
  grid-column: 1 / -1;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.hero-metric {
  grid-column: 1 / -1;
  text-align: left;
  background: var(--panel);
}

.hero-metric span {
  display: block;
  color: var(--text-soft);
  font-size: 13px;
  text-transform: uppercase;
}

.hero-metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(28px, 4vw, 46px);
}

.admin-card:nth-of-type(3) {
  grid-row: span 2;
}

.admin-card h2 {
  border-bottom: 1px solid #deddd8;
  padding-bottom: 10px;
}

.metric-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e5e4df;
  padding-bottom: 8px;
}

.table-wrap {
  max-height: 420px;
  overflow: auto;
  margin-top: 12px;
  border: 1px solid #e5e4df;
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid #e5e4df;
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--panel);
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
}

.tester-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.tester-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid #e5e4df;
  padding-bottom: 8px;
}

.reset-card {
  border-color: #d7a39e;
}

.milestone-config {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  margin-top: 14px;
}

@media (max-width: 760px) {
  .admin-grid,
  .admin-login {
    grid-template-columns: 1fr;
  }

  .admin-header,
  .inline-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .top-bar {
    align-items: flex-start;
  }

  .stats-drawer {
    top: 166px;
    left: calc(-100vw + 76px);
    width: calc(100vw - 18px);
  }

  .stats-drawer:hover,
  .stats-drawer:focus-within,
  .stats-drawer.is-open {
    left: 0;
  }

  .drawer-inner {
    width: calc(100vw - 58px);
  }
}

/* ClickWorld experience polish */
button,
a,
input,
select,
textarea {
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 100ms ease, opacity 140ms ease;
}

button:active {
  transform: translateY(1px);
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 11px 12px;
  resize: vertical;
}

.notification-shell {
  position: relative;
  inset: auto;
  z-index: 120;
  flex: 0 0 auto;
  margin-left: auto;
}

.notification-panel {
  top: calc(100% + 10px);
  right: 0;
  bottom: auto;
  max-height: min(520px, calc(100vh - 90px));
  overflow: hidden;
}

.notification-list {
  max-height: 410px;
  overflow-y: auto;
}

.site-header .nav-toggle {
  margin-left: 8px;
}

.site-footer {
  width: min(1050px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 34px auto 100px;
  border-top: 1px solid var(--border);
  padding: 26px 0;
}

.site-footer > div {
  display: grid;
  gap: 5px;
}

.site-footer span,
.site-footer a {
  color: var(--text-soft);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 18px;
}

.site-footer a:hover {
  color: var(--accent);
}

.modern-panel,
.feedback-form {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.feedback-shell {
  max-width: 850px;
}

.feedback-form small {
  color: var(--text-soft);
}

.profile-page-shell {
  max-width: 1040px;
}

.profile-top-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.social-profile-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.profile-cover {
  height: 150px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--profile-accent) 35%, #11161d), color-mix(in srgb, var(--profile-accent) 10%, #202933)),
    repeating-linear-gradient(90deg, transparent 0 44px, rgba(255,255,255,.025) 44px 45px);
}

.profile-identity {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 0 26px 22px;
}

.profile-avatar-wrap {
  position: relative;
  flex: 0 0 auto;
  margin-top: -62px;
}

.profile-avatar-xl {
  width: 128px;
  height: 128px;
  border: 5px solid var(--panel);
  border-radius: 50%;
  object-fit: cover;
  font-size: 42px;
}

.avatar-edit-button {
  position: absolute;
  right: 2px;
  bottom: 4px;
  width: 36px;
  min-height: 36px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  color: #07140d;
  padding: 0;
  font-size: 22px;
}

.profile-name-block {
  min-width: 0;
}

.profile-name-block h1 {
  margin: 4px 0;
  font-size: clamp(28px, 5vw, 42px);
  overflow-wrap: anywhere;
}

.profile-name-block p,
.profile-name-block span {
  margin: 0;
  color: var(--text-soft);
}

.profile-name-block .profile-title {
  color: var(--profile-accent);
  font-size: 17px;
  font-weight: 700;
}

.profile-stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border);
}

.profile-stat-strip > div {
  display: grid;
  gap: 3px;
  padding: 20px 26px;
}

.profile-stat-strip > div + div {
  border-left: 1px solid var(--border);
}

.profile-stat-strip strong {
  font-size: 25px;
}

.profile-stat-strip span {
  color: var(--text-soft);
  font-size: 13px;
}

.profile-content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.profile-content-grid .profile-settings-panel {
  grid-column: 1 / -1;
}

.modern-panel > header {
  margin-bottom: 18px;
}

.modern-panel h2 {
  margin: 3px 0 0;
}

.profile-badge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-badge {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-strong);
  padding: 11px;
}

.profile-badge > span {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, var(--panel));
  color: var(--accent);
}

.crop-dialog {
  width: min(500px, calc(100% - 24px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
}

.crop-dialog::backdrop {
  background: rgba(3, 7, 12, 0.82);
}

.crop-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.crop-dialog header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.crop-dialog h2 {
  margin: 4px 0;
}

.crop-stage {
  width: min(320px, 100%);
  aspect-ratio: 1;
  justify-self: center;
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: 50%;
  touch-action: none;
}

.crop-stage canvas {
  width: 100%;
  height: 100%;
  cursor: move;
}

.crop-controls {
  display: grid;
  gap: 8px;
}

.crop-controls p {
  margin: 0;
  color: var(--text-soft);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.reaction-row button {
  min-height: 34px;
}

.pixel-world-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.world-toolbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.world-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.world-toolbar > div:first-child {
  display: grid;
  gap: 2px;
}

.world-toolbar span {
  color: var(--text-soft);
  font-size: 13px;
}

.world-toolbar button {
  min-width: 42px;
  min-height: 42px;
}

.pixel-world-viewport {
  height: min(68vh, 660px);
  overflow: hidden;
  background: #192028;
  touch-action: none;
  cursor: grab;
}

.pixel-world-viewport:active {
  cursor: grabbing;
}

.pixel-world-map {
  --tile: 42px;
  position: relative;
  width: calc(var(--world-width) * var(--tile));
  height: calc(var(--world-height) * var(--tile));
  min-width: 100%;
  min-height: 100%;
  transform-origin: top left;
  image-rendering: pixelated;
  background-color: var(--ground);
  background-image:
    linear-gradient(45deg, var(--ground-alt) 25%, transparent 25%, transparent 75%, var(--ground-alt) 75%),
    linear-gradient(45deg, var(--ground-alt) 25%, transparent 25%, transparent 75%, var(--ground-alt) 75%);
  background-position: 0 0, var(--tile) var(--tile);
  background-size: calc(var(--tile) * 2) calc(var(--tile) * 2);
}

.placed-world-object {
  position: absolute;
  left: calc(var(--x) * var(--tile));
  top: calc(var(--y) * var(--tile));
  z-index: var(--layer);
  display: grid;
  justify-items: center;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0;
}

.placed-world-object > span:last-child {
  max-width: 110px;
  margin-top: 4px;
  border-radius: 3px;
  background: rgba(10, 14, 18, 0.75);
  padding: 3px 6px;
  font-size: 11px;
}

.pixel-sprite {
  display: grid;
  grid-template-columns: repeat(var(--sprite-width), calc(var(--sprite-scale) * 1px));
  grid-auto-rows: calc(var(--sprite-scale) * 1px);
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(0,0,0,.18));
}

.pixel-sprite i {
  background: var(--pixel);
}

.pixel-sprite.is-locked {
  filter: grayscale(1) brightness(.35) opacity(.7);
}

.world-object-details {
  min-height: 130px;
  border-top: 1px solid var(--border);
  padding: 18px;
}

.world-object-details h2,
.world-object-details p {
  margin: 5px 0;
}

.sprite-editor-shell {
  display: grid;
  grid-template-columns: 160px minmax(280px, 1fr) minmax(160px, 260px);
  gap: 16px;
  margin: 20px 0;
}

.sprite-tools {
  display: grid;
  align-content: start;
  gap: 7px;
}

.sprite-canvas {
  --sprite-width: 8;
  width: min(100%, 520px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--sprite-width), 1fr);
  align-self: start;
  border: 1px solid var(--border);
  background-image: linear-gradient(45deg, #202733 25%, #161b22 25%, #161b22 75%, #202733 75%);
  background-size: 20px 20px;
  image-rendering: pixelated;
}

.sprite-canvas button {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 0;
  background: var(--pixel);
  padding: 0;
}

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

.sprite-frames button.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.sprite-preview {
  min-height: 130px;
  display: grid;
  place-items: center;
  margin-top: 8px;
  border: 1px solid var(--border);
  background: #26313a;
}

.layout-object-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.layout-object-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-strong);
  padding: 12px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.world-layout-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.world-admin-preview {
  min-height: 170px;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: 7px;
  background: #10151b;
  padding: 12px;
}

.mini-world {
  --tile: 12px;
  min-width: 0;
  min-height: 150px;
  transform: none;
}

.feedback-row {
  width: 100%;
  display: grid;
  text-align: left;
}

.feedback-row p {
  margin: 4px 0;
}

.feedback-screenshot {
  width: 100%;
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 6px;
  object-fit: contain;
  background: #0d1117;
}

[data-panel="simulation"] {
  border-top: 3px solid #ffd166;
}

@media (max-width: 900px) {
  .sprite-editor-shell {
    grid-template-columns: 1fr;
  }

  .sprite-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header {
    gap: 6px;
  }

  .notification-shell {
    margin-left: auto;
  }

  .notification-panel {
    position: fixed;
    top: 58px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 72px);
  }

  .site-footer,
  .site-footer nav,
  .profile-identity,
  .world-toolbar,
  .chat-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .site-footer nav {
    display: grid;
    justify-content: stretch;
  }

  .site-footer a {
    min-height: 42px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
  }

  .profile-cover {
    height: 110px;
  }

  .profile-identity {
    gap: 10px;
    padding: 0 18px 18px;
  }

  .profile-avatar-wrap {
    align-self: flex-start;
  }

  .profile-avatar-xl {
    width: 104px;
    height: 104px;
  }

  .profile-stat-strip,
  .profile-content-grid,
  .profile-badge-grid,
  .layout-object-grid {
    grid-template-columns: 1fr;
  }

  .profile-stat-strip > div + div {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .pixel-world-viewport {
    height: 56vh;
  }

  .world-toolbar > div:last-child {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  button,
  a,
  input,
  select,
  textarea {
    transition: none;
  }
}

/* ClickWorld launch polish */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-strong: #1d2430;
  --text: #f2f5f8;
  --text-soft: #9ba7b5;
  --border: #303946;
  --accent: #57d68d;
  --accent-strong: #35b978;
  --danger: #e25d68;
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0;
}

body:not(.dark-mode) {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-strong: #e9edf1;
  --text: #17202a;
  --text-soft: #647181;
  --border: #cbd3dc;
  color-scheme: light;
}

button,
input,
select,
textarea {
  min-height: 44px;
  max-width: 100%;
  border-radius: 6px;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  z-index: 80;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
  backdrop-filter: blur(10px);
}

.brand {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 20px;
  font-weight: 750;
  text-decoration: none;
}

.site-nav {
  display: flex;
  width: auto;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  overflow: visible;
  padding: 0;
}

.site-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  color: var(--text-soft);
  padding: 0 12px;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.is-active {
  background: var(--panel-strong);
  color: var(--text);
}

.nav-toggle {
  display: none;
  width: 44px;
  padding: 10px;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: currentColor;
  margin: 4px 0;
}

.home-shell,
.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.home-shell {
  padding: 64px 0 100px;
}

.home-hero {
  max-width: 760px;
  margin: 0 auto 42px;
  text-align: center;
}

.eyebrow {
  display: block;
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(36px, 7vw, 66px);
  font-weight: 780;
  line-height: 1.04;
}

.home-hero > p:last-child {
  max-width: 640px;
  margin: 20px auto 0;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.6;
}

.click-dashboard {
  display: grid;
  gap: 18px;
}

.click-core {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 30px;
}

.global-button {
  width: 210px;
  height: 210px;
  border: 2px solid #e8edf2;
  border-radius: 50%;
  background: #f7f9fb;
  box-shadow: 0 8px 0 #aeb8c2, 0 14px 28px rgba(0, 0, 0, 0.28);
  color: #111820;
  font-size: 32px;
  font-weight: 850;
  touch-action: manipulation;
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.global-button:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #aeb8c2, 0 7px 16px rgba(0, 0, 0, 0.25);
}

.global-button:disabled {
  cursor: wait;
  opacity: 0.92;
}

.click-feedback {
  min-height: 22px;
  margin: 18px 0 0;
  color: var(--accent);
}

.click-feedback.is-error {
  color: #f0a5aa;
}

.click-sync-notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: var(--panel);
  padding: 16px 18px;
}

.click-sync-notice strong {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.click-sync-notice p {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.counter-grid,
.milestone-grid,
.home-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.metric-card,
.goal-card,
.dashboard-panel,
.unlock-card,
.leaderboard-panel,
.vote-option,
.profile-summary,
.profile-section,
.locked-state {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 24px;
}

.metric-card span,
.goal-heading span,
.metric-card small,
.goal-card p,
.dashboard-panel p,
.unlock-card p,
.unlock-card small {
  color: var(--text-soft);
}

.metric-card strong {
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1;
}

.goal-card {
  padding: 22px;
}

.goal-heading,
.dashboard-panel header,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.goal-card h2,
.dashboard-panel h2,
.unlock-card h3 {
  margin: 10px 0;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--panel-strong);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.home-panels {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.dashboard-panel {
  min-width: 0;
  padding: 22px;
}

.dashboard-panel header {
  align-items: center;
}

.dashboard-panel header a {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
}

.activity-list,
.preview-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.activity-item,
.preview-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.activity-item span {
  color: var(--text-soft);
  font-size: 12px;
}

.preview-row {
  grid-template-columns: 24px minmax(0, 1fr) auto;
  color: inherit;
  text-decoration: none;
}

.unlock-section {
  margin-top: 58px;
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading > p {
  max-width: 480px;
  margin: 0;
  color: var(--text-soft);
  line-height: 1.5;
}

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

.unlock-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
}

.unlock-card h3,
.unlock-card p {
  margin-top: 0;
}

.unlock-card small {
  grid-column: 1 / -1;
}

.unlock-card.is-unlocked {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.lock-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-soft);
}

.is-unlocked .lock-mark {
  border-color: var(--accent);
  color: var(--accent);
}

.dots-trigger {
  position: fixed;
  z-index: 90;
  top: 76px;
  right: 22px;
  display: flex;
  width: 48px;
  height: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.dots-trigger span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d98a5;
}

.dots-trigger:hover {
  background: var(--panel);
}

.side-drawer {
  position: fixed;
  z-index: 120;
  inset: 0 0 0 auto;
  width: min(420px, 100%);
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg);
  box-shadow: -16px 0 45px rgba(0, 0, 0, 0.28);
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.side-drawer.is-open {
  transform: translateX(0);
}

.menu-drawer-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.menu-drawer-inner > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.menu-drawer-inner h2,
.menu-drawer-inner h3 {
  margin: 0;
}

.menu-section {
  display: grid;
  gap: 13px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.profile-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #092316;
  font-weight: 750;
  text-decoration: none;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
}

.field-note,
.small-note,
.message {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.45;
}

.field-note.is-invalid,
.message:not(:empty) {
  color: #f0a5aa;
}

.logout-button {
  margin-top: auto;
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.stats-drawer {
  position: fixed;
  z-index: 70;
  top: 50%;
  left: 0;
  width: min(370px, calc(100% - 45px));
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: var(--panel);
  transform: translate(-100%, -50%);
  transition: transform 180ms ease;
}

.stats-drawer.is-open {
  transform: translate(0, -50%);
}

.stats-handle {
  position: absolute;
  top: 50%;
  left: 100%;
  width: 46px;
  border-radius: 0 6px 6px 0;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
}

.stats-drawer .drawer-inner {
  max-height: 70vh;
  overflow-y: auto;
  padding: 18px;
}

.tab-row,
.account-mode {
  display: flex;
  gap: 6px;
}

.tab-button {
  flex: 1;
  padding: 0 10px;
}

.tab-button.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.stat-row,
.title-option,
.achievement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 13px 0;
}

.achievement-item,
.title-option {
  width: 100%;
  align-items: flex-start;
  flex-direction: column;
}

.toast-stack {
  position: fixed;
  z-index: 140;
  bottom: 18px;
  left: 18px;
  display: grid;
  width: min(360px, calc(100% - 36px));
  gap: 10px;
}

.achievement-toast {
  display: grid;
  gap: 4px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--panel);
  padding: 16px;
  transition: opacity 800ms ease;
}

.achievement-toast.is-fading {
  opacity: 0;
}

.social-mini {
  position: fixed;
  z-index: 65;
  right: 18px;
  bottom: 18px;
  width: min(340px, calc(100% - 36px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.28);
}

.social-mini header,
.mini-compose {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
}

.social-mini header {
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.mini-messages {
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 12px;
}

.mini-message {
  display: grid;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
}

.mini-compose input {
  min-width: 0;
}

.page-shell {
  padding: 42px 0 80px;
}

.page-heading {
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 7vw, 48px);
}

.page-heading p {
  color: var(--text-soft);
}

.leaderboard-grid {
  gap: 18px;
}

.leaderboard-panel,
.vote-option,
.profile-summary,
.profile-section,
.locked-state {
  padding: 20px;
}

.leader-row {
  min-width: 0;
  border-color: var(--border);
}

.leader-row > span:nth-of-type(2) {
  min-width: 0;
}

.leader-row strong,
.leader-row b {
  overflow-wrap: anywhere;
}

.milestone-row {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 6px;
}

.milestone-row.is-reached {
  border-left-color: var(--accent);
}

.world-scene {
  width: 100%;
  min-height: clamp(360px, 60vw, 620px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.vote-option button,
.form-grid > button {
  border-color: var(--accent);
  background: var(--accent);
  color: #092316;
  font-weight: 750;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .home-panels,
  .unlock-grid {
    grid-template-columns: 1fr 1fr;
  }

  .home-panels > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: 58px;
    align-items: center;
    flex-direction: row;
    padding: 0 16px;
  }

  .nav-toggle {
    display: block;
    margin-left: auto;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    width: 100%;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 10px 14px 14px;
  }

  .site-nav.is-open {
    display: grid;
  }

  .site-nav a {
    width: 100%;
  }

  .home-shell,
  .page-shell {
    width: min(100% - 28px, 1180px);
  }

  .home-shell {
    padding: 38px 0 90px;
  }

  .home-hero {
    margin-bottom: 28px;
    text-align: left;
  }

  .home-hero h1 {
    font-size: 42px;
  }

  .home-hero > p:last-child {
    margin-left: 0;
    font-size: 16px;
  }

  .click-core {
    min-height: 230px;
    padding: 20px;
  }

  .global-button {
    width: 164px;
    height: 164px;
    font-size: 27px;
  }

  .counter-grid,
  .milestone-grid,
  .home-panels,
  .unlock-grid,
  .leaderboard-grid,
  .vote-grid {
    grid-template-columns: 1fr;
  }

  .home-panels > :first-child {
    grid-column: auto;
  }

  .metric-card,
  .goal-card,
  .dashboard-panel {
    padding: 18px;
  }

  .section-heading,
  .goal-heading,
  .dashboard-panel header {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-panel header a {
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .dots-trigger {
    top: 65px;
    right: 8px;
  }

  .side-drawer {
    width: 100%;
    border-left: 0;
  }

  .menu-drawer-inner {
    padding: 18px;
  }

  .stats-drawer {
    inset: auto 0 0;
    width: 100%;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
    transform: translateY(calc(100% - 44px));
  }

  .stats-drawer.is-open {
    transform: translateY(0);
  }

  .stats-handle {
    position: static;
    width: 100%;
    border-radius: 7px 7px 0 0;
    transform: none;
    writing-mode: horizontal-tb;
  }

  .stats-drawer .drawer-inner {
    max-height: 65vh;
  }

  .social-mini {
    right: 10px;
    bottom: 52px;
    width: calc(100% - 20px);
  }

  .leader-row {
    grid-template-columns: 28px 36px minmax(0, 1fr);
  }

  .leader-row b {
    grid-column: 3;
    justify-self: start;
  }

  .milestone-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .profile-summary {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .profile-clicks {
    grid-column: 1 / -1;
  }

  .chat-shell {
    height: calc(100dvh - 58px);
  }

  .chat-header,
  .chat-messages,
  .chat-compose {
    padding-right: 14px;
    padding-left: 14px;
  }
}

@media (max-width: 380px) {
  .home-hero h1 {
    font-size: 36px;
  }

  .global-button {
    width: 148px;
    height: 148px;
  }

  .tab-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab-button {
    font-size: 12px;
    padding: 0 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.admin-page {
  background: var(--bg);
  color: var(--text);
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 70px;
}

.admin-header,
.admin-card,
.admin-login {
  border-color: var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.admin-header {
  margin-bottom: 18px;
  padding: 20px;
}

.admin-header h1,
.admin-card h2 {
  margin-top: 0;
}

.admin-grid {
  gap: 16px;
}

.admin-card,
.admin-login {
  padding: 20px;
}

.metric-row,
.tester-row {
  border-color: var(--border);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-color: var(--border);
  padding: 11px;
  text-align: left;
}

@media (max-width: 760px) {
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

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

  .inline-tools {
    align-items: stretch;
    flex-direction: column;
  }
}

.site-header {
  position: relative;
  z-index: 15;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0 28px;
}

.brand {
  color: inherit;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 18px;
}

.site-nav a,
.text-button,
.profile-link {
  color: var(--text-soft);
  text-decoration: none;
}

.site-nav a:hover,
.text-button:hover,
.profile-link:hover {
  color: inherit;
}

.clickworld-stage {
  min-height: calc(100vh - 64px);
}

.clickworld-stage .top-bar {
  top: 82px;
}

.global-button {
  display: grid;
  place-items: center;
  color: #262724;
  font-size: 18px;
  font-weight: 700;
}

.dark-mode .global-button {
  color: #ffffff;
}

.title-list {
  display: grid;
  gap: 8px;
}

.title-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  padding: 10px;
  text-align: left;
}

.title-option span {
  color: var(--text-soft);
  font-size: 12px;
}

.title-option.is-selected {
  border-color: #6f8cff;
}

.profile-link {
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  padding: 10px 12px;
  text-align: center;
}

.social-mini {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 25;
  width: min(340px, calc(100vw - 40px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.dark-mode .social-mini {
  background: #252623;
}

.social-mini > header {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.social-mini > header > span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.social-mini a {
  color: var(--text-soft);
}

.mini-messages {
  display: grid;
  gap: 8px;
  min-height: 90px;
  max-height: 160px;
  overflow: auto;
  padding: 10px 12px;
}

.mini-message {
  display: grid;
  gap: 2px;
}

.mini-message span {
  color: var(--text-soft);
  font-size: 13px;
}

.mini-compose,
.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 10px;
}

.page-shell {
  width: min(1100px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.page-heading h1,
.chat-header h1 {
  margin: 4px 0 0;
  font-size: clamp(30px, 5vw, 52px);
}

.eyebrow {
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
}

.profile-layout,
.leaderboard-grid {
  display: grid;
  gap: 16px;
}

.profile-summary,
.profile-section,
.leaderboard-panel,
.progress-section,
.vote-option,
.locked-state {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 20px;
}

.dark-mode .profile-summary,
.dark-mode .profile-section,
.dark-mode .leaderboard-panel,
.dark-mode .progress-section,
.dark-mode .vote-option,
.dark-mode .locked-state {
  background: #252623;
}

.profile-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
}

.profile-summary.badge-border {
  border: 2px solid #6f8cff;
}

.profile-summary h2,
.profile-section h2,
.leaderboard-panel h2,
.vote-option h2 {
  margin-top: 0;
}

.profile-title {
  color: #6f8cff;
  font-weight: 700;
}

.profile-clicks {
  font-size: 24px;
}

.profile-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-avatar.large {
  width: 92px;
  height: 92px;
  font-size: 32px;
}

.profile-avatar.small {
  width: 34px;
  height: 34px;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: var(--profile-color);
  color: #ffffff;
  font-weight: 700;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  padding: 6px 10px;
  font-size: 13px;
}

.world-scene {
  min-height: 440px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #d9e5ec;
  overflow: hidden;
}

.dark-mode .world-scene {
  background: #252c30;
}

.world-ground {
  position: relative;
  width: 100%;
  height: 440px;
  border-bottom: 110px solid #789563;
}

.world-object {
  position: absolute;
  bottom: -70px;
}

.tree {
  left: 18%;
  width: 34px;
  height: 110px;
  background: #6a4e39;
}

.tree span {
  position: absolute;
  left: -40px;
  top: -55px;
  width: 115px;
  height: 105px;
  border-radius: 50%;
  background: #4d7c49;
}

.campfire {
  left: 48%;
  width: 56px;
  height: 38px;
  background: #d85d32;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.village {
  right: 15%;
  display: flex;
  align-items: end;
  gap: 8px;
}

.village span {
  width: 62px;
  height: 70px;
  background: #c5aa7a;
  clip-path: polygon(50% 0, 100% 35%, 100% 100%, 0 100%, 0 35%);
}

.leaderboard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.leader-row {
  display: grid;
  grid-template-columns: 26px 34px 1fr auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--border);
  color: inherit;
  padding: 10px 0;
  text-decoration: none;
}

.leader-row small {
  display: block;
  color: var(--text-soft);
}

.rank {
  color: var(--text-soft);
}

.milestone-timeline {
  display: grid;
  gap: 12px;
}

.milestone-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 18px;
  border-left: 3px solid var(--border);
  background: var(--panel);
  padding: 18px;
  opacity: 0.55;
}

.milestone-row.is-reached {
  border-left-color: #6f8cff;
  opacity: 1;
}

.milestone-row h2,
.milestone-row p {
  margin: 0;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.vote-option {
  display: grid;
  gap: 16px;
}

.chat-page {
  overflow: hidden;
}

.chat-shell {
  height: calc(100vh - 64px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
}

.chat-messages {
  overflow: auto;
  padding: 18px max(20px, calc((100vw - 900px) / 2));
}

.chat-message {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
}

.chat-message > div > header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chat-message header a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.chat-message header span {
  color: #6f8cff;
  font-size: 12px;
}

.chat-message time {
  color: var(--text-soft);
  font-size: 11px;
}

.chat-message p {
  margin: 4px 0;
  line-height: 1.45;
}

.reaction-row {
  display: flex;
  gap: 6px;
}

.reaction-row button {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: inherit;
  padding: 4px 7px;
  font-size: 12px;
}

.chat-compose {
  padding: 14px max(20px, calc((100vw - 900px) / 2));
}

.chat-compose.is-disabled {
  opacity: 0.55;
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px;
  }

  .site-nav {
    width: 100%;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .clickworld-stage {
    min-height: calc(100vh - 108px);
  }

  .clickworld-stage .top-bar {
    top: 126px;
  }

  .leaderboard-grid,
  .vote-grid {
    grid-template-columns: 1fr;
  }

  .profile-summary {
    grid-template-columns: auto 1fr;
  }

  .profile-clicks {
    grid-column: 1 / -1;
  }

  .page-heading,
  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Final cascade guard for the launch header and mobile shell. */
html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: 64px;
  align-items: center;
  flex-direction: row;
  justify-content: flex-start;
  gap: 28px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
}

.site-nav {
  width: auto;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  overflow: visible;
  padding: 0;
}

.site-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 0 12px;
}

.site-nav a:hover,
.site-nav a.is-active {
  background: var(--panel-strong);
  color: var(--text);
}

.nav-toggle {
  display: none;
}

.is-locked .lock-mark {
  font-size: 0;
}

.is-locked .lock-mark::before,
.locked-state .lock-mark::before {
  width: 10px;
  height: 8px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 2px;
  content: "";
}

.is-locked .lock-mark::after,
.locked-state .lock-mark::after {
  position: absolute;
  width: 7px;
  height: 7px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  content: "";
  transform: translateY(-7px);
}

.lock-mark {
  position: relative;
}

.locked-state .lock-mark {
  font-size: 0;
}

@media (max-width: 760px) {
  .site-header {
    min-height: 58px;
    align-items: center;
    flex-direction: row;
    gap: 12px;
    padding: 0 16px;
  }

  .nav-toggle {
    display: block;
    margin-left: auto;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    width: 100%;
    gap: 4px;
    margin: 0;
    overflow: visible;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 10px 14px 14px;
  }

  .site-nav.is-open {
    display: grid;
  }

  .site-nav a {
    width: 100%;
    padding: 0 12px;
  }

  .page-heading {
    padding-top: 4px;
  }
}

/* Secure admin dashboard */
.admin-page {
  min-height: 100vh;
  background: #0d1117;
  color: #f2f5f8;
}

.admin-auth-shell {
  width: min(100% - 32px, 440px);
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 20px;
  margin: 0 auto;
}

.admin-login-card {
  display: grid;
  gap: 18px;
  border: 1px solid #303946;
  border-radius: 8px;
  background: #161b22;
  padding: 28px;
}

.admin-login-card h1,
.admin-login-card p {
  margin: 0;
}

.admin-login-card > p {
  color: #9ba7b5;
  line-height: 1.5;
}

.admin-login-form {
  display: grid;
  gap: 14px;
}

.admin-login-form label {
  display: grid;
  gap: 7px;
  color: #b8c2ce;
  font-size: 13px;
}

.admin-login-form button,
.admin-editor button[type="submit"],
.settings-form > button {
  border-color: #57d68d;
  background: #57d68d;
  color: #092316;
  font-weight: 750;
}

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  z-index: 110;
  top: 0;
  height: 100vh;
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid #303946;
  background: #11161d;
  padding: 18px 12px;
}

.admin-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 8px 18px;
}

.admin-brand-row > span {
  border: 1px solid #3d4a58;
  border-radius: 4px;
  color: #9ba7b5;
  padding: 3px 7px;
  font-size: 11px;
  text-transform: uppercase;
}

.admin-nav {
  display: grid;
  gap: 3px;
  overflow-y: auto;
}

.admin-nav button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: #9ba7b5;
  padding: 0 12px;
  text-align: left;
}

.admin-nav button:hover,
.admin-nav button.is-active {
  background: #1d2430;
  color: #f2f5f8;
}

.admin-nav button.is-active {
  box-shadow: inset 3px 0 #57d68d;
}

.admin-sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid #303946;
  padding: 16px 8px 0;
}

.admin-sidebar-footer span {
  color: #9ba7b5;
  font-size: 13px;
}

.admin-sidebar-footer a {
  color: #57d68d;
  font-size: 13px;
}

.admin-mobile-header {
  display: none;
}

.admin-main {
  width: min(100% - 48px, 1380px);
  min-width: 0;
  margin: 0 auto;
  padding: 36px 0 80px;
}

.admin-section {
  display: none;
}

.admin-section.is-active {
  display: block;
}

.admin-page-heading,
.admin-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.admin-page-heading {
  margin-bottom: 22px;
}

.admin-page-heading h1,
.admin-card-header h2 {
  margin: 0;
}

.admin-page-heading > p {
  max-width: 460px;
  margin: 0;
  color: #9ba7b5;
}

.admin-page-heading > button {
  border-color: #57d68d;
  color: #57d68d;
}

.admin-flash {
  position: fixed;
  z-index: 150;
  top: 18px;
  right: 18px;
  max-width: min(380px, calc(100% - 36px));
  margin: 0;
  border-radius: 6px;
  background: #173526;
  color: #baf5d3;
  padding: 12px 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.admin-flash:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

.admin-flash.is-error {
  background: #462126;
  color: #ffc7cb;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.admin-summary-card,
.admin-card {
  min-width: 0;
  border: 1px solid #303946;
  border-radius: 8px;
  background: #161b22;
}

.admin-summary-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.admin-summary-card span {
  color: #9ba7b5;
  font-size: 13px;
}

.admin-summary-card strong {
  font-size: clamp(24px, 3vw, 38px);
}

.admin-card {
  padding: 20px;
}

.admin-card h2 {
  margin: 0 0 16px;
  border: 0;
  padding: 0;
  font-size: 18px;
}

.admin-content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-span-two {
  grid-column: 1 / -1;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-list-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #303946;
  padding: 11px 0;
}

.admin-list-row:last-child {
  border-bottom: 0;
}

.admin-list-row > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.admin-list-row span,
.admin-list-row time {
  color: #9ba7b5;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-list-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid #303946;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.admin-list-button:hover {
  background: #1d2430;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #596574;
}

.status-dot.is-on {
  background: #57d68d;
}

.admin-search {
  width: min(360px, 100%);
}

.responsive-table {
  max-width: 100%;
  overflow-x: auto;
}

.responsive-table table {
  min-width: 760px;
}

.responsive-table td:first-child {
  display: grid;
  gap: 3px;
}

.responsive-table small {
  color: #9ba7b5;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #3d4a58;
  border-radius: 999px;
  color: #b8c2ce;
  padding: 4px 8px;
  font-size: 11px;
  text-transform: capitalize;
}

.status-pill.is-admin {
  border-color: #57d68d;
  color: #8cf0b7;
}

.status-pill.is-danger {
  border-color: #e25d68;
  color: #ff9fa7;
}

.user-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.user-detail-grid > div {
  min-width: 0;
  display: grid;
  gap: 5px;
  border: 1px solid #303946;
  border-radius: 6px;
  padding: 12px;
}

.user-detail-grid span {
  color: #9ba7b5;
  font-size: 12px;
}

.user-detail-grid strong {
  overflow-wrap: anywhere;
}

.admin-action-grid {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-action-grid label {
  min-width: 180px;
  flex: 1;
}

.admin-live-total {
  color: #57d68d;
  font-size: clamp(26px, 5vw, 48px);
}

.admin-editor-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(420px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.admin-editor-layout > .admin-list {
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  border: 1px solid #303946;
  border-radius: 8px;
  background: #161b22;
  padding: 8px 14px;
}

.admin-editor {
  position: sticky;
  top: 20px;
}

.form-grid.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-field {
  grid-column: 1 / -1;
}

.admin-editor textarea,
.settings-form textarea {
  resize: vertical;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.danger-button {
  border-color: #e25d68 !important;
  background: #462126 !important;
  color: #ffc7cb !important;
}

.danger-zone {
  margin-top: 20px;
  border-color: #7b3940;
}

.badge-live-preview,
.world-live-preview {
  display: grid;
  min-height: 100px;
  place-items: center;
  margin-top: 18px;
  border: 1px dashed #3d4a58;
  border-radius: 7px;
  background: #11161d;
  padding: 18px;
}

.badge-live-preview span {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--badge-border);
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 7px 13px;
}

.badge-live-preview b {
  color: var(--badge);
}

.world-live-preview article {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 13px;
  border: 1px solid var(--item-color);
  border-radius: 7px;
  background: #161b22;
  padding: 15px;
}

.world-live-preview article > strong {
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--item-color) 18%, #161b22);
  color: var(--item-color);
}

.world-live-preview p {
  margin: 5px 0 0;
  color: #9ba7b5;
}

.settings-form {
  display: grid;
  gap: 20px;
}

.admin-confirm-dialog {
  width: min(440px, calc(100% - 30px));
  border: 1px solid #3d4a58;
  border-radius: 8px;
  background: #161b22;
  color: #f2f5f8;
  padding: 0;
}

.admin-confirm-dialog::backdrop {
  background: rgba(4, 8, 12, 0.76);
  backdrop-filter: blur(3px);
}

.admin-confirm-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.admin-confirm-dialog h2,
.admin-confirm-dialog p {
  margin: 0;
}

.admin-confirm-dialog p {
  color: #9ba7b5;
  line-height: 1.5;
}

.admin-confirm-dialog label {
  display: grid;
  gap: 7px;
  color: #b8c2ce;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .admin-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .admin-app {
    display: block;
  }

  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    height: 100dvh;
    box-shadow: 18px 0 45px rgba(0, 0, 0, 0.4);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-mobile-header {
    position: sticky;
    z-index: 90;
    top: 0;
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #303946;
    background: #11161d;
    padding: 0 14px;
  }

  .admin-main {
    width: min(100% - 28px, 1380px);
    padding-top: 24px;
  }

  .admin-editor-layout {
    grid-template-columns: 1fr;
  }

  .admin-editor-layout > .admin-list {
    max-height: 340px;
  }

  .admin-editor {
    position: static;
  }
}

@media (max-width: 620px) {
  .admin-summary-grid,
  .admin-content-grid,
  .form-grid.two-column,
  .user-detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-span-two,
  .full-field {
    grid-column: auto;
  }

  .admin-page-heading,
  .admin-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-search {
    width: 100%;
  }

  .admin-card,
  .admin-login-card {
    padding: 16px;
  }

  .admin-action-grid {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-action-grid > * {
    width: 100%;
  }

  .admin-list-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-list-button {
    align-items: center;
    flex-direction: row;
  }
}

.announcement-banner {
  position: relative;
  z-index: 85;
  border-bottom: 1px solid var(--announcement-color);
  background: color-mix(in srgb, var(--announcement-color) 14%, var(--bg));
  color: var(--text);
  padding: 10px 18px;
  text-align: center;
}

.managed-world-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-self: stretch;
  padding: 20px;
}

.managed-world-grid article {
  display: grid;
  min-width: 0;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--world-accent);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.managed-world-grid article > strong {
  display: grid;
  min-height: 58px;
  place-items: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--world-accent) 16%, var(--panel));
  color: var(--world-accent);
}

.managed-world-grid article > img {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
}

.managed-world-grid h2,
.managed-world-grid p {
  margin: 0;
}

.managed-world-grid p {
  margin-top: 6px;
  color: var(--text-soft);
}

@media (max-width: 520px) {
  .managed-world-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}

/* Launch support systems */
.notification-shell {
  position: fixed;
  z-index: 130;
  top: 9px;
  right: 14px;
}

.notification-button {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  min-height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--panel);
}

.bell-mark {
  width: 15px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 4px 4px;
}

.notification-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
}

.notification-count.is-empty {
  display: none;
}

.notification-panel {
  position: absolute;
  top: 52px;
  right: 0;
  width: min(380px, calc(100vw - 28px));
  display: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
}

.notification-shell.is-open .notification-panel {
  display: block;
}

.notification-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 14px;
}

.notification-panel h2 {
  margin: 0;
  font-size: 17px;
}

.mark-all-read {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
}

.notification-list {
  max-height: min(520px, 70vh);
  overflow-y: auto;
}

.notification-item {
  width: 100%;
  display: grid;
  gap: 5px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 13px 15px;
  text-align: left;
}

.notification-item.is-unread {
  box-shadow: inset 3px 0 var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.notification-item span,
.notification-item time {
  color: var(--text-soft);
  font-size: 12px;
}

.community-progress-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 20px;
  padding: 20px;
}

.community-progress-card h2,
.community-progress-card p {
  margin: 0;
}

.community-progress-card > strong {
  color: var(--text-soft);
}

.news-toolbar,
.history-filter-row,
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

.news-toolbar {
  margin-bottom: 14px;
}

.news-toolbar input {
  flex: 1;
}

.news-feed {
  height: min(66vh, 760px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  scroll-behavior: smooth;
}

.news-day-group {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.news-day-group > h2 {
  position: sticky;
  z-index: 2;
  top: -16px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-soft);
  padding: 10px 2px;
  font-size: 13px;
}

.news-post {
  display: grid;
  gap: 10px;
  border-left: 3px solid var(--event-color);
  background: var(--panel-strong);
  padding: 15px;
}

.news-post.is-pinned {
  outline: 1px solid var(--event-color);
}

.news-post header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
}

.news-post header > span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--event-color) 16%, var(--panel));
  color: var(--event-color);
  font-size: 11px;
}

.news-post header > div {
  display: grid;
  gap: 3px;
}

.news-post small,
.news-post p {
  color: var(--text-soft);
}

.news-post p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.news-preview-item {
  text-decoration: none;
}

.pager {
  justify-content: center;
  margin-top: 14px;
}

.pager span {
  color: var(--text-soft);
  font-size: 13px;
}

.pager button:disabled {
  opacity: 0.4;
  cursor: default;
}

.history-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.history-index {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 15px;
}

.history-index label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 12px;
}

.history-index h2 {
  margin: 4px 0 0;
  font-size: 15px;
}

.history-index nav {
  display: grid;
  gap: 4px;
}

.history-index button {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
}

.history-index button.is-active,
.history-index button:hover {
  background: var(--panel-strong);
  color: var(--text);
}

.history-filter-row {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.history-timeline {
  display: grid;
  gap: 12px;
}

.history-event {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 15px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--event-color);
  border-radius: 7px;
  background: var(--panel);
  padding: 17px;
}

.history-event-icon {
  display: grid;
  min-height: 54px;
  place-items: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--event-color) 14%, var(--panel));
  color: var(--event-color);
  font-size: 12px;
}

.history-event h2,
.history-event p {
  margin: 4px 0;
}

.history-event > div:last-child > span,
.history-event time,
.history-event small {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
}

.tour-dialog {
  width: min(520px, calc(100% - 28px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
}

.tour-dialog::backdrop {
  background: rgba(4, 8, 12, 0.78);
}

.tour-dialog form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.tour-dialog h2,
.tour-dialog ol {
  margin: 0;
}

.tour-dialog li {
  margin: 9px 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.event-live-preview {
  min-height: 100px;
  display: grid;
  place-items: center;
  margin-top: 18px;
  border: 1px dashed #3d4a58;
  border-radius: 7px;
  background: #11161d;
  padding: 18px;
}

.event-live-preview article {
  width: min(100%, 500px);
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 13px;
  border-left: 3px solid var(--event-color);
  background: #1d2430;
  padding: 14px;
}

.event-live-preview article > strong {
  display: grid;
  place-items: center;
  color: var(--event-color);
}

.event-live-preview p {
  margin: 5px 0 0;
  color: #9ba7b5;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.analytics-wide {
  grid-column: 1 / -1;
}

.bar-chart {
  height: 240px;
  display: flex;
  align-items: end;
  gap: 5px;
  overflow-x: auto;
  padding-top: 20px;
}

.bar-chart > div {
  min-width: 30px;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  gap: 4px;
  text-align: center;
}

.bar-chart i {
  height: var(--bar);
  min-height: 2px;
  display: block;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.bar-chart span,
.bar-chart strong {
  color: var(--text-soft);
  font-size: 10px;
}

.compact-bars {
  display: grid;
  gap: 7px;
}

.compact-bars > div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}

.compact-bars i {
  height: 7px;
  display: block;
  border-radius: 4px;
  background: var(--accent);
}

.empty-state {
  color: var(--text-soft);
  line-height: 1.5;
}

@media (min-width: 901px) {
  .home-panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-panels > :first-child {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .notification-shell {
    top: 7px;
    right: 65px;
  }

  .news-toolbar,
  .history-filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .history-layout {
    grid-template-columns: 1fr;
  }

  .history-index {
    position: static;
  }

  .history-index nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .history-index button {
    flex: 0 0 auto;
  }

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

  .analytics-wide {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .history-event {
    grid-template-columns: 1fr;
  }

  .history-event-icon {
    min-height: 40px;
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  .site-header {
    min-height: 58px;
    padding: 0 16px;
  }

  .nav-toggle {
    display: block;
    margin-left: auto;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    width: 100%;
    gap: 4px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 10px 14px 14px;
  }

  .site-nav.is-open {
    display: grid;
  }

  .site-nav a {
    width: 100%;
  }

  .notification-shell {
    top: 7px;
    right: 65px;
  }
}

@media (max-width: 760px) {
  .stats-drawer {
    inset: auto auto 22% 0;
    width: 48px;
    min-height: 0;
    height: 88px;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    border-left: 0;
    border-radius: 0 7px 7px 0;
    transform: none;
    overflow: hidden;
  }

  .stats-drawer:not(.is-open) {
    height: 88px;
  }

  .stats-drawer:not(.is-open) .drawer-inner {
    display: none;
  }

  .stats-drawer.is-open {
    inset: auto 0 0;
    width: 100%;
    height: auto;
    border-right: 0;
    border-radius: 8px 8px 0 0;
    transform: none;
  }

  .stats-handle {
    position: static;
    width: 48px;
    min-height: 88px;
    border-radius: 0 7px 7px 0;
    transform: none;
    writing-mode: vertical-rl;
  }

  .stats-drawer.is-open .stats-handle {
    width: 100%;
    min-height: 44px;
    border-radius: 7px 7px 0 0;
    writing-mode: horizontal-tb;
  }

  .stats-drawer .drawer-inner {
    width: 100%;
    max-height: 62vh;
    overflow-y: auto;
  }

  .social-mini {
    position: static;
    width: auto;
    margin: 12px 8px 0;
    border-radius: 7px;
  }

  .social-mini .mini-messages,
  .social-mini .mini-compose {
    display: none;
  }
}

/* Final component precedence */
.site-header .notification-shell {
  position: relative;
  inset: auto;
  z-index: 120;
  flex: 0 0 auto;
  margin-left: auto;
}

.site-header .notification-panel {
  top: calc(100% + 10px);
  right: 0;
  bottom: auto;
  max-height: min(520px, calc(100vh - 90px));
}

.social-profile-card,
.modern-panel,
.feedback-form,
.pixel-world-panel {
  border-radius: 8px;
  background: var(--panel);
}

.profile-content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.pixel-world-viewport {
  overflow: hidden;
  background: #192028;
}

.pixel-world-map {
  position: relative;
  width: calc(var(--world-width) * var(--tile));
  height: calc(var(--world-height) * var(--tile));
}

.pixel-sprite {
  display: grid;
  grid-template-columns: repeat(var(--sprite-width), calc(var(--sprite-scale) * 1px));
  grid-auto-rows: calc(var(--sprite-scale) * 1px);
}

@media (max-width: 760px) {
  .site-header .notification-shell {
    top: auto;
    right: auto;
    margin-left: auto;
  }

  .site-header .notification-panel {
    position: fixed;
    top: 58px;
    right: 8px;
    left: 8px;
    width: auto;
  }

  .profile-content-grid {
    grid-template-columns: 1fr;
  }
}
/* ClickWorld progression revamp */
:root {
  --user-accent: #57d68d;
}

.global-button,
button:not(.danger-button):not(.logout-button).is-active {
  border-color: color-mix(in srgb, var(--user-accent) 70%, #ffffff 10%);
}

.progress-track > span,
.global-button,
.side-drawer .profile-link {
  background-color: var(--user-accent);
}

.home-shell {
  position: relative;
  isolation: isolate;
}

.home-shell::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--user-accent) 25%, transparent) 1px, transparent 1.5px);
  background-size: 48px 48px;
  transition: opacity 500ms ease;
}

body[data-progress-atmosphere="100"] .home-shell::before { opacity: .12; }
body[data-progress-atmosphere="500"] .home-shell::before { opacity: .18; animation: world-atmosphere 16s linear infinite; }
body[data-progress-atmosphere="1000"] .home-shell::before { opacity: .24; animation: world-atmosphere 14s linear infinite; }
body[data-progress-atmosphere="5000"] .home-shell::before { opacity: .32; animation: world-atmosphere 11s linear infinite; }
body[data-progress-atmosphere="10000"] .home-shell::before { opacity: .38; animation: world-atmosphere 9s linear infinite; }

@keyframes world-atmosphere {
  to { background-position: 48px -48px; }
}

.home-hero {
  padding-bottom: 18px;
}

.click-dashboard {
  max-width: 920px;
  margin-inline: auto;
}

.home-panels .dashboard-panel:nth-child(2),
.home-panels .dashboard-panel:nth-child(4),
.unlock-section {
  display: none;
}

.home-panels {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 1040px;
  margin-inline: auto;
}

.profile-page-shell {
  max-width: 1120px;
}

.profile-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  scrollbar-width: thin;
}

.profile-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.profile-tabs button.is-active {
  color: var(--text);
  background: color-mix(in srgb, var(--user-accent) 18%, var(--panel));
}

.profile-tab-panel {
  margin-top: 18px;
}

.profile-identity {
  align-items: end;
}

.profile-share {
  margin-left: auto;
}

.avatar-edit-button {
  right: 2px;
  bottom: 2px;
  width: 36px;
  height: 36px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  box-shadow: 0 3px 12px rgb(0 0 0 / 28%);
}

.profile-cover {
  background-size: cover;
  background-position: center;
}

.profile-header-actions,
.editor-actions,
.connected-account-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.profile-header-actions {
  margin-left: auto;
}

.admin-profile-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--user-accent) 45%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--user-accent) 14%, var(--panel));
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.banner-editor-preview {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--user-accent) 22%, #121923), #182230),
    repeating-linear-gradient(90deg, transparent 0 38px, rgb(255 255 255 / 4%) 38px 39px);
  background-size: cover;
  background-position: center;
  color: var(--text-soft);
}

.account-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.connected-account-list {
  display: grid;
  gap: 10px;
}

.connected-account-row {
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
}

.connected-account-row div {
  display: grid;
  gap: 2px;
}

.connected-account-row span {
  color: var(--text-soft);
  font-size: .9rem;
}

.crop-stage.is-banner-crop {
  width: min(720px, 92vw);
  aspect-ratio: 3 / 1;
  border-radius: 8px;
}

.crop-dialog {
  max-width: min(820px, 96vw);
}

.founders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.founder-card {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  text-decoration: none;
}

.founder-card strong {
  color: var(--accent);
}

.founder-card small {
  color: var(--text-soft);
}

@media (max-width: 720px) {
  .profile-identity {
    display: grid;
    align-items: start;
  }

  .profile-header-actions {
    margin-left: 0;
  }

  .account-settings-grid {
    grid-template-columns: 1fr;
  }

  .crop-stage.is-banner-crop {
    width: 92vw;
  }
}

.profile-featured-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 28px 18px;
}

.cosmetic-chip {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-strong);
  font-size: .82rem;
}

.profile-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.invite-card {
  grid-column: 1 / -1;
}

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

.copy-field input {
  min-width: 0;
}

.picture-editor-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin: 18px 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.theme-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.theme-presets button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--border);
}

.collection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.cosmetic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cosmetic-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 190px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  background: var(--panel);
}

.cosmetic-card:hover:not(:disabled) {
  border-color: var(--user-accent);
  transform: translateY(-2px);
}

.cosmetic-card.is-selected {
  outline: 2px solid var(--user-accent);
  background: color-mix(in srgb, var(--user-accent) 10%, var(--panel));
}

.cosmetic-card.is-locked {
  opacity: .52;
  filter: grayscale(.65);
}

.cosmetic-icon,
.achievement-node-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid currentColor;
  border-radius: 8px;
  font-weight: 800;
  background: rgb(255 255 255 / 5%);
}

.cosmetic-image {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: pixelated;
}

.rarity-uncommon { --rarity: #57d68d; }
.rarity-rare { --rarity: #65a9ff; }
.rarity-epic { --rarity: #d39bff; }
.rarity-legendary { --rarity: #ffd166; }
.rarity-founder { --rarity: #ff7f6e; }
.cosmetic-card[class*="rarity-"],
.achievement-node[class*="rarity-"] { border-color: color-mix(in srgb, var(--rarity, var(--border)) 65%, var(--border)); }

.achievement-tree {
  display: grid;
  gap: 12px;
}

.achievement-node {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.achievement-node.is-complete {
  background: color-mix(in srgb, var(--user-accent) 8%, var(--panel));
}

.achievement-node.is-hidden-achievement {
  opacity: .6;
}

.world-icon-sprite {
  display: grid;
  place-items: center;
  min-width: 54px;
  min-height: 44px;
  padding: 8px;
  border: 2px solid rgb(20 42 24 / 45%);
  border-radius: 6px;
  color: #17341e;
  background: #a8d393;
  box-shadow: 0 5px 0 rgb(37 76 43 / 28%);
  font: 800 10px/1 system-ui, sans-serif;
  text-transform: uppercase;
}

.world-icon-sprite.is-locked {
  color: #c7ccd2;
  background: #59616b;
  filter: grayscale(1);
}

.pixel-world-viewport {
  touch-action: none;
  cursor: grab;
}

.pixel-world-viewport:active {
  cursor: grabbing;
}

.admin-legacy-tool {
  display: none !important;
}

@media (max-width: 760px) {
  .home-panels,
  .profile-overview-grid,
  .cosmetic-grid {
    grid-template-columns: 1fr;
  }

  .profile-identity {
    align-items: center;
  }

  .profile-share {
    margin: 10px 0 0;
  }

  .profile-featured-badges {
    justify-content: center;
    padding-inline: 16px;
  }

  .profile-stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .collection-heading {
    display: block;
  }

  .copy-field {
    grid-template-columns: 1fr;
  }
}

.world-imported-sprite {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
}

.world-imported-sprite.is-locked {
  filter: grayscale(1) brightness(.6);
  opacity: .75;
}

.mini-world .placed-world-object > span {
  display: none;
}
