:root {
  --bg: #f3f0e7;
  --surface: #fffdf8;
  --surface-2: #ebe7dc;
  --ink: #171915;
  --muted: #6f7269;
  --line: #1f211d;
  --red: #c92b36;
  --green: #3c8b54;
  --green-soft: #d8ead9;
  --yellow: #f0cc62;
  --shadow: 8px 8px 0 rgba(23, 25, 21, 0.14);
  --radius: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body[data-theme="night"] {
  --bg: #0d100f;
  --surface: #171b19;
  --surface-2: #222824;
  --ink: #f3f0e7;
  --muted: #a9afa7;
  --line: #e7e1d4;
  --red: #ff6670;
  --green: #79c58e;
  --green-soft: #263d2c;
  --yellow: #f2d878;
  --shadow: 8px 8px 0 rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(60, 139, 84, 0.12), transparent 28rem),
    radial-gradient(circle at 88% 20%, rgba(201, 43, 54, 0.08), transparent 24rem),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  transition: background 240ms ease, color 240ms ease;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.23;
  background-image:
    linear-gradient(rgba(60, 139, 84, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 139, 84, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 calc(36px + var(--safe-bottom));
  position: relative;
  z-index: 1;
}

.topbar {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1,
.brand p,
.player-card h2,
.section-heading h2,
.section-heading p,
.lucky-card h3,
.lucky-card p,
.gift-vault p,
.gift-vault h2,
footer {
  margin: 0;
}

.brand h1 {
  font-size: clamp(1.05rem, 2vw, 1.38rem);
  letter-spacing: 0.02em;
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.69rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  margin-bottom: 5px !important;
}

.earth-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 3px solid var(--line);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: #9fcaf4;
  box-shadow: 4px 4px 0 rgba(23, 25, 21, 0.2);
}

.land {
  position: absolute;
  background: var(--green);
  border: 2px solid var(--line);
}

.land-a {
  width: 27px;
  height: 18px;
  border-radius: 42% 58% 55% 45%;
  right: -2px;
  top: -3px;
  rotate: -8deg;
}

.land-b {
  width: 24px;
  height: 14px;
  border-radius: 45% 55% 35% 65%;
  left: -5px;
  bottom: 1px;
  rotate: 16deg;
}

.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #17254a;
  font-size: 0.83rem;
  font-weight: 800;
  translate: 1px 2px;
  z-index: 2;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn,
.text-btn,
.reroll-btn {
  border: 2px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.top-text-btn {
  min-height: 43px;
  color: var(--ink);
  font-weight: 800;
}

.primary-text-btn {
  color: white;
  background: var(--green);
}

.danger-text-btn {
  color: var(--red);
}

.icon-btn {
  width: 43px;
  height: 43px;
  border-radius: 13px;
  font-size: 1.1rem;
  box-shadow: 3px 3px 0 rgba(23, 25, 21, 0.16);
}

.icon-btn:hover,
.text-btn:hover,
.reroll-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(23, 25, 21, 0.18);
}

.icon-btn:active,
.text-btn:active,
.reroll-btn:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.player-card,
.mission-panel,
.mini-panel,
.gift-vault {
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.player-card {
  border-radius: 30px;
  padding: clamp(20px, 4vw, 34px);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.player-card::after {
  content: "404 / STILL PLAYING";
  position: absolute;
  right: -24px;
  top: 28px;
  rotate: 90deg;
  font-family: ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.player-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
}

.server-label {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 700;
}

.online-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 18%, transparent);
  animation: ping 1.8s ease-in-out infinite;
}

@keyframes ping {
  50% { box-shadow: 0 0 0 9px transparent; }
}

.player-main h2 {
  font-size: clamp(1.55rem, 4vw, 2.5rem);
  line-height: 1.15;
}

.server-copy {
  max-width: 660px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.level-badge {
  min-width: 92px;
  min-height: 92px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 24px;
  background: var(--yellow);
  color: #1b1b17;
  display: grid;
  place-items: center;
  align-content: center;
  box-shadow: 5px 5px 0 rgba(23, 25, 21, 0.18);
  rotate: 2deg;
}

.level-badge span {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.level-badge strong {
  font-size: 2.05rem;
  line-height: 1;
}

.xp-row {
  margin-top: 28px;
}

.xp-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.xp-track {
  height: 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.xp-fill {
  width: 0%;
  height: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      var(--green) 0 8px,
      color-mix(in srgb, var(--green) 82%, white) 8px 16px
    );
  transition: width 500ms cubic-bezier(.2,.85,.2,1);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.stat {
  border: 1.5px dashed var(--line);
  border-radius: 15px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.stat span {
  color: var(--muted);
  font-size: 0.76rem;
}

.stat strong {
  font-size: 0.82rem;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr);
  gap: 24px;
  align-items: start;
}

.mission-panel,
.mini-panel {
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 30px);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: clamp(1.25rem, 2vw, 1.55rem);
}

.section-heading.compact {
  margin-bottom: 14px;
}

.text-btn,
.reroll-btn {
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 0.72rem;
}

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

.task-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 84px;
  padding: 15px 16px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

.task-item:hover {
  transform: translateY(-2px);
}

.task-item.is-done {
  background: var(--green-soft);
}

.task-item.is-done .task-title {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: 0.72;
}

.task-check {
  width: 33px;
  height: 33px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 900;
  font-size: 1.1rem;
}

.task-check[aria-checked="true"] {
  color: white;
  background: var(--green);
}

.task-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}

.task-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.task-meta {
  display: inline-block;
  margin-top: 7px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
}

.reward-chip {
  white-space: nowrap;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: #1b1b17;
  background: var(--yellow);
  font-family: ui-monospace, monospace;
  font-weight: 800;
  font-size: 0.68rem;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin: 26px 0 20px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
}

.divider span {
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 13px);
}

.lucky-card {
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--red) 8%, transparent), transparent 55%),
    var(--surface);
}

