.world .lighting::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 67% 56% at 54% 38%, #100b098a, #100b0952 55%, transparent 100%);
  opacity: 0;
  transition: opacity .35s ease;
}

.world:is([data-camera-scene="2"], [data-camera-scene="3"]) .lighting::before {
  opacity: 1;
}

.chapter-area:has(.activity-chapter:not([hidden])) {
  align-content: start;
  padding-block: clamp(24px, 4.4vw, 48px) 56px;
}

.activity-chapter {
  min-width: 0;
  text-shadow: 0 1px 3px #100904, 0 3px 12px #100904b3;
}

.activity-chapter .era {
  margin-bottom: 9px;
}

.chapter.activity-chapter h1 {
  max-width: none;
  font-size: clamp(2rem, 3.6vw, 2.9rem);
}

.activity-chapter .description {
  margin-top: 8px;
}

/* ======================== Tools Layout ======================== */

.tool-layout {
  display: grid;
  grid-template-columns: minmax(176px, 218px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(15px, 2vw, 26px);
  margin-top: 24px;
}

.tool-sidebar {
  min-width: 0;
  padding: 16px 12px;
  border: 1px solid rgba(246, 223, 194, .16);
  border-radius: 8px;
  background: rgba(20, 14, 10, .08);
  transition: border-color .3s ease, background-color .3s ease;
}

.tool-group + .tool-group {
  margin-top: 20px;
}

.tool-group h2 {
  margin: 0 0 8px 12px;
  color: var(--accent);
  font-size: .92rem;
}

.tool-list,
.game-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tool-list {
  gap: 3px;
}

.activity-launch {
  width: 100%;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-shadow: inherit;
  transition: color .18s ease, background-color .22s ease, border-color .22s ease;
}

.activity-summary[hidden],
.activity-chapter [hidden] {
  display: none !important;
}

.tool-choice {
  position: relative;
  min-height: 40px;
  padding: 7px 10px 7px 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #f1dfcf;
  overflow-wrap: break-word;
}

.tool-choice strong { font-weight: 550; }

.tool-choice:hover {
  color: #fff6e8;
  background: rgba(246, 223, 194, .06);
}

.tool-choice[aria-pressed="true"] {
  color: #ffe0a9;
}

.tool-choice[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 2px;
  height: .85em;
  border-radius: 1px;
  background: currentColor;
  transform: translateY(-50%);
}

.tool-choice[aria-pressed="true"] strong { font-weight: 720; }

.activity-panel {
  min-width: 0;
  padding: 2px clamp(0px, 2vw, 20px) 0;
}

#tools .activity-panel {
  padding: 22px clamp(18px, 2.4vw, 28px) 24px;
  border: 1px solid rgba(246, 223, 194, .18);
  border-radius: 8px;
  background-color: rgba(20, 14, 10, .10);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  box-shadow: 0 0 0 0 rgba(10, 6, 4, 0);
  transition:
    background-color .32s ease,
    border-color .32s ease,
    box-shadow .32s ease,
    backdrop-filter .32s ease,
    -webkit-backdrop-filter .32s ease;
}

#tools .activity-panel:is(.is-engaged, [data-engaged="true"]) {
  border-color: rgba(246, 223, 194, .34);
  background-color: rgba(20, 13, 9, .58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  box-shadow:
    0 14px 36px rgba(10, 6, 4, .28),
    inset 0 1px 0 rgba(255, 236, 210, .06);
}

.activity-panel > h2 {
  margin: 0 0 19px;
  color: #fff3dd;
  font: 700 1.35rem/1.35 var(--heading);
}

