﻿/* ============================================================
 * 大厂模拟器 · 样式
 * 纸张 / 墨水 / 一处朱红。克制的，像一份档案。
 * ============================================================ */

:root {
  --paper: #f4f0e6;
  --paper-2: #ebe5d6;
  --card: #fbf8f1;
  --ink: #1d1b17;
  --ink-soft: #4a453c;
  --muted: #7d766a;
  --line: #d9d2c2;
  --line-soft: #e6e0d2;
  --accent: #b0392c;
  --accent-soft: #f3e2de;
  --blue: #2f5d8a;
  --green: #4c7c58;
  --gold: #a2751f;
  --violet: #6b5a8c;
  --shadow: 0 1px 0 rgba(29, 27, 23, .04), 0 12px 32px -18px rgba(29, 27, 23, .35);
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(176, 57, 44, .05), transparent 42%),
    radial-gradient(circle at 82% 88%, rgba(47, 93, 138, .05), transparent 46%);
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------------- 屏幕 ---------------- */
.screen { display: none; }
.screen.active { display: block; }

/* ---------------- 开始页 ---------------- */
#screen-start { padding: 48px 20px; }
#screen-start.active {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-wrap {
  width: 100%;
  max-width: 640px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 28px;
}
.brand-mark { color: var(--accent); letter-spacing: .1em; }
.brand-dot { opacity: .5; }

.title {
  font-family: var(--serif);
  font-size: clamp(44px, 8vw, 72px);
  line-height: 1.05;
  letter-spacing: .02em;
  margin: 0 0 18px;
  font-weight: 700;
}

.subtitle {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.9;
  color: var(--ink-soft);
  margin: 0 0 36px;
}

.field-row { display: flex; gap: 12px; margin-bottom: 30px; }
.field { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.field span {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
}
.field input {
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 8px 2px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
}
.field input:focus { border-color: var(--accent); }
.field-block { margin-bottom: 16px; }

.arch-label {
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 12px;
}

.arch-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 32px; }

.arch {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 2px;
  padding: 16px 14px;
  text-align: left;
  transition: all .18s ease;
  position: relative;
}
.arch:hover { border-color: var(--ink-soft); transform: translateY(-2px); }
.arch.selected { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 1px var(--accent) inset; }
.arch-name { font-family: var(--serif); font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.arch-tag { font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: .08em; margin-bottom: 8px; }
.arch-desc { font-size: 12px; line-height: 1.6; color: var(--muted); }

.btn-primary {
  width: 100%;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 15px 20px;
  font-size: 15px;
  letter-spacing: .08em;
  border-radius: 2px;
  transition: all .18s;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-ghost {
  width: 100%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 12px 20px;
  font-size: 13px;
  border-radius: 2px;
  margin-top: 10px;
  transition: all .18s;
}
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }

.footnote {
  margin-top: 34px;
  font-size: 11px;
  line-height: 1.9;
  color: var(--muted);
}

/* ---------------- 游戏页 ---------------- */
#screen-game { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 240, 230, .86);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.logo { font-family: var(--serif); font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.week-chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 2px;
}
.topbar-right { display: flex; gap: 8px; }

.btn-icon {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 2px;
  transition: all .15s;
}
.btn-icon:hover { border-color: var(--ink-soft); color: var(--ink); }

.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 0;
  max-width: 1180px;
  margin: 0 auto;
  min-height: calc(100vh - 57px);
}

/* 侧栏 */
.side {
  border-right: 1px solid var(--line);
  padding: 26px 22px 40px;
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  overflow-y: auto;
}

