:root {
  color-scheme: light;
  --paper: #e9e5da;
  --sheet: #f8f6ef;
  --ink: #141512;
  --muted: #62645d;
  --acid: #d9ff48;
  --error: #b93225;
  --line: #96988f;
  --page-width: 1120px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; overflow-x: hidden; color: var(--ink); background: var(--paper); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible, [tabindex="-1"]:focus-visible { outline: 3px solid var(--error); outline-offset: 4px; }
button:disabled { cursor: default; opacity: .5; }
main, footer { width: min(var(--page-width), calc(100% - 40px)); margin-inline: auto; }

.sentence-hero {
  display: grid;
  min-height: clamp(340px, 50vh, 500px);
  padding: clamp(40px, 6vw, 72px) 0;
  grid-template-columns: minmax(120px, .28fr) minmax(0, 1fr) minmax(220px, .38fr);
  gap: clamp(24px, 5vw, 70px);
  align-items: center;
}
.hero-index, .section-index, .station-head > div > p {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .13em;
}
.hero-index { align-self: start; padding-top: 14px; writing-mode: vertical-rl; }
.sentence-hero h1 {
  margin: 0;
  padding-bottom: .08em;
  font-size: clamp(5rem, 12vw, 9.8rem);
  font-weight: 900;
  letter-spacing: -.095em;
  line-height: 1;
  white-space: nowrap;
}
.sentence-hero h1 span { font-weight: 350; }
.sentence-hero h1 strong { color: var(--sheet); text-shadow: 5px 5px 0 var(--ink); -webkit-text-stroke: 2px var(--ink); }
.hero-copy { align-self: end; padding: 18px 0 6px 18px; border-left: 1px solid var(--line); }
.hero-copy p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.9; }
.hero-copy a {
  display: inline-flex;
  min-height: 44px;
  margin-top: 18px;
  padding: 11px 0 7px;
  align-items: center;
  border-bottom: 2px solid currentColor;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 850;
  text-decoration: none;
}

