:root {
  color-scheme: light;
  --ink: #23383a;
  --muted: #75898a;
  --paper: #fffdf6;
  --paper-deep: #f4e9cd;
  --mist: #d4e9ea;
  --mist-deep: #b9d7d9;
  --sage: #759d8f;
  --sage-deep: #4d756c;
  --red: #bc5c57;
  --red-deep: #8e3e3d;
  --gold: #d49b3a;
  --gold-pale: #f7dfa4;
  --shadow: rgba(43, 75, 77, 0.15);
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-width: 320px;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background-color: #f4f0e7;
  background-image: url("ancient-background.jpg");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid rgba(188, 92, 87, 0.4);
  outline-offset: 2px;
}

.app-shell {
  width: min(480px, 100%);
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 13px calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

.eyebrow {
  margin: 0;
  color: var(--sage-deep);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.simple-header,
.game-topbar,
.page-topbar,
.brand-line,
.header-tools,
.game-tools,
.game-level,
.candidate-heading,
.game-actions,
.detail-topline {
  display: flex;
  align-items: center;
}

.simple-header,
.game-topbar,
.page-topbar {
  justify-content: space-between;
  flex: 0 0 auto;
}

.simple-header {
  min-height: 316px;
  align-items: flex-start;
}

.brand-line {
  width: 100%;
  justify-content: center;
  padding-top: 58px;
}

.home-mark,
.success-mark {
  display: grid;
  place-items: center;
  color: #fff9eb;
  background: var(--red);
  border: 2px solid rgba(255, 251, 235, 0.8);
  box-shadow: 0 0 0 2px var(--red), 0 5px 12px rgba(104, 56, 50, 0.16);
  font-family: "STKaiti", "KaiTi", serif;
}

.brand-title-image {
  display: block;
  width: min(170px, 46vw);
  height: auto;
  max-height: 255px;
  object-fit: contain;
}

.header-tools,
.game-tools {
  gap: 6px;
}

.coin-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 31px;
  padding: 0 9px;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.78);
  border: 1px solid rgba(92, 130, 126, 0.2);
  border-radius: 4px;
  box-shadow: 0 3px 10px rgba(58, 101, 101, 0.07);
  font-size: 12px;
}

.compact-coin {
  min-height: 29px;
  padding: 0 7px;
  font-size: 11px;
}

.coin-icon,
.mini-coin {
  display: inline-grid;
  place-items: center;
  color: #fff7d7;
  background: var(--gold);
  border: 1px solid #f5d57d;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-weight: 700;
  line-height: 1;
}

.coin-icon {
  width: 19px;
  height: 19px;
  font-size: 12px;
}

.mini-coin {
  width: 14px;
  height: 14px;
  font-size: 8px;
}

