:root {
  --bg: #eef8ef;
  --surface: rgba(255, 255, 252, 0.82);
  --surface-solid: #fffefa;
  --ink: #17332a;
  --muted: #6f837a;
  --line: #d6e6d8;
  --green: #0aa267;
  --green-deep: #087e52;
  --green-soft: #dff5e7;
  --red: #ee654d;
  --red-soft: #fff0ed;
  --blue: #3b84d6;
  --blue-soft: #eaf3ff;
  --shadow: 0 22px 60px rgba(44, 91, 63, 0.11);
  --radius-lg: 28px;
  --radius-md: 17px;
  --radius-sm: 11px;
  color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(59, 132, 214, .35);
  outline-offset: 3px;
}
.is-hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.app-shell { min-height: 100vh; padding: 22px 34px 28px; }
.site-header {
  width: min(1180px, 100%); margin: 0 auto 16px; display: flex; align-items: center; justify-content: space-between;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px 14px 14px 4px;
  background: var(--green); color: white; font-family: "Ma Shan Zheng", cursive; font-size: 27px; box-shadow: 0 8px 18px rgba(10, 162, 103, .2);
}
.eyebrow, .mini-label, .section-kicker { margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.site-header h1 { margin: 1px 0 0; font-size: 22px; letter-spacing: -.05em; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.status-pill {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.55); color: var(--muted); font-size: 12px; font-weight: 600;
}
.icon-button {
  width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.65); color: var(--green-deep); font-size: 21px; line-height: 1; transition: transform .2s ease, background .2s ease;
}
.icon-button:hover { transform: rotate(-18deg); background: white; }

.app-layout {
  width: min(1180px, 100%); min-height: calc(100vh - 110px); margin: 0 auto;
  display: grid; grid-template-rows: minmax(120px, 1fr) minmax(390px, 3fr) minmax(145px, 1fr); gap: 15px;
}
.rules-panel, .game-panel, .answer-panel {
  min-width: 0; border: 1px solid rgba(199, 221, 203, .8); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.rules-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 34px; border-radius: var(--radius-lg); }
.rules-copy { min-width: 0; }
.rules-copy h2, .answer-copy h2, .play-toolbar h2 { margin: 4px 0 5px; letter-spacing: -.06em; }
.rules-copy h2 { font-size: clamp(10px, 2.5vw, 15px); }
.rules-copy p:last-child, .answer-copy p { margin: 0; color: var(--muted); font-size: 20px; line-height: 1.75; }
.rules-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 16px; flex: 0 0 auto; }
.legend-item { display: grid; grid-template-columns: 9px auto; grid-template-rows: auto auto; column-gap: 7px; color: var(--muted); font-size: 10px; line-height: 1.2; }
.legend-item strong { grid-column: 2; color: var(--ink); font-size: 11px; letter-spacing: .08em; }
.legend-swatch { grid-row: 1 / span 2; width: 9px; height: 28px; border-radius: 99px; }
.legend-swatch.is-red { background: var(--red); }
.legend-swatch.is-blue { background: var(--blue); }
.legend-swatch.is-green { background: var(--green); }