.activity-panel-body {
  font-size: .96rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.activity-panel-body > :first-child { margin-top: 0; }
.activity-panel-body > :last-child { margin-bottom: 0; }

/* ======================== Games Layout (Hub -> Expanded) ======================== */

@keyframes game-view-in {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.game-hub {
  width: min(100%, 660px);
}

.game-hub:not([hidden]) {
  animation: game-view-in .26s cubic-bezier(.22, 1, .36, 1) both;
}

.game-hub-nav {
  margin-top: 26px;
}

.game-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.game-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  padding: 20px 24px;
  border: 1px solid rgba(246, 223, 194, .18);
  border-radius: 6px;
  background-color: rgba(20, 14, 10, .12);
  color: #f6eadb;
  transition:
    border-color .22s ease,
    background-color .22s ease,
    color .22s ease,
    box-shadow .22s ease;
}

.game-card:is(:hover, :focus-visible) {
  border-color: rgba(246, 223, 194, .44);
  background-color: rgba(24, 16, 11, .32);
  color: #fff8ec;
  box-shadow: 0 8px 24px rgba(10, 6, 4, .22);
}

.game-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(246, 223, 194, .20);
  border-radius: 6px;
  background: rgba(20, 14, 10, .18);
  color: var(--accent);
  flex-shrink: 0;
  transition: border-color .22s ease, background-color .22s ease;
}

.game-card:is(:hover, :focus-visible) .game-card-icon {
  border-color: rgba(237, 213, 178, .48);
  background: rgba(237, 213, 178, .12);
}

.game-card-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.game-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.game-card-head strong {
  font-size: 1.08rem;
  font-weight: 680;
  color: #fff6e8;
  transition: color .2s ease;
}

.game-card:is(:hover, :focus-visible) .game-card-head strong {
  color: #ffe3b3;
}

.game-card-badge {
  padding: 1px 7px;
  border: 1px solid rgba(246, 223, 194, .24);
  border-radius: 3px;
  color: #e9d4b8;
  font-family: var(--mono);
  font-size: .74rem;
  line-height: 1.5;
  white-space: nowrap;
}

.game-card-copy .activity-summary {
  color: #e4d1be;
  font-size: .88rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.game-card-progress {
  margin-top: 2px;
  color: #cbb59f;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.4;
}

.game-card-progress.is-exhausted {
  color: #fca5a5;
}

/* Expanded Game View: top back bar + single-column deepened frosted stage */
.game-expanded {
  width: min(100%, 760px);
}

.game-expanded[data-active-game="dusk-patrol"] {
  width: min(100%, 1080px);
}

#games[data-active-game="dusk-patrol"] .activity-panel {
  padding: 18px clamp(18px, 2.2vw, 26px) 18px;
}

.game-view--patrol {
  gap: 10px;
}

.patrol-stage-actions {
  align-items: center;
  flex-shrink: 0;
}

.patrol-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: clamp(280px, calc(100svh - 335px), 550px);
  border: 1px solid rgba(246, 223, 194, .28);
  border-radius: 6px;
  overflow: hidden;
  background: #182028;
  box-shadow: inset 0 0 0 1px rgba(10, 6, 4, .45);
}

.patrol-viewport:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.patrol-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #182028;
}

.patrol-controls-note {
  margin-top: 2px;
}

.game-expanded:not([hidden]) {
  animation: game-view-in .28s cubic-bezier(.22, 1, .36, 1) both;
}

.game-stage-topbar {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.game-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 13px;
  border: 1px solid rgba(246, 223, 194, .26);
  border-radius: 5px;
  background-color: rgba(20, 13, 9, .48);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  color: #f3e2ce;
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.4;
  cursor: pointer;
  text-shadow: inherit;
  transition:
    border-color .2s ease,
    background-color .2s ease,
    color .2s ease;
}

.game-back-btn:is(:hover, :focus-visible) {
  border-color: var(--accent);
  background-color: rgba(24, 16, 11, .74);
  color: #fff8ec;
}

#games .activity-panel {
  padding: 24px clamp(20px, 2.6vw, 30px) 26px;
  border: 1px solid rgba(246, 223, 194, .34);
  border-radius: 8px;
  background-color: rgba(18, 12, 8, .70);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    0 18px 42px rgba(10, 6, 4, .38),
    inset 0 1px 0 rgba(255, 236, 210, .08);
  transition:
    background-color .32s ease,
    border-color .32s ease,
    box-shadow .32s ease,
    backdrop-filter .32s ease,
    -webkit-backdrop-filter .32s ease;
}

