@font-face { font-family: 'Mountains of Christmas'; font-weight: 700; font-display: swap; src: url(fonts/xmas.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 600 900; font-display: swap; src: url(fonts/nunito.woff2) format('woff2'); }
:root {
  color-scheme: light;
  --cream: #fff6e8;
  --cream-deep: #f6e3c6;
  --ink: #4a2512;
  --ink-soft: #7a4a2c;
  --berry: #c2364a;
  --pine: #3d7a4f;
  --gold: #e3a640;
  --xmas-red: #b81d3a;
  --xmas-green: #1f6b3e;
  --glass: rgba(74, 37, 18, .78);
  --shadow: 0 3px 0 #d9b98f, 0 8px 18px rgba(74, 37, 18, .28);
  background: #7a3f1c;
  color: var(--ink);
  font: 700 16px/1.4 'Nunito', system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: #7a3f1c; }
[hidden] { display: none !important; }
main { position: relative; width: 100%; height: 100dvh; overflow: hidden; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--ink); }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 10; padding: .6em 1em; border-radius: 999px; background: var(--cream); color: var(--ink); font-weight: 800; }
.skip-link:focus { top: max(12px, env(safe-area-inset-top)); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Pills and buttons share the sculpted cream treatment of the approved concept. */
.primary, .result-actions button, .menu button {
  border: 0; border-radius: 999px; background: var(--cream); color: var(--ink); box-shadow: var(--shadow);
  min-height: 44px; padding: .55em 1.2em; font-weight: 800;
}
.primary, .result-actions .primary { background: linear-gradient(#c02a52, #9c1f3f); color: #fff; box-shadow: 0 3px 0 #6e1229, 0 9px 20px rgba(120, 20, 40, .35); font-size: 1.1rem; min-width: 11rem; min-height: 52px; }
.primary:active, .result-actions button:active { transform: translateY(2px); }
.primary:disabled { opacity: .65; cursor: wait; }

/* Intro: the Christmas logo and gentle snowfall. */
.intro { overflow-y: auto; display: grid; place-items: safe center; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: url(assets/patisserie-portrait.webp) center / cover; }
@media (min-aspect-ratio: 1/1) { .intro { background-image: url(assets/patisserie-wide.webp); } }
.intro-card { position: relative; z-index: 1; width: min(30rem, 100%); text-align: center; display: grid; justify-items: center; gap: 10px; }
.game-title { margin: 0; width: min(27rem, 90vw); filter: drop-shadow(0 10px 14px rgba(60, 20, 5, .4)); }
.game-title img { display: block; width: 100%; height: auto; }
.collection { margin: 0; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; color: var(--cream); text-shadow: 0 1px 3px rgba(60, 20, 5, .7); }
.tagline { margin: 0 0 10px; font-family: 'Mountains of Christmas', Georgia, serif; font-size: 1.7rem; line-height: 1.15; color: #fff; text-shadow: 0 2px 6px rgba(60, 20, 5, .75); }
.intro-treats { display: flex; justify-content: center; align-items: center; margin: -4px 0 8px; }
.intro-treats img { width: clamp(84px, 24vw, 132px); height: auto; filter: drop-shadow(0 8px 8px rgba(60, 20, 5, .45)); }
.intro-treats img:nth-child(1) { transform: rotate(-12deg) translateX(14px); }
.intro-treats img:nth-child(2) { width: clamp(110px, 32vw, 170px); position: relative; z-index: 1; }
.intro-treats img:nth-child(3) { transform: rotate(10deg) translateX(-14px); }
.intro-best, .intro-challenge { margin: 4px 0 0; padding: .5em 1em; background: var(--cream); border-radius: 14px; box-shadow: var(--shadow); }
.intro-measurement, .intro-policies { margin: 6px 0 0; font-size: .82rem; color: var(--cream); text-shadow: 0 1px 3px rgba(60, 20, 5, .8); }
.intro-measurement { max-width: 24rem; padding: 10px 12px; border-radius: 14px; background: var(--glass); text-shadow: none; }
.intro-measurement p { margin: 0 0 6px; }
.intro-measurement button, .menu [data-measurement] button { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 999px; min-height: 36px; padding: .3em .9em; font-size: .8rem; box-shadow: none; }
.intro-policies a { color: #fff; }
.snow { position: absolute; inset: 0; pointer-events: none; background-image:
  radial-gradient(3px 3px at 20px 30px, #fff 50%, transparent 52%), radial-gradient(2px 2px at 80px 120px, #fff 50%, transparent 52%),
  radial-gradient(4px 4px at 150px 60px, rgba(255,255,255,.9) 50%, transparent 52%), radial-gradient(2.5px 2.5px at 220px 170px, #fff 50%, transparent 52%),
  radial-gradient(3px 3px at 290px 90px, rgba(255,255,255,.85) 50%, transparent 52%), radial-gradient(2px 2px at 340px 200px, #fff 50%, transparent 52%);
  background-size: 360px 240px; animation: snow 14s linear infinite; opacity: .75; }
@keyframes snow { to { background-position: 40px 240px; } }

/* Story and certificate: written on the festive Christmas card. The paper is a border image, so the bow and
   corners keep their shape and only the plain middle stretches. */
.story, .result { overflow-y: auto; position: absolute; inset: 0; z-index: 6; display: grid; place-items: safe center; padding: 16px; background: rgba(40, 14, 4, .5); }
.story-card, .result-card { width: min(32rem, 100%); filter: drop-shadow(0 18px 30px rgba(30, 10, 2, .55)); text-align: center; animation: rise .5s cubic-bezier(.2, .9, .3, 1.2);
  border-style: solid; border-color: transparent; border-width: clamp(118px, 31vw, 160px) clamp(34px, 9vw, 48px) clamp(84px, 22vw, 116px);
  border-image: url(assets/paper.webp) 280 84 210 84 fill / 1 stretch; padding: 0 4px 6px; display: flex; flex-direction: column; justify-content: center; }
.story-card h2, .result-card h2 { font-family: 'Mountains of Christmas', Georgia, serif; font-size: clamp(1.8rem, 7.4vw, 2.4rem); line-height: 1.05; color: var(--xmas-red); margin: 2px 0 12px; }
.story-card p { font-size: clamp(1.1rem, 4.3vw, 1.25rem); line-height: 1.45; color: var(--ink); margin: 0 0 12px; }
.story-card .story-twist strong { font-family: 'Mountains of Christmas', Georgia, serif; font-size: 1.5em; color: var(--xmas-green); }
.story-card .how { list-style: none; margin: 6px 0 18px; padding: 12px 14px; border: 2px dashed #d7a64a; border-radius: 16px; background: rgba(255, 250, 240, .7); text-align: left; display: grid; gap: 6px; font-size: clamp(1.02rem, 4vw, 1.15rem); color: var(--ink); }
.story-card .how b { color: var(--xmas-red); }
.story-card .primary, .result-card .primary { align-self: center; }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }
@keyframes pop { from { transform: scale(.7); opacity: .3; } }

/* Playfield */
#playfield canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
#playfield canvas[data-grab=aim] { cursor: none; }
#cutting { position: absolute; inset: 0; pointer-events: none; }
#cutting:focus-visible { outline: 4px solid #fff; outline-offset: -8px; }

/* Composition. The plate slot is empty: the game seats the treat's plate and the guests' settings in it.
   Tall screens: the party's scores across the top, the treat's card, the objective, then the table.
   Wide screens: the treat's card at the left, the objective above the table in the middle, the scores at the right. */
.layout { position: absolute; inset: 0; display: grid; pointer-events: none;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  grid-template-columns: 100%; grid-template-rows: auto auto auto minmax(220px, 1fr); grid-template-areas: "party" "dish" "goal" "slot"; row-gap: 6px; }
.party-bar { grid-area: party; }
.dish { grid-area: dish; display: grid; justify-items: center; }
.goal { grid-area: goal; display: grid; justify-items: center; }
.plate-slot { grid-area: slot; min-height: 0; }
.menu-button { position: absolute; z-index: 8; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); }
.icon-button { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 50%; background: var(--glass); color: var(--cream); box-shadow: 0 2px 6px rgba(40, 14, 4, .3); }
.icon-button svg { width: 22px; height: 22px; }
.icon-button[aria-expanded=true] { background: var(--cream); color: var(--ink); }

/* The party's scores: treats shared, the personal best and the world best, always in view. */
.party-bar { display: flex; align-items: stretch; justify-content: flex-end; gap: 6px; padding-left: 54px; }
.party-bar p { margin: 0; }
.stat { display: grid; justify-items: center; align-content: center; min-width: 4.6rem; padding: .25em .7em .3em; border-radius: 16px; background: var(--glass); color: var(--cream); line-height: 1.1; text-align: center; }
.stat span { font-size: .72rem; font-weight: 800; letter-spacing: .02em; opacity: .9; }
.stat b { font-size: 1.3rem; font-weight: 900; color: #ffe2a6; font-variant-numeric: tabular-nums; }
.stat-main { flex-direction: row; background: linear-gradient(#b8263f, #8e1a31); box-shadow: 0 2px 0 #5e0f20, 0 6px 14px rgba(90, 14, 30, .35); }
.stat-main b { font-size: 1.7rem; color: #fff; }
.stat-main span { font-size: .78rem; }
#shared.bump { animation: pop .45s cubic-bezier(.2, .9, .3, 1.6); }
.stat.beaten { background: linear-gradient(#e3a640, #b57a1c); }
.stat.beaten b { color: #fff; }
.entry { display: none; }

/* This treat: a porcelain-and-gold place card with its country, name and story. */
.place-card { position: relative; display: grid; justify-items: center; width: min(36rem, 100%); padding: 8px 18px 10px; border-radius: 20px; text-align: center;
  background: linear-gradient(#fffaf0, #f8ead2); box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px #e0b25a, 0 3px 0 #c99a5b, 0 10px 24px rgba(60, 20, 5, .32); animation: pop .5s cubic-bezier(.2, .9, .3, 1.3) both; }
.origin { display: flex; align-items: center; gap: 8px; margin: 0; font-family: 'Mountains of Christmas', Georgia, serif; font-size: clamp(1.15rem, 4.8vw, 1.4rem); line-height: 1.1; color: var(--xmas-green); font-weight: 700; }
.origin img { width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0, 0, 0, .3); object-fit: cover; }
.dessert-name { margin: 0; font-size: clamp(1.45rem, 6.4vw, 2rem); line-height: 1.05; font-weight: 900; color: var(--ink); }
.story-hook { margin: 3px 0 0; font-family: 'Mountains of Christmas', Georgia, serif; font-size: clamp(1.1rem, 4.6vw, 1.35rem); line-height: 1.1; font-weight: 700; color: var(--xmas-red); }
.story-text { margin: 3px 0 0; font-size: clamp(.86rem, 3.5vw, .98rem); line-height: 1.35; color: var(--ink); font-weight: 650; }

/* The objective: unmistakable, on a ribbon-red banner. */
.objective { margin: 0; text-align: center; animation: pop .45s cubic-bezier(.2, .9, .3, 1.4) both; }
.objective { padding: .3em 1.4em .4em; border-radius: 18px; background: linear-gradient(#c02a52, #9c1f3f); color: #fff; box-shadow: 0 3px 0 #6e1229, 0 8px 18px rgba(120, 20, 40, .35); }
.objective p { margin: 0; }
.objective-main { font-size: clamp(1.25rem, 5.4vw, 1.7rem); font-weight: 900; line-height: 1.15; }
.objective-main b { color: #ffe2a6; }
.objective.bump { animation: pop .3s cubic-bezier(.2, .9, .3, 1.5); }

/* Once the guests are served, the result ribbon and the next-treat button sit on the emptied plate. Neither changes
   the layout, so the plate never moves during the reveal. */
.ribbon { position: absolute; z-index: 3; left: var(--plate-cx, 50%); top: var(--plate-cy, 40%); transform: translate(-50%, -150%); margin: 0; pointer-events: none; max-width: 96vw; }
.ribbon span { position: relative; display: block; padding: .14em 1em .2em; border-radius: 999px; background: linear-gradient(#fff8ea, #f6e3c6); box-shadow: 0 3px 0 #d9b98f, 0 0 30px rgba(255, 214, 120, .9);
  font: 900 clamp(1.3rem, 5.6vw, 2.4rem)/1.1 'Nunito', system-ui, sans-serif; color: var(--pine); white-space: nowrap; animation: pop .5s cubic-bezier(.2, .9, .3, 1.6); }
.ribbon span::before, .ribbon span::after { content: ""; position: absolute; z-index: -1; top: 30%; width: 40px; height: 52%; background: var(--pine); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.ribbon span::before { left: -30px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 28% 50%); }
.ribbon span::after { right: -30px; clip-path: polygon(0 0, 100% 0, 72% 50%, 100% 100%, 0 100%); }
#playfield:has(.dish.failed) .ribbon span { color: var(--berry); box-shadow: 0 3px 0 #d9b98f; }
#playfield:has(.dish.failed) .ribbon span::before, #playfield:has(.dish.failed) .ribbon span::after { background: #8a5a3a; }
.party-over .ribbon { display: none !important; }

/* Guidance. */
.hint { position: absolute; z-index: 3; left: var(--hint-x, 50%); top: var(--hint-y, auto); transform: translateX(-50%); margin: 0; padding: .55em 1.2em; border-radius: 999px; background: rgba(74, 37, 18, .9); color: var(--cream); font-size: clamp(.95rem, 3.9vw, 1.05rem); font-weight: 800; text-align: center; width: max-content; max-width: calc(100% - 24px); pointer-events: none; animation: rise .3s ease-out; }

/* Wide screens: the card, the table and the scores side by side. */
@media (min-aspect-ratio: 23/20) {
  .layout { grid-template-columns: minmax(230px, 23vw) minmax(0, 1fr) minmax(160px, 15vw); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "dish goal party" "dish slot party";
    column-gap: clamp(10px, 1.6vw, 28px); row-gap: 10px; padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .dish { align-self: center; }
  .place-card { padding: 18px 18px 20px; }
  .dessert-name { font-size: clamp(1.6rem, 2.3vw, 2.2rem); margin-top: 2px; }
  .story-hook { font-size: clamp(1.25rem, 1.7vw, 1.6rem); margin-top: 8px; }
  .story-text { font-size: clamp(.95rem, 1.15vw, 1.1rem); margin-top: 6px; }
  .goal { padding-top: 4px; }
  .party-bar { align-self: center; flex-direction: column; align-items: stretch; gap: 10px; padding: 0; }
  .stat { padding: .45em .8em .55em; border-radius: 20px; }
  .stat span { font-size: .9rem; }
  .stat b { font-size: 2rem; }
  .stat-main { display: grid; padding: .5em .8em .7em; }
  .stat-main b { font-size: 3.4rem; line-height: 1; }
  .stat-main span { font-size: 1rem; }
  .hint { max-width: min(22vw, 22rem); white-space: normal; }
}
@media (min-aspect-ratio: 23/20) and (max-height: 620px) {
  .story-text { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
  .stat-main b { font-size: 2.4rem; }
  .stat b { font-size: 1.5rem; }
  .objective-main { font-size: 1.2rem; }
}

/* Story and results cards fit the screen. */
.story-card, .result-card { border-width: clamp(76px, min(31vw, 13vh), 150px) clamp(28px, min(9vw, 4.5vh), 46px) clamp(56px, min(22vw, 9vh), 108px); }

/* Menu: every utility in one place, opened from the corner. */
.menu { position: absolute; z-index: 7; top: calc(max(10px, env(safe-area-inset-top)) + 54px); left: max(12px, env(safe-area-inset-left)); width: min(290px, calc(100% - 24px)); max-height: calc(100dvh - 80px); overflow: auto;
  display: grid; justify-items: start; gap: 8px; padding: 14px 16px; border-radius: 18px; background: var(--cream); box-shadow: 0 10px 28px rgba(60, 20, 5, .45); font-size: .95rem; animation: rise .2s ease-out; }
.menu button { background: var(--cream-deep); box-shadow: none; min-height: 42px; padding: .4em 1.1em; }
.menu label { display: flex; align-items: center; gap: .55rem; min-height: 40px; }
.menu input { width: 22px; height: 22px; accent-color: var(--berry); }
.menu a { color: var(--ink); }
.menu .menu-link { font-weight: 900; font-size: 1.05rem; }
.menu [data-measurement] p { margin: 0 0 4px; font-weight: 600; }

/* Optional knife buttons (Menu → Show knife buttons) for players who cannot drag. */
.access { position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: max-content; max-width: calc(100% - 16px); }
.access button { min-width: 48px; min-height: 48px; border: 0; border-radius: 14px; background: var(--cream); color: var(--ink); box-shadow: var(--shadow); font-size: 1.2rem; font-weight: 900; }
.access .access-cut { background: linear-gradient(#c02a52, #9c1f3f); color: #fff; padding: 0 1.1em; font-size: 1.05rem; }
#playfield:has(#access:not([hidden])) .hint { display: none; }

@media (orientation: landscape) and (max-height: 560px) {
  .intro-card { width: min(46rem, 100%); grid-template-columns: 1fr 1fr; align-items: center; column-gap: 20px; row-gap: 6px; }
  .intro-card > .game-title, .intro-card > .collection, .intro-card > .tagline, .intro-card > .intro-treats { grid-column: 1; }
  .intro-card > :not(.game-title):not(.collection):not(.tagline):not(.intro-treats) { grid-column: 2; }
  .intro-card > .game-title { grid-row: 1; width: min(17rem, 36vw); justify-self: center; }
  .intro-card > .collection { grid-row: 2; }
  .intro-card > .tagline { grid-row: 3; font-size: 1.2rem; margin: 0; }
  .intro-card > .intro-treats { display: none; }
  #start { grid-row: 1; align-self: end; }
}

/* Results certificate. */
.result-card .collection { color: var(--ink-soft); text-shadow: none; }
.result-score { margin: 0; display: grid; }
.result-score strong { font-size: 4rem; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.result-score span { font-size: 1rem; color: var(--ink-soft); }
.party-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 8px; }
.party-stats div { padding: 8px 4px; border-radius: 14px; background: rgba(246, 227, 198, .85); }
.party-stats dt { font-size: .72rem; color: var(--ink-soft); }
.party-stats dd { margin: 0; font-size: 1.1rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.world-status { margin: 6px 0; font-weight: 850; color: var(--pine); font-size: 1.02rem; padding: .45em .8em; border-radius: 14px; background: rgba(61, 122, 79, .1); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0 6px; }
.result-actions .primary { flex-basis: 100%; }
.back-to-games { color: var(--ink); font-weight: 750; display: inline-block; padding: .6em .4em; }
#share-link { width: 100%; margin: 6px 0; padding: 8px; border-radius: 10px; border: 1px solid #d9b98f; font: inherit; font-size: .8rem; }
.steam-interest { margin: 8px 0 4px; display: grid; justify-items: center; gap: 4px; }
.steam-interest button { border: 1px solid #d9b98f; border-radius: 999px; background: transparent; color: var(--ink); min-height: 40px; padding: .4em 1em; font-weight: 750; }
.steam-interest button[aria-pressed=true] { background: var(--cream-deep); }
.steam-interest p { margin: 0; font-size: .72rem; color: var(--ink-soft); }

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

/* Results: the end of a Christmas party, fitted to a 900 px desktop screen and a phone. */
.result-card h2 { margin-bottom: 4px; }
.result-score strong { font-size: clamp(3rem, 10vh, 4.6rem); color: var(--xmas-red); }
.final-note { margin: 2px 0 0; font-weight: 900; color: var(--pine); font-size: 1.05rem; }
.final-note:empty { display: none; }
.party-stats { margin: 8px 0 6px; }
.party-stats dd { font-size: 1.35rem; }
.result-actions { margin: 8px 0 4px; }

.menu { z-index: 9; }

/* Corrections from independent play. On tall screens the first hints sit at the foot of the screen, over the empty
   place settings; the result ribbon fits a phone; the objective gives way to the results card; the
   scores fit a narrow phone. */
.hint.low { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
#playfield .ribbon span { font-size: clamp(1.05rem, 5vw, 2.4rem); }
.party-over .goal { visibility: hidden; }
.origin { flex-wrap: wrap; justify-content: center; text-wrap: balance; }
@media (max-width: 420px) {
  .party-bar { gap: 4px; padding-left: 52px; }
  .stat { min-width: 0; flex: 1 1 0; padding: .2em .35em .25em; }
  .stat span { font-size: .66rem; }
  .stat b { font-size: 1.15rem; }
  .stat-main b { font-size: 1.5rem; }
}
@media (min-aspect-ratio: 23/20) { .layout { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); } }
/* The ribbon stays within the plate, wrapping onto two lines if it must; the collection line on the intro reads clearly. */
#playfield .ribbon { max-width: min(96vw, calc(var(--plate-w, 90vw) + 40px)); }
#playfield .ribbon span { white-space: normal; text-wrap: balance; text-align: center; }
.intro .collection { padding: .2em .9em; border-radius: 999px; background: rgba(74, 37, 18, .72); color: #fff6e8; }
/* No callout, magnifier or selection when a finger rests on the table. */
#playfield canvas { -webkit-touch-callout: none; -webkit-user-select: none; -webkit-user-drag: none; }
