:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --ink: #1f2521;
  --muted: #687168;
  --panel: #ffffff;
  --panel-2: #f0f3ee;
  --line: #d4d7ce;
  --accent: #7c3aed;
  --accent-2: #b45309;
  --green: #15803d;
  --danger: #b42318;
  --danger-bg: #fff0ed;
  --gold: #c58a1f;
  --shadow: 0 18px 50px rgba(33, 30, 24, 0.14);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(244, 242, 237, 0.9)),
    repeating-linear-gradient(90deg, rgba(40, 34, 28, 0.05) 0 1px, transparent 1px 42px),
    var(--bg);
}

@media (min-width: 1081px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1320px, calc(100vw - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 12px 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.game-head,
.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.game-head {
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 15px;
}

.head-actions,
.decision-row,
.tool-row,
.final-row {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button,
.secondary-button,
.tool-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 20px rgba(124, 58, 237, 0.22);
}

.ghost-button,
.secondary-button {
  color: var(--ink);
  background: #e8e8df;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stat,
.offer-panel,
.case-zone,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow);
}

.stat {
  min-height: 52px;
  padding: 9px 10px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1;
}

.risk-stat.danger {
  border-color: #ef9b91;
  color: var(--danger);
  background: var(--danger-bg);
}

.play-layout {
  display: grid;
  grid-template-columns: 250px minmax(440px, 1fr) 310px;
  gap: 10px;
  align-items: stretch;
  min-height: 0;
}

.offer-panel,
.case-zone,
.side-panel {
  padding: 12px;
  min-height: 0;
  overflow: hidden;
}

.offer-panel,
.side-panel {
  display: grid;
  gap: 8px;
  align-content: start;
}

.offer-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-height: 68px;
  border-radius: 8px;
  background: #f1eee7;
}

.offer-readout strong {
  font-size: 38px;
  line-height: 1;
}

.offer-readout span {
  color: var(--muted);
  font-weight: 900;
}

.counter-result {
  display: grid;
  gap: 3px;
  border: 2px solid #94a3b8;
  border-radius: 8px;
  padding: 9px 10px;
  background: #f8fafc;
  color: #1f2937;
  text-align: center;
}

.counter-result.hidden {
  display: none;
}

.counter-result strong {
  font-size: 18px;
  line-height: 1.15;
}

.counter-result span {
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.counter-result.success {
  border-color: #22c55e;
  background: #ecfdf3;
  color: #14532d;
}

.counter-result.fail {
  border-color: #ef4444;
  background: #fff1f2;
  color: #7f1d1d;
}

.advice-box,
.reason-box,
.event-log,
.history-list {
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--panel-2);
  color: #343c36;
  font-size: 12px;
  line-height: 1.42;
}

.advice-box,
.reason-box {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.offer-panel .advice-box {
  display: block;
  min-height: 32px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 900;
  line-height: 1.2;
}

.reason-box {
  min-height: 48px;
}

.event-log {
  position: relative;
  min-height: 44px;
  border: 1px solid #d8cff8;
  border-left: 4px solid var(--accent);
  padding-left: 72px;
  background: #f6f2ff;
  color: #251d38;
  font-weight: 900;
}

.event-log::before {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  border-radius: 6px;
  padding: 4px 6px;
  color: #fff;
  background: var(--accent);
  font-size: 11px;
  line-height: 1;
  content: "最近事件";
}

.guide-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid #7c3aed;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f4efff;
  color: #241d35;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.16);
}

.guide-strip strong {
  flex: 0 0 auto;
  border-radius: 6px;
  padding: 5px 8px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
}

.banker-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.banker-card div {
  min-height: 45px;
  border-radius: 8px;
  padding: 7px;
  background: #f7f3eb;
}

.banker-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.banker-card strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.15;
}

.task-board {
  display: grid;
  gap: 8px;
}

.task-board.hidden {
  display: none;
}

.task-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfaf4;
}

.task-card strong {
  font-size: 14px;
  line-height: 1.25;
}

.task-card span,
.task-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.task-card span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-card small {
  color: #334139;
  font-weight: 900;
}

.player-task {
  border-color: #b9d7c1;
  background: #f2fbf4;
}

.banker-task {
  border-color: #d8c7a0;
  background: #fff8e8;
}

.package-card {
  display: grid;
  gap: 6px;
  border: 1px solid #d8c7a0;
  border-radius: 8px;
  padding: 9px;
  background: #fff8e8;
}

.package-card strong {
  font-size: 15px;
}

.package-card span {
  display: -webkit-box;
  overflow: hidden;
  color: #6d5f4d;
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.decision-row,
.tool-row,
.final-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tool-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  background: #e9e9df;
}

.tool-guide {
  border-radius: 8px;
  padding: 8px 9px;
  border: 1px solid #dbe5ef;
  background: #f8fafc;
  color: #31455b;
  font-size: 12px;
  line-height: 1.35;
}

