/* 《制图师》联机桌 — 羊皮纸制图风格 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper: #f0e6d2;
  --paper-deep: #e6d8bc;
  --paper-card: #f7f0e0;
  --ink: #3a2f25;
  --ink-soft: #6b5d4b;
  --ink-faint: #9a8a72;
  --line: #cbb894;
  --accent: #8a3324;
  --accent-2: #1f4e6b;
  --good: #3f6034;
  --violet: #5b4a78;
  --serif: "Kaiti SC", "STKaiti", KaiTi, "FangSong", "Noto Serif SC", serif;
  --sans: system-ui, "Microsoft YaHei", sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper-deep);
  overflow: hidden;
}

button {
  font-family: inherit; font-size: 13px; color: var(--ink);
  background: linear-gradient(#faf4e6, #eee0c5);
  border: 1px solid #b3a180; border-radius: 6px;
  padding: 5px 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(58,47,37,.15);
}
button:hover { background: linear-gradient(#fffaf0, #f2e6cc); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.primary { background: linear-gradient(#9c4a38, #7c2d1f); color: #f7ecd8; border-color: #5f2418; }
button.primary:hover { background: linear-gradient(#a85443, #8a3324); }
button.ghost { background: transparent; box-shadow: none; border-color: transparent; }
button.ghost:hover { border-color: #b3a180; background: rgba(255,255,255,.35); }
button.small { font-size: 12px; padding: 2px 8px; }

input, select, textarea {
  font-family: inherit; font-size: 13px; color: var(--ink);
  background: #fbf6ea; border: 1px solid #b9a884; border-radius: 5px; padding: 5px 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(138,51,36,.35); }
textarea { resize: vertical; }

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

/* ---------- 大厅 ---------- */
#lobby {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,250,235,.8), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(140,110,70,.25), transparent 55%),
    var(--paper-deep);
}
.lobby-card {
  width: 420px; max-width: 94vw;
  background: var(--paper-card);
  border: 1px solid #b3a180; border-radius: 10px;
  box-shadow: 0 12px 40px rgba(58,47,37,.35), inset 0 0 0 4px rgba(179,161,128,.25);
  padding: 30px 32px 26px;
}
.lobby-card h1 { font-size: 30px; text-align: center; letter-spacing: .12em; }
.lobby-card .sub { text-align: center; color: var(--ink-soft); font-size: 13px; margin: 6px 0 22px; }
.lobby-card .row { display: flex; gap: 8px; margin-bottom: 10px; }
.lobby-card input { flex: 1; }
.lobby-card .divider { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); font-size: 12px; margin: 16px 0; }
.lobby-card .divider::before, .lobby-card .divider::after { content: ""; flex: 1; border-top: 1px solid #cbb894; }
.lobby-note { font-size: 12px; color: var(--ink-faint); margin-top: 18px; line-height: 1.6; text-align: center; }
#lobbyError { color: var(--accent); font-size: 13px; min-height: 18px; text-align: center; margin-top: 8px; }

/* ---------- 主界面 ---------- */
#game { height: 100%; display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 12px;
  background: linear-gradient(#4a3d2f, #3a2f25);
  color: #e8dcc2; font-size: 13px;
  border-bottom: 2px solid #2a2119;
  flex-wrap: wrap;
}
#topbar .brand { font-family: var(--serif); font-size: 17px; letter-spacing: .1em; color: #f0e6d2; }
#roomCode { cursor: pointer; background: rgba(240,230,210,.12); border: 1px dashed rgba(240,230,210,.4); padding: 2px 10px; border-radius: 5px; font-weight: 700; letter-spacing: .18em; }
#roomCode:hover { background: rgba(240,230,210,.22); }
#phaseChip { font-family: var(--serif); font-size: 15px; }
.pchip { display: inline-flex; align-items: center; gap: 5px; background: rgba(240,230,210,.1); border-radius: 12px; padding: 2px 10px 2px 7px; }
.pchip .dot { width: 8px; height: 8px; border-radius: 50%; background: #777; }
.pchip.on .dot { background: #7ec96f; box-shadow: 0 0 5px #7ec96f; }
#topbar .spacer { flex: 1; }
#namedCount { color: #ead9ae; }
#topbar button { background: rgba(240,230,210,.14); color: #ead9ae; border-color: rgba(240,230,210,.35); box-shadow: none; }
#topbar button:hover { background: rgba(240,230,210,.25); }

#main { flex: 1; display: flex; min-height: 0; }

/* ---------- 地图区 ---------- */
#mapwrap { flex: 1; position: relative; overflow: hidden; background: #a89a7d; min-width: 0; }
#mapcanvas { position: absolute; inset: 0; touch-action: none; }
#overlay { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
#overlay:not(.interactive) .die, #overlay:not(.interactive) .maplabel { pointer-events: none; }

#toolbar {
  position: absolute; top: 10px; left: 10px; z-index: 20;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; max-width: calc(100% - 20px);
  background: rgba(247,240,224,.94);
  border: 1px solid #b3a180; border-radius: 8px; padding: 5px 8px;
  box-shadow: 0 3px 12px rgba(58,47,37,.3);
}
#toolbar .tgroup { display: flex; align-items: center; gap: 3px; padding: 0 6px; border-right: 1px solid #d8c9a5; }
#toolbar .tgroup:last-child { border-right: none; }
.toolbtn {
  width: 32px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; background: transparent; border: 1px solid transparent; box-shadow: none;
}
.toolbtn.active { background: #3a2f25; color: #f0e6d2; border-color: #3a2f25; }
.colorbtn { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(58,47,37,.3); padding: 0; box-shadow: none; }
.colorbtn.active { border-color: #3a2f25; outline: 2px solid #f0e6d2; }
#sizeRange { width: 70px; }
#zoomInfo { font-size: 11px; color: var(--ink-faint); min-width: 38px; text-align: center; }

/* 骰子 */
.die {
  position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 9px; pointer-events: auto; cursor: grab; user-select: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; box-shadow: 2px 3px 6px rgba(40,30,20,.4);
  border: 2px solid rgba(0,0,0,.25);
}
.die:active { cursor: grabbing; }
.die .v { font-size: 19px; line-height: 1; }
.die .m { font-size: 9px; line-height: 1.1; margin-top: 2px; text-align: center; white-space: nowrap; }
.die.landmark { background: linear-gradient(#2d5f83, #1f4e6b); color: #eaf2f8; }
.die.biome { background: linear-gradient(#fdf8ec, #efe3c8); color: #4a3a28; }
.die.temp { background: linear-gradient(#6d5991, #5b4a78); color: #efe9f8; }

/* 地图文字标注 */
.maplabel {
  position: absolute; transform: translate(-50%, -50%);
  pointer-events: auto; cursor: grab; user-select: none;
  font-family: var(--serif); color: #2f2417; white-space: nowrap;
  text-shadow: 0 0 3px rgba(240,230,210,.9), 0 0 6px rgba(240,230,210,.7);
  font-size: 15px; padding: 2px 4px;
}
.maplabel.named { font-size: 19px; font-weight: 700; letter-spacing: .06em; }
.maplabel.named::after { content: ""; display: block; border-bottom: 2px solid rgba(47,36,23,.55); margin-top: 1px; }

/* 地形图章 */
.marker {
  position: absolute; transform: translate(-50%, -50%);
  pointer-events: auto; cursor: grab; user-select: none;
  display: flex; flex-direction: column; align-items: center;
}
.marker .mk-badge {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(253, 251, 243, .92);
  border: 1.6px solid #8c7a6b;
  box-shadow: 0 2px 5px rgba(60, 45, 30, .35), inset 0 0 0 2.5px rgba(203,184,148,.35);
  display: flex; align-items: center; justify-content: center;
}
.marker .mk-badge svg { width: 22px; height: 22px; }
.marker .mk-name {
  margin-top: 1px; font-family: var(--serif); font-size: 14px; font-weight: 700;
  color: #2f2417; white-space: nowrap;
  text-shadow: 0 0 3px rgba(240,230,210,.95), 0 0 6px rgba(240,230,210,.8);
}
.marker:active { cursor: grabbing; }

/* 骰子飞散动画 */
.die.fly { transition: left .65s cubic-bezier(.22, 1, .36, 1), top .65s cubic-bezier(.22, 1, .36, 1), transform .65s cubic-bezier(.22, 1, .36, 1); }

/* 化身选项 */
.resolve-row { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; margin: 2px 0; }
.resolve-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 7px; min-width: 46px;
}
.resolve-btn svg { width: 20px; height: 20px; }
.resolve-btn span { font-size: 10px; }

/* 连线机遇提示 */
#pairHints { position: absolute; top: 56px; left: 10px; z-index: 19; display: flex; flex-direction: column; gap: 6px; }
.pairhint {
  background: rgba(247,240,224,.95); border: 1px solid #b3a180; border-left: 4px solid var(--accent-2);
  border-radius: 7px; padding: 6px 10px; font-size: 12px; color: var(--ink);
  box-shadow: 0 3px 10px rgba(58,47,37,.3); display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease-out;
}

/* 天气条 */
#weatherChip { font-size: 12px; color: var(--ink-soft); background: #efe3c8; border: 1px solid #cbb894; border-radius: 10px; padding: 2px 10px; display: inline-block; margin-top: 6px; }

/* 休整向导 */
#dlgRest { max-width: 560px; }
.rest-locs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rest-loc {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px; border: 2px solid #b9a884; border-radius: 10px;
  background: #fbf6ea; cursor: pointer; font-family: var(--serif);
}
.rest-loc:hover { border-color: var(--accent); background: #fffaf0; }
.rest-loc .rl-name { font-size: 16px; font-weight: 700; }
.rest-loc .rl-sub { font-size: 11px; color: var(--ink-faint); font-family: var(--sans); }
.rest-loc svg { width: 30px; height: 30px; }
.rest-head { display: flex; justify-content: space-between; align-items: center; background: #efe3c8; border: 1px solid #cbb894; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.rest-head .ra-count { font-size: 26px; font-family: var(--serif); font-weight: 700; color: var(--good); }
.rest-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rest-act {
  text-align: left; padding: 9px 11px; border: 1.5px solid #b9a884; border-radius: 9px;
  background: #fbf6ea; cursor: pointer;
}
.rest-act:hover:not(:disabled) { border-color: var(--accent); background: #fffaf0; }
.rest-act:disabled { opacity: .45; cursor: default; }
.rest-act .ra-name { font-family: var(--serif); font-size: 14.5px; font-weight: 700; }
.rest-act .ra-desc { font-size: 11px; color: var(--ink-soft); line-height: 1.5; margin-top: 2px; }
.rest-act.wide { grid-column: 1 / -1; }
.shop-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; margin: 10px 0; }
.shop-card {
  border: 1.5px solid #cbb894; border-radius: 9px; background: #fffdf7; padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px;
}
.shop-card .sc-face { font-family: Georgia, serif; font-size: 22px; font-weight: 700; }
.shop-card .sc-face.red { color: #b02318; } .shop-card .sc-face.black { color: #222; }
.shop-card .sc-price { background: #f4e5bd; border: 1px solid #d9c48a; border-radius: 6px; padding: 2px 8px; font-weight: 700; }
.sell-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.sell-row input { width: 54px; }

/* 骰子/标注弹出菜单 */
#popover {
  position: absolute; z-index: 40; display: none; flex-direction: column; gap: 4px;
  background: #f7f0e0; border: 1px solid #a08f6d; border-radius: 8px; padding: 7px;
  box-shadow: 0 6px 20px rgba(40,30,20,.4); min-width: 130px;
}
#popover .ptitle { font-size: 12px; color: var(--ink-soft); text-align: center; margin-bottom: 2px; }

/* ---------- 侧栏 ---------- */
#panel {
  width: 388px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--paper-card); border-left: 2px solid #b3a180; min-height: 0;
}
#tabs { display: flex; border-bottom: 2px solid #b3a180; background: var(--paper-deep); }
#tabs button {
  flex: 1; border: none; border-radius: 0; background: transparent; box-shadow: none;
  padding: 9px 2px; font-size: 14px; font-family: var(--serif); color: var(--ink-soft);
  border-bottom: 3px solid transparent;
}
#tabs button.active { color: var(--ink); border-bottom-color: var(--accent); background: var(--paper-card); }
.tabpane { flex: 1; overflow-y: auto; padding: 12px 14px; display: none; min-height: 0; }
.tabpane.active { display: block; }
.tabpane h3 { font-size: 15px; margin: 14px 0 6px; color: #5d4a33; }
.tabpane h3:first-child { margin-top: 0; }

.box {
  background: #fbf6ea; border: 1px solid #d8c9a5; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px;
}

/* 流程 */
#phaseBig { text-align: center; font-family: var(--serif); }
#phaseBig .round { font-size: 13px; color: var(--ink-soft); }
#phaseBig .name { font-size: 24px; margin: 2px 0 8px; }
.phase-nav { display: flex; gap: 8px; justify-content: center; }
#checklist { font-size: 13px; line-height: 1.75; color: #4a3a28; }
#checklist li { margin-left: 18px; }
#gameOverBanner {
  display: none; background: #7c2d1f; color: #f7ecd8; text-align: center;
  padding: 8px; border-radius: 8px; margin-bottom: 10px; font-family: var(--serif); font-size: 15px;
}
.poolrow { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 13px; }
.poolrow .pname { width: 58px; }
.poolrow .pcount { font-size: 17px; font-weight: 700; width: 26px; text-align: center; }
.pooldot { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.pooldot.landmark { background: #1f4e6b; } .pooldot.biome { background: #e6d8bc; border: 1px solid #a08f6d; } .pooldot.temp { background: #5b4a78; }
.actionsum { font-size: 12px; color: var(--ink-soft); line-height: 1.7; }
.actionsum b { color: var(--ink); }
#d6result { font-size: 15px; font-weight: 700; color: var(--accent-2); min-height: 20px; }

/* 卡牌 */
#cardArea { text-align: center; }
.playcard {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 96px; height: 132px; border-radius: 10px;
  background: #fffdf7; border: 1px solid #999;
  box-shadow: 0 4px 14px rgba(40,30,20,.3);
  font-family: Georgia, serif; margin: 6px auto;
}
.playcard .rank { font-size: 34px; font-weight: 700; line-height: 1; }
.playcard .suit { font-size: 30px; line-height: 1.1; }
.playcard.red { color: #b02318; }
.playcard.black { color: #222; }
.playcard.joker { font-family: var(--serif); font-size: 19px; letter-spacing: .1em; }
.playcard.back {
  background: repeating-linear-gradient(45deg, #7c2d1f 0 6px, #8a3324 6px 12px);
  color: #f0d9a8; font-family: var(--serif); font-size: 15px;
}
#drawInfo { font-size: 13px; color: var(--ink-soft); margin: 4px 0; min-height: 18px; }
#lookupBox { margin-top: 8px; }
#lookupBox .lookup-main { font-size: 15px; font-family: var(--serif); }
#lookupBox .lookup-sub { font-size: 12px; color: var(--ink-soft); margin: 3px 0 8px; }
#jokerTrack { display: flex; justify-content: center; gap: 16px; font-size: 13px; margin-top: 6px; }
.jokerpips span { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid #a08f6d; margin-left: 3px; vertical-align: -1px; }
.jokerpips span.f-red { background: #b02318; border-color: #7c1a12; }
.jokerpips span.f-black { background: #333; border-color: #111; }
#deckRow { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-top: 8px; }

/* 队伍 */
.seat { margin-bottom: 12px; }
.seat .seathead { display: flex; align-items: center; gap: 8px; }
.seat .seathead .cname { font-family: var(--serif); font-size: 17px; }
.seat .seathead .pname { font-size: 12px; color: var(--ink-faint); }
.seat .traits { font-size: 12px; color: var(--ink-soft); margin: 3px 0 6px; line-height: 1.6; }
.resrow { display: flex; align-items: center; gap: 4px; font-size: 13px; margin: 3px 0; }
.resrow .rlabel { width: 40px; color: var(--ink-soft); }
.resrow .rval { width: 30px; text-align: center; font-weight: 700; font-size: 15px; }
.resrow button { padding: 0 8px; font-size: 14px; line-height: 20px; }
.chiplist { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.chip {
  font-size: 12px; background: #efe3c8; border: 1px solid #cbb894; border-radius: 10px;
  padding: 2px 8px; cursor: pointer;
}
.chip.wound { background: #f3d9d3; border-color: #cf9b8e; color: #7c2d1f; }
.chip:hover { text-decoration: line-through; }
.addrow { display: flex; gap: 5px; margin-top: 4px; }
.addrow input { flex: 1; min-width: 0; }
.seat .empty { color: var(--ink-faint); font-size: 13px; }
.woundslots { font-size: 12px; color: var(--ink-soft); }

/* 日志 */
#journalList { display: flex; flex-direction: column; gap: 8px; }
.jentry {
  background: #fbf6ea; border: 1px solid #d8c9a5; border-left: 4px solid #b08d57;
  border-radius: 6px; padding: 8px 10px; font-size: 13px; line-height: 1.7;
}
.jentry .jmeta { font-size: 11px; color: var(--ink-faint); margin-bottom: 3px; display: flex; justify-content: space-between; }
.jentry .jdel { cursor: pointer; color: var(--ink-faint); }
.jentry .jdel:hover { color: var(--accent); }
#journalAdd textarea { width: 100%; height: 64px; }
#actionLog { font-size: 12px; color: var(--ink-soft); line-height: 1.8; max-height: 220px; overflow-y: auto; }
#actionLog div { border-bottom: 1px dotted #e0d3b3; padding: 1px 0; }

/* 规则书（侧栏目录页） */
#rulesNav { padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 5px; }
#rulesNav button { font-size: 12px; padding: 4px 9px; }

/* 规则书抽屉阅读器 */
#rulesDrawer {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(720px, 82%);
  z-index: 35; display: flex; flex-direction: column;
  background: var(--paper-card);
  border-right: 2px solid #8c7a6b;
  box-shadow: 8px 0 30px rgba(40, 30, 20, .45);
}
#rulesDrawer[hidden] { display: none; }
#rulesDrawerHead {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: var(--paper-deep);
  border-bottom: 1px solid #b3a180; flex-shrink: 0;
}
#rulesDrawerHead .rd-title { font-family: var(--serif); font-weight: 700; font-size: 15px; }
#rulesDrawerHead select { flex: 1; min-width: 0; max-width: 240px; }
#rulesDrawerHead a { color: var(--ink-soft); text-decoration: none; font-size: 15px; padding: 2px 6px; }
#rulesDrawerHead a:hover { color: var(--ink); }
#rulesDrawerClose { margin-left: auto; font-size: 15px; }
#rulesFrame { flex: 1; border: none; width: 100%; min-height: 0; background: #56504a; }
#rulesResize {
  position: absolute; top: 0; bottom: 0; right: -4px; width: 9px;
  cursor: ew-resize; z-index: 5;
}
#rulesResize:hover, #rulesResize.dragging { background: rgba(138, 51, 36, .25); }
@media (max-width: 900px) {
  #rulesDrawer { width: 100% !important; border-right: none; }
  #rulesResize { display: none; }
}

/* 对话框 */
dialog {
  border: 1px solid #a08f6d; border-radius: 10px; background: var(--paper-card); color: var(--ink);
  box-shadow: 0 16px 60px rgba(40,30,20,.5); padding: 20px 22px; max-width: 480px; width: 92vw;
}
dialog::backdrop { background: rgba(40,30,20,.55); }
dialog h3 { font-size: 18px; margin-bottom: 12px; }
.frow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.frow label { width: 72px; font-size: 13px; color: var(--ink-soft); flex-shrink: 0; }
.frow input, .frow select, .frow textarea { flex: 1; min-width: 0; }
.frow .rollhint { font-size: 11px; color: var(--accent-2); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlg-note { font-size: 12px; color: var(--ink-faint); line-height: 1.6; margin-top: 8px; }

/* toast */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  background: rgba(58,47,37,.95); color: #f0e6d2; font-size: 13px;
  padding: 8px 16px; border-radius: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  animation: toastIn .18s ease-out;
}
.toast.err { background: rgba(124,45,31,.96); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* 窄屏兜底 */
@media (max-width: 900px) {
  #main { flex-direction: column; }
  #panel { width: 100%; height: 46%; border-left: none; border-top: 2px solid #b3a180; }
}