.round-button {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  padding: 0;
  color: var(--sage-deep);
  background: rgba(255, 253, 246, 0.68);
  border: 1px solid rgba(92, 130, 126, 0.2);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(58, 101, 101, 0.07);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.round-button:hover {
  color: var(--red-deep);
  background: var(--paper);
}

.settings-button {
  font-family: Arial, sans-serif;
  font-size: 19px;
}

.back-button {
  font-size: 26px;
  font-family: Arial, sans-serif;
}

.home-button {
  font-size: 23px;
}

.home-icon {
  display: block;
  line-height: 1;
  transform: translateY(-1px);
}

.home-main {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 18px;
  text-align: center;
}

.home-mark {
  width: 94px;
  height: 106px;
  margin-bottom: 3px;
  border: 3px solid rgba(255, 251, 235, 0.85);
  outline: 2px solid var(--red);
  font-size: 38px;
  line-height: 0.95;
  transform: rotate(-3deg);
}

.home-kicker {
  margin: 0;
  color: var(--sage-deep);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.home-description {
  max-width: 280px;
  margin: -2px 0 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.home-progress {
  width: auto;
  margin: 0 0 8px;
  padding: 8px 14px;
  color: var(--muted);
  background: rgba(255, 253, 246, 0.57);
  border-top: 1px solid rgba(95, 137, 134, 0.2);
  border-bottom: 1px solid rgba(95, 137, 134, 0.2);
  font-size: 12px;
  text-align: center;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button {
  gap: 18px;
  min-width: 216px;
  padding: 0 20px;
  color: #fff9ed;
  background: var(--sage-deep);
  border: 0;
  box-shadow: 0 4px 0 #38584f;
}

.primary-button:hover {
  background: #416960;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #38584f;
}

.secondary-button {
  gap: 12px;
  min-width: 216px;
  padding: 0 19px;
  color: var(--sage-deep);
  background: rgba(255, 253, 246, 0.7);
  border: 1px solid rgba(78, 118, 109, 0.4);
  box-shadow: 0 3px 0 rgba(78, 118, 109, 0.14);
}

.secondary-button:hover {
  background: var(--paper);
  transform: translateY(-2px);
}

.button-arrow {
  font-size: 20px;
  line-height: 1;
}

.button-count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 5px;
  color: #fff9ed;
  background: var(--sage);
  border-radius: 999px;
  font-size: 11px;
}

.home-note {
  flex: 0 0 auto;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.home-settings-action {
  gap: 8px;
}

.home-action-icon {
  font-family: Arial, sans-serif;
  font-size: 18px;
  line-height: 1;
}

.game-screen,
.summary-screen,
.learn-screen {
  gap: 0;
}

.game-topbar,
.page-topbar {
  min-height: 38px;
}

.game-level {
  flex-direction: column;
  gap: 1px;
  text-align: center;
}

.game-level strong {
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 21px;
  line-height: 1;
}

.game-level span {
  color: var(--sage-deep);
  font-size: 10px;
}

.board-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  padding: 4px 3px 3px;
  color: var(--muted);
  font-size: 11px;
}

.board-heading strong {
  color: var(--sage-deep);
  font-weight: 700;
}

.game-board-area {
  display: grid;
  flex: 0 0 auto;
  min-height: 0;
  place-items: start center;
  padding: 0;
}

.paper-board-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(94vw, 350px, 43dvh);
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(71, 119, 121, 0.24);
  box-shadow: inset 0 0 0 1px rgba(244, 250, 244, 0.24);
}

.paper-board-wrap::before {
  position: absolute;
  inset: 9px;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.42);
  pointer-events: none;
}

.paper-board {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  gap: 2px;
  width: 88%;
  height: 88%;
}

.tile {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  color: #253638;
  background: var(--paper);
  border: 1.5px solid rgba(44, 62, 61, 0.8);
  border-radius: 3px;
  box-shadow: 0 2px 0 rgba(55, 78, 74, 0.18), 0 3px 6px rgba(53, 82, 80, 0.11);
  cursor: default;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(14px, 5vw, 25px);
  line-height: 1;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.tile.empty {
  color: transparent;
  background: rgba(119, 151, 154, 0.53);
  border-color: rgba(73, 111, 113, 0.45);
  box-shadow: inset 0 1px 5px rgba(38, 75, 76, 0.12);
  cursor: pointer;
}

.tile.empty:hover,
.tile.selected {
  background: rgba(255, 253, 246, 0.94);
  border-color: var(--red);
  transform: translateY(-1px);
}

.tile.selected {
  box-shadow: 0 0 0 3px rgba(188, 92, 87, 0.18), 0 4px 8px rgba(84, 57, 53, 0.15);
}

.tile.filled {
  background: #fffaf0;
  cursor: pointer;
}

.tile.correct-word {
  color: #fffaf0;
  background: var(--sage);
  border-color: var(--sage-deep);
  box-shadow: 0 2px 0 rgba(55, 91, 82, 0.26);
}

.tile.wrong {
  color: #fff8ef;
  background: var(--red);
  border-color: var(--red-deep);
  animation: wrong-flash 700ms ease;
}

.brush-mark {
  position: absolute;
  z-index: 0;
  width: 80px;
  height: 11px;
  opacity: 0.15;
  border-radius: 50%;
  background: #618a8b;
  transform: rotate(-30deg);
}

.brush-mark-one {
  left: 10%;
  bottom: 12%;
}

.brush-mark-two {
  right: 11%;
  bottom: 27%;
  width: 55px;
  transform: rotate(27deg);
}

.game-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 23px;
  margin-top: 7px;
  padding: 2px 3px 1px;
  color: var(--muted);
  font-size: 10px;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--sage);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(117, 157, 143, 0.15);
}

.candidate-panel {
  flex: 0 0 auto;
  margin-top: 7px;
  padding: 5px 5px 4px;
  background: rgba(255, 253, 246, 0.64);
  border-top: 1px solid rgba(89, 135, 130, 0.2);
  border-bottom: 1px solid rgba(89, 135, 130, 0.17);
}