.lucky-card.is-done {
  background: var(--green-soft);
}

.lucky-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 13px;
}

.lucky-top h3 {
  color: var(--red);
  font-size: 1.25rem;
}

.lucky-task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.why-copy {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.6;
  margin-top: 13px !important;
  padding-top: 12px;
  border-top: 1.5px dashed var(--line);
}

.side-column {
  display: grid;
  gap: 24px;
}

.panel-tip {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.save-state {
  color: var(--green);
  font-size: 0.69rem;
  font-family: ui-monospace, monospace;
}

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

.core-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.core-check {
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.core-check[aria-checked="true"] {
  color: white;
  background: var(--green);
}

.core-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  padding: 11px 4px;
  color: var(--ink);
  background: transparent;
  font-size: 0.88rem;
}

.core-input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.core-item.is-done .core-input {
  text-decoration: line-through;
  opacity: 0.64;
}

.status-block {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.status-block > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.status-button {
  aspect-ratio: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.status-button.is-active {
  color: white;
  background: var(--green);
  transform: translateY(-2px);
}

.note-label {
  display: block;
  margin: 22px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  color: var(--ink);
  background: var(--surface-2);
  line-height: 1.55;
}

.gift-vault {
  margin-top: 24px;
  border-radius: var(--radius);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  position: relative;
}

.gift-vault::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.7) 50%, transparent 80%);
  translate: -120% 0;
}

.gift-vault.is-unlocked {
  background:
    radial-gradient(circle at 90% 20%, rgba(240, 204, 98, 0.45), transparent 14rem),
    var(--green-soft);
}

.gift-vault.is-unlocked::after {
  opacity: 1;
  animation: shine 1.5s ease both;
}

@keyframes shine {
  to { translate: 120% 0; }
}

.gift-lock {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--muted);
  font: 800 0.66rem ui-monospace, monospace;
  rotate: -2deg;
}

.gift-vault.is-unlocked .gift-lock {
  background: var(--yellow);
  color: #191a16;
}

.gift-vault h2 {
  font-size: 1.15rem;
}

.gift-vault p:last-child {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.6;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 4px 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-family: ui-monospace, monospace;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 30;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 5px 5px 0 rgba(23, 25, 21, 0.2);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.82rem;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.level-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 12, 11, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-panel {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 12, 11, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-panel.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(520px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  padding: 24px;
  border: 3px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 10px 10px 0 rgba(0,0,0,0.34);
}

.wide-modal {
  width: min(920px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
}

.modal-close {
  flex: 0 0 auto;
}

.vault-toolbar,
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.vault-toolbar select,
.task-form input,
.task-form select,
.auth-form input {
  min-height: 39px;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface-2);
}

.import-label {
  display: inline-flex;
  align-items: center;
}

.task-form {
  display: grid;
  grid-template-columns: 1.2fr 1.7fr 90px repeat(3, minmax(100px, 1fr)) auto;
  gap: 9px;
  margin-bottom: 18px;
}

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

.vault-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 13px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.vault-item.is-disabled {
  opacity: 0.54;
}

.vault-item strong,
.vault-item p {
  margin: 0;
}

.vault-item p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.vault-item span,
.vault-item em {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  font-style: normal;
}

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

.achievement-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 11px;
  padding: 14px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  opacity: 0.58;
  background: var(--surface-2);
}

.achievement-item.is-unlocked {
  opacity: 1;
  border-style: solid;
  background: var(--green-soft);
}

.achievement-item b {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--yellow);
}