.inventory-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.inventory-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.inventory-item {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: 5px;
  min-height: 54px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 5px;
  background: linear-gradient(180deg, #ffffff, #f7fafc);
  color: var(--ink);
  text-align: center;
}

.inventory-item:hover,
.inventory-item.active {
  border-color: var(--accent);
  background: #f4efff;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.12);
}

.item-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.inventory-item strong {
  display: block;
  color: #111827;
  font-size: 12px;
  line-height: 1.1;
  white-space: pre-line;
}

.run-inventory-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.run-inventory-row div {
  border-radius: 7px;
  padding: 6px;
  background: #eef6ff;
  text-align: center;
}

.run-inventory-row span {
  display: block;
  color: #4d6178;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.run-inventory-row strong {
  display: block;
  margin-top: 4px;
  color: #102a43;
  font-size: 13px;
  line-height: 1;
}

.counter-input-wrap {
  display: grid;
  gap: 6px;
}

.counter-input-wrap span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.counter-input-wrap input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}

.counter-input-wrap input:disabled {
  color: #8b928a;
  background: #eee;
}

.wide-button {
  width: 100%;
}

.case-zone {
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto 1fr auto;
}

.selected-badge {
  min-height: 36px;
  border-radius: 999px;
  padding: 8px 12px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
}

.case-card {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 82px;
  border: 2px solid #a8aa9f;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 42%),
    #dedfd5;
  color: #333a34;
  font-weight: 900;
  overflow: hidden;
}

.case-card:not(.disabled):hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.case-card::before {
  position: absolute;
  top: 8px;
  width: 32px;
  height: 12px;
  border: 3px solid #86877d;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  content: "";
}

.case-card.mine {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 42%),
    #e0d4ff;
}

.case-card.hinted {
  border-color: #a8aa9f;
}

.hint-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  border: 1px solid #d8a94f;
  border-radius: 6px;
  padding: 3px 5px;
  color: #6a4509;
  background: #fff3c4;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(104, 71, 10, 0.12);
}

.case-card.opened {
  border-color: #caa56b;
  background: #fff4d9;
}

.case-card.opened.low {
  border-color: #8ac7a8;
}

.case-card.opened.high {
  border-color: #dc806f;
}

.case-card.disabled {
  cursor: default;
}

.case-card b {
  display: block;
  font-size: 19px;
}

.case-card span {
  color: var(--muted);
  font-size: 12px;
}

.case-card .case-value {
  color: var(--accent-2);
  font-size: 18px;
}

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

.value-pill {
  display: grid;
  place-items: center;
  min-height: 26px;
  border-radius: 7px;
  background: #f0f2ed;
  color: #26312b;
  font-size: 13px;
  font-weight: 900;
}

.value-pill.removed {
  color: #9c7b6e;
  background: #f3dfd9;
  text-decoration: line-through;
}

.history-list {
  display: grid;
  gap: 5px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  font-weight: 800;
  font-size: 12px;
}

.side-panel h2 {
  margin: 0;
  font-size: 13px;
}

.side-panel .eyebrow {
  margin-bottom: 0;
}

.side-panel .history-item:nth-child(n + 5) {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 19, 14, 0.56);
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(780px, 100%);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.rules-grid div,
.result-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfaf6;
}

.rules-grid strong {
  display: block;
  margin-bottom: 6px;
}

.rules-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.result-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.result-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

@media (max-height: 740px) and (min-width: 1081px) {
  .app-shell {
    width: min(1340px, calc(100vw - 20px));
    padding: 8px 0;
  }

  .game-head {
    margin-bottom: 6px;
  }

  h1 {
    font-size: 24px;
  }

  .hud-grid {
    gap: 6px;
    margin-bottom: 8px;
  }

  .stat {
    min-height: 46px;
    padding: 7px 9px;
  }

  .stat strong {
    font-size: 16px;
  }

  .offer-panel,
  .case-zone,
  .side-panel {
    padding: 10px;
  }

  .offer-panel,
  .side-panel,
  .case-zone {
    gap: 7px;
  }

  .offer-readout {
    min-height: 58px;
  }

  .offer-readout strong {
    font-size: 34px;
  }

  .case-card {
    min-height: 72px;
  }

  .guide-strip,
  .advice-box,
  .reason-box,
  .event-log,
  .task-card,
  .package-card {
    padding: 7px 8px;
  }

  .event-log {
    padding-left: 70px;
  }

  .guide-strip {
    font-size: 13px;
  }

  .value-pill {
    min-height: 23px;
  }

  .task-card span {
    -webkit-line-clamp: 1;
  }

  .reason-box,
  .advice-box {
    -webkit-line-clamp: 2;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    height: auto;
  }

  .offer-panel,
  .case-zone,
  .side-panel {
    overflow: visible;
  }

  .hud-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .play-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 1320px);
    padding-top: 12px;
  }

  .game-head,
  .board-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .hud-grid,
  .rules-grid,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .case-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
