/* Round the Year: the look of the game. Warm cream paper, soft watercolour washes, crayon lines in a darker shade
 * of the same colour (never black), rounded hand lettering, no gloss and no hard shadows.
 * --b is the size of one picture button in px, set by ui.js from the screen size.
 */
@font-face { font-family: 'Hand'; src: url('../fonts/patrick-hand.ttf') format('truetype'); font-display: swap; }

:root { --b: 64px; --paper: #f3e9d4; --ink: #5a4030; --line: #b89a6a; --soft: #fbf6ea; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: var(--paper); }
body {
  font-family: 'Hand', 'Chalkboard SE', 'Comic Neue', sans-serif; color: var(--ink);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app {
  position: fixed; overflow: hidden; touch-action: none;
  top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px);
}
#app * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#grain {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60;
  mix-blend-mode: multiply; opacity: 0.22;
}
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  -webkit-appearance: none; appearance: none; cursor: pointer; outline: none;
}
svg { overflow: visible; }
h1 { font-weight: normal; margin: 0; color: #6a4a2e; font-size: clamp(26px, calc(var(--b) * 0.48), 46px); line-height: 1.1; text-align: center; }

/* ---------- picture buttons: picture first, word underneath ---------- */
.pb {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  width: var(--b); font-size: max(14px, calc(var(--b) * 0.23)); line-height: 1.05;
}
.pb > svg:first-child {
  display: block; box-sizing: border-box; width: calc(var(--b) * 0.86); height: calc(var(--b) * 0.86); padding: calc(var(--b) * 0.06);
  background: rgba(255, 250, 238, 0.82); border: 2.5px solid #cdb58c;
  border-radius: 50% 46% 52% 48% / 48% 52% 46% 54%;
}
.pb > span { display: block; margin-top: 3px; white-space: nowrap; text-align: center; }
.pb .ico.slash {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: calc(var(--b) * 0.86); height: calc(var(--b) * 0.86);
  pointer-events: none;
}
.pb.off > svg:first-child { opacity: 0.5; }
.pb.on > svg:first-child { background: #fff1c2; border: 3.5px solid #b8862e; transform: scale(1.08); }
.pb.main { width: calc(var(--b) * 1.3); font-size: max(17px, calc(var(--b) * 0.27)); }
.pb.main > svg:first-child { width: calc(var(--b) * 1.12); height: calc(var(--b) * 1.12); background: #eef4dc; border-color: #8fae6a; }
.pb.main.alt > svg:first-child { background: rgba(255, 250, 238, 0.82); border-color: #cdb58c; }
.pb.wide { width: auto; min-width: calc(var(--b) * 1.3); padding: 0 6px; }
.pb.small { width: max(46px, calc(var(--b) * 0.8)); font-size: max(13px, calc(var(--b) * 0.19)); }
.pb.small > svg:first-child { width: calc(var(--b) * 0.64); height: calc(var(--b) * 0.64); }
.pb.glow > svg:first-child { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { background: #fff4c8; border-color: #d8a83a; transform: scale(1); }
  50% { background: #f8dc78; border-color: #b8862e; transform: scale(1.12); }
}

/* ---------- movement ---------- */
.wob { animation: wob 0.7s ease-in-out; }
@keyframes wob { 0% { transform: rotate(0); } 20% { transform: rotate(-9deg); } 45% { transform: rotate(7deg); } 70% { transform: rotate(-4deg); } 100% { transform: rotate(0); } }
.bounce { animation: bounce 0.9s ease-in-out infinite; }
.bounce.wob { animation: wob 0.7s ease-in-out, bounce 0.9s ease-in-out 0.7s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.pop { animation: pop 0.45s ease-out; }
@keyframes pop { 0% { transform: scale(0.5); opacity: 0.2; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.took { animation: took 0.45s ease-in forwards; pointer-events: none; }
@keyframes took { to { opacity: 0; transform: translateY(-40px) scale(0.7); } }
.hid { opacity: 0; pointer-events: none; }
.lift { opacity: 0.3; }
.ghost { position: absolute; left: 0; top: 0; z-index: 30; pointer-events: none; transform: scale(1.12); }
.ghost svg { display: block; width: 100%; height: 100%; }
.hitz { fill: transparent; stroke: none; pointer-events: all; }

/* ---------- Mossycap's words ---------- */
#say {
  position: fixed; left: 50%; z-index: 45; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + var(--b) * 1.3 + 18px);
  display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: max-content; max-width: min(88vw, 700px);
  padding: 6px 20px 6px 8px; background: #fffaf0; border: 3px solid var(--line);
  border-radius: 30px 36px 32px 28px / 28px 32px 36px 30px;
  font-size: clamp(20px, calc(1.6vw + 12px), 32px); line-height: 1.2; color: #4e3a26;
  pointer-events: none; opacity: 0; transition: opacity 0.35s;
}
#say.on { opacity: 1; }
#say.pop { animation: saypop 0.4s ease-out; }
@keyframes saypop { 0% { transform: translateX(-50%) scale(0.85); } 60% { transform: translateX(-50%) scale(1.04); } 100% { transform: translateX(-50%) scale(1); } }
#say .sayface { flex: none; width: 42px; height: 59px; }
html[data-screen="who"] #say { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }

/* ---------- top bars ---------- */
.topbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 20; box-sizing: border-box; height: calc(var(--b) * 1.3 + 12px);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; padding: 6px 8px 0;
}
.leaves, .acts { display: flex; gap: max(3px, calc(var(--b) * 0.07)); }
.pb.leafb > svg:first-child { background: rgba(255, 250, 238, 0.6); }
.topbar .sp { flex: 1; }
.galbar h1 { flex: 1; align-self: center; margin-top: -8px; }

/* ---------- who's playing ---------- */
.who {
  position: absolute; inset: 0; box-sizing: border-box; padding: 14px 14px 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 2vh, 18px);
}
.whobig { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.whobig .gnome { display: block; height: min(32vh, 250px); width: auto; }
.whobig .nm { font-size: clamp(30px, calc(var(--b) * 0.55), 52px); margin-top: 4px; }
.row { display: flex; align-items: flex-start; justify-content: center; flex-wrap: wrap; gap: 14px 26px; }
.kids { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.kidb {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; box-sizing: border-box;
  width: calc(var(--b) * 1.9); min-height: calc(var(--b) * 2.7); padding: 10px 6px 8px;
  background: rgba(255, 250, 240, 0.75); border: 3px solid #d2bc94; border-radius: 26px 32px 24px 30px / 30px 24px 32px 26px;
  font-size: clamp(18px, calc(var(--b) * 0.3), 28px); line-height: 1.1;
}
.kidb .gnome { display: block; height: calc(var(--b) * 1.9); width: auto; }
.kidb .ico { display: block; width: calc(var(--b) * 1.3); height: calc(var(--b) * 1.3); margin-bottom: calc(var(--b) * 0.3); }
.kidb span { text-align: center; }
.kidb.full { opacity: 0.5; }
.caps { display: grid; grid-template-columns: repeat(3, auto); gap: 12px 26px; }
.capb { display: flex; flex-direction: column; align-items: center; font-size: clamp(18px, calc(var(--b) * 0.3), 28px); }
.capb .cap { display: block; width: calc(var(--b) * 1.45); height: calc(var(--b) * 1.45); }
.capb.taken { opacity: 0.35; }
.namerow { display: flex; align-items: center; gap: 12px; }
.namerow .cap { display: block; width: var(--b); height: var(--b); flex: none; }
.namebox {
  min-width: 6em; min-height: 1.25em; padding: 0 0.3em; text-align: center;
  font-size: clamp(30px, calc(var(--b) * 0.6), 56px); line-height: 1.25; border-bottom: 3px solid var(--line);
}
.nametext { white-space: pre; }
.keys { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; width: min(calc(100% - 48px), calc(var(--b) * 8.4)); }
.key {
  aspect-ratio: 1 / 1; min-width: 0; font-size: clamp(22px, calc(var(--b) * 0.42), 38px); line-height: 1;
  background: var(--soft); border: 2.5px solid #c9b48e; border-radius: 42% 46% 40% 44%;
}
.corner { position: absolute; right: 8px; bottom: 6px; }
@media (orientation: landscape) {
  .caps { grid-template-columns: repeat(6, auto); }
  .keys { grid-template-columns: repeat(13, 1fr); width: min(calc(100% - 48px), calc(var(--b) * 12)); }
}
@media (orientation: portrait) and (max-width: 560px) {
  .keys { grid-template-columns: repeat(7, 1fr); gap: 5px; width: calc(100% - 16px); }
}
@media (max-height: 520px) {
  .who { gap: 6px; padding-bottom: 8px; }
  .who h1 { font-size: 24px; }
  .whobig .gnome { height: 26vh; }
  .key { font-size: 22px; }
  .namebox { font-size: 30px; }
  .kidb { min-height: 0; width: calc(var(--b) * 1.6); }
  .kidb .gnome { height: calc(var(--b) * 1.3); }
  .kidb .ico { width: var(--b); height: var(--b); margin-bottom: 4px; }
}

/* ---------- help ---------- */
.help {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(243, 233, 212, 0.9);
}
.helpcard {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 18px 28px; box-sizing: border-box;
  max-width: 94%; max-height: 94%; padding: 18px 22px; background: var(--soft); border: 3px solid #c9b48e;
  border-radius: 34px 40px 30px 38px / 38px 30px 40px 34px;
}
.helpcard .mossy.big { display: block; height: min(36vh, 260px); width: auto; }
.helpbtns { display: grid; grid-template-columns: repeat(3, auto); gap: 14px 22px; align-items: start; justify-items: center; }

/* ---------- the seasons table ---------- */
.scene { position: absolute; left: 0; top: 0; display: block; }
.weather { position: absolute; overflow: hidden; pointer-events: none; }
.wbit { position: absolute; top: -10%; animation: fall 18s linear infinite; }
.wbit .wb { display: block; width: 22px; height: 22px; animation: sway 3.2s ease-in-out infinite alternate; }
.wbit.w1 { animation-duration: 23s; }
.wbit.w1 .wb { width: 17px; height: 17px; animation-duration: 4s; }
.wbit.w2 { animation-duration: 15s; }
.wbit.w2 .wb { width: 20px; height: 20px; animation-duration: 2.6s; }
@keyframes fall { from { top: -10%; } to { top: 104%; } }
@keyframes sway { from { transform: translateX(-10px) rotate(-20deg); } to { transform: translateX(12px) rotate(25deg); } }
.hit { position: absolute; }
canvas.hung { position: absolute; display: block; box-sizing: border-box; border: 4px solid #a87a50; border-radius: 3px; background: var(--soft); }
.things { position: absolute; inset: 0; pointer-events: none; }
.it { position: absolute; pointer-events: auto; transform-origin: 50% 90%; }
.it svg { display: block; width: 100%; height: 100%; }
.tray {
  position: absolute; z-index: 10; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 12px 4px; border-top: 3px solid #b8946a; border-radius: 46px 52px 0 0 / 20px 24px 0 0;
  background-color: #e6d1a6;
  background-image: repeating-linear-gradient(90deg, rgba(168, 128, 72, 0.12) 0 3px, transparent 3px 14px),
    repeating-linear-gradient(0deg, rgba(168, 128, 72, 0.1) 0 2px, transparent 2px 12px);
}
.tis { position: relative; display: flex; align-items: center; gap: 10px; }
.ti { position: relative; flex: none; transform-origin: 50% 90%; }
.ti svg { display: block; width: 100%; height: 100%; }
.ti .n {
  position: absolute; right: -4px; bottom: -2px; min-width: 1.3em; padding: 0 0.25em; box-sizing: border-box; text-align: center;
  font-size: max(16px, calc(var(--b) * 0.25)); line-height: 1.2; background: #fbf4e2; border: 2px solid #b8946a; border-radius: 1em;
}
.tray .empty { position: relative; display: flex; align-items: center; gap: 12px; font-size: max(20px, calc(var(--b) * 0.32)); }
.tray .empty .ico { display: block; width: calc(var(--b) * 1.05); height: calc(var(--b) * 1.05); }
.tray .pg { position: relative; flex: none; width: max(44px, calc(var(--b) * 0.7)); height: max(44px, calc(var(--b) * 0.7)); }
.tray .pg .ico { display: block; width: 100%; height: 100%; background: rgba(255, 250, 238, 0.8); border: 2.5px solid #b8946a; border-radius: 50%; box-sizing: border-box; }

/* ---------- the nature walk ---------- */
.world { position: absolute; left: 0; top: 0; will-change: transform; }
svg.wood { position: absolute; left: 0; top: 0; display: block; }
g.hd, g.wt, g.wg, g.shake { transform-box: fill-box; transform-origin: 50% 100%; }
g.shake.go { animation: rustle 0.55s ease-in-out; }
@keyframes rustle { 0% { transform: rotate(0); } 20% { transform: rotate(-4deg) translateX(-4px); } 45% { transform: rotate(4deg) translateX(4px); } 70% { transform: rotate(-2deg); } 100% { transform: rotate(0); } }
g.hd.open .shake { opacity: 0.88; }
.walkbar .slots {
  flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; align-items: center; gap: 4px; box-sizing: border-box; padding: 4px 8px;
  background: rgba(251, 246, 234, 0.92); border: 2.5px solid #c9b48e; border-radius: 22px 26px 20px 24px / 24px 20px 26px 22px;
}
.walkbar .slotb { display: block; flex: none; width: auto; height: calc(var(--b) * 0.7); max-height: 100%; }
.slot {
  flex: 0 1 calc(var(--b) * 0.82); min-width: 20px; aspect-ratio: 1 / 1; max-height: calc(var(--b) * 0.82); box-sizing: border-box;
  background: rgba(255, 250, 240, 0.55); border: 2.5px dashed #c2a678; border-radius: 50%;
}
.slot.has { background: rgba(255, 250, 240, 0.85); border-style: solid; }
.slot svg { display: block; width: 100%; height: 100%; }
.slot.gslot { border-color: #8fae6a; }

/* ---------- wet painting ---------- */
.pwrap { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 4px 8px 8px; }
.pwrap.land { flex-direction: row; gap: 16px; }
.pwrap:not(.land) { justify-content: flex-start; padding-top: 2vh; }
.tools, .pacts { display: flex; flex-direction: row; justify-content: center; align-items: flex-start; gap: 8px; }
.pwrap.land .tools, .pwrap.land .pacts { flex-direction: column; align-items: center; flex-wrap: wrap; max-height: 100%; }
.pb.tool > svg:first-child { background: rgba(255, 250, 238, 0.7); }
.board {
  position: relative; flex: none; box-sizing: content-box; background: #fbf8f0; border: 3px solid #c8b08a; border-radius: 6px;
}
canvas.paper { display: block; width: 100%; height: 100%; touch-action: none; border-radius: 4px; }
canvas.paper-grain {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; border-radius: 4px; mix-blend-mode: multiply;
}

/* ---------- my paintings ---------- */
.gal {
  position: absolute; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 6px 16px 28px;
}
.gal, .gal * { touch-action: pan-y; }
.frames { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.frame { position: relative; display: block; padding: 6px; background: var(--soft); border: 4px solid #a87a50; border-radius: 4px; }
canvas.kept { display: block; }
.bigp canvas.big { border: 6px solid #a87a50; border-radius: 4px; background: var(--soft); }
.tag {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 2px; padding: 0 0.6em 0 0.2em;
  font-size: 17px; line-height: 1.3; background: rgba(251, 246, 234, 0.92); border: 2px solid #c9b48e; border-radius: 1em;
}
.tagi { display: block; width: 22px; height: 22px; }
p.ask { width: 100%; margin: 0; text-align: center; font-size: clamp(24px, calc(var(--b) * 0.42), 40px); }
.nopaint { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 8vh; font-size: clamp(24px, calc(var(--b) * 0.4), 38px); }
.nopaint .ico { display: block; width: calc(var(--b) * 2); height: calc(var(--b) * 2); }

/* ---------- lanterns on the table, and the winter door ---------- */
.things .dim { position: absolute; inset: 0; background: rgba(58, 53, 96, 0.25); pointer-events: none; }
.things svg.glows { position: absolute; display: block; pointer-events: none; }
.it.ln { z-index: 1; }
.it.ln.lit { z-index: 2; }
.ti.lt svg { display: block; width: 100%; height: 100%; }
.spdoor {
  position: absolute; z-index: 3; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 10% 6% 6%; background: #39405e; border: 4px solid #262b44; border-bottom-width: 2px;
  border-radius: 50% 50% 6px 6px / 34% 34% 6px 6px; color: #f6ecd2; font-size: max(17px, calc(var(--b) * 0.27)); line-height: 1.05;
}
.spdoor .spi { display: block; flex: none; }
.spdoor .lb { text-align: center; }
.spdoor .need { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; }
.spdoor .nd { position: relative; display: block; width: max(30px, calc(var(--b) * 0.5)); height: max(30px, calc(var(--b) * 0.5));
  background: rgba(251, 246, 234, 0.9); border-radius: 50%; }
.spdoor .nd svg { display: block; width: 100%; height: 100%; }
.spdoor .nd .n {
  position: absolute; right: -8px; bottom: -6px; min-width: 1.3em; padding: 0 0.2em; box-sizing: border-box; text-align: center;
  font-size: max(15px, calc(var(--b) * 0.22)); line-height: 1.2; color: var(--ink); background: #fbf4e2; border: 2px solid #b8946a; border-radius: 1em;
}

/* ---------- the craft table ---------- */
.craft { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 12px 40px; }
.craft .row { gap: 18px 40px; }
.craftb {
  display: flex; flex-direction: column; align-items: center; gap: 6px; box-sizing: border-box; padding: 14px 18px 10px;
  background: rgba(255, 250, 240, 0.8); border: 3px solid #d2bc94; border-radius: 30px 36px 28px 34px / 34px 28px 36px 30px;
  font-size: clamp(24px, calc(var(--b) * 0.42), 40px); line-height: 1.05;
}
.craftb .cbig { display: block; height: min(calc(var(--b) * 2.6), 34vh); width: auto; }
.craftb .ico.cbig { aspect-ratio: 1 / 1; }
.craftb svg.lantern.cbig { aspect-ratio: 100 / 140; }

/* ---------- making a lantern ---------- */
.lwork { position: absolute; box-sizing: border-box; }
.lbox { position: absolute; box-sizing: content-box; border: 4px solid #a87a50; border-radius: 4px; background: var(--soft); margin: -4px; }
.lbox canvas.kept { position: absolute; }
.lbox svg.folds { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.lbig { position: absolute; cursor: pointer; }
.lbig svg.lantern { position: absolute; display: block; }
.lside { position: absolute; box-sizing: border-box; display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 12px 18px; padding: 4px 8px; }
.lside.col { flex-direction: column; align-items: center; justify-content: center; }
svg.tool { position: absolute; display: block; touch-action: none; cursor: grab; }
.bigl { display: flex; justify-content: center; }
.frame.lf { padding: 10px 14px; }
.frame.lf svg.lantern { display: block; width: calc(var(--b) * 1.6); height: calc(var(--b) * 2.24); }

/* the place to touch next glows softly */
.glowme { animation: glowme 1.6s ease-in-out infinite; }
@keyframes glowme {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 214, 110, 0.5)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 214, 110, 0.95)); }
}
.glowline { animation: glowline 1.4s ease-in-out infinite; }
@keyframes glowline { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.9; } }

/* ---------- the Advent spiral ---------- */
html[data-screen="spiral"] body, html[data-screen="spiral"] { background: #1e2433; }
svg.sproom { position: absolute; left: 0; top: 0; display: block; }
.spbar .pb > span { color: #f5ede0; }
svg.sproom g.walker, svg.sproom g.st, svg.sproom g.big { cursor: pointer; }
svg.sproom g.straw { pointer-events: none; }
svg.sproom g.st.glowme, svg.sproom g.big.glowme { animation-duration: 1.8s; }

@media (prefers-reduced-motion: reduce) {
  .wbit, .wbit .wb { animation-duration: 60s; }
  .bounce { animation-duration: 1.6s; }
  .glowme, .glowline { animation-duration: 3.2s; }
}