#games .activity-panel:is(.is-engaged, [data-engaged="true"]) {
  border-color: rgba(246, 223, 194, .38);
  background-color: rgba(18, 12, 8, .74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    0 18px 42px rgba(10, 6, 4, .40),
    inset 0 1px 0 rgba(255, 236, 210, .08);
}

/* ======================== Shared Game Stage Components ======================== */

.game-view {
  display: grid;
  gap: 16px;
}

.game-stage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
}

.game-stage-title-group {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.game-stage-title,
.game-stage-title-btn {
  color: #fff3dd;
  font: 700 1.42rem/1.3 var(--heading);
}

.game-stage-title-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  text-shadow: inherit;
}

.game-dev-tag {
  color: var(--accent);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  opacity: .8;
}

.game-stage-subtitle {
  color: #e2ceba;
  font-size: .88rem;
  line-height: 1.5;
}

.game-stage-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: .78rem;
  color: #d6bfa9;
}

.game-meta-pill {
  padding: 2px 8px;
  border: 1px solid rgba(246, 223, 194, .18);
  border-radius: 4px;
  background: rgba(20, 14, 10, .16);
}

.game-timer {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.game-mini-btn {
  padding: 2px 8px;
  border: 1px solid rgba(246, 223, 194, .24);
  border-radius: 3px;
  background: transparent;
  color: #e6d2bd;
  font-family: var(--mono);
  font-size: .72rem;
  cursor: pointer;
}

.game-mini-btn:hover {
  border-color: var(--accent);
  color: #fff6e8;
}

.game-level-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-level-btn {
  padding: 5px 12px;
  border: 1px solid rgba(246, 223, 194, .22);
  border-radius: 4px;
  background: rgba(20, 14, 10, .14);
  color: #e5d1bd;
  font-family: var(--mono);
  font-size: .8rem;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}

.game-level-btn:hover {
  border-color: rgba(246, 223, 194, .45);
  color: #fff6e8;
}

.game-level-btn.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #1c120a;
  font-weight: 700;
  text-shadow: none;
}

.game-helper-note {
  color: #d8c2ac;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.5;
}

.game-frame {
  padding: 18px 16px;
  border: 1px solid rgba(246, 223, 194, .15);
  border-radius: 6px;
  background-color: rgba(20, 14, 10, .06);
  transition: border-color .28s ease, background-color .28s ease;
}

#games .activity-panel:is(.is-engaged, [data-engaged="true"]) .game-frame {
  border-color: rgba(246, 223, 194, .24);
  background-color: rgba(16, 10, 7, .26);
}

.game-subhead {
  margin-bottom: 10px;
  color: #fff3dd;
  font-family: var(--mono);
  font-size: .84rem;
  font-weight: 700;
}

.game-banner {
  padding: 14px 16px;
  border: 1px solid rgba(246, 223, 194, .24);
  border-radius: 6px;
  margin-bottom: 14px;
  text-align: center;
  background: rgba(20, 13, 9, .24);
}

.game-banner--danger {
  border-color: rgba(248, 113, 113, .45);
  background: rgba(127, 29, 29, .22);
  color: #fca5a5;
  font-family: var(--mono);
  font-size: .84rem;
}

.game-banner--hint {
  text-align: left;
  border-color: rgba(237, 213, 178, .36);
  background: rgba(237, 213, 178, .10);
  color: #ffe8c2;
  font-family: var(--mono);
  font-size: .86rem;
}

.game-banner--outcome {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-color: rgba(237, 213, 178, .48);
  background: rgba(237, 213, 178, .10);
}

.game-banner-heading {
  color: #fff5e4;
  font-family: var(--mono);
  font-size: 1.18rem;
  font-weight: 700;
}