.game-panel { position: relative; overflow: hidden; border-radius: var(--radius-lg); }
.setup-view, .play-view { height: 100%; }
.setup-view { display: grid; place-items: center; padding: 22px; }
.setup-card {
  width: min(590px, 100%); padding: clamp(22px, 3vw, 34px); border: 1px solid #d9e8da; border-radius: 24px; background: var(--surface-solid); box-shadow: 0 18px 42px rgba(56, 101, 71, .10); animation: rise-in .55s cubic-bezier(.2,.8,.2,1) both;
}
.setup-card-heading, .play-toolbar, .setup-footer, .share-strip, .answer-panel, .success-actions { display: flex; align-items: center; justify-content: space-between; }
.lock-icon { color: var(--green); font-size: 24px; transform: rotate(-22deg); }
.setup-card h2 { margin: 8px 0 7px; font-size: clamp(23px, 3vw, 33px); letter-spacing: -.07em; }
.setup-card > p { margin: 0 0 21px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.field-label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
textarea, input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fbfffb; color: var(--ink); transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
textarea { min-height: 78px; resize: vertical; padding: 13px 14px; line-height: 1.65; }
textarea::placeholder, input::placeholder { color: #a1b0a6; }
textarea:focus, input:focus { border-color: var(--green); background: white; box-shadow: 0 0 0 4px rgba(10, 162, 103, .10); outline: 0; }
.pinyin-preview { display: flex; align-items: baseline; gap: 9px; min-height: 30px; margin: 10px 2px 16px; color: var(--muted); font-size: 11px; }
.pinyin-preview strong { color: var(--green-deep); font-size: 14px; letter-spacing: .1em; word-break: break-all; }
.setup-footer { gap: 15px; }
.helper-text { color: var(--muted); font-size: 10px; }
.primary-button, .secondary-button, .submit-button, .text-button {
  border: 0; transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}
.primary-button, .submit-button { padding: 12px 18px; border-radius: 12px; background: var(--green); color: white; font-size: 12px; font-weight: 800; box-shadow: 0 9px 18px rgba(10, 162, 103, .18); }
.primary-button:hover, .submit-button:hover { transform: translateY(-2px); background: var(--green-deep); box-shadow: 0 12px 22px rgba(10, 126, 82, .22); }

.play-view { display: flex; flex-direction: column; padding: 22px 26px 14px; }
.play-toolbar { flex: 0 0 auto; padding-bottom: 14px; }
.play-toolbar h2 { font-size: clamp(20px, 2.7vw, 29px); }
.round-meta { display: flex; align-items: baseline; gap: 4px; color: var(--muted); font-size: 10px; }
.round-meta strong { color: var(--ink); font-size: 23px; letter-spacing: -.04em; }
.guess-board { min-height: 0; flex: 1; overflow-y: auto; padding: 5px 12px 16px 4px; scrollbar-color: #b8d8c0 transparent; scrollbar-width: thin; }
.empty-board { height: 100%; min-height: 140px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-orbit { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 10px; border: 1px dashed #a9cdb1; border-radius: 50%; color: var(--green); font-size: 22px; animation: breathe 2.4s ease-in-out infinite; }
.empty-board p { margin: 0; font-size: 12px; }
.guess-row { display: flex; align-items: center; gap: 11px; min-height: 72px; padding: 8px 0; animation: row-in .35s ease both; }
.guess-number { width: 28px; flex: 0 0 28px; color: #9aad9f; font-size: 10px; font-weight: 800; text-align: center; }
.letter-track { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; min-width: 0; }
.letter-cell { width: 43px; height: 54px; display: grid; place-items: center; border: 1px solid transparent; border-bottom-width: 5px; border-radius: 12px; box-shadow: 0 6px 13px rgba(33, 66, 45, .07); animation: pop-in .28s ease both; }
.letter-cell .letter { font-size: 22px; font-weight: 800; line-height: 1; }
.letter-cell .hint { margin-top: 2px; font-size: 11px; font-weight: 800; line-height: 1; }
.letter-cell.is-red { border-color: #ffd4cb; border-bottom-color: var(--red); background: var(--red-soft); color: #d64c38; }
.letter-cell.is-blue { border-color: #d0e3ff; border-bottom-color: var(--blue); background: var(--blue-soft); color: #2d71bf; }
.letter-cell.is-green { border-color: #bfe9ce; border-bottom-color: var(--green-deep); background: var(--green); color: white; }
.letter-cell.is-missing { border-color: #e2ebe2; border-bottom-color: #bdcfc1; background: #f5faf5; color: #a7b7ab; }
.guess-entry { display: flex; gap: 9px; flex: 0 0 auto; padding-top: 8px; }
.guess-entry input { min-width: 0; padding: 12px 14px; font-size: 14px; letter-spacing: .12em; }
.submit-button { white-space: nowrap; }
.share-strip { flex: 0 0 auto; gap: 8px; justify-content: flex-start; padding: 13px 0 0; color: var(--muted); font-size: 11px; }
.share-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(10, 162, 103, .1); }
.text-button { margin-left: auto; padding: 3px 0; background: transparent; color: var(--green-deep); font-size: 11px; font-weight: 800; }
.text-button:hover { color: var(--ink); }

.answer-panel { gap: 30px; padding: 22px 34px; border-radius: var(--radius-lg); }
.answer-copy { min-width: 0; }
.answer-copy h2 { font-size: clamp(18px, 2.2vw, 25px); }
.answer-entry { display: flex; gap: 9px; width: min(490px, 48%); }
.answer-entry input { min-width: 0; padding: 12px 14px; font-size: 13px; }
.secondary-button { padding: 11px 15px; border: 1px solid #c9dfce; border-radius: 11px; background: white; color: var(--green-deep); font-size: 12px; font-weight: 800; white-space: nowrap; }
.secondary-button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--green); box-shadow: 0 7px 15px rgba(26, 84, 46, .10); }
.secondary-button:disabled, .answer-entry input:disabled { cursor: not-allowed; opacity: .5; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; max-width: calc(100vw - 40px); padding: 11px 16px; border: 1px solid #cbe1cf; border-radius: 999px; background: #fffefa; color: var(--ink); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .25s ease, transform .25s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.success-modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(24, 57, 42, .23); backdrop-filter: blur(6px); }
.success-card { width: min(430px, 100%); padding: 32px; border: 1px solid #c7e4cf; border-radius: 26px; background: var(--surface-solid); box-shadow: 0 28px 80px rgba(24, 73, 42, .2); text-align: center; animation: rise-in .4s cubic-bezier(.2,.8,.2,1) both; }
.success-burst { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 21px 21px 21px 6px; background: var(--green); color: white; font-size: 31px; box-shadow: 0 12px 24px rgba(10, 162, 103, .24); }
.success-card h2 { margin: 6px 0 8px; font-size: 27px; letter-spacing: -.07em; }
.success-card p { margin: 0 0 24px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.success-actions { justify-content: center; gap: 10px; }

@keyframes rise-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes row-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(5px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.06); opacity: 1; } }

@media (max-width: 780px) {
  .app-shell { padding: 15px 14px 19px; }
  .site-header { margin-bottom: 11px; }
  .site-header h1 { font-size: 20px; }
  .status-pill { display: none; }
  .app-layout { min-height: calc(100vh - 78px); grid-template-rows: auto minmax(470px, 1fr) auto; gap: 10px; }
  .rules-panel { display: block; padding: 17px 18px; }
  .rules-copy h2 { font-size: 21px; }
  .rules-copy p:last-child { font-size: 11px; line-height: 1.65; }
  .rules-legend { justify-content: flex-start; margin-top: 13px; gap: 8px 13px; }
  .legend-item { font-size: 9px; }
  .legend-item strong { font-size: 10px; }
  .game-panel { min-height: 470px; }
  .play-view { padding: 18px 15px 13px; }
  .guess-row { gap: 7px; }
  .guess-number { width: 23px; flex-basis: 23px; }
  .letter-track { gap: 4px; }
  .letter-cell { width: 34px; height: 47px; border-radius: 10px; border-bottom-width: 4px; }
  .letter-cell .letter { font-size: 17px; }
  .letter-cell .hint { font-size: 9px; }
  .answer-panel { display: block; padding: 17px 18px; }
  .answer-entry { width: 100%; margin-top: 11px; }
  .answer-copy p { font-size: 11px; }
}
@media (max-width: 430px) {
  .setup-card { padding: 22px 18px; }
  .setup-footer { align-items: flex-end; }
  .helper-text { max-width: 110px; line-height: 1.5; }
  .primary-button, .submit-button, .secondary-button { padding-left: 13px; padding-right: 13px; }
  .share-strip { font-size: 10px; }
  .text-button { font-size: 10px; }
}