.achievement-item strong,
.achievement-item p {
  margin: 0;
}

.achievement-item p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.achievement-item span {
  display: inline-block;
  margin-top: 7px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.64rem;
}

.settlement-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 14px;
}

.settlement-lines {
  display: grid;
  gap: 10px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
}

.summary-line span {
  color: var(--muted);
}

.summary-line strong {
  text-align: right;
}

.share-card {
  min-height: 330px;
  padding: 24px;
  border: 3px solid var(--line);
  border-radius: 22px;
  color: #171915;
  background:
    radial-gradient(circle at 82% 12%, rgba(240, 204, 98, 0.9), transparent 8rem),
    linear-gradient(135deg, #fffdf8, #d8ead9);
  box-shadow: 8px 8px 0 rgba(23,25,21,0.16);
}

.share-card p,
.share-card h3,
.share-card blockquote,
.share-card footer {
  margin: 0;
}

.share-card p,
.share-card span,
.share-card footer {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
}

.share-card h3 {
  margin-top: 22px;
  font-size: 2rem;
}

.share-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
}

.share-card span {
  display: block;
  margin-top: 14px;
}

.share-card blockquote {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 2px dashed #171915;
  line-height: 1.7;
}

.share-card footer {
  padding-top: 22px;
  color: #3c5b43;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.minimal-mode .player-card,
.minimal-mode .side-column,
.minimal-mode .gift-vault,
.minimal-mode footer,
.minimal-mode .divider,
.minimal-mode .lucky-card,
.minimal-mode .section-heading,
.minimal-mode .top-actions .icon-btn:not(#minimalBtn),
.minimal-mode .top-actions .top-text-btn {
  display: none;
}

.minimal-mode .app-shell {
  width: min(440px, calc(100% - 18px));
}

.minimal-mode .topbar {
  justify-content: center;
}

.minimal-mode .mission-panel {
  padding: 16px;
  border-radius: 18px;
}

.minimal-mode .board {
  display: block;
}

.minimal-mode .task-list .task-item:not(:first-child) {
  display: none;
}

.minimal-mode .task-item {
  min-height: 72px;
}

body.pet-glow .earth-logo {
  filter: drop-shadow(0 0 12px rgba(240, 204, 98, .8));
}

body.pet-rainy .earth-logo::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  top: 4px;
  bottom: -8px;
  background:
    linear-gradient(#6f8fb6, #6f8fb6) 20% 64% / 2px 8px no-repeat,
    linear-gradient(#6f8fb6, #6f8fb6) 52% 72% / 2px 8px no-repeat,
    linear-gradient(#6f8fb6, #6f8fb6) 78% 62% / 2px 8px no-repeat;
  animation: pet-rain 780ms linear infinite;
  pointer-events: none;
}

body.pet-crowned .earth-logo::before {
  content: "♕";
  position: absolute;
  left: 50%;
  top: -13px;
  z-index: 4;
  transform: translateX(-50%);
  color: var(--yellow);
  text-shadow: 1px 1px 0 var(--line);
  font-size: 1.1rem;
}

body.pet-streak .brand::after {
  content: "✦";
  color: var(--yellow);
  animation: level-float 3s ease-in-out infinite;
}

.planet-hop {
  animation: planet-hop 520ms cubic-bezier(.18, .9, .28, 1.3) !important;
}

@keyframes pet-rain {
  to { background-position: 20% 82%, 52% 90%, 78% 80%; }
}

@keyframes planet-hop {
  0%, 100% { transform: translateY(0) scale(1); }
  42% { transform: translateY(-9px) scale(1.08); }
}

.level-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.level-modal-card {
  width: min(410px, 100%);
  padding: 28px;
  border: 3px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 10px 10px 0 rgba(0,0,0,0.34);
  text-align: center;
  transform: scale(0.92) rotate(-1deg);
  transition: transform 260ms cubic-bezier(.2,.9,.2,1.2);
}

.level-modal.show .level-modal-card {
  transform: scale(1) rotate(0);
}

.level-modal-card > strong {
  width: 110px;
  height: 110px;
  margin: 10px auto 18px;
  border: 3px solid var(--line);
  border-radius: 31px;
  display: grid;
  place-items: center;
  color: #171915;
  background: var(--yellow);
  font-size: 3.4rem;
  box-shadow: 7px 7px 0 rgba(23,25,21,0.18);
}

.level-modal-card p:not(.section-kicker) {
  color: var(--muted);
  line-height: 1.7;
}

.level-modal-card button {
  margin-top: 8px;
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
  color: white;
  background: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}

.particle {
  position: absolute;
  top: -30px;
  width: 10px;
  height: 16px;
  border: 2px solid var(--line);
  background: var(--yellow);
  animation: particle-fall 1.6s cubic-bezier(.2,.7,.3,1) forwards;
}

@keyframes particle-fall {
  to {
    translate: var(--drift) 110vh;
    rotate: var(--spin);
    opacity: 0.2;
  }
}


/* =========================================================
   V1.1 · 丝滑动效包
   仅修改前端视觉与交互，不涉及任何后端逻辑
   ========================================================= */

body .app-shell {
  opacity: 0;
  transform: translateY(12px);
}

body.is-ready .app-shell {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 680ms cubic-bezier(.2, .8, .2, 1),
    transform 680ms cubic-bezier(.2, .8, .2, 1);
}

body.is-ready .topbar {
  animation: smooth-rise 620ms 80ms cubic-bezier(.2, .85, .2, 1) both;
}

body.is-ready .player-card {
  animation: smooth-rise 680ms 150ms cubic-bezier(.2, .85, .2, 1) both;
}

body.is-ready .mission-panel {
  animation: smooth-rise 720ms 220ms cubic-bezier(.2, .85, .2, 1) both;
}

body.is-ready .side-column {
  animation: smooth-rise 720ms 290ms cubic-bezier(.2, .85, .2, 1) both;
}

body.is-ready .gift-vault {
  animation: smooth-rise 720ms 360ms cubic-bezier(.2, .85, .2, 1) both;
}

@keyframes smooth-rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 小地球：平时轻轻呼吸，悬停时完整自转一圈 */
.earth-logo {
  cursor: grab;
  transform-origin: 50% 50%;
  will-change: transform, filter;
  animation: planet-breathe 4.8s ease-in-out infinite;
  transition:
    filter 280ms ease,
    box-shadow 280ms ease;
}

.earth-logo:active {
  cursor: grabbing;
}

@keyframes planet-breathe {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -2px;
  }
}

@keyframes planet-spin-once {
  0% {
    transform: rotate(0deg) scale(1);
  }
  34% {
    transform: rotate(145deg) scale(1.09);
  }
  72% {
    transform: rotate(315deg) scale(1.035);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes tiny-face-blink {
  0%,
  42%,
  100% {
    scale: 1 1;
  }
  48%,
  55% {
    scale: 1 .18;
  }
}

.brand h1 {
  position: relative;
  display: inline-block;
}

.brand h1::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 420ms cubic-bezier(.2, .85, .2, 1);
}

.brand:hover h1::after {
  transform: scaleX(1);
}

/* 背景网格缓慢漂移，让页面不是“完全静止” */
.ambient-grid {
  will-change: transform;
  animation: grid-drift 18s ease-in-out infinite alternate;
}

@keyframes grid-drift {
  from {
    transform: translate3d(-8px, -5px, 0);
  }
  to {
    transform: translate3d(10px, 8px, 0);
  }
}

/* 卡片的悬浮与阴影缓动 */
.player-card,
.mission-panel,
.mini-panel,
.gift-vault {
  transition:
    transform 360ms cubic-bezier(.2, .8, .2, 1),
    box-shadow 360ms cubic-bezier(.2, .8, .2, 1),
    border-color 260ms ease,
    background 260ms ease;
  will-change: transform;
}

.player-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      115deg,
      transparent 20%,
      color-mix(in srgb, var(--surface) 72%, transparent) 44%,
      transparent 68%
    );
  translate: -125% 0;
  opacity: .85;
  transition: translate 900ms cubic-bezier(.2, .8, .2, 1);
}

.player-card:hover::before {
  translate: 125% 0;
}

.level-badge {
  transition:
    transform 420ms cubic-bezier(.2, .85, .2, 1),
    box-shadow 420ms cubic-bezier(.2, .85, .2, 1);
  animation: level-float 4.2s ease-in-out infinite;
}

@keyframes level-float {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -4px;
  }
}

@keyframes level-wiggle {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  24% {
    transform: rotate(-4deg) scale(1.04);
  }
  52% {
    transform: rotate(4deg) scale(1.06);
  }
  76% {
    transform: rotate(-2deg) scale(1.03);
  }
}

/* XP 条纹保持缓慢流动 */
.xp-fill {
  background-size: 24px 24px;
  animation: xp-flow 1.25s linear infinite;
}

@keyframes xp-flow {
  to {
    background-position: 24px 0;
  }
}

.stat,
.task-item,
.lucky-card,
.core-item,
.status-button,
.reward-chip,
.task-check,
.core-check,
.gift-lock,
textarea,
.core-input {
  transition:
    transform 240ms cubic-bezier(.2, .8, .2, 1),
    box-shadow 240ms ease,
    background 240ms ease,
    opacity 240ms ease,
    border-color 240ms ease;
}

.task-item {
  overflow: hidden;
}

.task-item::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 360ms cubic-bezier(.2, .85, .2, 1);
}

