:root {
  --moss: #3a6b45;
  --cream: #f4e7c8;
  --paper: #fff6df;
  --ink: #2a1a12;
  --gold: #d8b56a;
  --bark: #7a4a28;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  overflow-x: visible;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 14% 16%, rgba(227, 161, 43, 0.16), transparent 28%),
    linear-gradient(180deg, #6d8a55 0%, #2a4030 100%);
}

[hidden] { display: none !important; }

.site-switch {
  display: flex;
  width: min(920px, calc(100% - 32px));
  margin: 18px auto 0;
  border: 3px solid var(--gold);
  border-radius: 18px;
  overflow: hidden;
  background: #2a4030;
}

.site-switch a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-align: center;
  padding: 10px 8px;
  color: #f7eed4;
  text-decoration: none;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.02rem;
}

.site-switch a.on { background: var(--moss); }

.wrap { width: min(920px, calc(100% - 32px)); margin: 18px auto 48px; }

h1 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  color: #f7eed4;
  text-shadow: 0 3px 0 rgba(31, 61, 43, 0.35);
}

.subtitle { margin: 8px 0 16px; color: #f7eed4; opacity: 0.92; }

.module-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.pill {
  min-height: 44px;
  border: 3px solid var(--gold);
  border-radius: 18px;
  background: #2a4030;
  color: #f7eed4;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 0.92rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  cursor: pointer;
}

.pill.on, .pill[aria-current="page"] { background: var(--moss); }

.sheet {
  background: var(--paper);
  border: 4px solid var(--gold);
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 18px 0 rgba(31, 61, 43, 0.18);
  overflow: visible;
}

.mode-intro, .disclaimer, .muted, .hint, .stats {
  color: var(--bark);
  overflow-wrap: anywhere;
}

.disclaimer { font-size: 0.88rem; }

.rules-fold {
  margin: 12px 0;
  background: var(--cream);
  border-radius: 18px;
  padding: 8px 12px;
}

summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.auto-next {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

button, select, input[type="number"], textarea {
  min-height: 44px;
  font-size: 16px;
  color: var(--ink);
  border: 3px solid var(--gold);
  border-radius: 18px;
  background: #fffdf8;
  padding: 8px 12px;
  font-family: inherit;
  max-width: 100%;
}

button {
  cursor: pointer;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
}

button:hover { filter: brightness(1.04); }

#submitCase, #closeLesson {
  background: var(--moss);
  color: #f7eed4;
}

.case-card {
  margin-top: 10px;
  background: var(--cream);
  border: 3px solid var(--gold);
  border-radius: 22px;
  padding: 16px;
}

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

.pillar {
  background: var(--paper);
  border: 3px solid var(--gold);
  border-radius: 18px;
  padding: 10px;
  text-align: center;
  min-width: 0;
}

.pillar b {
  display: block;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.35rem;
}

.chart-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chart-meta span {
  background: var(--paper);
  border-radius: 18px;
  padding: 8px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  overflow-wrap: anywhere;
}

fieldset {
  min-width: 0;
  max-width: 100%;
  border: 3px solid var(--gold);
  border-radius: 18px;
  padding: 10px;
}

.field-block {
  display: block;
  margin: 12px 0;
  font-weight: 600;
  min-width: 0;
}

.field-block select,
.field-block input[type="number"],
.field-block textarea {
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  font-weight: 400;
}

.weights {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.weights label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  background: var(--paper);
  border-radius: 18px;
  padding: 0 12px;
  font-weight: 400;
}

.weights input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
  min-height: 20px;
}

.weight-total { margin: 8px 0 0; }

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

.feedback {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.feedback-block {
  background: var(--cream);
  border: 3px solid var(--gold);
  border-radius: 22px;
  padding: 14px;
  margin-bottom: 10px;
}

.feedback-block h3 {
  margin: 0 0 8px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
}

.mini-chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.mini-chart span {
  background: var(--paper);
  border-radius: 12px;
  padding: 6px;
  text-align: center;
  font-size: 0.9rem;
}

.task { font-weight: 700; }

.trap { color: #7a2a1c; }

#copyFallback {
  width: 100%;
  min-height: 88px;
  margin-top: 8px;
}

dialog {
  width: min(36rem, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 4px solid var(--gold);
  border-radius: 28px;
  background: var(--paper);
  color: var(--ink);
  padding: 18px;
}

dialog::backdrop { background: rgba(42, 26, 18, 0.45); }

.colophon { margin-top: 16px; color: #f7eed4; }

:focus-visible {
  outline: 3px solid #f7eed4;
  outline-offset: 2px;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.pill:focus-visible,
a:focus-visible,
#feedback:focus-visible {
  outline: 3px solid var(--moss);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  nav.site-switch {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  nav.site-switch > a {
    min-width: 0;
    min-height: 44px;
    padding: 8px 4px;
    font-size: 15px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .module-switch { grid-template-columns: 1fr 1fr; }
  .actions { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .sheet { padding: 14px; }
  .chart, .mini-chart {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  .pillar {
    padding: 4px 2px;
    border-width: 2px;
    border-radius: 10px;
  }
  .pillar b { font-size: 1.15rem; }
  .pillar .muted { font-size: 0.7rem; }
  .chart-meta span {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 0.85rem;
  }
}
