:root {
  color-scheme: light;
  --paper: #f5f1e8;
  --paper-bright: #fffdf8;
  --ink: #1d201f;
  --muted: #706e67;
  --line: #d6d0c4;
  --coral: #e85d4a;
  --coral-dark: #b83e31;
  --teal: #287f79;
  --mustard: #d5a62d;
  --cold: #648aa3;
  --shadow: 0 18px 55px rgba(53, 45, 35, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background-color: var(--paper);
  background-image: url("assets/lexicon-pattern.svg");
  background-attachment: fixed;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(29, 32, 31, 0.22);
}

.brand {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--paper-bright);
  background: var(--ink);
  border-radius: 4px;
  font-family: "STSong", "SimSun", serif;
  font-size: 24px;
  box-shadow: 5px 5px 0 var(--coral);
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-family: "STSong", "SimSun", serif;
  font-size: 25px;
  line-height: 1.05;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 18px;
}

.solved-stat,
.date-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.solved-stat strong {
  min-width: 28px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 20px;
  text-align: center;
}

.date-control {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.date-control input {
  height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
}

.date-control input:focus-visible,
.guess-form input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(40, 127, 121, 0.24);
  outline-offset: 2px;
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.85fr);
  min-height: 640px;
  margin: 38px 0 30px;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(29, 32, 31, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.play-area {
  position: relative;
  min-width: 0;
  padding: 52px 58px 44px;
}

.attempts-area {
  min-width: 0;
  padding: 40px 34px;
  background: rgba(238, 234, 224, 0.78);
  border-left: 1px solid var(--line);
}

.puzzle-heading,
.attempts-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  letter-spacing: 0;
}

h1 {
  max-width: 540px;
  margin-bottom: 0;
  font-family: "STSong", "SimSun", serif;
  font-size: 46px;
  font-weight: 700;
  line-height: 1.22;
}

.best-score {
  min-width: 90px;
  text-align: right;
}

.best-score > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.best-score strong {
  white-space: nowrap;
  font-family: Georgia, serif;
  font-weight: 400;
}

.best-score b {
  font-size: 31px;
  font-weight: 400;
}

.best-score small {
  color: var(--coral);
  font-size: 15px;
}

.best-meter {
  width: 100%;
  height: 5px;
  margin: 28px 0 42px;
  background: #ded9cf;
  overflow: hidden;
}