.game-banner-sub {
  color: #e4d0bc;
  font-family: var(--mono);
  font-size: .86rem;
}

.game-countdown {
  margin-top: 6px;
  color: #fff5e6;
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .16em;
}

.game-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.game-actions-row--center {
  justify-content: center;
}

.game-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 15px;
  border: 1px solid rgba(246, 223, 194, .24);
  border-radius: 5px;
  background: rgba(20, 14, 10, .18);
  color: #f3e2ce;
  font-family: var(--mono);
  font-size: .85rem;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease;
}

.game-btn--sm {
  min-height: 32px;
  padding: 4px 11px;
  font-size: .78rem;
}

.game-btn--ghost:hover:not(:disabled) {
  border-color: rgba(246, 223, 194, .48);
  background: rgba(246, 223, 194, .10);
  color: #fff6e8;
}

.game-btn--primary {
  border-color: rgba(237, 213, 178, .72);
  background: rgba(237, 213, 178, .22);
  color: #fff6e8;
  font-weight: 680;
}

#games .activity-panel:is(.is-engaged, [data-engaged="true"]) .game-btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #1b1109;
  text-shadow: none;
}

.game-btn--primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.game-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
}

/* Slot Underline Input (Idiom Quest & Guess Number) */
.game-slot-input-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.game-slot-input {
  width: min(100%, 340px);
  padding: 4px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #fff6e8;
  font-family: var(--mono);
  font-size: 1.4rem;
  letter-spacing: .32em;
  text-align: center;
  outline: none;
}

.game-slot-input::placeholder {
  color: rgba(246, 223, 194, .48);
  font-size: .95rem;
  letter-spacing: .04em;
}

.game-slot-input.is-exhausted {
  letter-spacing: normal;
  font-size: .95rem;
}

.game-slot-input:focus-visible {
  background: rgba(246, 223, 194, .04);
}

.game-slot-bars {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.game-slot-bar {
  width: clamp(36px, 9vw, 56px);
  height: 2px;
  border-radius: 1px;
  background: rgba(246, 223, 194, .24);
  transition: background-color .18s ease;
}

.game-slot-bar.is-filled {
  background: var(--accent);
}

.game-attempts-note {
  color: #d6c0aa;
  font-family: var(--mono);
  font-size: .78rem;
}

.game-inline-msg {
  margin-top: 8px;
  color: #f0d7b5;
  font-family: var(--mono);
  font-size: .8rem;
  text-align: center;
}

.game-inline-msg.is-danger {
  color: #fca5a5;
}

/* ======================== Idiom Quest Specific ======================== */

.idiom-history-wrap {
  margin-bottom: 18px;
}

.idiom-history-list {
  display: grid;
  gap: 10px;
}

.idiom-history-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(246, 223, 194, .16);
  border-radius: 6px;
  background: rgba(20, 13, 9, .22);
}

.idiom-history-idx {
  padding-top: 16px;
  color: #c8b29b;
  font-family: var(--mono);
  font-size: .75rem;
}

.idiom-history-chars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.idiom-char-col {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.idiom-tzg {
  position: relative;
  width: clamp(46px, 7.2vw, 58px);
  aspect-ratio: 1;
  border: 1px solid rgba(246, 223, 194, .26);
  border-radius: 5px;
  overflow: hidden;
  background: rgba(24, 16, 11, .32);
}

.idiom-tzg.is-correct {
  border-color: var(--accent);
  background: var(--accent);
}

.idiom-tzg-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: rgba(246, 223, 194, .18);
  pointer-events: none;
}

.idiom-tzg.is-correct .idiom-tzg-grid {
  color: rgba(28, 18, 10, .16);
}

.idiom-tzg-char {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #f3e4d2;
  font-family: "STKaiti", "KaiTi", "楷体", var(--heading);
  font-size: clamp(1.3rem, 2.2vw, 1.55rem);
  font-weight: 700;
}