.sentence-station { display: flow-root; color: var(--sheet); background: var(--ink); }
.station-head {
  display: grid;
  padding: clamp(24px, 3vw, 36px);
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 30px;
  align-items: end;
  border-bottom: 1px solid #4c4d48;
}
.station-head > div > p { color: #a5a79f; }
.station-head h2 { margin: 10px 0 0; font-size: clamp(1.8rem, 3.3vw, 3.25rem); letter-spacing: -.06em; line-height: 1; }
.station-head dl { display: grid; margin: 0; grid-template-columns: repeat(5, auto); gap: clamp(14px, 2.5vw, 30px); }
.station-head dl div { display: grid; gap: 5px; }
.station-head dt { color: #a5a79f; font-size: .62rem; letter-spacing: .1em; }
.station-head dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; white-space: nowrap; }

.difficulty-track {
  display: grid;
  margin: 0;
  padding: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid #4c4d48;
  list-style: none;
}
.difficulty-track li {
  min-width: 0;
  min-height: 48px;
  padding: 12px clamp(8px, 2vw, 20px);
  border-right: 1px solid #4c4d48;
  color: #a5a79f;
  font-size: .74rem;
  font-weight: 800;
}
.difficulty-track li:last-child { border-right: 0; }
.difficulty-track li span { margin-right: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .58rem; }
.difficulty-track li.is-passed { color: var(--sheet); }
.difficulty-track li.is-active { color: var(--ink); background: var(--acid); }

.proof-sheet {
  position: relative;
  overflow: hidden;
  margin: clamp(12px, 2vw, 24px);
  padding: clamp(20px, 3.5vw, 42px);
  color: var(--ink);
  background-color: var(--sheet);
  background-image: linear-gradient(rgb(20 21 18 / 5%) 1px, transparent 1px);
  background-size: 100% 32px;
}
.game-panel { position: relative; overflow: hidden; }
.game-panel::after {
  position: absolute;
  z-index: 5;
  top: 30%;
  left: 50%;
  padding: .08em .16em .04em;
  border: 4px solid var(--ink);
  color: var(--ink);
  background: var(--acid);
  content: "NICE.";
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(3rem, 9vw, 7rem);
  font-weight: 950;
  letter-spacing: -.1em;
  line-height: .9;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-7deg) scale(.7);
}
.proof-instruction { display: flex; margin-bottom: 26px; justify-content: space-between; gap: 20px; align-items: baseline; }
.proof-instruction span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .65rem; font-weight: 800; letter-spacing: .12em; }
.proof-instruction p { margin: 0; color: var(--muted); font-size: .76rem; }
.puzzle-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}
.word-tile {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: clamp(82px, 10vw, 112px);
  padding: 18px 12px 13px;
  place-items: center;
  border: 0;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: rgb(248 246 239 / 90%);
  cursor: pointer;
  transition: color 120ms ease-out, background 120ms ease-out;
  touch-action: manipulation;
}
.word-tile:hover { background: #ece9de; }
.word-tile.is-selected { color: var(--ink); background: var(--acid); }
.word-tile small { position: absolute; top: 8px; left: 9px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .58rem; }
.word-tile span { min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(.82rem, 2.4vw, 1.45rem); font-weight: 850; letter-spacing: -.045em; white-space: nowrap; }
.puzzle-grid.is-wrong { animation: wrong-shake 340ms ease-in-out; }
.is-complete .word-tile { background: var(--acid); }
.is-celebrating .word-tile { animation: word-lock 560ms cubic-bezier(.175, .885, .32, 1.275) both; animation-delay: calc(var(--tile-order) * 55ms); }

.proof-controls { display: flex; margin-top: 24px; gap: 8px; flex-wrap: wrap; }
.proof-controls button, .answer-reveal button {
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font-size: .78rem;
  font-weight: 850;
  cursor: pointer;
  transition: color 120ms ease-out, background 120ms ease-out;
}
.proof-controls button:hover, .answer-reveal button:hover { color: var(--sheet); background: var(--ink); }
.proof-controls .primary-action { color: var(--ink); background: var(--acid); }
.game-status { min-height: 24px; margin: 17px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.6; }

.answer-reveal {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  padding: clamp(20px, 4vw, 46px);
  flex-direction: column;
  justify-content: center;
  border: 3px solid var(--ink);
  color: var(--ink);
  background: var(--sheet);
}
.answer-reveal:focus-visible { outline-color: var(--ink); }
.answer-reveal[hidden] { display: none; }
.answer-label { margin: 0 0 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .65rem; font-weight: 850; letter-spacing: .13em; }
.answer-reveal h2 { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(1.35rem, 3.7vw, 3rem); letter-spacing: -.055em; line-height: 1.12; }
.translation { margin: 16px 0 0; font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.7; }
.language-note { display: grid; margin: 16px 0 0; padding: 12px 0; grid-template-columns: 100px minmax(0, 1fr); gap: 20px; border-block: 1px solid var(--line); }
.language-note span { color: var(--muted); font-size: .68rem; font-weight: 800; }
.language-note p { margin: 0; color: var(--muted); line-height: 1.7; }
.answer-actions { display: flex; margin-top: 18px; gap: 8px; flex-wrap: wrap; }
.answer-actions button { margin: 0; }
.answer-actions .primary-action { color: var(--ink); background: var(--acid); }
.is-celebrating .answer-reveal { animation: answer-enter 720ms cubic-bezier(.05, .7, .1, 1) 650ms both; }

.success-sweep { position: absolute; z-index: 1; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 35%, rgb(217 255 72 / 52%) 50%, transparent 65%); transform: translateX(-120%); }
.is-celebrating .success-sweep { animation: sweep 1700ms cubic-bezier(.2, 0, 0, 1) 180ms both; }
.paper-burst { position: absolute; z-index: 4; top: 46%; left: 50%; width: 1px; height: 1px; pointer-events: none; }
.paper-burst i { position: absolute; width: 7px; height: 13px; background: var(--acid); opacity: 0; }
.paper-burst i:nth-child(1) { --x: -210px; --y: -110px; --r: -45deg; }
.paper-burst i:nth-child(2) { --x: -150px; --y: -165px; --r: 34deg; }
.paper-burst i:nth-child(3) { --x: -80px; --y: -125px; --r: 78deg; }
.paper-burst i:nth-child(4) { --x: -25px; --y: -185px; --r: -24deg; }
.paper-burst i:nth-child(5) { --x: 55px; --y: -150px; --r: 58deg; }
.paper-burst i:nth-child(6) { --x: 125px; --y: -180px; --r: -72deg; }
.paper-burst i:nth-child(7) { --x: 195px; --y: -105px; --r: 38deg; }
.paper-burst i:nth-child(8) { --x: -175px; --y: -45px; --r: 91deg; }
.paper-burst i:nth-child(9) { --x: 175px; --y: -35px; --r: -54deg; }
.paper-burst i:nth-child(10) { --x: 20px; --y: -105px; --r: 125deg; }
.is-celebrating .paper-burst i { animation: paper-burst 1200ms cubic-bezier(.2, 0, 0, 1) 420ms both; }
.is-celebrating .game-panel::after { animation: verdict-stamp 1700ms cubic-bezier(.175, .885, .32, 1.275) 360ms both; }

