:root {
  --ink: #100E0C;
  --panel: #17130F;
  --panel-2: #1E1915;
  --line: rgba(237, 230, 216, 0.12);
  --line-strong: rgba(237, 230, 216, 0.22);
  --cream: #EDE6D8;
  --muted: #A79D8C;
  --brass: #C8A45C;
  --brass-dim: #8C7440;
  --red: #B4453A;
  --green: #5E8C61;
  --amber: #D19A3E;
  --radius: 10px;
  --radius-lg: 14px;
  --serif: Georgia, "Times New Roman", "Songti SC", serif;
  --sans: "SF Pro Text", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(200, 164, 92, 0.10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.screen { display: none; height: 100%; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }

/* ── shared bits ───────────────────────────────────────── */
.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--cream);
  padding: 10px 18px;
  border-radius: var(--radius);
  font: 500 14px/1 var(--sans);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brass); color: var(--brass); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brass); border-color: var(--brass); color: #1A1409; font-weight: 600; }
.btn-primary:hover { background: #D9B76F; border-color: #D9B76F; color: #1A1409; }
.btn-ghost { border-color: var(--line); color: var(--muted); }
.btn.small { padding: 7px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.hidden { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head.sub { border-top: 1px solid var(--line); }
.panel-head h3 { font-size: 14px; letter-spacing: 0.04em; color: var(--cream); }
.panel-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; min-height: 0; }
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
.hint-inline { font-size: 11px; color: var(--muted); }
.badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
  border: 1px solid var(--brass-dim);
  border-radius: 999px;
  padding: 3px 8px;
}
.badge.fallback { color: var(--muted); border-color: var(--line-strong); }

/* ── home ──────────────────────────────────────────────── */
#screen-home { justify-content: center; align-items: center; padding: 24px; }
.home-wrap { width: 100%; max-width: 520px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand-mark {
  width: 44px; height: 44px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border: 1px solid var(--brass);
  border-radius: 999px;
  font: 500 15px/1 var(--serif);
  letter-spacing: 0.06em;
  color: var(--brass);
}
.brand h1 { font-size: 40px; letter-spacing: 0.02em; }
.brand h1 span { color: var(--brass); font-style: italic; }
.tagline { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.home-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--cream);
  padding: 12px 14px;
  font: 400 15px/1.2 var(--sans);
  outline: none;
  transition: border-color 0.12s;
}
input:focus { border-color: var(--brass); }
input::placeholder { color: #6E655A; }

.family-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.fam-card {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.fam-card:hover { border-color: var(--line-strong); }
.fam-card.selected { border-color: var(--brass); background: rgba(200, 164, 92, 0.07); }
.fam-card .name { font-size: 13px; }
.fam-card .origin { font-size: 10px; color: var(--muted); }
.fam-dot { width: 9px; height: 9px; border-radius: 999px; flex: 0 0 auto; }

.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: 0.2em; text-align: center; font-family: var(--serif); }
.hint { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
.home-foot {
  position: absolute; bottom: 16px; left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  font-size: 10px; letter-spacing: 0.08em; color: #5C5449;
}
.dot { width: 6px; height: 6px; border-radius: 999px; background: var(--red); }
.dot.on { background: var(--green); }

/* ── lobby ─────────────────────────────────────────────── */
#screen-lobby { padding: 24px; }
.lobby-wrap {
  width: 100%; max-width: 980px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px; height: 100%;
}
.lobby-head { display: flex; align-items: flex-end; justify-content: space-between; }
.lobby-head h2 { font-size: 44px; letter-spacing: 0.16em; color: var(--brass); }
.lobby-grid { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-height: 0; }
.lobby-rules p { margin: 0 0 12px; color: var(--muted); line-height: 1.6; }
.lobby-rules ol { margin: 0; padding-left: 18px; color: var(--cream); line-height: 2; font-size: 13px; }
.seat {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.seat:last-child { border-bottom: none; }
.seat .who { font-size: 13px; }
.seat .tag { font-size: 10px; color: var(--muted); border: 1px solid var(--line); padding: 2px 7px; border-radius: 999px; }
.seat .tag.you { color: var(--brass); border-color: var(--brass-dim); }
.lobby-foot { display: flex; justify-content: flex-end; gap: 10px; }

/* ── game header ───────────────────────────────────────── */
.game-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 19, 15, 0.75);
}
.me { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.me .fam-dot { width: 10px; height: 10px; }
.me-name { font-family: var(--serif); font-size: 16px; }
.me-sub { font-size: 10px; color: var(--muted); letter-spacing: 0.06em; }
.round-block { flex: 1 1 auto; max-width: 340px; }
.round-line { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.phase { color: var(--brass); }
.timer-track { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--brass); transition: width 0.4s linear; }
.stats { display: flex; gap: 18px; margin-left: auto; }
.stat { text-align: right; }
.stat .v { font-family: var(--serif); font-size: 17px; line-height: 1; }
.stat .k { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.stat.hot .v { color: var(--red); }
.stat.warm .v { color: var(--amber); }

/* ── game body ─────────────────────────────────────────── */
.game-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.95fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.district-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; height: 100%; }
.district {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 0;
}
.district-head { display: flex; justify-content: space-between; align-items: baseline; }
.district-name { font-family: var(--serif); font-size: 13px; }
.district-mod { font-size: 10px; color: var(--muted); }
.slot {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.12s, background 0.12s;
}
.slot:hover { border-color: var(--line-strong); background: #241E19; }
.slot .biz { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .owner { font-size: 10px; color: var(--muted); }
.slot.mine { border-color: var(--brass-dim); }
.slot.open .biz { color: var(--muted); }
.slot .pip { width: 6px; height: 6px; border-radius: 999px; background: var(--line-strong); }

.feed-item { padding: 9px 0; border-bottom: 1px solid var(--line); animation: rise 0.25s ease both; }
.feed-item:last-child { border-bottom: none; }
.feed-item .r { font-size: 9px; letter-spacing: 0.14em; color: var(--brass-dim); text-transform: uppercase; margin-bottom: 4px; }
.feed-item .t { font-size: 12.5px; line-height: 1.5; color: var(--cream); }
.feed-item.npc .t { font-family: var(--serif); font-style: italic; color: #D8CBB2; }
.feed-item.news { background: rgba(200, 164, 92, 0.05); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; border-bottom: none; }
.feed-item.news .t { font-family: var(--serif); font-size: 13px; line-height: 1.55; }
.feed-item .hl { font-family: var(--serif); font-size: 13px; color: var(--brass); display: block; margin-bottom: 4px; letter-spacing: 0.02em; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.lt { padding: 9px 0; border-bottom: 1px solid var(--line); }
.lt:last-child { border-bottom: none; }
.lt-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lt-name { font-size: 13px; }
.lt-role { font-size: 10px; color: var(--muted); }
.lt-bar { height: 2px; background: var(--line); margin: 7px 0 5px; border-radius: 999px; overflow: hidden; }
.lt-fill { height: 100%; background: var(--green); }
.lt-fill.low { background: var(--red); }
.lt-fill.mid { background: var(--amber); }
.lt-mood { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.rivals .rival { display: flex; justify-content: space-between; padding: 7px 0; font-size: 12px; border-bottom: 1px solid var(--line); }
.rivals .rival:last-child { border-bottom: none; }
.rivals .rival .val { color: var(--muted); font-size: 11px; }

/* ── game footer ───────────────────────────────────────── */
.game-footer {
  flex: 0 0 auto;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
  background: rgba(16, 14, 12, 0.9);
}
.chips { display: flex; gap: 7px; margin-bottom: 9px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font: 400 11px/1 var(--sans);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.chip:hover { color: var(--brass); border-color: var(--brass-dim); }
.order-row { display: flex; gap: 10px; }
.order-row input { height: 46px; font-size: 15px; }
.order-row .btn { padding: 0 24px; }
.order-hint { min-height: 15px; font-size: 11px; color: var(--muted); padding-top: 6px; }
.order-hint.bad { color: var(--red); }
.order-hint.good { color: var(--green); }

/* ── end screen ────────────────────────────────────────── */
#screen-end { overflow-y: auto; }
.end-wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 48px 24px 40px; }
.end-wrap h2 { font-size: 34px; margin-bottom: 20px; color: var(--brass); }
.end-body { font-family: var(--serif); font-size: 14px; line-height: 1.85; color: #DCD2BE; white-space: pre-wrap; }
.end-standings { margin: 24px 0; border-top: 1px solid var(--line); }
.end-standings .row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.end-standings .row.win { color: var(--brass); }
.end-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--line-strong);
  color: var(--cream); padding: 10px 18px; border-radius: var(--radius);
  font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1180px) {
  .game-body { grid-template-columns: 1fr 1fr; }
  .crew-panel { grid-column: span 2; }
}
@media (max-width: 820px) {
  .home-wrap { max-width: 100%; }
  .brand h1 { font-size: 30px; }
  .game-body { grid-template-columns: 1fr; overflow-y: auto; }
  .crew-panel { grid-column: auto; }
  .map-panel { min-height: 420px; }
  .stats { gap: 12px; }
  .stat .v { font-size: 15px; }
  .me { min-width: 0; }
}

/* ── 语言切换 ─────────────────────────────────────────── */
.lang-switch {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(23, 19, 15, 0.86);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.lang-switch:hover {
  border-color: var(--brass-dim);
  color: var(--brass);
}
.lang-switch svg { color: var(--brass); }

@media (max-width: 820px) {
  .lang-switch { top: 10px; right: 10px; padding: 5px 9px; }
}