.best-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--coral);
  transition: width 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.feedback {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.feedback strong {
  display: block;
  margin-bottom: 3px;
  font-family: "STSong", "SimSun", serif;
  font-size: 22px;
}

.feedback p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.temperature-dot {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
  color: var(--cold);
  transition: color 250ms ease, background 250ms ease, transform 250ms ease;
}

.temperature-dot::after {
  content: "";
  position: absolute;
  inset: 10px;
  background: currentColor;
  border-radius: 50%;
  opacity: 0.28;
}

.temperature-dot.is-idle {
  color: #aaa59b;
}

.temperature-dot.is-cool {
  color: var(--cold);
}

.temperature-dot.is-warm {
  color: var(--mustard);
}

.temperature-dot.is-hot {
  color: var(--coral);
  background: rgba(232, 93, 74, 0.08);
  transform: scale(1.08);
}

.guess-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.input-wrap {
  position: relative;
  min-width: 0;
}

.guess-form input {
  width: 100%;
  height: 58px;
  padding: 0 60px 0 18px;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid #aaa49a;
  border-radius: 4px;
  font-size: 17px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.guess-form input::placeholder {
  color: #aaa59b;
}

.guess-form input:focus {
  border-color: var(--teal);
  box-shadow: inset 0 -3px 0 rgba(40, 127, 121, 0.14);
}

.input-count {
  position: absolute;
  top: 50%;
  right: 15px;
  color: #aaa59b;
  font-size: 10px;
  transform: translateY(-50%);
}

.guess-form button,
.success-panel button {
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 22px;
  color: white;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.guess-form button:hover,
.success-panel button:hover {
  background: var(--teal);
  border-color: var(--teal);
}

.guess-form button:active,
.success-panel button:active {
  transform: translateY(1px);
}

.guess-form button:disabled,
.guess-form input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-note {
  margin: 9px 0 30px;
  color: var(--muted);
  font-size: 11px;
}

.heat-scale {
  display: grid;
  grid-template-columns: auto repeat(5, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

.heat-scale i {
  height: 5px;
  background: var(--cold);
}

.heat-scale i:nth-of-type(2) {
  background: #70a6a0;
}

.heat-scale i:nth-of-type(3) {
  background: var(--mustard);
}

.heat-scale i:nth-of-type(4) {
  background: #e38645;
}

.heat-scale i:nth-of-type(5) {
  background: var(--coral);
}

.success-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  color: var(--paper-bright);
  background-color: #222a27;
  background-image: url("assets/lexicon-pattern.svg");
  background-blend-mode: soft-light;
}

.success-panel[hidden] {
  display: none;
}

.success-stamp {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin-bottom: 30px;
  color: white;
  background: var(--coral);
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  font-family: "STSong", "SimSun", serif;
  font-size: 34px;
  transform: rotate(-7deg);
  box-shadow: 0 0 0 5px var(--coral);
}

.success-panel p {
  margin-bottom: 8px;
  color: #f0b2a9;
  font-size: 12px;
  font-weight: 700;
}

.success-panel h2 {
  margin: 0 0 12px;
  font-family: "STSong", "SimSun", serif;
  font-size: 42px;
}

.success-panel div > span {
  color: #c6ccc8;
  font-size: 13px;
}

.success-panel button {
  height: 46px;
  margin-top: 34px;
  color: var(--ink);
  background: var(--paper-bright);
  border-color: var(--paper-bright);
}

.attempts-heading {
  align-items: center;
  padding-bottom: 20px;
}

.attempts-heading h2 {
  margin-bottom: 0;
  font-family: "STSong", "SimSun", serif;
  font-size: 25px;
}

.attempt-count {
  color: var(--muted);
  font-size: 11px;
}

.attempt-count b {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 19px;
  font-weight: 400;
}

.attempt-columns,
.attempt-list li {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) minmax(76px, 0.9fr) 72px;
  align-items: center;
  gap: 10px;
}

.attempt-columns {
  padding: 10px 0;
  color: #8d8980;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.attempt-columns span:last-child {
  text-align: right;
}

.attempt-list {
  max-height: 456px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  scrollbar-color: #bcb5aa transparent;
  scrollbar-width: thin;
  list-style: none;
}

.attempt-list li {
  min-height: 58px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(214, 208, 196, 0.76);
  animation: row-in 260ms ease both;
}

.attempt-word {
  min-width: 0;
  overflow: hidden;
  font-family: "STSong", "SimSun", serif;
  font-size: 17px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-badge {
  width: fit-content;
  max-width: 100%;
  padding: 3px 7px;
  color: var(--muted);
  background: rgba(29, 32, 31, 0.06);
  border-radius: 3px;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attempt-score {
  font-family: Georgia, serif;
  font-size: 16px;
  text-align: right;
}

.attempt-score small {
  color: var(--muted);
  font-size: 10px;
}

.attempt-list li[data-heat="hot"] .attempt-score,
.attempt-list li[data-heat="hit"] .attempt-score {
  color: var(--coral-dark);
}

.attempt-list li[data-heat="warm"] .attempt-score {
  color: #a57300;
}

.empty-attempts {
  min-height: 270px;
  display: grid;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-attempts[hidden] {
  display: none;
}

.empty-glyph {
  position: relative;
  width: 88px;
  height: 70px;
  margin: 0 auto 18px;
}

.empty-glyph span {
  position: absolute;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--paper-bright);
  background: var(--ink);
  border-radius: 3px;
  font-family: "STSong", "SimSun", serif;
  font-size: 19px;
}

.empty-glyph span:nth-child(1) {
  left: 0;
  top: 5px;
  background: var(--teal);
  transform: rotate(-8deg);
}

.empty-glyph span:nth-child(2) {
  left: 27px;
  top: 0;
  z-index: 2;
}

.empty-glyph span:nth-child(3) {
  right: 0;
  top: 22px;
  background: var(--coral);
  transform: rotate(7deg);
}

.empty-attempts p {
  margin: 0;
  font-size: 12px;
}

footer {
  min-height: 54px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #77736b;
  font-size: 10px;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  background: var(--coral);
  animation: confetti-fall 1800ms ease-in forwards;
}

.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;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--drift), 105vh, 0) rotate(720deg);
  }
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100% - 28px, 680px);
  }

  .game-layout {
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .attempts-area {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .attempt-list {
    max-height: 360px;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: 100%;
  }

  .topbar {
    min-height: 78px;
    padding: 0 18px;
  }

  .brand small,
  .solved-stat span,
  .date-control > span {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 21px;
  }

  .brand strong {
    font-size: 22px;
  }

  .topbar-tools {
    gap: 10px;
  }

  .date-control {
    padding-left: 10px;
  }

  .date-control input {
    width: 132px;
  }

  .game-layout {
    min-height: 0;
    margin: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .play-area {
    padding: 34px 20px 32px;
  }

  .attempts-area {
    padding: 30px 20px 36px;
  }

  .puzzle-heading {
    gap: 12px;
  }

  h1 {
    font-size: 31px;
  }

  .success-panel h2 {
    font-size: 31px;
  }

  .best-score {
    min-width: 73px;
  }

  .best-score b {
    font-size: 25px;
  }

  .best-meter {
    margin: 22px 0 30px;
  }

  .feedback {
    min-height: 66px;
  }

  .feedback strong {
    font-size: 19px;
  }

  .guess-form {
    grid-template-columns: 1fr;
  }

  .guess-form input,
  .guess-form button {
    height: 54px;
  }

  .guess-form button {
    width: 100%;
  }

  .success-panel {
    padding: 34px 24px;
  }

  footer {
    padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