.learning-note, .sentence-faq {
  display: grid;
  padding: clamp(76px, 11vw, 132px) 0;
  grid-template-columns: minmax(120px, .25fr) minmax(0, 1fr);
  gap: clamp(28px, 7vw, 90px);
  border-bottom: 1px solid var(--line);
}
.section-index { padding-top: 9px; }
.learning-note h2, .sentence-faq h2 { margin: 0; font-size: clamp(2.2rem, 5.5vw, 5rem); letter-spacing: -.07em; line-height: .98; }
.learning-note > div > p { margin: 28px 0 0; color: var(--muted); line-height: 1.9; }
.learning-note ol { margin: 46px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.learning-note li { display: grid; padding: 20px 0; grid-template-columns: 52px minmax(0, .55fr) minmax(0, 1fr); gap: 20px; border-bottom: 1px solid var(--line); }
.learning-note li span { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; }
.learning-note li strong { font-size: .95rem; }
.learning-note li p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.7; }
.sentence-faq details { border-top: 1px solid var(--line); }
.sentence-faq details:last-child { border-bottom: 1px solid var(--line); }
.sentence-faq summary { min-height: 56px; padding: 17px 0; font-weight: 800; cursor: pointer; }
.sentence-faq details p { margin: 0; padding: 0 0 22px; color: var(--muted); line-height: 1.8; }
footer { display: flex; padding: 34px 0 50px; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .72rem; }
footer p { margin: 0; }
footer nav { display: flex; gap: 18px; }
footer a { min-height: 44px; color: inherit; text-underline-offset: 4px; }

@keyframes wrong-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 55% { transform: translateX(8px); } 78% { transform: translateX(-4px); } }
@keyframes word-lock { 0% { transform: scale(1); } 42% { transform: scale(.92); } 100% { transform: scale(1); background: var(--acid); } }
@keyframes sweep { from { transform: translateX(-120%); } to { transform: translateX(120%); } }
@keyframes paper-burst { 0% { opacity: 0; transform: translate(0, 0) rotate(0); } 18% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)); } }
@keyframes answer-enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes verdict-stamp {
  0%, 12% { opacity: 0; transform: translate(-50%, -50%) rotate(-7deg) scale(1.35); }
  24%, 70% { opacity: 1; transform: translate(-50%, -50%) rotate(-7deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) rotate(-4deg) scale(1.05); }
}

@media (max-width: 720px) {
  main, footer { width: min(var(--page-width), calc(100% - 24px)); }
  .sentence-hero { min-height: auto; padding: 32px 0 44px; grid-template-columns: 1fr; gap: 16px; }
  .hero-index { padding: 0; writing-mode: initial; }
  .sentence-hero h1 { font-size: min(calc(20vw + .6rem), 7rem); }
  .sentence-hero h1 strong { text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke-width: 1.5px; }
  .hero-copy { padding: 14px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .station-head { padding: 20px 14px; grid-template-columns: 1fr; gap: 18px; }
  .station-head dl { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
  .station-head dd { white-space: normal; }
  .difficulty-track li { min-height: 52px; padding: 9px 4px; text-align: center; }
  .difficulty-track li span { display: block; margin: 0 0 2px; }
  .proof-sheet { margin: 8px; padding: 18px 10px 24px; }
  .proof-instruction { display: grid; gap: 8px; }
  .word-tile { min-height: 78px; padding: 18px 5px 10px; }
  .word-tile span { font-size: clamp(.68rem, 3.2vw, .95rem); }
  .proof-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .proof-controls .primary-action { grid-column: 1 / -1; }
  .proof-controls button { width: 100%; }
  .answer-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .answer-actions button { width: 100%; }
  .answer-reveal { padding: 16px 14px; }
  .answer-label { margin-bottom: 8px; }
  .answer-reveal h2 { font-size: clamp(1.15rem, 5.1vw, 1.5rem); }
  .translation { margin-top: 9px; font-size: .9rem; line-height: 1.5; }
  .language-note { margin-top: 10px; padding: 9px 0; grid-template-columns: 1fr; gap: 4px; font-size: .78rem; }
  .answer-actions { margin-top: 10px; }
  .learning-note, .sentence-faq { grid-template-columns: 1fr; gap: 20px; }
  .learning-note h2, .sentence-faq h2 { font-size: min(calc(8vw + .75rem), 3.6rem); }
  .learning-note li { grid-template-columns: 38px minmax(0, 1fr); gap: 8px 12px; }
  .learning-note li p { grid-column: 2; }
  footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