.idiom-tzg.is-correct .idiom-tzg-char {
  color: #1c120a;
  text-shadow: none;
}

.idiom-pinyin {
  font-family: var(--mono);
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .02em;
  text-align: center;
}

.py-match { color: #4ade80; }
.py-neutral { color: #f4e6d6; }
.py-tone-miss { color: #fb923c; }

.py-tone-holder {
  position: relative;
  display: inline-block;
}

.py-tone-mark {
  position: absolute;
  left: 50%;
  top: -.26em;
  transform: translateX(-50%);
  font-size: 1.25em;
  line-height: 1;
  font-weight: 700;
}

.idiom-form {
  padding-top: 6px;
}

.idiom-form-actions {
  display: flex;
  gap: 10px;
}

.idiom-guess-btn {
  flex: 1;
  min-height: 42px;
}

.idiom-hint-btn {
  min-width: 84px;
  min-height: 42px;
}

/* ======================== Takuzu (XXOO) Specific ======================== */

.takuzu-frame {
  padding: 18px 14px;
}

.takuzu-board {
  display: grid;
  grid-template-columns: repeat(var(--takuzu-size, 4), minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 248px);
  margin: 0 auto;
}

.takuzu-board[data-size="6"] { width: min(100%, 324px); gap: 3px; }
.takuzu-board[data-size="8"] { width: min(100%, 396px); gap: 3px; }
.takuzu-board[data-size="10"] { width: min(100%, 468px); gap: 2px; }
.takuzu-board[data-size="12"] { width: min(100%, 516px); gap: 2px; }

.takuzu-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(246, 223, 194, .22);
  border-radius: 3px;
  background: rgba(20, 14, 10, .12);
  color: #fff5e6;
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

.takuzu-board[data-size="8"] .takuzu-cell { font-size: 1rem; }
.takuzu-board[data-size="10"] .takuzu-cell { font-size: .86rem; }
.takuzu-board[data-size="12"] .takuzu-cell { font-size: .74rem; }

#games .activity-panel:is(.is-engaged, [data-engaged="true"]) .takuzu-cell {
  border-color: rgba(246, 223, 194, .30);
  background: rgba(24, 16, 11, .34);
}

.takuzu-cell:hover:not([data-locked="true"]):not([data-sealed="true"]) {
  border-color: rgba(237, 213, 178, .58);
  background: rgba(237, 213, 178, .12);
}

.takuzu-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  z-index: 2;
}

.takuzu-cell[data-locked="true"] {
  background: rgba(246, 223, 194, .12);
  border-color: rgba(246, 223, 194, .28);
  color: #edd5b2;
  font-weight: 800;
  cursor: default;
}

#games .activity-panel:is(.is-engaged, [data-engaged="true"]) .takuzu-cell[data-locked="true"] {
  background: rgba(246, 223, 194, .18);
  border-color: rgba(246, 223, 194, .36);
}

.takuzu-cell[data-sealed="true"] {
  background: rgba(246, 223, 194, .08);
  color: rgba(246, 223, 194, .68);
  opacity: .82;
  cursor: default;
}

.takuzu-cell[data-error="true"] {
  border-color: #f87171 !important;
  background: rgba(239, 68, 68, .22) !important;
  color: #fecaca !important;
}

.takuzu-cell[data-won="true"] {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #1c120a !important;
  text-shadow: none;
}

.takuzu-trial-order {
  position: absolute;
  top: 1px;
  right: 2px;
  color: #d9c3ad;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
}

.game-error-panel {
  padding: 11px 14px;
  border: 1px solid rgba(248, 113, 113, .55);
  border-radius: 6px;
  background: rgba(127, 29, 29, .24);
  color: #fca5a5;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.75;
}

.game-trial-banner {
  padding: 9px 12px;
  border: 1px dashed rgba(246, 223, 194, .32);
  border-radius: 6px;
  background: rgba(20, 14, 10, .18);
  color: #e1ccb8;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.55;
}