.candidate-heading {
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.candidate-heading-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.candidate-heading span:last-child {
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
}

.candidate-tray {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  margin: 4px auto 0;
}

.candidate-tile {
  display: grid;
  width: 100%;
  aspect-ratio: 1.15;
  place-items: center;
  padding: 0;
  color: #263a3b;
  background: #fffdf7;
  border: 1px solid rgba(52, 70, 68, 0.6);
  border-radius: 4px;
  box-shadow: 0 3px 0 rgba(73, 100, 93, 0.16);
  cursor: pointer;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(16px, 5vw, 24px);
  line-height: 1;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.candidate-tile:hover:not(:disabled) {
  color: var(--red-deep);
  background: #fff2d4;
  transform: translateY(-2px);
}

.candidate-tile:disabled {
  color: rgba(42, 59, 59, 0.27);
  background: rgba(242, 240, 226, 0.58);
  box-shadow: none;
  cursor: default;
  transform: translateY(2px);
}

.candidate-tile.used {
  opacity: 0.38;
}

.game-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 66px;
  margin-top: 10px;
  padding: 5px 3px 2px;
}

.game-tool-button {
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  gap: 2px;
  padding: 0;
  color: var(--sage-deep);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.game-tool-icon {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  color: #fffaf0;
  background: #3d5355;
  border: 2px solid rgba(255, 253, 246, 0.56);
  border-radius: 50%;
  box-shadow: 0 3px 0 rgba(34, 58, 59, 0.24), 0 4px 9px rgba(43, 75, 77, 0.12);
  font-family: Arial, sans-serif;
  font-size: 21px;
  line-height: 1;
  transition: background 150ms ease, transform 150ms ease;
}

.game-tool-button:hover .game-tool-icon,
.game-tool-button:focus-visible .game-tool-icon {
  background: var(--sage-deep);
  transform: translateY(-2px);
}

.game-settings-icon {
  font-size: 21px;
}

.hint-icon {
  font-size: 20px;
}

.random-hint-icon {
  font-size: 27px;
  font-weight: 700;
}

.game-tool-label {
  max-width: 100%;
  overflow: hidden;
  color: var(--sage-deep);
  font-size: 9px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-tool-cost {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 14px;
  color: #a8782b;
  font-size: 9px;
  line-height: 1;
}

.candidate-clear-button {
  display: inline-grid;
  width: 23px;
  height: 23px;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(117, 137, 138, 0.35);
  border-radius: 3px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 15px;
  line-height: 1;
}

.candidate-clear-button:hover {
  color: var(--red-deep);
  background: #fff8e5;
  border-color: rgba(188, 92, 87, 0.4);
}

.text-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
  color: var(--sage-deep);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 10px;
}

.text-action:hover {
  color: var(--red-deep);
}

.muted-action {
  color: var(--muted);
}

.action-icon {
  font-size: 14px;
}

.action-cost {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: #a8782b;
}

.page-title {
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 21px;
  font-weight: 700;
}

.topbar-spacer {
  width: 31px;
  height: 31px;
}

.summary-main {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 6px;
  text-align: center;
}

.success-mark {
  width: 48px;
  height: 48px;
  margin: 0 0 5px;
  border-radius: 50%;
  font-family: Arial, sans-serif;
  font-size: 28px;
  transform: none;
}

.summary-main h2 {
  margin: 2px 0 2px;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 27px;
}

.summary-copy {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.summary-reward {
  margin: 0 0 10px;
  color: var(--sage-deep);
  font-size: 13px;
  font-weight: 700;
}

.summary-list {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(48px, auto);
  align-content: start;
  gap: 8px;
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.idiom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 5px 7px;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.8);
  border: 1px solid rgba(91, 130, 126, 0.25);
  border-radius: 4px;
  box-shadow: 0 2px 0 rgba(88, 120, 114, 0.1);
  cursor: pointer;
  text-align: left;
}

.idiom-item:hover {
  background: #fff8e5;
  border-color: rgba(188, 92, 87, 0.45);
}

.idiom-item-main {
  display: grid;
  gap: 2px;
}

.idiom-item-main strong {
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 18px;
  line-height: 1;
}

.idiom-item-main small {
  color: var(--muted);
  font-size: 10px;
}

.summary-list .idiom-item-main small {
  display: none;
}

.summary-list .idiom-item {
  min-height: 48px;
  padding: 7px 10px;
}

.summary-list .idiom-item-main strong {
  font-size: 20px;
  line-height: 1.15;
}

.summary-list .idiom-item-arrow {
  font-size: 17px;
}

.idiom-item-arrow {
  color: var(--sage-deep);
  font-size: 23px;
  line-height: 1;
}

.summary-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 4px 0 2px;
}

.summary-actions .primary-button,
.summary-actions .secondary-button {
  min-width: 0;
  width: 47%;
  min-height: 41px;
  font-size: 12px;
}

.summary-actions .primary-button {
  gap: 7px;
}

.learn-heading {
  flex: 0 0 auto;
  padding: 13px 5px 10px;
}

.learn-heading h2 {
  margin: 4px 0;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 27px;
}

.learn-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.learn-list {
  display: grid;
  align-content: start;
  gap: 7px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 3px 8px;
  scrollbar-width: thin;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  color: var(--gold);
  font-size: 30px;
}

.empty-state p,
.empty-state small {
  margin: 0;
}

.empty-state p {
  color: var(--ink);
  font-size: 14px;
}

.empty-state small {
  font-size: 11px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: min(90vw, 360px);
  padding: 9px 13px;
  color: #fff9ed;
  background: rgba(35, 56, 58, 0.94);
  border-radius: 3px;
  box-shadow: 0 8px 20px rgba(35, 56, 58, 0.2);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(26, 49, 51, 0.54);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.68);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.settings-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal {
  position: relative;
  display: flex;
  width: min(94vw, 560px);
  height: auto;
  max-height: min(94dvh, 920px);
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px 12px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.27);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.settings-close {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 1;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0 0 3px;
  color: #fff;
  background: #c74636;
  border: 2px solid #87362f;
  border-radius: 50%;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-size: 34px;
  line-height: 1;
}

.settings-profile {
  display: grid;
  min-height: 126px;
  grid-template-columns: 76px minmax(0, 1fr) 116px;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 12px;
}

.profile-avatar {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  color: #fff;
  background: #6269c4;
  border-radius: 50%;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 34px;
}

.profile-name {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.profile-name strong {
  overflow-wrap: anywhere;
  color: #222;
  font-size: 18px;
}

.profile-name small {
  color: #777;
  font-size: 11px;
}

.profile-switch {
  min-height: 48px;
  padding: 4px 12px;
  color: #21331d;
  background: #9bdf62;
  border: 1px solid #5b8a37;
  border-radius: 24px;
  box-shadow: inset 0 -3px 0 rgba(48, 93, 30, 0.28), 0 2px 2px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.settings-rows {
  flex: 0 0 auto;
}

.settings-row {
  display: grid;
  min-height: 66px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid #9d9d9d;
}

.settings-label {
  min-width: 0;
  color: #161616;
  font-size: 21px;
  white-space: nowrap;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 9px;
}

.volume-control {
  display: grid;
  width: min(220px, 52vw);
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
}

.volume-slider {
  width: 100%;
  height: 28px;
  margin: 0;
  accent-color: var(--sage-deep);
  cursor: pointer;
}

.volume-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(
    to right,
    var(--sage-deep) 0 var(--volume-percent, 0%),
    #d0d0ce var(--volume-percent, 0%) 100%
  );
  border: 1px solid #b7c1be;
  border-radius: 6px;
}

.volume-slider::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  appearance: none;
  background: #f2c35d;
  border: 1px solid #79715b;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.volume-slider::-moz-range-track {
  height: 6px;
  background: #d0d0ce;
  border: 1px solid #b7c1be;
  border-radius: 6px;
}

.volume-slider::-moz-range-progress {
  height: 6px;
  background: var(--sage-deep);
  border-radius: 6px;
}

.volume-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #f2c35d;
  border: 1px solid #79715b;
  border-radius: 50%;
}

