.fun-view {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 36px clamp(20px, 4vw, 56px);
  background:
    radial-gradient(circle at 78% 12%, rgba(59, 130, 246, 0.1), transparent 28%),
    var(--panel);
  color: var(--zinc-200);
}

.fun-head {
  max-width: 760px;
}

.fun-head h2 {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 32px;
}

.fun-head > p:last-child {
  margin: 10px 0 0;
  color: var(--zinc-400);
  line-height: 1.7;
}

.fun-grid {
  width: min(100%, 1040px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.fun-mode-card {
  min-height: 240px;
  border: 1px solid rgba(96, 165, 250, 0.34);
  border-radius: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: 14px;
  padding: 22px;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.12), rgba(42, 45, 53, 0.92));
}

.fun-mode-card.soon {
  border-color: var(--card-line);
  background: rgba(42, 45, 53, 0.66);
}

.fun-mode-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  font-size: 24px;
}

.fun-status {
  color: #60a5fa;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.fun-mode-card.soon .fun-status {
  color: var(--zinc-500);
}

.fun-mode-card h3 {
  margin: 5px 0 7px;
  font-size: 20px;
}

.fun-mode-card p {
  margin: 0;
  color: var(--zinc-400);
  font-size: 14px;
  line-height: 1.65;
}

.fun-mode-card > button,
.fun-coming {
  grid-column: 2;
  justify-self: start;
  margin-top: auto;
}

.fun-coming {
  color: var(--zinc-500);
  font-size: 13px;
  font-weight: 700;
}

.story-shell {
  width: min(100%, 820px);
  margin: 0 auto;
}

.story-progress {
  display: flex;
  justify-content: space-between;
  color: var(--zinc-400);
  font-size: 12px;
}

.story-progress strong {
  color: #93c5fd;
}

.story-scene {
  margin: 18px 0;
  border-left: 3px solid rgba(96, 165, 250, 0.72);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--zinc-400);
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 17px;
  line-height: 1.8;
}

.story-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  padding: 18px;
  background: var(--card);
}

.story-message small {
  color: var(--zinc-500);
  font-size: 12px;
}

.story-message p {
  margin: 6px 0 0;
  color: var(--zinc-200);
  line-height: 1.7;
}

.story-prompt {
  margin-top: 20px;
}

.story-prompt h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.story-choices {
  display: grid;
  gap: 10px;
}

.story-choice {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--zinc-400);
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.story-choice > span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 800;
}

.story-choice p {
  margin: 0;
  line-height: 1.6;
}

.story-choice.matching {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
  color: #dbeafe;
}

.story-choice.dimmed {
  opacity: 0.48;
}

.fun-char {
  border-radius: 4px;
  transition: color 80ms ease, background 80ms ease;
}

.fun-char.pending {
  color: inherit;
}

