:root {
  --bg: #f5f2ea;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-soft: #fcfaf5;
  --line: rgba(77, 58, 36, 0.12);
  --line-strong: rgba(77, 58, 36, 0.2);
  --text: #221a12;
  --muted: #675a4a;
  --muted-2: #8c7e6d;
  --accent: #8d5c2f;
  --accent-soft: #efe1cf;
  --danger: #9d4b43;
  --good: #2b7454;
  --shadow: 0 10px 30px rgba(52, 37, 20, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f7f2e8 0%, #f2ecdf 100%);
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
}

.shell {
  width: min(1200px, calc(100% - 20px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted-2);
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: -.04em;
}

.hero-copy {
  margin-top: 12px;
  max-width: 700px;
  color: var(--muted);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  align-items: start;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.ghost {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 999px;
  transition: transform .14s ease, opacity .14s ease, background-color .14s ease;
}

.primary:hover,
.ghost:hover { transform: translateY(-1px); }
.primary:disabled,
.ghost:disabled { opacity: .5; cursor: not-allowed; transform: none; }

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

.ghost {
  background: var(--accent-soft);
  color: var(--accent);
}

.small { min-height: 36px; padding: 0 12px; font-size: 14px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr);
  gap: 14px;
}

.board-panel, .sidebar, .inventory-panel, .relic-panel, .shop-panel, .log-panel {
  padding: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.round-badge,
.selection-hint {
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #d8c4a6 0%, #caa67e 100%);
  color: var(--text);
  position: relative;
  overflow: hidden;
  padding: 8px;
  text-align: left;
}

.tile.hidden::after {
  content: "未挖掘";
  position: absolute;
  inset: auto 8px 8px 8px;
  font-size: 12px;
  color: rgba(34, 26, 18, 0.72);
}

.tile.revealed {
  background: #fffaf0;
}

.tile.empty {
  background: linear-gradient(180deg, #efe2cf 0%, #e0c8aa 100%);
}

.tile.polluted {
  background: linear-gradient(180deg, #a39681 0%, #897763 100%);
  color: #fff;
}

.tile.fragment {
  background: linear-gradient(180deg, #fff9ec 0%, #f5ecdb 100%);
}

.tile.special {
  background: linear-gradient(180deg, #efe4ff 0%, #ddd0f0 100%);
}

.tile-label {
  font-size: 13px;
  font-weight: 600;
}

.tile-meta {
  margin-top: 8px;
  font-size: 12px;
  color: inherit;
  line-height: 1.45;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 26px;
  letter-spacing: -.03em;
}

.status-box {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.status-box h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.rule-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.rule-list.compact li + li { margin-top: 4px; }

.actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory,
.modifier-options,
.submitted-relics {
  display: grid;
  gap: 10px;
}

.inventory {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.fragment-card,
.modifier-card,
.relic-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel-soft);
  padding: 12px;
}

.fragment-card {
  cursor: pointer;
}

.fragment-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: #fff6eb;
}

.fragment-top,
.modifier-top,
.relic-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.fragment-name,
.modifier-name,
.relic-name {
  font-weight: 650;
  line-height: 1.35;
}

.badge-row,
.trait-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge,
.trait {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.fragment-meta,
.modifier-desc,
.relic-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modifier-options {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.modifier-card button {
  margin-top: 10px;
  width: 100%;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.log-entry {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.hidden { display: none !important; }
.empty-state { color: var(--muted-2); }

.help-dialog {
  border: none;
  padding: 0;
  border-radius: 18px;
  width: min(540px, calc(100% - 24px));
}

.help-dialog::backdrop {
  background: rgba(32, 20, 9, 0.32);
}

.dialog-body {
  padding: 20px;
  background: #fff;
}

.dialog-body ol {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.dialog-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    width: calc(100% - 14px);
    padding-top: 10px;
  }

  .hero {
    flex-direction: column;
    padding: 16px;
  }

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

  .metrics {
    grid-template-columns: 1fr 1fr;
  }
}