.volume-slider:focus-visible {
  outline: 3px solid rgba(188, 92, 87, 0.42);
  outline-offset: 3px;
}

.volume-value {
  min-width: 32px;
  color: var(--sage-deep);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.setting-state {
  width: 19px;
  color: #9a9a9a;
  font-size: 19px;
  text-align: center;
}

.settings-control[data-on="false"] .setting-state-off,
.settings-control[data-on="true"] .setting-state-on {
  color: #222;
}

.setting-switch {
  position: relative;
  display: block;
  width: 58px;
  height: 28px;
  flex: 0 0 58px;
  cursor: pointer;
}

.setting-switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-track {
  position: absolute;
  inset: 2px 0;
  background: #d0d0ce;
  border: 1px solid #dededb;
  border-radius: 6px;
}

.toggle-track::before {
  position: absolute;
  top: -3px;
  left: -1px;
  width: 30px;
  height: 30px;
  background: #f2c35d;
  border: 1px solid #79715b;
  border-radius: 50%;
  content: "";
  transition: transform 150ms ease;
}

.setting-switch input:checked + .toggle-track::before {
  transform: translateX(28px);
}

.setting-switch input:focus-visible + .toggle-track {
  outline: 3px solid rgba(188, 92, 87, 0.42);
  outline-offset: 3px;
}

.settings-footer {
  display: flex;
  min-height: 39px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 2px 0;
  color: #555;
  font-size: 11px;
}

.version-update-button {
  display: grid;
  width: 100%;
  min-height: 60px;
  grid-template-columns: 34px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 10px;
  color: #343434;
  background: #f4f4f2;
  border: 1px solid #c9c9c5;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}

.version-update-button:hover {
  background: #eaeae5;
}

.version-update-button.available {
  color: #245527;
  background: #dff2d9;
  border-color: #6fae63;
  box-shadow: inset 0 -3px 0 rgba(73, 128, 67, 0.18);
}

.version-update-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: #7b7b76;
  border-radius: 50%;
  font-family: Arial, sans-serif;
  font-size: 20px;
  line-height: 1;
}

.version-update-button.available .version-update-icon {
  background: #4f9a50;
}

.version-update-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.version-update-main strong {
  font-size: 17px;
}

.version-update-main small {
  overflow: hidden;
  color: #777;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-update-button.available .version-update-main small,
.version-update-button.available .version-update-arrow {
  color: #347437;
}

.version-update-arrow {
  color: #777;
  font-family: Arial, sans-serif;
  font-size: 25px;
  line-height: 1;
  text-align: center;
}

@media (max-height: 680px) {
  .settings-modal {
    padding: 12px 18px 8px;
  }

  .settings-profile {
    min-height: 86px;
    grid-template-columns: 62px minmax(0, 1fr) 96px;
    gap: 8px;
    padding: 4px 0 8px;
  }

  .profile-avatar {
    width: 62px;
    height: 62px;
    font-size: 29px;
  }

  .profile-switch {
    min-height: 42px;
    font-size: 18px;
  }

  .settings-row {
    min-height: 56px;
    padding: 4px;
  }

  .settings-label {
    font-size: 18px;
  }

  .setting-state {
    font-size: 16px;
  }

  .settings-footer {
    min-height: 30px;
    padding-top: 6px;
  }
}

.auth-backdrop,
.update-backdrop {
  position: fixed;
  inset: 0;
  z-index: 52;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(24, 42, 44, 0.68);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.progress-conflict-backdrop {
  position: fixed;
  inset: 0;
  z-index: 56;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(24, 42, 44, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.auth-backdrop.visible,
.update-backdrop.visible,
.progress-conflict-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal,
.update-modal,
.progress-conflict-modal {
  width: min(100%, 390px);
  background: var(--paper);
  border: 1px solid #c49755;
  box-shadow: 0 16px 35px rgba(28, 49, 51, 0.28);
}

.auth-modal {
  position: relative;
  padding: 24px 22px 22px;
}

.auth-heading h2 {
  margin: 5px 0 4px;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 30px;
}

.auth-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin: 18px 0 14px;
  padding: 3px;
  background: rgba(212, 233, 234, 0.58);
  border: 1px solid rgba(78, 118, 109, 0.2);
}

.auth-tab {
  min-height: 36px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.auth-tab.active {
  color: var(--sage-deep);
  background: var(--paper);
  box-shadow: 0 2px 5px rgba(58, 101, 101, 0.12);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-field {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.auth-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(78, 118, 109, 0.34);
  border-radius: 3px;
  outline: 0;
  font-size: 14px;
}

.auth-field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(188, 92, 87, 0.14);
}

.auth-message {
  min-height: 18px;
  margin: -2px 0 0;
  color: var(--sage-deep);
  font-size: 11px;
  line-height: 1.5;
}

.auth-message.error {
  color: var(--red-deep);
}

.auth-submit {
  width: 100%;
  min-width: 0;
  border-radius: 3px;
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.62;
}

.progress-conflict-modal {
  width: min(100%, 440px);
  padding: 22px 16px 16px;
}

.progress-conflict-heading h2 {
  margin: 6px 0 5px;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 28px;
}

.progress-conflict-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.progress-conflict-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.progress-choice {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 12px 11px 11px;
  background: #fff;
  border: 1px solid rgba(78, 118, 109, 0.28);
  border-radius: 3px;
}

.progress-choice-heading {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.progress-choice-heading h3 {
  margin: 0;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 21px;
}

.progress-choice-heading span {
  color: var(--muted);
  font-size: 10px;
}

.progress-choice > p {
  margin: 0 0 6px;
  color: #5e7071;
  font-size: 11px;
  line-height: 1.35;
}

.progress-choice > p:last-of-type {
  margin-bottom: 13px;
}

.progress-choice-button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  margin-top: auto;
  padding: 0 8px;
  font-size: 12px;
}

.update-modal {
  padding: 24px 22px 22px;
  text-align: center;
}

.update-badge {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  place-items: center;
  color: #fff;
  background: var(--sage-deep);
  border-radius: 50%;
  font-family: Arial, sans-serif;
  font-size: 28px;
}

.update-modal h2 {
  margin: 0 0 7px;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 27px;
}

.update-modal p {
  min-height: 22px;
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.update-progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  background: #d8dddd;
  border: 1px solid #b5c3c3;
  border-radius: 6px;
}

.update-progress-bar {
  width: 0;
  height: 100%;
  background: var(--sage-deep);
  transition: width 120ms linear;
}

.update-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.update-progress-meta strong {
  color: var(--sage-deep);
}

.update-dismiss {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  margin-top: 17px;
  font-size: 12px;
}

.detail-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.detail-modal {
  position: relative;
  width: min(100%, 390px);
  max-height: 86dvh;
  overflow-y: auto;
  padding: 23px 22px 25px;
  background: var(--paper);
  border: 1px solid #c49755;
  box-shadow: 0 16px 35px rgba(28, 49, 51, 0.24);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

.detail-topline {
  justify-content: space-between;
  gap: 10px;
}

.detail-label {
  color: var(--sage-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.speak-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  color: var(--sage-deep);
  background: rgba(212, 233, 234, 0.65);
  border: 1px solid rgba(78, 118, 109, 0.24);
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.detail-modal h2 {
  margin: 19px 0 4px;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 38px;
  letter-spacing: 0.08em;
}

.detail-pinyin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 17px;
}

.detail-pinyin {
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  color: var(--sage-deep);
  font-size: 14px;
}

.detail-section {
  padding: 13px 0;
  border-top: 1px solid rgba(90, 128, 125, 0.18);
}

.detail-section h3 {
  margin: 0 0 7px;
  color: var(--red-deep);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 20px;
}

.detail-section p {
  margin: 0;
  color: #5e7071;
  font-size: 13px;
  line-height: 1.75;
}

@keyframes wrong-flash {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@media (max-height: 680px) {
  .simple-header {
    min-height: 244px;
  }

  .brand-line {
    padding-top: 34px;
  }

  .brand-title-image {
    width: min(136px, 48vw);
    max-height: 204px;
  }

  .home-mark {
    width: 70px;
    height: 78px;
    font-size: 30px;
  }

  .home-main {
    gap: 8px;
  }

  .home-kicker {
    font-size: 22px;
  }

  .home-description {
    margin-bottom: 3px;
  }

  .paper-board-wrap {
    width: min(92vw, 320px, 42dvh);
  }

  .game-actions {
    margin-top: 5px;
  }

  .game-status,
  .candidate-panel {
    margin-top: 4px;
  }

  .volume-control {
    width: min(190px, 50vw);
  }

  .candidate-tile {
    font-size: clamp(15px, 4.8vw, 22px);
  }

  .summary-main {
    padding-top: 5px;
  }

  .success-mark {
    width: 48px;
    height: 48px;
    font-size: 28px;
  }

  .summary-main h2 {
    font-size: 27px;
  }
}

@media (min-width: 481px) {
  .app-shell {
    padding-left: 18px;
    padding-right: 18px;
  }
}