.fun-char.current {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.fun-char.correct {
  color: #4ade80;
}

.fun-char.wrong {
  color: var(--red);
}

.fun-typing-hint {
  margin-top: 16px;
  color: var(--zinc-500);
  font-size: 12px;
}

.fun-keyboard-card {
  margin-top: 20px;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(24, 26, 32, 0.72);
}

.fun-keyboard-toggle {
  width: 100%;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  background: transparent;
  color: var(--zinc-200);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.fun-keyboard-toggle span:last-child {
  color: var(--zinc-400);
  font-size: 13px;
  font-weight: 650;
}

.fun-keyboard-toggle[aria-expanded="false"] + .virtual-keyboard {
  display: none;
}

.ending-shell {
  max-width: 660px;
  padding-top: min(12vh, 100px);
  text-align: center;
}

.ending-mark {
  width: 66px;
  height: 66px;
  margin: 14px auto;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  font-size: 30px;
}

.ending-shell h2 {
  margin: 0;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 30px;
}

.ending-shell > p:not(.eyebrow) {
  color: var(--zinc-400);
  line-height: 1.8;
}

.story-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.memory-shell {
  width: min(100%, 820px);
  margin: 0 auto;
}

.memory-intro {
  max-width: 660px;
}

.memory-intro h2,
.memory-result h2 {
  margin: 0;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 32px;
}

.memory-intro > p:last-child,
.memory-tip {
  color: var(--zinc-400);
  line-height: 1.7;
}

.memory-options {
  margin-top: 28px;
}

.memory-options h3 {
  margin: 20px 0 10px;
  font-size: 14px;
}

.memory-choice-row,
.memory-difficulty-grid {
  display: grid;
  gap: 10px;
}

.memory-choice-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.memory-choice,
.memory-difficulty {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  background: var(--card);
  color: var(--zinc-300);
  cursor: pointer;
}

.memory-choice {
  min-height: 44px;
  font-weight: 750;
}

.memory-choice:hover,
.memory-choice.active,
.memory-difficulty:hover,
.memory-difficulty.active {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  color: #dbeafe;
}

.memory-difficulty-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.memory-difficulty {
  display: grid;
  gap: 5px;
  padding: 16px;
  text-align: left;
}

.memory-difficulty strong {
  font-size: 16px;
}

.memory-difficulty span {
  color: #93c5fd;
  font-weight: 800;
}

.memory-difficulty small {
  color: var(--zinc-500);
  line-height: 1.5;
}

.memory-pinyin-option {
  margin-top: 14px;
  border: 1px solid var(--card-line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.memory-pinyin-option input {
  width: 18px;
  height: 18px;
  accent-color: #3b82f6;
}

.memory-pinyin-option span,
.memory-pinyin-option strong,
.memory-pinyin-option small {
  display: block;
}

.memory-pinyin-option small {
  margin-top: 3px;
  color: var(--zinc-500);
}

.memory-records {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  color: var(--zinc-400);
  font-size: 13px;
}

.memory-records span {
  border: 1px solid var(--card-line);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.035);
}

.memory-records strong {
  margin-left: 4px;
  color: #fbbf24;
}

.memory-stage,
.memory-result {
  padding-top: min(8vh, 70px);
  text-align: center;
}

.memory-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 14px 0;
  color: var(--zinc-400);
}

.memory-countdown svg {
  width: 58px;
  height: 58px;
  overflow: visible;
}

.memory-countdown > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.memory-countdown strong {
  color: #93c5fd;
  font-size: 42px;
}

.memory-clock-track,
.memory-clock-progress {
  fill: rgba(15, 23, 42, 0.4);
  stroke-width: 3;
}

.memory-clock-track {
  stroke: rgba(148, 163, 184, 0.18);
}

.memory-clock-progress {
  fill: none;
  stroke: #60a5fa;
  stroke-dasharray: 100;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  animation: memory-clock-drain var(--clock-duration) linear forwards;
}

.memory-clock-hand {
  stroke: #bfdbfe;
  stroke-linecap: round;
  stroke-width: 2;
  transform-origin: 24px 24px;
  animation: memory-clock-turn var(--clock-duration) linear forwards;
}

.memory-clock-pin {
  fill: #dbeafe;
}

.memory-clock--input strong {
  color: #fbbf24;
}

.memory-clock--input .memory-clock-progress {
  stroke: #f59e0b;
}

.memory-clock--input .memory-clock-hand {
  stroke: #fde68a;
}

.memory-clock--input .memory-clock-pin {
  fill: #fef3c7;
}

@keyframes memory-clock-drain {
  to { stroke-dashoffset: 100; }
}

@keyframes memory-clock-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .memory-clock-progress,
  .memory-clock-hand {
    animation: none;
  }
}

.memory-target {
  margin: 28px auto 18px;
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 14px;
  padding: 34px 24px;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.12), rgba(42, 45, 53, 0.92));
  color: #fff;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: 0.08em;
  line-height: 1.5;
}

.memory-target.with-pinyin {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: center;
  gap: 7px;
  letter-spacing: 0;
}

.memory-target-char {
  display: inline-grid;
  justify-items: center;
  gap: 3px;
}

.memory-target-char small {
  min-height: 18px;
  color: #93c5fd;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.memory-target-char strong {
  font: inherit;
}

.memory-hidden-mark {
  margin: 28px 0;
  color: var(--zinc-600);
  font-size: 34px;
  letter-spacing: 0.32em;
}

.memory-typed-preview {
  min-height: 78px;
  border: 1px dashed var(--card-line);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 18px;
  color: #dbeafe;
  font-size: 26px;
  line-height: 1.5;
}

.memory-placeholder {
  color: var(--zinc-600);
  font-size: 15px;
}

.memory-input-label {
  display: block;
  margin: 20px 0 8px;
  color: var(--zinc-400);
  font-size: 13px;
  text-align: left;
}

.memory-input {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--card-line);
  border-radius: 10px;
  padding: 14px;
  resize: vertical;
  background: var(--card);
  color: var(--zinc-100);
  font: inherit;
  font-size: 18px;
  line-height: 1.6;
}