.profile { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.avatar {
  width: 42px; height: 42px;
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 19px;
}
.profile-name { font-family: var(--serif); font-size: 16px; font-weight: 700; }
.profile-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.stats { display: flex; flex-direction: column; gap: 15px; }
.stat { }
.stat-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.stat-label { font-size: 11px; letter-spacing: .08em; color: var(--muted); }
.stat-val { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.stat-track { height: 3px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.stat-fill { height: 100%; width: 0; border-radius: 2px; transition: width .5s cubic-bezier(.2,.8,.2,1), background .3s; }
.stat-fill.blue { background: var(--blue); }
.stat-fill.green { background: var(--green); }
.stat-fill.gold { background: var(--gold); }
.stat-fill.violet { background: var(--violet); }
.stat-fill.red { background: var(--accent); }
.stat-delta {
  font-family: var(--mono);
  font-size: 10px;
  margin-left: 4px;
  opacity: 0;
  transition: opacity .3s;
}
.stat-delta.show { opacity: 1; }
.up { color: var(--green); }
.down { color: var(--accent); }

.side-foot { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.side-line { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.side-line b { font-family: var(--mono); color: var(--ink-soft); font-weight: 600; }

/* 主区 */
.main {
  padding: 34px 40px 90px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stage { max-width: 640px; width: 100%; }

.stage-head { margin-bottom: 22px; }
.stage-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 2px;
  margin-bottom: 12px;
}
.stage-title {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.3;
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
}

.prose {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 2.05;
  color: var(--ink-soft);
  white-space: pre-wrap;
  min-height: 120px;
  margin-bottom: 30px;
}
.prose .caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.choices { display: flex; flex-direction: column; gap: 9px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px 16px;
  border-radius: 2px;
  transition: all .16s ease;
  opacity: 0;
  transform: translateY(6px);
  animation: rise .35s forwards;
}
@keyframes rise { to { opacity: 1; transform: none; } }
.choice:hover { border-color: var(--accent); background: #fff; transform: translateX(2px); }
.choice-idx {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  width: 19px; height: 19px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.choice:hover .choice-idx { border-color: var(--accent); color: var(--accent); }
.choice-body { flex: 1; min-width: 0; }
.choice-label { font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.choice-hint { font-size: 11px; color: var(--muted); margin-top: 3px; font-family: var(--mono); }

.result { display: none; }
.result.show { display: block; animation: fadeIn .4s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.result-line {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2;
  color: var(--ink-soft);
  white-space: pre-wrap;
  padding-left: 16px;
  border-left: 2px solid var(--accent-soft);
  margin-bottom: 18px;
}
.result-flavor {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  padding-left: 16px;
  margin-bottom: 18px;
}
.deltas { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; padding-left: 16px; }
.delta-chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--card);
}
.delta-chip.up { color: var(--green); border-color: #cfdcd2; }
.delta-chip.down { color: var(--accent); border-color: #ecd4d0; }

.result-upkeep {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding-left: 16px;
  margin: -8px 0 22px;
}
.btn-next {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 26px;
  font-size: 14px;
  letter-spacing: .08em;
  border-radius: 2px;
  transition: all .18s;
}
.btn-next:hover { background: var(--accent); border-color: var(--accent); }

/* 自由输入 */
.free-row {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
  display: flex;
  gap: 8px;
  max-width: 640px;
}
.free-input {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  padding: 11px 13px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  border-radius: 2px;
  transition: border-color .18s;
}
.free-input:focus { border-color: var(--ink-soft); background: #fff; }
.btn-small {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 0 18px;
  font-size: 13px;
  border-radius: 2px;
}
.btn-small:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- 结局页 ---------------- */
#screen-ending {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
}
#screen-ending.active { display: flex; }
.ending-wrap { max-width: 560px; width: 100%; text-align: center; position: relative; }
.ending-grade {
  position: absolute;
  top: -76px;
  right: -12px;
  font-family: var(--serif);
  font-size: 190px;
  line-height: 1;
  color: var(--accent);
  opacity: .10;
  user-select: none;
  pointer-events: none;
}
.ending-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--muted); margin-bottom: 10px; }
.ending-name { font-family: var(--serif); font-size: 42px; margin: 0 0 22px; font-weight: 700; }
.ending-text {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 2.1;
  color: var(--ink-soft);
  white-space: pre-wrap;
  text-align: left;
  border-left: 2px solid var(--accent-soft);
  padding-left: 20px;
  margin-bottom: 30px;
}

.ending-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 30px;
}
.ending-stat { background: var(--card); padding: 14px 6px; }
.ending-stat b { display: block; font-family: var(--mono); font-size: 17px; }
.ending-stat span { font-size: 10px; color: var(--muted); letter-spacing: .06em; }

.ending-actions { display: flex; flex-direction: column; gap: 10px; }
.ending-actions .btn-ghost { margin-top: 0; }
#share-canvas { width: 100%; max-width: 340px; margin: 24px auto 0; border: 1px solid var(--line); border-radius: 2px; }

/* ---------------- 弹层 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(29, 27, 23, .4);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-family: var(--serif); font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-tip { font-size: 12px; line-height: 1.8; color: var(--muted); margin: 0 0 18px; }
.modal-tip.small { font-size: 11px; margin-top: 14px; }

.log-item {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.log-week { font-family: var(--mono); font-size: 10px; color: var(--muted); padding-top: 3px; }
.log-title { color: var(--ink); margin-bottom: 3px; }
.log-choice { font-size: 11px; color: var(--muted); }
.log-deltas { font-family: var(--mono); font-size: 10px; margin-top: 4px; }
.log-deltas span { margin-right: 8px; }
.log-upkeep { font-family: var(--mono); font-size: 10px; color: var(--muted); opacity: .85; margin-top: 2px; }

.col-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.col-grade { font-family: var(--mono); font-size: 11px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); color: var(--muted); flex-shrink: 0; }
.col-item.locked .col-grade { opacity: .35; }
.col-name { font-family: var(--serif); font-size: 15px; }
.col-item.locked .col-name { color: var(--muted); }
.col-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  padding: 10px 18px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 100;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .topbar-left { gap: 10px; }
  .topbar-right { gap: 6px; }
  .btn-icon { padding: 5px 9px; font-size: 11px; }
  .side {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 16px 16px 20px;
  }
  .stats { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 12px 16px; }
  .stat { flex: 1 1 42%; min-width: 0; }
  .side-foot { display: none; }
  .main { padding: 22px 16px 70px; }
  .arch-list { grid-template-columns: 1fr; }
  .stage-title { font-size: 23px; }
  .prose { font-size: 16px; line-height: 1.95; }
  .choice { padding: 12px 13px; gap: 10px; }
  .ending-stats { grid-template-columns: repeat(3, 1fr); }
  .field-row { flex-direction: column; gap: 18px; }
  .free-row { position: static; margin-top: 28px; }
  #share-canvas { max-width: 100%; }
}
