* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at top, #493022, #141313 75%);
  color: #f9ebd3;
  font-family: system-ui, sans-serif;
}
main {
  width: min(100%, 480px);
  margin: auto;
  padding: 20px 0 28px;
}
header {
  text-align: center;
}
header small {
  color: #d5a760;
  font-size: 10px;
  letter-spacing: 2px;
}
h1 {
  font: italic bold 38px Georgia;
  margin: 8px 0;
  color: #ffe6ae;
}
header p {
  font-size: 12px;
  color: #c8b9a4;
  margin: 8px 0 18px;
}
.hud {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 12px 16px;
  background: #241911;
  border: 1px solid #805a31;
  border-radius: 10px;
}
.hud b {
  color: #ffc96a;
  font-size: 20px;
  margin-left: 8px;
}
#board {
  width: 100%;
  aspect-ratio: 440/620;
  outline: none;
}
#board:focus-visible {
  outline: none;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.instructions {
  text-align: center;
  margin-top: -10px;
}
#feedback {
  font-size: 15px;
  min-height: 22px;
  margin: 0 0 10px;
}
.instructions small {
  color: #b8aa94;
  font-size: 11px;
}
.meter {
  height: 5px;
  background: #4a3a2a;
  border-radius: 5px;
  width: 65%;
  margin: 10px auto;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: #ffc96a;
}
.actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px 0;
}
button {
  border: 1px solid #946a39;
  background: #35261a;
  color: #ffe6ae;
  border-radius: 9px;
  padding: 12px 18px;
  font-weight: bold;
  cursor: pointer;
}
#next {
  background: #efbb65;
  color: #291b0d;
}
button[hidden] {
  display: none;
}
details {
  font-size: 12px;
  color: #b8aa94;
  line-height: 1.6;
}
summary {
  cursor: pointer;
  text-align: center;
}
button:focus-visible {
  outline: 2px solid white;
}
#board canvas {
  width: 100% !important;
  height: 100% !important;
}

.back {
  display: inline-block;
  color: #d5a760;
  text-decoration: none;
  font-size: 12px;
  margin-bottom: 14px;
}

#store-logo {
  display: block;
  width: min(100%, 290px);
  height: auto;
  margin: 0 auto 16px;
}
.product-offer {
  margin: 24px 0;
  padding: 20px;
  text-align: center;
  border: 1px solid #805a31;
  border-radius: 12px;
  background: #241911;
}
.product-offer h2 {
  margin: 0 0 8px;
  font: bold 25px Georgia;
}
.product-offer p {
  color: #ffd477;
  margin: 8px 0;
}
#product-price {
  font-size: 32px;
}
#product-weight {
  display: block;
  margin-top: 6px;
}
#board:focus-visible {
  outline: none;
  outline-offset: -2px;
  border-radius: 0;
}

#store-logo {
  filter: brightness(0) invert(1);
}

