:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --ink: #1f2320;
  --muted: #667067;
  --line: #d8d1c3;
  --panel: #fffdfa;
  --accent: #2f6f64;
  --accent-strong: #234f48;
  --soft: #e7eee9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(120px, .55fr) minmax(120px, .55fr) minmax(120px, .55fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  line-height: 1;
}

.toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:nth-child(n + 2) {
  background: var(--soft);
  color: var(--accent-strong);
}

.chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(148px, auto));
  gap: 8px;
}

.palace,
.center,
.copyPanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.palace {
  min-height: 148px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  cursor: pointer;
}

.palace.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.palace.target {
  border-color: #2f6f64;
  background: #f4faf6;
  box-shadow: inset 0 0 0 2px rgba(47, 111, 100, 0.18);
  position: relative;
}

.palace.target::after {
  content: "落点";
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #2f6f64;
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
}

.focusChip.lu {
  --chip: #e4f4ec;
  --ink: #245f4f;
}

.focusChip.quan {
  --chip: #e7eef9;
  --ink: #274f7f;
}

.focusChip.ke {
  --chip: #f6ebd4;
  --ink: #7b5b1f;
}

.focusChip.ji {
  --chip: #f7e4df;
  --ink: #923c33;
}

.palace header,
.palace footer,
.panelHeader {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.palace header strong {
  font-size: 15px;
  line-height: 1.2;
}

.palace header span,
.palace footer,
#status {
  color: var(--muted);
  font-size: 12px;
}

.stars {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  line-height: 1.2;
}

.stars span {
  display: inline-flex;
  gap: 2px;
  align-items: baseline;
  padding: 3px 6px;
  border-radius: 5px;
  background: #f2efe8;
  font-size: 13px;
  white-space: nowrap;
}

.stars span.hitStar {
  box-shadow: inset 0 0 0 1px rgba(47, 111, 100, 0.26);
  background: #f7fbf8;
}

.stars em {
  color: var(--accent-strong);
  font-style: normal;
  font-size: 11px;
}

.cardTransformStrip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.transformBlock,
.transformBadge {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  font-weight: 700;
  line-height: 1.2;
}

.transformBlock {
  padding: 3px 6px;
  font-size: 12px;
}

.transformBadge {
  margin-left: 3px;
  padding: 2px 4px;
  font-size: 11px;
}

.transformBlock.lu,
.transformBadge.lu {
  background: #2f7d59;
  color: #fff;
}

.transformBlock.quan,
.transformBadge.quan {
  background: #2f5f92;
  color: #fff;
}

.transformBlock.ke,
.transformBadge.ke {
  background: #b8822d;
  color: #fff;
}

.transformBlock.ji,
.transformBadge.ji {
  background: #a33a2b;
  color: #fff;
}

.center {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  padding: 16px;
}

.centerTitle {
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 700;
}

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

dl div {
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 3px 0 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.copyPanel {
  margin-top: 14px;
  padding: 12px;
}

.focusPanel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  gap: 10px;
}

.focusPanel .panelHeader strong {
  font-size: 18px;
}

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

.focusGroup {
  display: grid;
  gap: 6px;
}

.focusLabel {
  color: var(--muted);
  font-size: 12px;
}

.focusChips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.focusChip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--chip, #f2efe8);
  color: var(--ink, var(--ink));
  font-size: 13px;
  line-height: 1.35;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.focusChip.lu,
.focusChip.quan,
.focusChip.ke,
.focusChip.ji {
  font-weight: 600;
}

.panelHeader {
  margin-bottom: 8px;
}

textarea {
  min-height: 320px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
  white-space: pre;
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 12px, 680px);
    padding: 8px 0 18px;
  }

  .toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
  }

  .actions {
    justify-content: stretch;
    gap: 6px;
  }

  .actions button {
    flex: 1 1 calc(50% - 6px);
    padding: 0 8px;
  }

  .toggle {
    justify-content: flex-start;
  }

  .chart {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(4, 118px);
    gap: 4px;
  }

  .palace {
    min-height: 0;
    padding: 5px;
    gap: 4px;
    overflow: hidden;
  }

  .palace header,
  .palace footer {
    gap: 4px;
  }

  .palace header strong {
    font-size: 12px;
  }

  .palace header span,
  .palace footer {
    font-size: 9px;
    line-height: 1.25;
  }

  .palace footer {
    display: grid;
    align-content: end;
  }

  .palace.target::after {
    right: 4px;
    top: 4px;
    padding: 1px 4px;
    font-size: 9px;
  }

  .stars {
    gap: 3px;
    overflow: hidden;
  }

  .stars span {
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 10px;
  }

  .stars em {
    font-size: 9px;
  }

  .cardTransformStrip {
    gap: 3px;
  }

  .transformBlock {
    padding: 2px 4px;
    font-size: 9px;
  }

  .transformBadge {
    padding: 1px 3px;
    font-size: 9px;
  }

  .focusPanel .panelHeader {
    align-items: flex-start;
  }

  .center {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    min-height: 0;
    padding: 8px;
    overflow: auto;
  }

  .centerTitle,
  .focusPanel .panelHeader strong {
    font-size: 14px;
  }

  dl {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  dt {
    font-size: 10px;
  }

  dd {
    margin-top: 1px;
    font-size: 11px;
  }

  .focusPanel,
  .copyPanel {
    margin-top: 8px;
    padding: 8px;
  }

  .focusChip {
    padding: 3px 6px;
    font-size: 11px;
  }
}
