.theme-preload * {
  transition: none !important;
  animation: none !important;
}

:root {
  --bg: #fafafa;
  --bg-overlay: rgba(250, 250, 250, 0.84);
  --surface: transparent;
  --surface-hover: rgba(0, 0, 0, 0.03);
  --surface-soft: rgba(255, 255, 255, 0.72);
  --floating-panel: rgba(255, 255, 255, 0.86);
  --text: #2c2e33;
  --text-main: #1a1a1a;
  --subtext: #71717a;
  --line: #eaeaea;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.08);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 18px 40px rgba(37, 99, 235, 0.16);
  --sim-white: linear-gradient(180deg, #f3f4f6, #d1d5db);
  --sim-blue: linear-gradient(180deg, #7dd3fc, #2563eb);
  --sim-purple: linear-gradient(180deg, #c4b5fd, #7c3aed);
  --sim-gold: linear-gradient(180deg, #fde68a, #f59e0b);
  --sim-red: linear-gradient(180deg, #fda4af, #e11d48);
}

html.theme-dark {
  --bg: #121212;
  --bg-overlay: rgba(18, 18, 18, 0.75);
  --surface: transparent;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --surface-soft: rgba(255, 255, 255, 0.03);
  --floating-panel: rgba(24, 24, 27, 0.88);
  --text: #e5e5e5;
  --text-main: #f5f5f5;
  --subtext: #9ca3af;
  --line: #2e2e2e;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --shadow-soft: 0 16px 36px rgba(0, 0, 0, 0.22);
  --shadow-float: 0 22px 44px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  padding: 32px 24px 56px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: url("cursor.cur"), auto;
}

a,
button,
input,
select {
  cursor: url("cursor.cur"), auto;
}

button,
input,
select {
  font: inherit;
}

.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 88px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.back-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  background: var(--surface-hover);
  color: var(--text-main);
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.back-home:hover {
  background: var(--line);
  color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--surface-hover);
  color: var(--text);
  border-radius: 50%;
  font-size: 16px;
  transition: transform 0.24s ease, background-color 0.24s ease, color 0.24s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--line);
  color: var(--accent);
  transform: rotate(15deg);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.layout {
  width: 100%;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 64px;
  align-items: start;
}

.intro {
  position: sticky;
  top: 40px;
  display: flex;
  flex-direction: column;
}

.intro-kicker {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtext);
  margin-bottom: 16px;
  font-weight: 600;
}

.name {
  margin: 0 0 16px;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-main);
}

.bio {
  margin: 0 0 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--subtext);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: transparent;
  transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  animation: fade-up 0.55s ease both;
}

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

.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.4;
  color: var(--text-main);
}

.panel > .note {
  margin-bottom: 14px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-hover);
}

.form-group.full {
  grid-column: 1 / -1;
  padding: 0;
  border: none;
  background: transparent;
}

label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

input[type="number"],
select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  background: var(--surface-hover);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

option {
  color: var(--text);
  background: var(--bg);
}

input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

html.theme-dark input[type="number"]:focus,
html.theme-dark select:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

html.theme-dark select,
html.theme-dark option {
  color: #f5f5f5;
  background: #1f2937;
}

.note {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--subtext);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row {
  margin-top: 14px;
}

button {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

.preset-btn,
.primary-btn {
  background: var(--accent);
  color: #fff;
}

.preset-btn:hover,
.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn {
  background: var(--surface-hover);
  color: var(--text-main);
}

.secondary-btn:hover {
  background: var(--line);
  color: var(--accent);
}

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-btn:hover {
  background: rgba(220, 38, 38, 0.14);
}

.success-btn {
  background: var(--success-soft);
  color: var(--success);
}

.success-btn:hover {
  background: rgba(21, 128, 61, 0.14);
}

.preset-status {
  min-height: 20px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--subtext);
  line-height: 1.7;
}

.preset-status strong {
  color: var(--text-main);
}

.tier-container {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.tier-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-hover);
  animation: fade-up 0.35s ease both;
}

.tier-row {
  display: grid;
  grid-template-columns: auto minmax(88px, 1fr) auto minmax(88px, 1fr);
  gap: 8px;
  align-items: center;
}

.tier-row.price-row {
  grid-template-columns: auto minmax(0, 1fr);
}

.tier-label {
  font-size: 13px;
  color: var(--subtext);
  font-weight: 500;
  white-space: nowrap;
}

.tier-separator {
  text-align: center;
  color: var(--subtext);
  white-space: nowrap;
}

.tier-item input[type="number"] {
  width: 100%;
}

.activity-screenshot {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-hover);
  display: none;
}

.screenshot-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.screenshot-caption {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--subtext);
  text-align: center;
}