.task-item:hover::after,
.task-item.is-done::after {
  transform: scaleX(1);
}

.task-item.is-done .task-check,
.lucky-card.is-done .task-check,
.core-item.is-done .core-check {
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 18%, transparent);
}

.lucky-card {
  position: relative;
  overflow: hidden;
}

.lucky-card::before {
  content: "✦";
  position: absolute;
  right: 16px;
  bottom: 10px;
  color: color-mix(in srgb, var(--red) 22%, transparent);
  font-size: 3.2rem;
  transform: rotate(-12deg);
  transition:
    transform 460ms cubic-bezier(.2, .85, .2, 1),
    opacity 300ms ease;
  opacity: .55;
  pointer-events: none;
}

.lucky-card:hover::before {
  transform: rotate(8deg) scale(1.12);
  opacity: .9;
}

.status-button:active,
.task-check:active,
.core-check:active {
  transform: scale(.88);
}

textarea:focus,
.core-input:focus {
  transform: translateY(-2px);
}

.gift-lock {
  transform-origin: 50% 60%;
}

.gift-vault.is-unlocked .gift-lock {
  animation: gift-unlock-wiggle 1s cubic-bezier(.2, .85, .2, 1) both;
}

@keyframes gift-unlock-wiggle {
  0% {
    transform: rotate(0) scale(.85);
  }
  30% {
    transform: rotate(-8deg) scale(1.08);
  }
  58% {
    transform: rotate(7deg) scale(1.04);
  }
  100% {
    transform: rotate(0) scale(1);
  }
}