.memory-input:focus {
  border-color: #60a5fa;
  outline: 2px solid rgba(96, 165, 250, 0.18);
}

.memory-score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.memory-performance-compare {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.memory-performance-compare > div {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.memory-performance-compare span,
.memory-performance-compare strong {
  display: block;
}

.memory-performance-compare span {
  color: var(--zinc-500);
  font-size: 12px;
}

.memory-performance-compare strong {
  margin-top: 5px;
  color: #93c5fd;
  font-size: 14px;
}

.memory-score-grid > div {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  padding: 14px 8px;
  background: var(--card);
}

.memory-score-grid span,
.memory-score-grid strong {
  display: block;
}

.memory-score-grid span {
  color: var(--zinc-500);
  font-size: 12px;
}

.memory-score-grid strong {
  margin-top: 5px;
  font-size: 22px;
}

.memory-comparison {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  text-align: left;
}

.memory-comparison p {
  margin: 0;
  border: 1px solid var(--card-line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.035);
}

.memory-comparison span {
  color: var(--zinc-500);
}

.memory-attempt-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  text-align: left;
}

.memory-attempt {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.035);
}

.memory-attempt > span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  font-size: 12px;
  font-weight: 800;
}

.memory-attempt.perfect > span {
  background: rgba(74, 222, 128, 0.12);
  color: #86efac;
}

.memory-attempt div {
  min-width: 0;
}

.memory-attempt small,
.memory-attempt strong {
  display: block;
}

.memory-attempt small {
  margin-bottom: 3px;
  color: var(--zinc-500);
}

.memory-attempt strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-attempt em {
  color: #fca5a5;
  font-size: 12px;
  font-style: normal;
}

.memory-attempt.perfect em {
  color: #86efac;
}

.memory-attempt.timed-out em {
  color: #fbbf24;
}

@media (max-width: 700px) {
  .memory-choice-row,
  .memory-difficulty-grid,
  .memory-score-grid,
  .memory-performance-compare {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-difficulty:last-child,
  .memory-score-grid > div:last-child {
    grid-column: 1 / -1;
  }

  .memory-attempt {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .memory-attempt em {
    grid-column: 2;
  }
}

.detective-shell {
  width: min(100%, 820px);
  margin: 0 auto;
}

.case-intro,
.statement-card,
.accusation-panel,
.case-result {
  border: 1px solid var(--card-line);
  border-radius: 12px;
  padding: clamp(18px, 3vw, 28px);
  background: var(--card);
}

.case-intro {
  border-top: 3px solid #60a5fa;
}

.detective-shell h2 {
  margin: 0 0 14px;
  font-size: 24px;
}

.detective-shell p {
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.case-intro > p,
.case-result > p,
.accusation-panel > p {
  color: var(--zinc-400);
}

.statement-card,
.accusation-panel {
  margin-top: 20px;
}

.statement-text {
  margin-bottom: 0;
  color: var(--zinc-200);
  font-size: 19px;
  white-space: pre-wrap;
}

.clue-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.clue-card {
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  background: rgba(245, 158, 11, 0.06);
}

.clue-card strong {
  color: #fbbf24;
  font-size: 12px;
}

.clue-card p {
  margin: 6px 0 0;
  color: var(--zinc-300);
  font-size: 14px;
}

.accusation-panel .accusation-answer {
  min-height: 54px;
  border: 1px solid rgba(96, 165, 250, 0.6);
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(59, 130, 246, 0.06);
  color: var(--zinc-200);
  white-space: pre-wrap;
}

.accusation-answer::after {
  content: '';
  display: inline-block;
  height: 1.1em;
  border-left: 2px solid #60a5fa;
  vertical-align: text-bottom;
}

.case-result {
  border-top: 3px solid #4ade80;
}

.case-result h2,
.case-result .eyebrow {
  color: #4ade80;
}

@media (max-width: 700px) {
  .fun-view {
    padding: 24px 14px;
  }

  .fun-grid {
    grid-template-columns: 1fr;
  }

  .fun-mode-card {
    min-height: 210px;
    padding: 18px;
  }

  .story-scene {
    font-size: 15px;
  }

  .story-actions {
    display: grid;
  }
}

@media (max-width: 980px) {
  .fun-keyboard-card {
    padding: 12px;
  }

  .fun-keyboard-toggle[aria-expanded="false"] + .virtual-keyboard {
    display: none;
  }
}
