:root {
  --paper: #f5efe3;
  --card: #fffdf8;
  --ink: #17262d;
  --muted: #718087;
  --line: #d9d1c3;
  --coral: #db5b43;
  --teal: #247e76;
  --yellow: #f5c95c;
  --word: #fff0b9;
  --selected: #f7c952;
  --error: #ffd3ca;
  --revealed: #d9eee8;
  --block: #203139;
  --shadow: 0 20px 55px rgba(52, 44, 31, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 4%, rgba(245, 201, 92, .22), transparent 23rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.puzzle-head,
.focus-clue strong,
.status,
.progress-panel,
.clue,
.howto {
  -webkit-user-select: text;
  user-select: text;
}

.focus-clue strong,
.clue { cursor: text; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0 36px; }
.masthead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.brand-mark {
  position: relative; width: 52px; height: 52px; display: grid; grid-template: repeat(3, 14px) / repeat(3, 14px);
  place-content: center; gap: 2px; flex: 0 0 auto; border: 2px solid var(--ink); border-radius: 19px;
  background: var(--ink); box-shadow: 5px 5px 0 rgba(23, 38, 45, .16); transform: rotate(-3deg);
}
.mark-tile, .mark-center { display: grid; place-items: center; border-radius: 5px; }
.mark-tile { width: 14px; height: 14px; }
.mark-top { grid-area: 1 / 2; background: var(--teal); }
.mark-left { grid-area: 2 / 1; background: #e98465; }
.mark-center { grid-area: 2 / 2; width: 14px; height: 14px; background: var(--yellow); color: var(--ink); font-size: 12px; font-weight: 950; }
.mark-right { grid-area: 2 / 3; background: #f0e7d5; }
.mark-bottom { grid-area: 3 / 2; background: var(--coral); }
.brand-copy { flex: 1; }
.brand-copy h1 { display: inline; margin: 1px 8px 0 0; font-size: clamp(23px, 3vw, 30px); letter-spacing: -.06em; line-height: 1.05; }
.kicker { margin: 0; color: var(--teal); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.brand-en { display: inline; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .22em; }
.freshness { align-self: flex-start; margin-top: 8px; color: var(--teal); font-size: 12px; font-weight: 800; }
.freshness span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #34a98f; box-shadow: 0 0 0 4px #34a98f22; }

.game-layout { display: grid; grid-template-columns: minmax(540px, 1fr) 380px; gap: 18px; align-items: start; }
.play-card, .clue-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.play-card { padding: 16px; }
.puzzle-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.puzzle-head h2 { margin: 6px 0 2px; font-size: clamp(18px, 2.5vw, 23px); letter-spacing: -.03em; }
.puzzle-head p { margin: 0; color: var(--muted); font-size: 13px; }
.meta-line { display: none; }
.topic-tag { padding: 5px 9px; border-radius: 99px; background: #e3f1ed; color: var(--teal); }
.head-tools { display: flex; align-items: stretch; gap: 7px; }
.hint-button {
  min-width: 74px; padding: 7px 10px; border: 1px solid #e4ba4e; border-radius: 12px;
  background: #fff4c9; color: var(--ink); cursor: pointer; text-align: center;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.hint-button:hover { transform: translateY(-1px); background: #ffedaa; box-shadow: 0 5px 12px #25343a12; }
.hint-button:active { transform: translateY(0); }
.hint-button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.hint-icon { display: block; font-size: 20px; line-height: 1.1; }
.hint-copy { display: block; margin-top: 3px; font-size: 10px; font-weight: 800; }
.hint-copy b { color: var(--coral); font-size: 12px; }
.clock { min-width: 78px; padding: 9px 12px; border-radius: 12px; background: #f2eee6; text-align: right; }
.clock span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; }
.clock strong { font-variant-numeric: tabular-nums; font-size: 20px; letter-spacing: .04em; }

.focus-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(100%, 680px); margin: 8px auto; }
.focus-clue {
  min-width: 0; min-height: 68px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: #f4f0e9; text-align: left; cursor: pointer; transition: background .12s, border-color .12s;
}
.focus-clue span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.focus-clue span b { color: var(--coral); font-size: 14px; }
.focus-clue strong { display: block; overflow: visible; font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; white-space: normal; }
.focus-clue.active { border: 2px solid var(--ink); background: var(--word); box-shadow: inset 4px 0 var(--coral); }
.focus-clue:disabled { cursor: default; opacity: .55; }

.board-wrap { position: relative; width: min(100%, 680px, 74vh); margin: 0 auto; }
.board {
  display: grid; aspect-ratio: 1; width: 100%; overflow: hidden;
  border: 3px solid var(--block); border-radius: 5px; background: var(--block); gap: 2px;
  box-shadow: 0 9px 24px rgba(28, 43, 49, .12);
}
.cell { position: relative; min-width: 0; background: #fffefb; transition: background .12s ease; }
.cell.block { background: var(--block); }
.cell.word { background: var(--word); box-shadow: inset 0 -2px var(--teal); }
.cell.selected { z-index: 3; background: var(--selected); box-shadow: inset 0 0 0 3px var(--ink); }
.cell.selected::after { content: attr(data-direction); position: absolute; z-index: 4; right: 2px; bottom: 0; color: var(--coral); font-size: clamp(10px, 1.5vw, 14px); font-weight: 950; pointer-events: none; }
.cell.correct:not(.selected)::after { content: "✓"; position: absolute; z-index: 4; right: 2px; bottom: 0; color: var(--teal); font-size: 11px; font-weight: 950; pointer-events: none; }
.cell.error { background: var(--error); box-shadow: inset 0 0 0 3px #aa3d2b; animation: nudge .2s ease 2; }
.cell.error::after { content: "!"; position: absolute; z-index: 4; right: 3px; bottom: 0; color: #aa3d2b; font-size: 12px; font-weight: 950; pointer-events: none; }
.cell.revealed { background: var(--revealed); }
.cell-number { position: absolute; z-index: 2; top: 2px; left: 3px; font-size: clamp(7px, 1.1vw, 10px); font-weight: 900; line-height: 1; pointer-events: none; }
.cell input {
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 3px 0 0;
  border: 0; outline: 0; background: transparent; text-align: center;
  color: var(--ink); font-size: clamp(18px, 3vw, 30px); font-weight: 850; caret-color: var(--coral);
}
.cell input:focus-visible { box-shadow: inset 0 0 0 3px var(--ink); }
.pause-curtain {
  position: absolute; inset: 0; display: none; place-items: center; align-content: center; gap: 6px;
  border-radius: 5px; background: rgba(23, 38, 45, .94); color: white; text-align: center;
}
.pause-curtain.show { display: grid; }
.pause-curtain strong { font-size: 26px; }
.pause-curtain span { color: #d9e2e4; font-size: 13px; }

.status { min-height: 20px; margin: 8px 2px 6px; color: var(--muted); font-size: 12px; }
.status.negative { color: #aa3d2b; font-weight: 700; }
.status.positive { color: var(--teal); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: #faf7f0; }
.button {
  min-height: 42px; padding: 10px 14px; border: 1px solid #d6cec1; border-radius: 11px;
  background: #f4f0e9; font-size: 13px; font-weight: 850; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 5px 12px #25343a12; }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { border-color: var(--coral); background: var(--coral); color: white; }
.button.warm { border-color: #e4ba4e; background: #f8d56f; }
.button.quiet { background: transparent; }
.actions .button.primary { flex: 1 1 138px; }
.actions .button.warm { flex: 1 1 112px; }
.actions #reset { margin-left: auto; }

.clue-card { position: sticky; top: 12px; padding: 14px; max-height: calc(100vh - 24px); overflow: auto; scrollbar-width: thin; scroll-behavior: smooth; }
.progress-panel { padding: 14px; border-radius: 15px; background: #f4f0e9; }
.progress-title { display: flex; justify-content: space-between; font-size: 13px; }
.progress-title strong { font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; margin: 10px 0 11px; overflow: hidden; border-radius: 99px; background: #ded8cf; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--teal); transition: width .2s; }
.stats { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.stats b { color: var(--ink); }
.clue-section { margin-top: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; padding: 0 3px; }
.section-title h3 { margin: 0 0 9px; font-size: 16px; }
.section-title span { color: var(--muted); font-size: 11px; }
.clue-list { display: grid; gap: 7px; }
.clue {
  width: 100%; padding: 10px 11px; border: 0; border-radius: 10px; background: #f4f0e9;
  text-align: left; line-height: 1.45; font-size: 13px;
}
.clue:hover, .clue.active { background: var(--word); }
.clue.active { box-shadow: inset 3px 0 var(--coral); }
.clue-number { margin-right: 7px; color: var(--coral); font-weight: 900; }
.clue-category { display: inline-block; margin: 0 5px 0 2px; color: var(--teal); font-size: 9px; font-weight: 800; white-space: nowrap; }
.clue-difficulty { display: none; }
.difficulty-简单 { background: #e2f2e9; color: #267357; }
.difficulty-困难 { background: #f8e1dc; color: #a94432; }
.clue-length { color: var(--muted); font-size: 11px; white-space: nowrap; }
.howto { margin: 20px 2px 2px; padding-top: 15px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 11px; line-height: 1.7; }

.complete-dialog { width: min(390px, calc(100% - 36px)); padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); color: var(--ink); text-align: center; box-shadow: 0 28px 90px #13262e44; }
.complete-dialog::backdrop { background: rgba(20, 35, 42, .65); backdrop-filter: blur(3px); }
.complete-dialog h2 { margin: 8px 0; }
.complete-dialog p:not(.kicker) { color: var(--muted); line-height: 1.6; }
.complete-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 50%; background: var(--teal); color: white; font-size: 26px; font-weight: 900; }
.complete-actions { display: flex; justify-content: center; gap: 8px; }

.fatal { width: min(560px, calc(100% - 32px)); margin: 12vh auto; padding: 28px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
@keyframes nudge { 50% { transform: translateX(2px); } }

@media (max-width: 920px) {
  .game-layout { grid-template-columns: 1fr; }
  .clue-card { position: static; max-height: none; }
  .board-wrap { width: min(100%, 680px); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 15px; }
  .freshness { display: none; }
  .masthead { gap: 12px; margin-bottom: 17px; }
  .brand-mark { width: 52px; height: 52px; grid-template: repeat(3, 14px) / repeat(3, 14px); gap: 1px; border-radius: 16px; box-shadow: 4px 4px 0 rgba(23, 38, 45, .16); }
  .mark-tile, .mark-center { width: 14px; height: 14px; border-radius: 4px; }
  .mark-center { font-size: 12px; }
  .brand-copy h1 { font-size: 26px; }
  .kicker { font-size: 10px; letter-spacing: .08em; }
  .brand-en { margin-top: 3px; font-size: 8px; }
  .play-card, .clue-card { border-radius: 16px; }
  .play-card { padding: 12px; }
  .puzzle-head { gap: 8px; margin-bottom: 12px; }
  .puzzle-head h2 { margin-top: 6px; }
  .puzzle-head p { display: none; }
  .focus-guide { grid-template-columns: 1fr; gap: 6px; }
  .focus-clue { min-height: 60px; padding: 7px 9px; }
  .clock { min-width: 68px; padding: 8px; }
  .board { gap: 1px; border-width: 2px; }
  .cell input { font-size: clamp(20px, 7.5vw, 34px); }
  .button { flex: 1 1 auto; }
  .button.primary { flex-basis: 45%; }
  .button.quiet { margin-left: 0; }
}
