/* --cell: 68 CSS px is 1.3 cm on the 12.9 inch iPad (132 CSS px per inch) */
:root { --cell: 68px; --bg: #fbf3e6; --ink: #3b2a20; --line: #b08a6a; --secret: #ffe2a8; --go: #4f9a60; --warm: #e9c79a; }
* { box-sizing: border-box; }
/* upright everything fits one screen; held sideways the page scrolls down, never sideways */
body { overflow-x: hidden; }
body { margin: 0; color: var(--ink); font-family: ui-rounded, system-ui, sans-serif;
  background: linear-gradient(#2b2d5c, #6a4a7c 45%, #d98a6a 80%, #f7c99b) fixed; }

/* The winter village: sky on the body, snow, and the drawing from index.html along the bottom */
#scene, #snow { position: fixed; left: 0; width: 100%; z-index: -1; pointer-events: none; }
#scene { bottom: 0; height: 300px; }
#snow { top: 0; height: 100%; overflow: hidden; }
#snow::before, #snow::after { content: ''; position: absolute; inset: -400px 0 0 0; background-repeat: repeat;
  animation: fall 22s linear infinite; }
#snow::before { background-size: 430px 400px; background-image:
  radial-gradient(circle at 40px 60px, #fff 3px, transparent 4px), radial-gradient(circle at 180px 150px, #fff 4px, transparent 5px),
  radial-gradient(circle at 300px 40px, #fff 3px, transparent 4px), radial-gradient(circle at 110px 300px, #fff 4px, transparent 5px),
  radial-gradient(circle at 340px 260px, #fff 3px, transparent 4px), radial-gradient(circle at 240px 360px, #fff 3px, transparent 4px); }
#snow::after { opacity: .6; animation-duration: 38s; background-size: 270px 400px; background-image:
  radial-gradient(circle at 30px 90px, #fff 2px, transparent 3px), radial-gradient(circle at 150px 20px, #fff 2px, transparent 3px),
  radial-gradient(circle at 90px 210px, #fff 2px, transparent 3px), radial-gradient(circle at 170px 330px, #fff 2px, transparent 3px); }
@keyframes fall { to { transform: translateY(400px); } }
/* without motion the puffs stay where they are drawn */
.puff { transform-box: fill-box; transform-origin: center; opacity: .7; animation: puff 5s ease-out infinite; }
.puff:nth-child(2) { animation-delay: -1.7s; }
.puff:nth-child(3) { animation-delay: -3.4s; }
@keyframes puff { from { opacity: 0; transform: translate(-6px, 30px) scale(.5); } 30% { opacity: .8; }
  to { opacity: 0; transform: translate(14px, -40px) scale(1.5); } }

main { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px; height: 100dvh; }
main:not([hidden]) { animation: enter .25s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
h1 { margin: 0; font-size: 24px; }
/* everything with text sits on a warm paper card, the sky stays behind */
header, #clue, #side, #clues, #intro, #final, #nonogram, .santa p {
  background: var(--bg); border-radius: 16px; box-shadow: 0 4px 0 rgba(43, 45, 92, .25); }
button { font-family: inherit; touch-action: manipulation; transition: transform .12s ease-out; }
button:active:not(:disabled) { transform: scale(.96); }

/* Santa and what he says */
.santa { display: flex; align-items: flex-start; gap: 8px; }
.face { font-size: 52px; line-height: 1; }
.face.big { font-size: 96px; }
.santa p { position: relative; margin: 0; padding: 10px 14px; font-size: 20px; line-height: 1.3; flex: 1;
  background: #fff; box-shadow: none; border: 2px solid var(--line); border-radius: 4px 16px 16px 16px; }

/* Round 1: the clue of the selected word above the grid, the Hand beside it, the full list scrolls below */
#round1 { display: grid; grid-template: auto auto minmax(0, 230px) / auto minmax(0, 1fr); gap: 12px;
  align-content: start; align-items: stretch; justify-content: center; max-width: 1024px; margin: 0 auto; }
#clue { grid-column: 1 / -1; margin: 0; padding: 12px 18px; min-height: 52px; font-size: 21px; line-height: 28px; }
#clue b { margin-right: 10px; color: #8c3f2e; }
#clue:not(.on) { color: #8a6a50; }
/* align-content: a tall side column (Santa's long closing line) must not spread the rows apart */
#grid { display: grid; gap: 2px; align-content: start; }
#grid, #hand { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cell { position: relative; width: var(--cell); height: var(--cell); background: #fff; border: 2px solid var(--line);
  border-radius: 6px; display: grid; place-items: center; font-size: 36px; font-weight: bold; user-select: none; }
.cell.void { background: none; border: none; }
.cell.secret { background: var(--secret); }
.cell.lit { background: #d8ecf7; }
.cell.secret.lit { background: #f3d68a; }
.cell[data-n]::before { content: attr(data-n); position: absolute; top: 2px; left: 4px; font-size: 13px; font-weight: normal; }
.cell.pending { color: #8a6a50; border-style: dashed; }
.cell.ok { box-shadow: inset 0 0 0 4px #5aa86b; }
.cell.bad { box-shadow: inset 0 0 0 4px #d0503c; }
.cell.done { background: #ffd35c; box-shadow: inset 0 0 0 4px #e0a020; animation: glow .6s ease-out; }
@keyframes glow { from { background: #fff7c0; transform: scale(1.08); } }
.lifted { opacity: 0.3; }
.tile.ghost { position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -60%) scale(1.1);
  display: grid; place-items: center; }

#side { display: flex; flex-direction: column; gap: 12px; padding: 14px 12px; min-width: 0; }
#round { font-size: 19px; }
#score { font-size: 20px; font-weight: bold; white-space: pre-line; line-height: 1.35; }
#side .santa { flex-direction: column; }
#side .santa p { width: 100%; font-size: 18px; }
#over { margin: 0; font-size: 22px; color: var(--go); }
#over:empty { display: none; }
#turn { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
#turn li { font-size: 16px; padding: 4px 10px; border-radius: 8px; background: #f1e1c8; }
#turn li:last-child { font-weight: bold; background: var(--warm); }
#hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: auto; }
.tile { width: var(--cell); height: var(--cell); font-size: 36px; font-weight: bold; border: none; border-radius: 10px;
  background: var(--warm); color: var(--ink); box-shadow: 0 3px 0 var(--line); }
.tile.selected { outline: 4px solid #d0503c; }
.tile:disabled { opacity: 0.3; }
#submit, .next { font-size: 22px; padding: 14px 20px; border-radius: 12px; border: none; background: var(--go); color: #fff;
  font-weight: bold; box-shadow: 0 3px 0 #356b42; }
#submit:disabled { background: #c9bba9; box-shadow: none; }

#clues { grid-column: 1 / -1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px 18px 12px;
  display: grid; grid-template: auto 1fr / 1fr 1fr; grid-auto-flow: column; column-gap: 28px; }
#clues h2 { font-size: 18px; margin: 6px 0 4px; color: #8c3f2e; }
#clues ul { margin: 0; padding: 0; list-style: none; }
#clues li { font-size: 18px; padding: 5px 6px; border-radius: 6px; }
#clues li.secret { font-weight: bold; }
#clues li.lit { background: #d8ecf7; }

/* Round 2: nonogram */
:root { --ncell: 48px; --nline: #8a6a50; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 18px; min-width: 560px; }
#tools { display: flex; gap: 12px; }
#tools button { font-size: 22px; padding: 12px 28px; border-radius: 12px; border: none; background: var(--bg); color: var(--ink);
  box-shadow: 0 3px 0 var(--line); }
#tools button.on { background: var(--go); color: #fff; box-shadow: 0 3px 0 #356b42; }
#status { font-size: 22px; font-weight: bold; color: var(--go); }
#nonogram { display: grid; padding: 8px 20px 20px 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
#nonogram .clue { font-size: 18px; font-weight: bold; }
#nonogram .clue.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 6px; line-height: 1.2; }
#nonogram .clue.row { display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; white-space: nowrap; }
.ncell { width: var(--ncell); height: var(--ncell); background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.ncell.edge-right { border-right: 3px solid var(--nline); }
.ncell.edge-bottom { border-bottom: 3px solid var(--nline); }
.ncell[data-v="fill"] { background: var(--ink); }
.ncell[data-v="cross"]::after { content: '✕'; color: #b08a6a; font-size: 26px; }
/* the reveal: filled cells take their colours from picture.js; the grid lines and crosses go,
   so the empty cells inside the ball read as a paper-coloured digit */
#nonogram.solved .ncell { border-color: transparent; background: var(--bg); transition: background .5s; }
#nonogram.solved .ncell[data-v="cross"]::after { content: none; }
#nonogram.solved .clue { opacity: .25; transition: opacity .5s; }

/* Screens: below the threshold only Santa's message to use a bigger device */
[hidden] { display: none !important; }
#gate { display: none; height: 100dvh; align-items: center; justify-content: center; padding: 16px; }
#gate .santa { max-width: 420px; }
@media (max-width: 700px), (max-height: 500px) {
  body > main, #sound { display: none !important; }
  #gate { display: flex; }
}
#intro, #final { height: auto; max-width: 720px; margin: 60px auto 0; padding: 28px 32px 32px; text-align: center; }
#intro-text p { font-size: 21px; line-height: 1.4; margin: 8px 0; }
#final .santa { text-align: left; }
#secrets { list-style: none; margin: 0; padding: 0; display: flex; gap: 24px; }
#secrets li { font-size: 40px; font-weight: bold; padding: 8px 20px; border-radius: 10px; background: var(--secret); }
#ball { display: grid; width: 360px; aspect-ratio: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* the sound switch in the bottom right corner, on the snow below every screen's cards */
#sound { position: fixed; bottom: 12px; right: 12px; z-index: 5; width: 56px; height: 56px; border-radius: 50%; border: none;
  font-size: 28px; background: var(--bg); box-shadow: 0 3px 0 rgba(43, 45, 92, .25); }
#sound.off { opacity: .7; }