#calculateBtn {
  width: 100%;
  margin-top: 2px;
  padding: 14px 18px;
  font-size: 15px;
}

.results {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.results.visible {
  opacity: 1;
  transform: translateY(0);
}

.result-stack {
  display: grid;
  gap: 12px;
}

.result-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-hover);
}

.result-item h3 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--text-main);
}

.result-item p {
  margin: 0;
  white-space: pre-line;
  line-height: 1.8;
}

.result-note {
  margin-top: 10px;
}

.highlight {
  color: var(--accent);
  font-weight: 700;
}

.recommendation {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  line-height: 1.8;
}

.step {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  line-height: 1.8;
}

.cost-table-container {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cost-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.cost-table th,
.cost-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.cost-table th {
  background: var(--surface-hover);
  color: var(--text-main);
  font-weight: 700;
}

.cost-table td {
  color: var(--subtext);
}

.site-footer {
  margin-top: 64px;
  text-align: left;
  color: var(--subtext);
  font-size: 13px;
}

.author-link {
  color: var(--subtext);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.author-link:hover {
  color: var(--accent);
}

#apex-sim-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: var(--shadow-float);
}

#apex-sim-btn:hover {
  background: var(--accent-strong);
}

#apex-sim {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 998;
  width: 340px;
  max-width: calc(100vw - 32px);
  display: none;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--floating-panel);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.sim-header {
  margin-bottom: 12px;
}

.sim-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.sim-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-hover);
  border: 1px solid var(--line);
}

.sim-progress-inner {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 0.25s ease;
}

.sim-progress-text {
  margin-top: 8px;
  text-align: right;
  font-size: 12px;
  color: var(--subtext);
}

.sim-box-area {
  text-align: center;
  margin-bottom: 12px;
}

.sim-box-img {
  width: 90px;
  height: auto;
  display: block;
  margin: 0 auto 10px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease;
}

.sim-box-img:hover {
  transform: translateY(-2px) scale(1.02);
}

.sim-single-result {
  min-height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.sim-result-area {
  min-height: 76px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-hover);
}

.sim-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sim-controls button {
  background: var(--accent);
  color: #fff;
}

.sim-controls button:hover {
  background: var(--accent-strong);
}

.sim-batch {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.sim-stats {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-hover);
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.7;
}

.loot {
  width: 30px;
  height: 42px;
  border-radius: 8px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.18);
  animation: loot-pop 0.24s ease;
}

.white { background: var(--sim-white); }
.blue { background: var(--sim-blue); }
.purple { background: var(--sim-purple); }
.gold { background: var(--sim-gold); }
.red { background: var(--sim-red); }

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loot-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 900px) {
  body {
    background: var(--bg);
    backdrop-filter: none;
    padding: 22px 18px 84px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .intro {
    position: static;
  }

  .name {
    font-size: 30px;
  }

  .site-footer {
    margin-top: 44px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 18px 14px 84px;
  }

  .topbar {
    margin-bottom: 28px;
  }

  .back-home {
    padding: 9px 12px;
  }

  .panel,
  .result-item {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 108px;
    align-items: center;
    gap: 10px 12px;
    padding: 12px;
    border-radius: 12px;
  }

  .form-group.full {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
  }

  .form-group label {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
  }

  .form-group input[type="number"],
  .form-group select {
    width: 108px;
    min-width: 108px;
    justify-self: end;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14px;
  }

  .tier-row {
    grid-template-columns: auto minmax(80px, 1fr) auto minmax(80px, 1fr);
  }

  .tier-row.price-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  #apex-sim {
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    bottom: 84px;
    padding: 14px;
  }

  #apex-sim-btn {
    right: 12px;
    bottom: 12px;
    width: 58px;
    height: 58px;
    border-radius: 16px;
    font-size: 12px;
  }
}

@media (max-width: 520px) {
  body {
    padding: 16px 12px 84px;
  }

  .name {
    font-size: 25px;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button-row button {
    width: 100%;
    justify-content: center;
  }

  .cost-table {
    min-width: 380px;
  }

  .form-group {
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 8px 10px;
    padding: 10px;
  }

  .tier-item {
    padding: 12px;
  }

  .tier-row {
    grid-template-columns: auto minmax(72px, 1fr) auto minmax(72px, 1fr);
    gap: 8px;
  }

  .tier-row.price-row {
    grid-template-columns: auto minmax(72px, 1fr);
  }

  .tier-label,
  .tier-separator {
    font-size: 12px;
  }

  .form-group input[type="number"],
  .form-group select {
    width: 92px;
    min-width: 92px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .tier-item input[type="number"] {
    width: 100%;
    padding: 7px 9px;
    font-size: 13px;
  }

  .sim-controls {
    grid-template-columns: 1fr;
  }
}
