*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", "PT Sans", "Liberation Sans", sans-serif;
  line-height: 1.4;
  color: var(--ink, #fff8e8);
  background: var(--sky, #0a1628);
  overflow: hidden;
}
body.catalog-page {
  overflow: auto;
  height: auto;
  min-height: 100%;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }

.snow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow: hidden;
}
.flake {
  position: absolute;
  top: -8%;
  pointer-events: none;
  color: transparent;
  font-size: 0;
  line-height: 0;
  animation: fall linear infinite;
}
.flake svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  overflow: visible;
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1.4px rgba(40, 20, 10, .45));
}
@keyframes fall {
  0%   { transform: translate3d(0, -8vh, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translate3d(8vw, 108vh, 0) rotate(150deg); opacity: 0; }
}

.sky-decor {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.sky-dot {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: .7;
}
.sky-bokeh {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: .35;
}

.frame {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  height: 100vh;
  max-height: 100dvh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}

.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 6px;
}
.top a, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid var(--chip-border, rgba(255,255,255,.28));
  background: var(--chip, rgba(255,255,255,.14));
  color: var(--chip-ink, #fff);
  border-radius: 999px;
  padding: 6px 10px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.top-title {
  flex: 1;
  text-align: center;
  min-width: 0;
}
.top-title h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: .02em;
  line-height: 1.15;
}
.top-title p {
  margin: 2px 0 0;
  font-size: 11px;
  opacity: .8;
}
.progress {
  display: block;
  margin: 0 auto 4px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--chip, rgba(255,255,255,.14));
  width: max-content;
  font-size: 13px;
  font-weight: 700;
}