/* JS 在完成任务后调用的弹性反馈 */
.completion-pop {
  animation: completion-pop 560ms cubic-bezier(.18, .9, .28, 1.3);
}

.completion-card-flash {
  animation: completion-card-flash 720ms cubic-bezier(.2, .8, .2, 1);
}

@keyframes completion-pop {
  0% {
    transform: scale(.72) rotate(-10deg);
  }
  52% {
    transform: scale(1.2) rotate(5deg);
  }
  78% {
    transform: scale(.96) rotate(-2deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes completion-card-flash {
  0% {
    filter: brightness(1);
  }
  38% {
    filter: brightness(1.12);
    transform: translateY(-4px) scale(1.012);
  }
  100% {
    filter: brightness(1);
    transform: translateY(0) scale(1);
  }
}

@media (hover: hover) and (pointer: fine) {
  .earth-logo:hover {
    animation:
      planet-spin-once 920ms cubic-bezier(.18, .82, .2, 1),
      planet-breathe 4.8s 920ms ease-in-out infinite;
    filter: saturate(1.12) drop-shadow(0 7px 8px rgba(23, 25, 21, .22));
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--green) 13%, transparent);
  }

  .earth-logo:hover .face {
    animation: tiny-face-blink 920ms ease-in-out;
  }

  .player-card:hover,
  .mission-panel:hover,
  .mini-panel:hover,
  .gift-vault:hover {
    transform: translateY(-4px);
    box-shadow: 11px 13px 0 rgba(23, 25, 21, .13);
  }

  body[data-theme="night"] .player-card:hover,
  body[data-theme="night"] .mission-panel:hover,
  body[data-theme="night"] .mini-panel:hover,
  body[data-theme="night"] .gift-vault:hover {
    box-shadow: 11px 13px 0 rgba(0, 0, 0, .42);
  }

  .level-badge:hover {
    animation: level-wiggle 720ms cubic-bezier(.2, .85, .2, 1);
    box-shadow: 8px 9px 0 rgba(23, 25, 21, .18);
  }

  .task-item:hover {
    transform: translateY(-4px) translateX(2px);
    box-shadow: 5px 6px 0 color-mix(in srgb, var(--line) 14%, transparent);
  }

  .task-item:hover .reward-chip,
  .lucky-card:hover .reward-chip {
    transform: translateX(-3px) rotate(-2deg);
  }

  .stat:hover {
    transform: translateY(-2px);
    background: color-mix(in srgb, var(--green-soft) 62%, var(--surface));
  }

  .status-button:hover {
    transform: translateY(-3px) scale(1.04);
  }

  .task-check:hover,
  .core-check:hover {
    transform: rotate(-4deg) scale(1.08);
    box-shadow: 3px 3px 0 color-mix(in srgb, var(--line) 18%, transparent);
  }

  .gift-vault:hover .gift-lock {
    transform: rotate(-4deg) scale(1.04);
  }
}


/* =========================================================
   V1.2 · 自动跨日刷新提示
   页面跨过 00:00 或重新聚焦时，会自动切换到新一天任务
   ========================================================= */

body.new-day-arrived .player-card {
  animation: new-day-glow 1.2s cubic-bezier(.2, .85, .2, 1) both;
}

body.new-day-arrived .earth-logo {
  animation: planet-spin-once 920ms cubic-bezier(.18, .82, .2, 1) both;
}

body.new-day-arrived .mission-panel {
  animation: smooth-rise 720ms 120ms cubic-bezier(.2, .85, .2, 1) both;
}

@keyframes new-day-glow {
  0% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  34% {
    transform: translateY(-7px) scale(1.012);
    filter: brightness(1.13);
    box-shadow: 14px 16px 0 color-mix(in srgb, var(--green) 20%, transparent);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}


@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 22px, 720px);
    padding-top: 13px;
  }

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

  .side-column {
    grid-template-columns: 1fr 1fr;
  }

  .task-form,
  .settlement-grid {
    grid-template-columns: 1fr;
  }

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

  .vault-item {
    grid-template-columns: 1fr;
  }

  .player-card::after {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --shadow: 5px 5px 0 rgba(23, 25, 21, 0.14);
    --radius: 20px;
  }

  .topbar {
    min-height: 62px;
    align-items: flex-start;
  }

  .brand {
    gap: 10px;
  }

  .earth-logo {
    width: 44px;
    height: 44px;
  }

  .eyebrow {
    display: none;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .icon-btn {
    width: 39px;
    height: 39px;
  }

  .top-text-btn {
    min-height: 39px;
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .player-card {
    border-radius: 23px;
    padding: 19px;
  }

  .player-main h2 {
    font-size: 1.42rem;
    padding-right: 2px;
  }

  .server-copy {
    font-size: 0.79rem;
  }

  .level-badge {
    min-width: 72px;
    min-height: 72px;
    border-radius: 18px;
  }

  .level-badge strong {
    font-size: 1.55rem;
  }

  .stats-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .stat {
    padding: 9px 11px;
  }

  .mission-panel,
  .mini-panel {
    padding: 18px;
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .task-item {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 78px;
  }

  .reward-chip {
    grid-column: 2;
    justify-self: start;
    margin-top: -4px;
  }

  .lucky-task {
    grid-template-columns: auto 1fr;
  }

  .lucky-task .reward-chip {
    grid-column: 2;
  }

  .gift-vault {
    padding: 18px;
    align-items: flex-start;
  }

  .gift-lock {
    width: 58px;
    height: 58px;
    border-radius: 16px;
  }

  footer {
    flex-direction: column;
    gap: 5px;
  }

  .modal-panel {
    padding: 10px;
  }

  .modal-card {
    padding: 18px;
    border-radius: 20px;
  }

  .vault-toolbar > *,
  .auth-actions > * {
    flex: 1 1 130px;
  }

  .share-card {
    min-height: 300px;
    padding: 19px;
  }

  .share-card h3 {
    font-size: 1.55rem;
  }
}

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