/* Chalet is independent of gameplay: a video can later replace this backdrop. */
main {
  background:
    linear-gradient(#160b03a6, #160b03b8),
    url("assets/chalet-vide.png") center top / auto var(--chalet-height, 1400px)
      no-repeat;
}
header {
  padding: 18px 12px;
  background: linear-gradient(135deg, #28170dec, #4b2b17e8);
  border: 1px solid #976b35;
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: 0 5px 20px #0007;
}
#board {
  overflow: hidden;
  border-radius: 0;
  margin-top: 0;
}
.instructions {
  position: relative;
  margin-top: 0;
  padding: 16px 8px;
  background: #211309eb;
  border: 1px solid #805a31;
  border-radius: 10px;
}

/* Keep text panels inset while the game scene remains edge to edge. */
main > header,
main > .hud,
main > .product-offer,
main > details {
  margin-left: 18px;
  margin-right: 18px;
}

/* Art-directed wooden interface, values remain live HTML. */
main {
  padding-top: 0;
  background:
    linear-gradient(#160b0320, #160b0360),
    url("assets/chalet-vide.png") center top / auto var(--chalet-height, 1400px)
      no-repeat;
}
main > header {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1.5;
  padding: 0;
  margin: 0 6px -8px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
}
header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("assets/title-sign.png") center / 100% 100% no-repeat;
  clip-path: polygon(
    4% 21%,
    10% 15%,
    28% 17%,
    40% 12%,
    45% 8%,
    49% 12%,
    57% 16%,
    69% 13%,
    86% 16%,
    96% 21%,
    99% 48%,
    95% 57%,
    95% 82%,
    92% 85%,
    8% 85%,
    5% 82%,
    5% 57%,
    1% 49%
  );
}
header #store-logo {
  position: absolute;
  width: 57%;
  height: auto;
  left: 21.5%;
  top: 25%;
  margin: 0;
}
header h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
header p {
  position: absolute;
  bottom: 3%;
  width: 100%;
  margin: 0;
  color: #ffebcc;
  font:
    italic 16px Georgia,
    serif;
  text-shadow: 0 2px 3px #000;
}
main > .hud {
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0;
  gap: 22px;
  margin: 8px 12px 12px;
}
.hud > span {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 48%;
  min-height: 61px;
  padding: 12px 10px;
  background: url("assets/wood-panel.png") center / 100% 100%;
  border-radius: 10px;
  box-shadow: 0 5px 8px #0007;
  font-size: 10px;
  letter-spacing: 0.7px;
  white-space: nowrap;
}
.hud b {
  margin-left: 0;
  font-size: 23px;
  color: #ffd078;
  text-shadow: 1px 2px #321a06;
}
.hud i {
  font-style: normal;
  font-size: 25px;
  color: #f3ba5a;
  text-shadow: 0 2px 3px #000;
}
.instructions {
  background: url("assets/wood-panel.png") center / 100% 100%;
  border: 0;
  border-radius: 12px;
  margin: 0 12px;
  padding: 18px 18px;
  box-shadow: 0 5px 12px #0008;
}
#feedback {
  font:
    italic 19px/1.3 Georgia,
    serif;
  color: #ffedce;
  text-shadow: 0 2px 3px #000;
}
.instructions small {
  font-size: 11px;
  color: #decaad;
}
.meter {
  height: 3px;
  margin: 9px auto;
  background: #b68b4940;
}
.meter i {
  background: linear-gradient(90deg, #c38839, #ffe4a1);
  box-shadow: 0 0 8px #ffc764;
}
.actions button {
  background: url("assets/wood-panel.png") center / 100% 100%;
  border: 1px solid #b8843c;
  border-radius: 22px;
  min-width: 170px;
  padding: 14px 26px;
  font:
    bold 17px Georgia,
    serif;
  box-shadow: 0 4px 10px #0008;
}
.product-offer {
  background:
    linear-gradient(#f6e5c5eb, #e7c98ded),
    url("assets/wood-panel.png") center/cover;
  color: #382010;
  border: 3px double #a47737;
  box-shadow: 0 6px 18px #0006;
}
.product-offer p {
  color: #9a1e14;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}
@media (max-width: 350px) {
  .hud > span {
    font-size: 9px;
    gap: 4px;
    padding: 10px 7px;
  }
  .hud b {
    font-size: 20px;
  }
  .hud i {
    font-size: 20px;
  }
  header p {
    font-size: 14px;
  }
}

@font-face {
  font-family: "Intermarche";
  src: url("assets/INTERMARCHE.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Intermarche";
  src: url("assets/INTERMARCHE_Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
body {
  font-family: "Intermarche", sans-serif;
}
main > header {
  width: 76%;
  margin: 0 auto 0;
}
header p {
  font-family: "Intermarche", sans-serif;
  font-style: normal;
  font-size: 14px;
}
main > .hud {
  margin: 6px 8% 20px;
  gap: 16%;
}
.hud > span {
  width: 42%;
  min-height: 48px;
  padding: 9px 8px;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0;
}
.hud b {
  font-size: 23px;
}
.hud i {
  font-size: 22px;
}
#feedback {
  font-family: "Intermarche", sans-serif;
  font-style: normal;
}
.actions button,
.product-offer h2 {
  font-family: "Intermarche", sans-serif;
}
@media (max-width: 350px) {
  main > header {
    width: 80%;
  }
  main > .hud {
    margin-left: 6%;
    margin-right: 6%;
    gap: 12%;
  }
  .hud > span {
    width: 44%;
    font-size: 10px;
    gap: 4px;
    padding: 8px 6px;
  }
  .hud b {
    font-size: 21px;
  }
  .hud i {
    font-size: 18px;
  }
  header p {
    font-size: 12px;
  }
}

/* End-of-game overlay: live content over the blurred chalet. */
#result-dialog {
  box-sizing: border-box;
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 10px;
  border: 0;
  background: transparent;
  color: #fff0cc;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #bc8c46 #2b170e;
}
#result-dialog::backdrop {
  background: rgb(17 9 4 / 32%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
body:has(#result-dialog[open]) {
  overflow: hidden;
}
.result-content {
  text-align: center;
  display: grid;
  gap: 12px;
}
.result-brand {
  width: 78%;
  margin: auto;
  padding: 20px 16px 16px;
  background: url("assets/title-sign.png") center / 100% 100% no-repeat;
  aspect-ratio: 2.25;
  box-sizing: border-box;
  clip-path: polygon(
    3% 12%,
    25% 10%,
    50% 0,
    75% 10%,
    98% 12%,
    100% 97%,
    0 100%
  );
}
.result-brand img {
  width: 78%;
  max-height: 48px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.result-brand span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#result-dialog .wood {
  background: #301709 url("assets/wood-panel.png") center / 100% 100% no-repeat;
  border: 1px solid #b9833d;
  border-radius: 16px;
  box-shadow:
    0 5px 12px #0008,
    inset 0 0 0 3px #261409;
  padding: 18px 16px;
}
#result-dialog h2 {
  margin: 0 0 8px;
  font-size: 29px;
}
#result-heading,
.result-share h2 {
  font-family: Georgia, serif;
  font-style: italic;
  color: #ffedba;
  text-shadow: 0 2px 2px #000;
}
#result-heading:focus {
  outline: none;
}
#result-dialog p {
  margin: 5px 0;
  font-size: 14px;
}
.result-score > strong {
  display: block;
  font-size: 58px;
  line-height: 1.1;
  color: #ffd177;
  text-shadow:
    0 2px 0 #8c4b10,
    0 4px 6px #000;
}
.result-score small {
  font-size: 19px;
}
#result-stars {
  font-size: 32px;
  letter-spacing: 7px;
  color: #6b5133;
}
#result-stars .earned {
  color: #ffcc66;
  text-shadow:
    0 0 12px #ffa42a88,
    0 2px 2px #000;
}
#round-recap {
  opacity: 0.75;
}
.result-offer {
  overflow: hidden;
  padding: 0 16px 19px;
  border-radius: 17px;
  border: 2px solid #dbab67;
  outline: 1px solid #784722;
  outline-offset: -7px;
  background: radial-gradient(ellipse at center, #fff2d5, #ead0a0);
  color: #381b0b;
  box-shadow: 0 8px 24px #0006;
}
.result-photo {
  height: 185px;
  margin: 0 -16px 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(0deg, #f3deb7, transparent 45%),
    url("assets/chalet-vide.png") center 62% / cover;
}
.result-photo img {
  width: 200px;
  height: 185px;
  object-fit: contain;
  filter: drop-shadow(0 9px 8px #20100870);
}
#result-product {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 30px;
}
#result-offer-label {
  display: inline-block;
  background: #a91816;
  color: #fff1d5;
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 23px !important;
  font-weight: 700;
  text-transform: uppercase;
}
#result-price {
  display: block;
  color: #a91816;
  font-size: 58px;
  line-height: 1.2;
}
#result-dialog [hidden] {
  display: none;
}
.result-share > div {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
#result-dialog button {
  font:
    700 15px "Intermarche",
    sans-serif;
  color: #ffedc6;
  background:
    linear-gradient(#56361999, #1a100bd9),
    url("assets/wood-panel.png") center / cover;
  border: 1px solid #e2ac56;
  border-radius: 14px;
  padding: 12px 10px;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 2px #29180b,
    0 3px 8px #0005;
}
.result-share button {
  flex: 1;
}
#result-dialog button:hover {
  filter: brightness(1.18);
}
#result-dialog button:focus-visible {
  outline: 2px solid #fff0b5;
  outline-offset: 3px;
}
#result-replay {
  justify-self: center;
  min-width: 180px;
}
#share-feedback {
  overflow-wrap: anywhere;
}
#share-feedback:empty {
  display: none;
}
@media (max-width: 350px) {
  #result-dialog {
    padding: 4px;
  }
  #result-dialog .wood {
    padding: 14px 12px;
  }
  #result-dialog button {
    font-size: 13px;
  }
}
.result-brand {
  position: relative;
  padding: 0;
}
.result-brand img {
  position: absolute;
  top: 24%;
  left: 21%;
  width: 58%;
  height: 30%;
  max-height: none;
}
main > .hud {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 8px;
  margin: 6px 5% 20px;
}
.hud > span {
  width: auto;
  min-width: 0;
  padding: 7px 5px;
  gap: 4px;
}
.hud .score-panel b {
  font-size: 28px;
}
.hud img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.hud small {
  font-size: 11px;
}
.play-scene {
  position: relative;
}
.play-scene.is-preview canvas {
  filter: blur(2px);
  opacity: 0.85;
}
#start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 12%;
  background: #20100512;
}
#start-overlay[hidden],
#start-overlay [hidden] {
  display: none;
}
#start-overlay p {
  color: #fff2cc;
  text-shadow: 0 2px 5px #000;
  font-weight: bold;
  font-size: 17px;
}
#start-game {
  font:
    700 25px "Intermarche",
    sans-serif;
  color: #fff1cd;
  background: linear-gradient(#ba2821, #73100c);
  border: 2px solid #e9b86a;
  border-radius: 16px;
  padding: 13px 34px;
  box-shadow:
    0 5px 0 #3c150b,
    0 9px 22px #0008;
  cursor: pointer;
}
#start-game:focus-visible {
  outline: 2px solid white;
  outline-offset: 4px;
}
#countdown {
  position: absolute;
  top: 38%;
  font-size: 90px;
  color: #ffe0a0;
  text-shadow:
    0 4px 0 #754318,
    0 8px 20px #000;
}
#pull-hint {
  position: absolute;
  left: 50%;
  top: 78%;
  width: 7%;
  display: grid;
  gap: 9px;
  transform: translateX(-50%);
  pointer-events: none;
}
#pull-hint[hidden] {
  display: none;
}
#pull-hint i {
  display: block;
  width: 100%;
  aspect-ratio: 2;
  background: #ffda87;
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 40%, 50% 100%, 0 40%);
  animation: pull-chevron 1.5s ease-in-out infinite;
}
#pull-hint i:nth-child(2) {
  animation-delay: 0.18s;
}
#pull-hint i:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes pull-chevron {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(-3px);
  }
  50% {
    opacity: 1;
    transform: translateY(4px);
  }
}
@media (prefers-reduced-motion: reduce) {
  #pull-hint i {
    animation: none;
    opacity: 0.85;
  }
}
/* Short, skippable results ceremony. */
#result-skip {
  justify-self: end;
  padding: 6px 15px !important;
  font-size: 13px !important;
}
.result-score {
  position: relative;
}
#final-score {
  font-variant-numeric: tabular-nums;
}
#result-stars span {
  display: inline-block;
}
#round-recap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  min-height: 22px;
}
.throw-chip {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid #bc914b66;
  border-radius: 5px;
  opacity: 0;
  transform: translateY(7px);
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.throw-chip.revealed {
  opacity: 1;
  transform: none;
}
.ceremony:not(.ceremony-done) .result-offer,
.ceremony:not(.ceremony-done) .result-share,
.ceremony:not(.ceremony-done) #result-replay {
  visibility: hidden;
  opacity: 0;
  transform: translateY(10px);
}
.ceremony .result-offer,
.ceremony .result-share,
.ceremony #result-replay {
  transition:
    opacity 0.3s,
    transform 0.3s;
}
.ceremony-done .result-share {
  transition-delay: 0.12s;
}
.reward-sparkles {
  position: absolute;
  left: 10%;
  top: 42%;
  width: 80%;
  color: #ffe3a3;
  font-size: 36px;
  letter-spacing: 12px;
  opacity: 0;
  pointer-events: none;
}
.ceremony-reward .reward-sparkles {
  animation: reward-burst 0.65s ease-out;
}
.ceremony-reward .result-score {
  animation: reward-glow 0.6s ease-out;
}
@keyframes reward-burst {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.35) translateY(-22px);
  }
}
@keyframes reward-glow {
  25% {
    box-shadow:
      0 0 28px #ffd67970,
      inset 0 0 22px #ffcb6540;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ceremony *,
  .throw-chip {
    animation: none !important;
    transition: none !important;
  }
}

/* Compact score sign leaves the chalet visible around the result. */
#result-dialog .result-score {
  box-sizing: border-box;
  width: 84%;
  justify-self: center;
  padding: 12px 10px;
}
#result-dialog .result-score h2 {
  font-size: 27px;
  margin-bottom: 3px;
}
#result-dialog .result-score p {
  margin: 3px 0;
}
.result-score > strong {
  font-size: 49px;
  line-height: 1;
}
.result-score #result-stars {
  font-size: 28px;
  line-height: 1.2;
}
.result-score #round-recap {
  gap: 3px;
  min-height: 0;
}
.result-score .throw-chip {
  font-size: 10px;
  padding: 2px 4px;
}

/* Keep instruction changes from shifting the backdrop. */
#feedback {
  min-height: 2.6em;
}