.takuzu-rule-demo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.takuzu-demo-triple {
  display: inline-flex;
  gap: 3px;
}

.takuzu-demo-triple span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #f87171;
  border-radius: 3px;
  background: rgba(239, 68, 68, .16);
  color: #fca5a5;
  font-weight: 700;
  font-size: .75rem;
}

.takuzu-demo-note {
  color: #fca5a5;
}

/* ======================== Guess Number Specific ======================== */

.guess-history-wrap {
  margin-bottom: 16px;
}

.guess-history-list {
  display: grid;
  gap: 8px;
}

.guess-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  border: 1px solid rgba(246, 223, 194, .18);
  border-radius: 5px;
  background: rgba(20, 13, 9, .24);
  font-family: var(--mono);
}

.guess-history-idx {
  color: #cbb59f;
  font-size: .8rem;
}

.guess-history-num {
  color: #fff6e8;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: .16em;
}

.guess-history-fb {
  color: var(--accent);
  font-size: .88rem;
  font-weight: 700;
}

.guess-form {
  padding-top: 8px;
}

/* ======================== Game Rules Box ======================== */

.game-rules {
  padding: 13px 16px;
  border: 1px solid rgba(246, 223, 194, .14);
  border-radius: 6px;
  background: rgba(20, 14, 10, .05);
  transition: border-color .28s ease, background-color .28s ease;
}

#games .activity-panel:is(.is-engaged, [data-engaged="true"]) .game-rules {
  border-color: rgba(246, 223, 194, .22);
  background: rgba(16, 10, 7, .22);
}

.game-rules-title {
  margin-bottom: 6px;
  color: #fff3dd;
  font-family: var(--mono);
  font-size: .84rem;
  font-weight: 700;
}

.game-rules-body {
  color: #d9c4af;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.85;
}

.game-rules-body strong {
  color: #fff3dd;
}

.game-rules-lead {
  margin-top: 4px;
  color: #fff3dd;
  font-weight: 700;
}

.game-rules-indent {
  padding-left: 10px;
}

.game-rules-example {
  margin: 6px 0;
  padding: 7px 11px;
  border: 1px solid rgba(246, 223, 194, .18);
  border-radius: 4px;
  background: rgba(20, 14, 10, .18);
}

/* ======================== Shared Tool Forms & Outputs ======================== */

.activity-form,
.activity-form label {
  display: grid;
  gap: 8px;
}

.activity-form {
  gap: 16px;
}

.activity-form p {
  margin: 0;
}

.activity-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 12px 16px;
}

.activity-fields[hidden],
.activity-result[hidden] {
  display: none;
}

.activity-form :is(input, textarea, select) {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #160f0bd1;
  color: inherit;
  font: inherit;
  accent-color: var(--accent);
}

.activity-form input[type="range"] {
  padding: 0;
}

.activity-form textarea {
  min-height: 100px;
  resize: vertical;
}

.activity-form :is(input, textarea, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.activity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.activity-actions :is(button, a) {
  display: inline-flex;
  align-items: center;
  min-height: 37px;
  padding: 6px 13px;
  border: 0;
  border-radius: 5px;
  background: #33251abd;
  color: #fff3dd;
  cursor: pointer;
  font: inherit;
}

.activity-actions :is(button, a):hover:not(:disabled) {
  background: #493426;
}

.activity-actions button:disabled {
  opacity: .5;
  cursor: default;
}

.activity-status {
  margin: 12px 0 0;
  color: var(--accent);
}

.activity-status:empty,
.activity-result:empty {
  display: none;
}

.activity-result {
  max-width: 100%;
  margin-top: 12px;
  overflow-x: auto;
  overflow-wrap: anywhere;
}

.activity-result :is(canvas, img) {
  display: block;
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  margin: 0 0 12px;
  border-radius: 6px;
}

.activity-result dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.activity-result dl > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 14px;
  padding: 5px 0;
  border-bottom: 1px solid #eacaa433;
}