.tree-stage {
  position: relative;
  flex: 1 1 0%;
  min-height: 0;
  display: block;
  overflow: hidden;
}
.tree-stage svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: visible;
}
.ornament {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
}
.bulb.is-just-lit {
  animation: bulb-ignite 1.15s ease-out both;
  filter: url(#glow-lit);
}
@keyframes bulb-ignite {
  0% { opacity: 0.2; transform: scale(0.55); }
  40% { opacity: 1; transform: scale(1.7); }
  70% { transform: scale(0.94); }
  100% { opacity: 1; transform: scale(1); }
}
.ornament.is-just-lit {
  animation: orn-ignite 0.9s ease-out;
}
.ornament.is-done .orn-glow {
  opacity: 0.95;
  animation: orn-halo 1.35s ease-in-out infinite;
}
.ornament.is-done {
  filter: drop-shadow(0 0 2px #fff8d0) drop-shadow(0 0 6px #ffbf1a);
}
@keyframes orn-halo {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes orn-ignite {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.ornament:focus { outline: none; }
.ornament:focus-visible .hit {
  stroke: #fff;
  stroke-width: 2;
  stroke-opacity: .9;
}
.ornament .hit { fill: transparent; }
.caption {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px 4px;
  min-height: 20px;
  opacity: .92;
}

.demo-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
}
.demo-bar .btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  letter-spacing: .01em;
  padding: 8px 10px;
  font-size: 14px;
}
.btn-main {
  background: linear-gradient(#ffd45a, #f0a020);
  color: #3a2408;
  box-shadow: 0 3px 0 #c47a10;
}
.btn-ghost {
  background: var(--chip, rgba(255,255,255,.14));
  color: var(--chip-ink, #fff);
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
  border: 1px solid var(--chip-border, rgba(255,255,255,.25));
}

/* lights */
.bulb {
  transform-box: fill-box;
  transform-origin: center;
}
.bulb.is-lit { filter: url(#glow-lit); animation: bulb-idle 1.8s ease-in-out infinite; }
.tree-svg.is-finale .bulb.is-lit {
  animation: bulb-blink 0.75s ease-in-out infinite;
}
@keyframes bulb-idle {
  0%, 100% { opacity: .78; }
  50% { opacity: 1; }
}
@keyframes bulb-blink {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}
.star-group { transform-box: fill-box; transform-origin: center; opacity: 0.4; }
.star-group .star-core { filter: grayscale(.25); }
.star-group.is-lit { opacity: 1; }
.star-group.is-lit .star-core {
  filter: url(#star-glow);
}
.tree-svg.is-finale .star-group.is-lit {
  animation: star-pulse 1.05s ease-in-out infinite;
}
@keyframes star-pulse {
  0%, 100% { transform: scale(.96); opacity: .85; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* modal */
.modal-backdrop, .finale-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 8, 20, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  transition: opacity .2s ease;
}
.modal-backdrop.is-visible, .finale-backdrop.is-visible { opacity: 1; }
.finale-backdrop { z-index: 80; }
@media (min-width: 600px) {
  .modal-backdrop, .finale-backdrop { align-items: center; }
}
.task-sheet, .finale-card {
  width: min(480px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--sheet, #fffaf3);
  color: var(--sheet-ink, #2a120c);
  border-radius: 22px;
  padding: 20px 18px 18px;
  position: relative;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.sheet-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.08);
  font-size: 26px; line-height: 1;
  cursor: pointer; color: inherit;
}
.sheet-kicker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 36px 8px 0; }
.sheet-day, .sheet-subject {
  font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 4px 10px;
}
.sheet-day { background: #ffe7a3; color: #5a3a00; }
.sheet-subject { background: #dceeff; color: #163a62; }
.task-sheet h2, .finale-card h2 {
  margin: 8px 0 8px;
  font-size: 22px;
  line-height: 1.25;
}
.sheet-intro { margin: 0 0 14px; font-size: 16px; }
.sheet-note { margin: 0 0 16px; font-size: 14px; opacity: .8; }
.finale-card p { margin: 0 0 10px; font-size: 16px; }
.finale-card .from { font-weight: 800; margin-top: 12px; }
.finale-hint {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff4d6;
  border-left: 4px solid #e09a12;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

/* variants: page chrome */
body.v1 {
  --sky: #0a1628;
  --ink: #fff6e0;
  --chip: rgba(255,255,255,.12);
  --chip-border: rgba(255,230,180,.28);
  --chip-ink: #fff6e0;
  --sheet: #fffaf3;
  --sheet-ink: #2a120c;
  background: radial-gradient(ellipse at 50% 0%, #1a3a68 0%, #0a1628 50%, #070b14 100%);
}
body.theme-tree,
body.v2 {
  --sky: #4a121c;
  --ink: #fff6e0;
  --chip: rgba(255,247,235,.16);
  --chip-border: rgba(232,195,106,.45);
  --chip-ink: #fff7eb;
  --sheet: #fffaf3;
  --sheet-ink: #2a120c;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(232,195,106,.28), transparent 42%),
    linear-gradient(#6b1d28 0%, #4a121c 42%, #2a0a10 100%);
}
body.theme-tree .btn-main,
body.v2 .btn-main {
  background: linear-gradient(#ffd45a, #f0a020);
  color: #3a2408;
}
body.v3 {
  --sky: #e8d5b0;
  --ink: #3a2410;
  --chip: rgba(255,255,255,.55);
  --chip-border: rgba(90,50,20,.25);
  --chip-ink: #3a2410;
  --sheet: #fffaf0;
  --sheet-ink: #2a180c;
  background-color: #e6d0a8;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 11px, rgba(90,50,20,.04) 11px, rgba(90,50,20,.04) 12px),
    repeating-linear-gradient(90deg, transparent, transparent 11px, rgba(90,50,20,.04) 11px, rgba(90,50,20,.04) 12px),
    radial-gradient(ellipse at 50% 0%, #f3e4c4, #d9c08e 80%);
}
body.v3 .btn-main {
  background: #c62828;
  color: #fff8e8;
  box-shadow: 0 3px 0 #7a1414;
}
body.v3 .btn-ghost { color: #3a2410; }
body.v4 {
  --sky: #1b2040;
  --ink: #f4efe6;
  --chip: rgba(230, 210, 190, .14);
  --chip-border: rgba(210, 170, 130, .35);
  --chip-ink: #f4efe6;
  --sheet: #f7f1e6;
  --sheet-ink: #2a2230;
  background: linear-gradient(180deg, #2a2450 0%, #1a2a48 42%, #152036 100%);
}
body.v4 .btn-main {
  background: linear-gradient(#e8c9a0, #c9a06a);
  color: #3a2410;
  box-shadow: 0 3px 0 #8a6a3a;
}

/* index */
.catalog {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  position: relative;
  z-index: 1;
}
.catalog h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; text-align: center; }
.catalog .lead {
  margin: 0 0 18px;
  text-align: center;
  font-size: 15px;
}
.cards { display: grid; gap: 12px; }
.card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: var(--card, rgba(255,255,255,.1));
  border: 1px solid var(--card-border, rgba(255,255,255,.2));
  border-radius: 18px;
  padding: 10px;
  min-height: 108px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card p { margin: 0; font-size: 13px; line-height: 1.4; opacity: .92; }
.card-preview {
  width: 92px; height: 108px;
  border-radius: 12px;
  overflow: hidden;
}
.card-preview svg { width: 100%; height: 100%; display: block; }
.back-home {
  display: block;
  text-align: center;
  margin: 16px 0 0;
  font-weight: 700;
}
body.catalog-page {
  --sky: #2a1218;
  color: #fff6e0;
  background:
    radial-gradient(ellipse at 50% 0%, #5a1d28, #2a1218 60%);
}
body.catalog-page .card {
  background: rgba(255,250,240,.1);
  border-color: rgba(232,195,106,.35);
}


/* task typography */
.sheet-title { font-size: 22px; font-weight: 800; line-height: 1.25; }
.sheet-intro,
.already,
.crossing-help { font-size: 16px; line-height: 1.5; }
.sheet-question { font-size: 18px; line-height: 1.45; font-weight: 800; }
.translate-hint {
  margin: -4px 0 12px;
  padding: 8px 12px;
  background: #fff4d6;
  border-left: 4px solid #e09a12;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #4a2a10;
}
.option,
.word-chip,
.match-item,
.answer-input { font-size: 16px; font-weight: 700; }
.word-chip { min-height: 44px; padding: 8px 14px; }
.btn { font-size: 16px; min-height: 48px; }
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; position: relative; z-index: 75; }
.top-title { grid-column: 2; }
.top .ghost[data-reset] { grid-column: 1; justify-self: start; }
.top .ghost[data-switch] { grid-column: 3; justify-self: end; }
.progress { position: relative; z-index: 75; }

.part-tag { font-size: 13px; font-weight: 800; color: #8a3a20; margin: 0 0 8px; }
.part-box + .part-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed rgba(138, 58, 32, .35);
}
.chip-tray, .chip-bank {
  display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px;
  padding: 10px; border-radius: 14px;
}
.chip-tray { background: #fff; border: 2px dashed #d2b46a; margin-bottom: 10px; }
.chip-bank { background: #f7ead4; }
.word-chip {
  border: 2px solid #e0d2b6; background: #fff; color: inherit;
  border-radius: 999px; cursor: pointer;
}
.word-chip:hover { border-color: #e09a12; }
.chip-tray .word-chip { background: #fff4d6; border-color: #e09a12; }

/* matching + lines */
.match-board { position: relative; margin: 8px 0 12px; }
.match-lines {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible; z-index: 1;
}
.match-grid {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 40px;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  text-align: left; border: 2px solid #e0d2b6; background: #fff;
  border-radius: 14px; padding: 10px 12px; min-height: 48px; cursor: pointer;
  color: inherit; position: relative;
}
.match-item.is-picked { border-color: #e09a12; background: #fff4d6; box-shadow: 0 0 0 3px rgba(224,154,18,.25); }
.match-item.is-paired { border-color: #2f9a5c; background: #e8fff2; }
.match-item .pair-icon { margin-right: 6px; }
.match-line { fill: none; stroke-linecap: round; stroke-width: 3.5; }
.match-line.is-ok { stroke: #2f9a5c; }
.match-line.is-temp { stroke: #e09a12; stroke-dasharray: 6 5; }

/* crossing / ferry */
.crossing { margin-top: 6px; }
.crossing-scene { display: flex; flex-direction: column; gap: 8px; }
.bank {
  background: linear-gradient(#efe0c4, #d8c49a);
  border: 2px solid #a67a3e;
  border-radius: 16px;
  padding: 8px 8px 10px;
}
.bank h3 {
  margin: 0 0 8px; font-size: 13px; text-align: center; text-transform: uppercase;
  letter-spacing: .04em; color: #4a2a10; font-weight: 800;
}
.bank[data-bank="left"] {
  background: linear-gradient(#eef3f8, #d5e2ee);
  border-color: #7f97b0;
}
.bank[data-bank="right"] {
  background: linear-gradient(#fff8dc, #f6d98a);
  border-color: #d39a2e;
}
.bank-actors {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  min-height: 98px;
  align-items: start;
}
.actor {
  border: 2px solid #c9a06a; background: #fffaf0; border-radius: 14px;
  padding: 4px 2px 6px; min-height: 92px; min-width: 0; width: 100%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  font-weight: 800; font-size: 11px; line-height: 1.15; color: inherit;
  box-sizing: border-box;
}
.actor span { text-align: center; max-width: 100%; }
.actor svg {
  width: 54px;
  height: 54px;
  min-width: 54px;
  min-height: 54px;
  max-width: none;
  flex: 0 0 auto;
  display: block;
}
.actor:hover { border-color: #e09a12; }
.actor[disabled] { opacity: .45; cursor: default; }

.river-scene {
  position: relative;
  height: 268px;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #1d4e68;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 244, 210, .28), transparent 42%),
    linear-gradient(#1a6284 0%, #134861 46%, #0e3348 100%);
  box-shadow: inset 0 10px 18px rgba(255,255,255,.08);
}
.river-water {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.wave-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  display: block;
  will-change: transform;
}
.wave-layer svg {
  width: 100%;
  height: 100%;
  display: block;
}
.wave-1 { animation: wave-slide 5.5s linear infinite; }
.wave-2 { animation: wave-slide 8s linear infinite reverse; }
.wave-3 { animation: wave-slide 6.5s linear infinite; }
@keyframes wave-slide {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Mobile: banks top/bottom, boat sails up/down across the river */
.ferry {
  position: absolute;
  top: 3%;
  left: 50%;
  width: 78%;
  max-width: 250px;
  z-index: 2;
  transform: translateX(-50%);
  transition: top .75s ease-in-out;
}
.ferry.is-right { top: 38%; left: 50%; }
.ferry.is-sailing { z-index: 3; }
.ferry-art { width: 100%; height: auto; display: block; overflow: visible; max-width: none; }
.ferry-seats {
  position: absolute;
  left: 6%;
  right: 30%;
  bottom: 40%;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  pointer-events: auto;
  min-height: 64px;
}
.ferry-seats .seat {
  width: 58px;
  min-height: 64px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.ferry .actor {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 56px;
  height: 64px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  gap: 0;
  overflow: visible;
}
.ferry .actor svg { width: 48px; height: 48px; max-width: none; }
.ferry .actor span {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
  background: rgba(255,250,240,.95);
  border-radius: 6px;
  padding: 0 3px;
  max-width: none;
}
.crossing-help { text-align: left; }
.crossing-actions { justify-content: center; width: 100%; }
.crossing-scene .crossing-actions { margin: 4px 0; }
@media (min-width: 700px) {
  .crossing-scene .crossing-actions { grid-column: 1 / -1; }
}
.crossing, .crossing-scene { width: 100%; max-width: 100%; }
.bank h3 { text-align: center; }
.bank-year { display: block; font-size: 15px; letter-spacing: 0; text-transform: none; margin-top: 2px; }
@media (max-width: 700px) {
  .modal-backdrop { padding: 8px; }
  .task-sheet { width: 100%; max-width: 100%; }
  .bank-actors { justify-content: center; }
}

.crossing-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-sail { background: linear-gradient(#ffd45a, #f0a020); color: #3a2408; flex: 1; }
.btn-restart { background: #fff; border: 2px solid #e0d2b6; color: inherit; flex: 1; }
.crossing-status {
  box-sizing: border-box;
  min-height: 2.8em;
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}
.crossing-status.is-bad { color: #8a3b00; }
.crossing-status.is-ok { color: #0e6b38; }

.letter-paper {
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 214, 90, .55), transparent 28%),
    radial-gradient(circle at 100% 100%, rgba(198, 40, 40, .12), transparent 32%),
    #fffaf0;
  border: 3px solid #e8c36a;
  border-radius: 16px;
  padding: 16px 16px 12px;
  font-family: "Segoe UI", "PT Sans", "Noto Sans", Georgia, serif;
  color: #2a120c;
  box-shadow: 0 8px 0 rgba(140, 40, 30, .15);
  text-align: left;
  font-size: 16px;
  line-height: 1.5;
}
.letter-sky {
  text-align: center;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}
.letter-paper .dear { font-weight: 800; color: #8a1e24; }
.letter-paper .wish {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff1c2;
  border-radius: 12px;
  font-weight: 800;
}
.letter-paper .from { margin: 12px 0 0; text-align: right; font-weight: 800; }
.letter-paper .from span { display: block; margin-top: 4px; font-weight: 700; font-size: 14px; color: #8a5a18; }
.letter-paper h2 { margin: 0 0 8px; font-size: 24px; text-align: center; font-weight: 800; color: #9a1c24; }
.envelope-art { font-size: 56px; text-align: center; line-height: 1; margin-bottom: 8px; }


@media (min-width: 700px) {
  .crossing-scene {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 10px;
    align-items: stretch;
  }
  .river-scene { height: auto; min-height: 280px; }
  .ferry {
    top: 30%;
    left: 4%;
    width: 54%;
    max-width: none;
    transform: none;
    transition: left .75s ease-in-out;
  }
  .ferry.is-right { left: 42%; top: 30%; }
  .bank-actors { grid-template-columns: 1fr 1fr; min-height: 0; }
  .actor { flex-direction: column; align-items: center; justify-content: flex-start; min-height: 0; }
}

/* ---- mini-games ---- */
.game-wrap { margin-top: 6px; }
.game-rules {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.45;
  color: #3a2418;
  background: #fff6e8;
  border: 1px solid #efd3a6;
  border-radius: 12px;
  padding: 10px 12px;
}
.game-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 10px;
  min-height: 48px;
}
.game-stat {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 1.35em;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  color: #6a2e12;
}
.game-status {
  box-sizing: border-box;
  min-height: 2.8em;
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
  color: #3a2418;
}
.game-status.is-ok { color: #1d6b3a; }
.game-status.is-bad { color: #9b1c1c; }

/* Hanoi */
.hanoi-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: end;
  min-height: 220px;
  padding: 8px 4px 0;
}
.hanoi-peg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 200px;
  padding: 0 4px 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  z-index: 1;
}
.hanoi-peg::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: 8px;
  height: 150px;
  transform: translateX(-50%);
  border-radius: 6px;
  background: linear-gradient(#c9a06a, #8a5a28);
  box-shadow: inset 1px 0 0 rgba(255,255,255,.35);
  pointer-events: none;
}
.hanoi-peg::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 86%;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: #6b4220;
  pointer-events: none;
}
.hanoi-peg.is-selected {
  background: rgba(255, 220, 140, .6);
  box-shadow: inset 0 0 0 3px #e0a020;
  border-radius: 14px;
}
.hanoi-stack {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 3px;
  width: 100%;
  pointer-events: none;
}
.hanoi-disk {
  height: 36px;
  border-radius: 8px;
  border: 2px solid #4a2408;
  box-shadow: 0 2px 0 #3a1a08, inset 0 2px 0 rgba(255,255,255,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
  z-index: 2;
}
.hanoi-disk.is-lifted {
  transform: translateY(-14px) scale(1.08);
  box-shadow: 0 12px 16px rgba(40,10,10,.38), 0 0 0 3px #ffe27a;
  z-index: 6;
}
.hanoi-disk.size-3 { width: 96%; background: linear-gradient(#c62828, #8e1414); }
.hanoi-disk.size-2 { width: 74%; background: linear-gradient(#2e7d32, #1b5e20); }
.hanoi-disk.size-1 { width: 52%; background: linear-gradient(#f4c430, #c99200); }
.hanoi-disk .bow {
  width: 10px; height: 100%;
  background: rgba(255,255,255,.55);
  box-shadow: 0 0 0 2px rgba(180, 40, 40, .25);
}
.hanoi-peg-label {
  position: absolute;
  bottom: -2px;
  font-size: 12px;
  font-weight: 800;
  color: #5a3010;
  text-align: center;
  width: 100%;
}

/* Scale */
.scale-scene { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.scale-hint {
  width: 100%;
  background: #fff8e8;
  border: 2px solid #c9a24a;
  border-radius: 14px;
  color: #2a120c;
  font-size: 15px;
  line-height: 1.45;
}
.scale-hint summary {
  cursor: pointer;
  font-weight: 800;
  padding: 10px 12px;
  color: #2a120c;
  list-style: none;
}
.scale-hint summary::-webkit-details-marker { display: none; }
.scale-hint summary::before { content: "▸ "; }
.scale-hint[open] summary::before { content: "▾ "; }
.scale-hint-body { padding: 0 12px 12px; color: #2a120c; }
.scale-hint-body p { margin: 0 0 8px; color: #2a120c; }
.scale-hint-body ul { margin: 0 0 8px; padding-left: 20px; color: #2a120c; }
.scale-hint-body li { margin: 0 0 4px; }
.scale-stand { width: min(100%, 420px); height: 258px; position: relative; overflow: visible; z-index: 2; }
.scale-beam {
  position: absolute; left: 5%; right: 5%; top: 56px; height: 12px;
  background: linear-gradient(#8d6e3a, #5a3e18);
  border-radius: 6px;
  transform-origin: 50% 50%;
  transition: transform .55s cubic-bezier(.2,.8,.2,1);
  z-index: 2;
}
.scale-arm {
  position: absolute;
  top: 12px;
  width: 46%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.scale-arm-left { left: 0; }
.scale-arm-right { right: 0; }
.scale-string {
  width: 3px;
  height: 22px;
  background: #5a3e18;
  border-radius: 2px;
}
.scale-fulcrum {
  position: absolute; left: 50%; top: 42px; width: 0; height: 0;
  border-left: 16px solid transparent; border-right: 16px solid transparent;
  border-bottom: 28px solid #3a2410;
  transform: translateX(-50%);
  z-index: 3;
}
.scale-post {
  position: absolute; left: 50%; top: 66px; width: 14px; height: 110px;
  transform: translateX(-50%);
  background: linear-gradient(#8d6e3a, #4a3010);
  border-radius: 4px;
}
.scale-base {
  position: absolute; left: 50%; bottom: 4px; width: 130px; height: 14px;
  transform: translateX(-50%);
  background: #4a3010; border-radius: 8px;
}
.scale-pan {
  width: 100%;
  min-height: 108px;
  border: 3px solid #5a3e18; border-top: 0;
  border-radius: 0 0 22px 22px;
  background: #fff8e8;
  cursor: pointer;
  z-index: 4;
  padding: 4px 4px 8px;
  transform-origin: 50% 0%;
  transition: transform .55s cubic-bezier(.2,.8,.2,1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}
.scale-pan.is-target { outline: 3px solid #c47a10; outline-offset: 2px; }
.scale-pan-label {
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #3a2410;
  margin-bottom: 2px;
}
.scale-pan-hold {
  display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center;
  gap: 4px; min-height: 56px;
}
.scale-tray {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  width: 100%; min-height: 76px;
  padding: 8px; border-radius: 14px; background: #fff8e8; border: 2px dashed #c9a24a;
  position: relative; z-index: 1;
}
.scale-actions {
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 10px 18px 12px;
  box-sizing: border-box;
  background: #fffaf3;
  border-top: 1px solid #efd3a6;
  flex: 0 0 auto;
  z-index: 8;
}
.task-sheet:has([data-scale]) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.task-sheet:has([data-scale]) .sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.task-sheet:has([data-scale]) .sheet-intro { margin-bottom: 8px; }
.task-sheet:has([data-scale]) .game-rules { display: none; }
.task-sheet:has([data-scale]) .game-toolbar { margin-bottom: 6px; }
.task-sheet:has([data-scale]) .game-status { min-height: 4.4em; }
.task-sheet:has([data-scale]) .scale-hint { margin: 0 0 6px; }


/* Wrapped presents */
.present, .gift-box.present {
  position: relative;
  width: 48px;
  height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: block;
  flex: 0 0 48px;
  pointer-events: auto;
  z-index: 5;
}
.present-bow {
  position: absolute;
  left: 50%;
  top: 0;
  width: 22px;
  height: 14px;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
}
.present-bow::before,
.present-bow::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 11px;
  height: 11px;
  background: #f4c430;
  border: 1px solid #8a5a10;
  box-sizing: border-box;
}
.present-bow::before { left: 0; border-radius: 10px 10px 4px 10px; }
.present-bow::after { right: 0; border-radius: 10px 10px 10px 4px; }
.present-body {
  position: absolute;
  left: 0; right: 0; bottom: 0; top: 10px;
  border-radius: 5px 5px 7px 7px;
  border: 2px solid #3a1408;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 2px 0 #3a1a08;
  overflow: hidden;
}
.present-ribbon-v,
.present-ribbon-h {
  position: absolute;
  background: linear-gradient(#ffe082, #e0b44a);
  pointer-events: none;
  z-index: 1;
}
.present-ribbon-v {
  top: 0; bottom: 0; left: 50%; width: 8px; margin-left: -4px;
}
.present-ribbon-h {
  left: 0; right: 0; top: 46%; height: 8px; margin-top: -4px;
}
.present-num {
  position: relative;
  z-index: 2;
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 1px #2a1208;
}
.present.is-selected { outline: 3px solid #1d6b3a; outline-offset: 2px; border-radius: 8px; }
.present.is-heavy { outline: 3px solid #c47a10; outline-offset: 2px; border-radius: 8px; }
.present.is-light { filter: saturate(.55); }
.present.is-light .present-body { opacity: .9; }
.present-tag {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  z-index: 4;
  background: #fff8e8;
  color: #2a120c;
  border: 1px solid #8a5a18;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  padding: 1px 3px;
  white-space: nowrap;
}
.present.c1 .present-body { background: linear-gradient(#e53935, #b71c1c); }
.present.c2 .present-body { background: linear-gradient(#43a047, #1b5e20); }
.present.c3 .present-body { background: linear-gradient(#f4c430, #c99200); }
.present.c3 .present-num { color: #3a1208; text-shadow: 0 1px 0 #fff3c0; }
.present.c3 .present-ribbon-v,
.present.c3 .present-ribbon-h { background: linear-gradient(#e53935, #b71c1c); }
.present.c3 .present-bow::before,
.present.c3 .present-bow::after { background: #c62828; border-color: #7a1414; }
.present.c4 .present-body { background: linear-gradient(#1e88e5, #0d47a1); }
.present.c5 .present-body { background: linear-gradient(#8e24aa, #4a148c); }
.present.c6 .present-body { background: linear-gradient(#fb8c00, #e65100); }
.present.c7 .present-body { background: linear-gradient(#26c6da, #006064); }
.present.c8 .present-body { background: linear-gradient(#ec407a, #880e4f); }
.present.c9 .present-body { background: linear-gradient(#7cb342, #33691e); }

@media (max-width: 419px) {
  .present, .gift-box.present { width: 44px; height: 52px; flex-basis: 44px; }
  .scale-stand { height: 222px; }
  .task-sheet:has([data-scale]) .scale-actions { padding: 8px 12px 10px; gap: 6px; }
  .task-sheet:has([data-scale]) .scale-actions .btn { padding: 8px 12px; font-size: 15px; }
}

/* Breakout / Арканоид */
.breakout-stage {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
.breakout-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 12px;
  background: #3a1018;
  touch-action: none;
  box-shadow: 0 4px 0 #2a0a10, inset 0 0 0 2px #7a2030;
  cursor: pointer;
}
.task-sheet:has([data-breakout]) {
  overscroll-behavior: none;
  touch-action: pan-y;
}

/* Screen lock while a game is active (phone) */
html.is-game-locked,
body.is-game-locked {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
  height: 100%;
}
body.is-game-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}


/* Jugs */
.jugs-scene {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: 100%; max-width: 100%; box-sizing: border-box;
}
.jugs-row {
  display: flex; justify-content: center; align-items: stretch;
  gap: 12px; width: 100%; max-width: 100%; box-sizing: border-box;
}
.jug-col {
  flex: 1 1 0; min-width: 0; max-width: 200px;
  display: flex; flex-direction: column; align-items: center;
}
.jug {
  flex: 1 1 auto; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 6px;
}
.jug-body {
  position: relative; width: 86px; border: 4px solid #5a3010;
  border-radius: 10px 10px 18px 18px; overflow: hidden; background: #eaf6ff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.5);
}
.jug-3 .jug-body { height: 108px; }
.jug-5 .jug-body { height: 160px; }
.jug-liquid {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(#7ec8e8, #1e88c8);
  transition: height .45s ease;
}
.jug-liquid::after {
  content: "";
  position: absolute; left: 0; right: 0; top: -6px; height: 12px;
  background: radial-gradient(circle at 50% 100%, #9ad4ee 40%, transparent 70%);
}
.jug-marks {
  position: absolute; inset: 0; pointer-events: none;
}
.jug-marks span {
  position: absolute; left: 4px; right: 4px; height: 1px; background: rgba(50,40,20,.35);
  font-size: 10px; color: #4a3010; text-align: right; padding-right: 2px;
}
.jug-label { font-size: 14px; font-weight: 800; color: #3a2418; text-align: center; }
.jug-actions {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  margin-top: 10px;
}
.jug-actions .btn {
  width: 100%; box-sizing: border-box;
  font-size: 13px; min-height: 44px; padding: 8px 6px;
  white-space: normal; line-height: 1.25; text-align: center;
}

@media (max-width: 419px) {
  .hanoi-disk { height: 32px; }
  .jug-body { width: 72px; }
  .jugs-row { gap: 8px; }
  .jug-actions .btn { font-size: 12px; padding: 8px 4px; }
}


/* Contrast: page chrome over the tree / burgundy sky */
.top-title h1,
.top-title p,
.caption {
  color: #fff8e8;
  text-shadow: 0 1px 2px rgba(26, 6, 10, .95), 0 0 10px rgba(26, 6, 10, .7);
}
.top-title p {
  opacity: 1;
  display: inline-block;
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(26, 6, 10, 0.55);
}
.progress {
  background: rgba(26, 6, 10, 0.62);
  color: #fff8e8;
  border: 1px solid rgba(232, 195, 106, 0.65);
  text-shadow: 0 1px 2px rgba(26, 6, 10, .9);
}
.caption {
  background: rgba(26, 6, 10, 0.55);
  border-radius: 999px;
  margin: 0 16px 8px;
  padding: 5px 12px;
  opacity: 1;
}
.top .ghost {
  background: rgba(26, 6, 10, 0.62);
  color: #fff8e8;
  border: 1px solid rgba(232, 195, 106, 0.7);
  text-shadow: 0 1px 1px rgba(26, 6, 10, .8);
}

/* Contrast: buttons and text on cream sheets */
.task-sheet,
.finale-card {
  color: #2a120c;
  background: #fffaf3;
}
.task-sheet .btn,
.finale-card .btn {
  background: #fff8e8;
  color: #2a120c;
  border: 2px solid #b8862a;
  box-shadow: none;
}
.task-sheet .btn-check,
.finale-card .btn-check,
.task-sheet .btn-main,
.finale-card .btn-main,
.task-sheet .btn-sail {
  background: linear-gradient(#ffd45a, #f0a020);
  color: #3a2408;
  border: 0;
  box-shadow: 0 3px 0 #c47a10;
}
.task-sheet .btn-ghost,
.finale-card .btn-ghost {
  background: #fff8e8;
  color: #2a120c;
  border: 2px solid #b8862a;
  box-shadow: none;
}
.task-sheet .btn:disabled,
.finale-card .btn:disabled {
  color: #5a3a22;
  background: #f0e4cc;
  border-color: #c9b48a;
  opacity: 1;
}
.game-stat,
.game-status,
.game-rules,
.crossing-help,
.jug-label,
.hanoi-peg-label {
  color: #2a120c;
}
.game-status.is-ok { color: #145a2c; }
.game-status.is-bad,
.crossing-status.is-bad { color: #8a1414; }
.game-status.is-ok,
.crossing-status.is-ok { color: #145a2c; }
.game-rules {
  background: #fff8e8;
  border: 1px solid #c9a24a;
  color: #2a120c;
}
.sheet-feedback.is-hint { color: #7a3200; }
.sheet-day { background: #ffe7a3; color: #4a2e00; }
.letter-paper,
.letter-paper p,
.letter-paper .from,
.finale-card p,
.finale-hint {
  color: #2a120c;
}
.finale-hint { background: #fff4d6; border-left-color: #c47a10; }


@media (max-width: 700px) {
  .task-sheet:has([data-breakout]) { padding-top: 16px; padding-bottom: 12px; }
  .task-sheet:has([data-breakout]) .sheet-title { font-size: 20px; margin: 4px 0 6px; }
  .task-sheet:has([data-breakout]) .sheet-intro { margin: 0 0 6px; font-size: 15px; }
  .task-sheet:has([data-breakout]) .game-rules { margin: 0 0 6px; padding: 8px 10px; font-size: 14px; }
  .task-sheet:has([data-breakout]) .game-toolbar { margin: 0 0 6px; }
.task-sheet:has([data-breakout]) .game-stat { min-height: 2.6em; }
}

body.is-gate,
body.is-admin {
  overflow: auto;
  height: auto;
  min-height: 100%;
}
body.is-gate .frame,
body.is-admin .frame,
body.is-gate .admin-screen,
body.is-admin .gate,
body.is-gate .snow,
body.is-admin .snow { display: none; }
.admin-screen[hidden] { display: none !important; }

.gate,
.admin-screen { position: relative; z-index: 80; }

.gate { display: none; }
body.is-gate .gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
}
.gate-card {
  width: min(100%, 420px);
  background: #fffaf3;
  color: #2a120c;
  border: 2px solid #e8c36a;
  border-radius: 24px;
  padding: 22px 18px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
}
.gate-kicker {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #8a3a20;
}
.gate-card h2 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.15;
  color: #9d1c2b;
}
.gate-card p { margin: 0 0 14px; font-size: 16px; line-height: 1.45; }
.gate-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
}
.gate-card input {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #e4c98a;
  background: #fff;
  color: #2a120c;
}
.gate-card .btn { width: 100%; }
.gate-error {
  min-height: 1.3em;
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 800;
  color: #9d1c2b;
}

.admin-screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 14px 48px;
  color: #fff8e8;
}
.admin-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  background: #4a121c;
}
.admin-bar .btn { min-height: 40px; padding: 8px 14px; }
.start-card {
  background: #fffaf3;
  color: #2a120c;
  border-radius: 16px;
  padding: 12px 14px;
  margin: 4px 0 12px;
}
.start-card label { display: block; font-weight: 800; margin-bottom: 4px; }
.start-help { margin: 0 0 8px; font-size: 14px; line-height: 1.35; }
.start-card input[type="date"] {
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid #e4c98a;
  background: #fff;
  color: #2a120c;
}
.start-card .btn { margin-top: 8px; min-height: 42px; }
.start-hint { margin: 8px 0 0; font-size: 14px; font-weight: 700; line-height: 1.35; }
.admin-stat {
  margin: 8px 0 4px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
}
.admin-stat b { color: #ffe08a; }
.admin-note {
  margin: 0 0 12px;
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
}
.admin-cut {
  margin: 22px 0 10px;
  font-size: 20px;
  text-align: center;
}
.who {
  background: rgba(255, 248, 232, .1);
  border: 1px solid rgba(232, 195, 106, .35);
  border-radius: 16px;
  padding: 10px 12px;
  margin: 8px 0;
}
.who h3 { margin: 0 0 2px; font-size: 18px; }
.who p { margin: 0; font-size: 14px; line-height: 1.35; }
.who-when { opacity: .85; }
.who.is-away { opacity: .55; }

.print-sheet {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.code-card {
  break-inside: avoid;
  background: #fffaf3;
  color: #2a120c;
  border: 1.5px dashed #5a3418;
  border-radius: 16px;
  padding: 12px 14px 10px;
}
.code-card-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #8a3a20;
}
.code-card-site {
  margin: 4px 0 8px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  color: #9d1c2b;
}
.code-card-label {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: #8a3a20;
}
.code-card-code {
  margin: 2px 0 6px;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 800;
}
.code-card-help { margin: 0; font-size: 14px; line-height: 1.35; }
.print-only { display: none; margin: 0 0 8px; text-align: center; font-size: 18px; }

@media (min-width: 700px) {
  .print-sheet { grid-template-columns: 1fr 1fr; }
}

@media print {
  .snow, .sky-decor, .burst-layer, .frame, .gate,
  .admin-bar, .admin-stat, .admin-note, .who, .admin-cut, .start-card { display: none !important; }
  body, body.is-admin {
    background: #fff !important;
    overflow: visible !important;
    height: auto !important;
  }
  .admin-screen {
    display: block !important;
    max-width: none;
    padding: 0;
    color: #000;
  }
  .print-only { display: block !important; color: #000; }
  .print-sheet { display: block !important; }
  .code-card {
    display: inline-block;
    vertical-align: top;
    width: 48%;
    margin: 0 1% 10px;
    box-shadow: none;
  }
}
@page { margin: 12mm; }
