:root {
  --pine: #1f3d2b;
  --moss: #3a6b45;
  --leaf: #6fa36a;
  --cream: #f4e7c8;
  --paper: #fff6df;
  --ink: #2a1a12;
  --bark: #7a4a28;
  --berry: #c44b2b;
  --gold: #e3a12b;
  --chalk: #eef6d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(227, 161, 43, 0.18), transparent 28%),
    linear-gradient(180deg, #6d8a55 0%, #3f5c3a 42%, #2a4030 100%);
}

.site-switch {
  display: flex;
  width: min(920px, calc(100% - 32px));
  margin: 18px auto 0;
  border: 3px solid #d8b56a;
  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: #3a6b45;
}

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

header {
  color: #f7eed4;
  margin-bottom: 18px;
}

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

.subtitle {
  margin: 8px 0 0;
  font-size: 1.05rem;
  opacity: 0.92;
}

.grade {
  margin: 8px 0 0;
  color: #e3a12b;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
}

.grade span {
  margin-left: 8px;
  letter-spacing: 0;
  color: #f7eed4;
  opacity: 0.88;
  font-size: 0.95rem;
}

.back {
  margin: 0 0 10px;
  font-size: 1rem;
}

.back a {
  color: #f7eed4;
  text-decoration: none;
  border-bottom: 1px dashed rgba(247, 238, 212, 0.45);
}

.sheet {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 18%),
    var(--paper);
  border: 4px solid #d8b56a;
  border-radius: 28px;
  box-shadow: 0 18px 0 rgba(31, 61, 43, 0.18);
  padding: 22px 22px 26px;
  position: relative;
  overflow: hidden;
}

.sheet::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(122, 74, 40, 0.18);
  border-radius: 20px;
  pointer-events: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.92rem;
}

select, button {
  font: inherit;
  border: 0;
  cursor: pointer;
  /* iPad touch target: at least 44 x 44 CSS px. */
  min-height: 44px;
}

button {
  min-width: 44px;
}

select {
  background: var(--cream);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: inset 0 0 0 2px rgba(122, 74, 40, 0.18);
  color: var(--ink);
  min-width: 132px;
}

button {
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--moss);
  color: #f7eed4;
  box-shadow: 0 4px 0 #24462d;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #24462d; }
button.ghost {
  background: #efe0b5;
  color: var(--bark);
  box-shadow: 0 4px 0 #c9ae6d;
}
button.berry {
  background: var(--berry);
  box-shadow: 0 4px 0 #8a2f18;
}

.board {
  position: relative;
  z-index: 1;
  background: linear-gradient(160deg, #35553a, #243826 70%);
  color: var(--chalk);
  border-radius: 22px;
  padding: 22px 20px 18px;
  min-height: 220px;
  box-shadow: inset 0 0 0 6px #1b2b1e;
}

.eqs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 18px;
  font-family: "Fredoka", "ZCOOL KuaiLe", sans-serif;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
}

.eqs.stack {
  grid-template-columns: 1fr;
}

.eq {
  background: rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 10px 14px;
  letter-spacing: 0.04em;
}

.hint {
  margin: 14px 0 0;
  opacity: 0.86;
  font-size: 0.98rem;
}

.answers {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin: 18px 0 14px;
}

.answers.cols-1 { grid-template-columns: minmax(160px, 280px); }
.answers.cols-2 { grid-template-columns: repeat(2, 1fr); }
.answers.cols-3 { grid-template-columns: repeat(3, 1fr); }

.letter-box {
  background: var(--cream);
  border-radius: 18px;
  padding: 12px 10px 14px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(122, 74, 40, 0.16);
}

.letter-box b {
  display: block;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.letter-box input {
  width: 100%;
  border: 0;
  background: #fffaf0;
  border-radius: 12px;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: 1.5rem;
  padding: 8px 4px;
  box-shadow: inset 0 0 0 2px rgba(122, 74, 40, 0.16);
}

.letter-box.ok { box-shadow: 0 4px 0 #3a6b45; }
.letter-box.bad { box-shadow: 0 4px 0 #c44b2b; }

.status {
  position: relative;
  z-index: 1;
  min-height: 1.6em;
  font-size: 1.15rem;
}

.howto {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  background: rgba(255, 246, 223, 0.7);
  border-radius: 16px;
  padding: 8px 14px;
}

.howto summary {
  cursor: pointer;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.1rem;
}

.howto ol {
  margin: 8px 0 6px;
  padding-left: 1.3em;
}

.print-area { display: none; }

@media (max-width: 700px) {
  .answers.cols-2, .answers.cols-3 { grid-template-columns: 1fr 1fr; }
  header { display: block; }
}

@media print {
  body { background: white; }
  .wrap { width: 100%; margin: 0; }
  header, .toolbar, .board, .answers, .status, .sheet, .site-switch { display: none !important; }
  .print-area { display: block; color: #111; }
  .print-item {
    break-inside: avoid;
    border: 2px solid #333;
    padding: 14px 16px 18px;
    margin-bottom: 16px;
    border-radius: 8px;
  }
  .print-item h3 { margin: 0 0 8px; }
  .print-eq { font-size: 1.2rem; margin: 4px 0; font-family: "Fredoka", sans-serif; }
  .print-blanks { margin-top: 10px; letter-spacing: 0.08em; }
}