.activity-result dd {
  margin: 0;
  color: var(--accent);
  font-family: var(--mono);
}

.activity-result table {
  width: 100%;
  border-collapse: collapse;
}

.activity-result :is(td, th) {
  padding: 7px 10px;
  border-bottom: 1px solid #eacaa433;
  text-align: left;
  white-space: nowrap;
}

.activity-form .activity-dropzone {
  position: relative;
  min-height: clamp(144px, 18vw, 192px);
  place-content: center;
  justify-items: center;
  padding: clamp(22px, 3vw, 34px) 20px;
  border: 1px dashed rgba(246, 223, 194, .13);
  border-radius: 6px;
  background-color: rgba(20, 14, 10, .04);
  color: #fff3dd;
  cursor: pointer;
  text-align: center;
  transition:
    color .2s ease,
    border-color .28s ease,
    background-color .28s ease;
}

.activity-dropzone small { color: #e1ccba; }

.activity-form .activity-dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

#tools .activity-panel:is(.is-engaged, [data-engaged="true"]) .activity-dropzone {
  border-color: rgba(246, 223, 194, .24);
  background-color: rgba(20, 13, 9, .18);
}

.activity-dropzone:is(:hover, :focus-within) {
  border-color: rgba(240, 195, 166, .48);
  background-color: rgba(240, 195, 166, .08);
  color: #ffe0a9;
}

.activity-dropzone:is(.is-dragging, [data-dragging="true"]) {
  border-color: rgba(240, 195, 166, .72);
  background-color: rgba(240, 195, 166, .14);
  color: #ffe0a9;
}

.activity-dropzone:is(:hover, :focus-within, .is-dragging, [data-dragging="true"]) strong {
  text-decoration: underline;
  text-underline-offset: 5px;
}

.activity-dropzone:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#tools .activity-form :is(input, textarea, select) {
  border-color: rgba(246, 223, 194, .14);
  transition: border-color .22s ease, background-color .22s ease;
}

#tools .activity-panel:is(.is-engaged, [data-engaged="true"]) .activity-form :is(input, textarea, select) {
  border-color: rgba(246, 223, 194, .22);
}

#tools .activity-form :is(input, textarea, select):hover {
  border-color: rgba(240, 195, 166, .34);
}

/* ======================== Responsive ======================== */

@media (max-height: 840px) and (min-width: 661px) {
  .chapter-area:has(#games:not([hidden])) {
    padding-block: 16px 28px;
  }

  .game-hub-nav {
    margin-top: 16px;
  }

  .game-list {
    gap: 10px;
  }

  .game-card {
    padding: 14px 20px;
  }
}

@media (max-width: 960px) {
  #games .activity-panel {
    padding: 20px 18px 22px;
  }

  .game-card {
    padding: 18px 20px;
    gap: 15px;
  }
}

@media (max-width: 660px) {
  .patrol-viewport {
    aspect-ratio: 4 / 3;
    max-height: min(62svh, 460px);
  }
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  .activity-panel { padding-inline: 0; }
  #tools .tool-sidebar { padding: 14px 12px; }
  #tools .activity-panel { padding: 18px 16px 20px; }
  #games .activity-panel { padding: 16px 14px 18px; }

  .tool-list {
    grid-template-columns: repeat(auto-fit, minmax(min(110px, 100%), 1fr));
  }

  .game-level-btn.is-desktop-only {
    display: none;
  }

  .game-card {
    padding: 15px 16px;
    gap: 13px;
  }

  .game-card-icon {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-hub:not([hidden]),
  .game-expanded:not([hidden]) {
    animation: none;
  }

  .world .lighting::before,
  .tool-sidebar,
  #tools .activity-panel,
  #tools .activity-form :is(input, textarea, select),
  .game-back-btn,
  #games .activity-panel,
  .game-frame,
  .game-rules,
  .game-btn,
  .game-level-btn,
  .game-slot-bar,
  .takuzu-cell,
  .activity-launch,
  .activity-dropzone { transition: none; }
}
