:root {
  --cream: #f7f1e4;
  --paper: #fffaf0;
  --forest: #0d3b2e;
  --dark: #082c23;
  --sage: #aabca2;
  --mint: #dce7d4;
  --coral: #d76550;
  --ochre: #d3a23e;
  --purple: #754c78;
  --line: #173e3228;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  color: var(--dark);
  background-color: var(--cream);
  background-image:
    linear-gradient(#173e3208 1px, transparent 1px),
    linear-gradient(90deg, #173e3208 1px, transparent 1px);
  background-size: 38px 38px;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Arial,
    sans-serif;
}
button,
a {
  font: inherit;
}
button {
  touch-action: manipulation;
}

header {
  position: relative;
  z-index: 5;
  height: 76px;
  padding: 0 clamp(24px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #173e3236;
  background: rgba(255, 251, 242, 0.95);
}
.mark {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--forest);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.site-pictogram {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--forest);
}
.site-pictogram::after {
  content: "";
  margin-left: 3px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid var(--paper);
}
.header-note {
  margin: 0;
  color: var(--forest);
  font-size: 0.9rem;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.hero {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 76px);
  padding: clamp(54px, 6vh, 78px) 24px clamp(90px, 9vh, 130px);
  overflow: hidden;
  background: url("assets/background.jpg") center bottom / cover no-repeat;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    90deg,
    rgba(255, 250, 240, 0.86) 0%,
    rgba(255, 250, 240, 0.78) 36%,
    rgba(255, 250, 240, 0.56) 53%,
    rgba(255, 250, 240, 0.12) 72%
  );
  pointer-events: none;
}
.hero-inner {
  display: grid;
  grid-template-columns: minmax(350px, 0.82fr) minmax(590px, 1.18fr);
  align-items: center;
  gap: clamp(42px, 5vw, 82px);
  width: min(1240px, 100%);
  margin: auto;
}
.intro,
.game-column,
.game-card {
  position: relative;
  z-index: 1;
}
.intro {
  align-self: center;
}
.overline {
  margin: 0 0 18px;
  color: #9e6741;
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  color: var(--forest);
  font-size: clamp(3.5rem, 5.15vw, 5.7rem);
  line-height: 0.96;
  letter-spacing: -0.065em;
  text-wrap: balance;
}
.subtitle {
  margin: 28px 0 0;
  color: #244b40;
  font-size: clamp(1.08rem, 1.45vw, 1.36rem);
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(100%, 380px);
  margin-top: 38px;
  padding: 21px 32px;
  border: 1px solid #06271f;
  border-radius: 18px;
  color: var(--paper);
  background: linear-gradient(145deg, #144d3c, #073326);
  box-shadow:
    0 14px 24px #102a2430,
    inset 0 1px #ffffff20;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 800;
  transition:
    transform 0.18s,
    box-shadow 0.18s;
}
.primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 30px #102a2440,
    inset 0 1px #ffffff20;
}
.play-icon {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 12px solid var(--paper);
}
.quick-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: min(100%, 500px);
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid #173e3236;
}
.quick-rules p {
  margin: 0;
  color: #244b40;
  font-size: 0.75rem;
  font-weight: 680;
  line-height: 1.35;
}
.quick-rules b {
  display: block;
  margin-bottom: 6px;
  color: #a66c44;
  font-size: 0.7rem;
}

.game-column {
  width: 100%;
}
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  margin: 0 auto 18px;
  padding: 10px 8px;
  border: 1px solid #173e3228;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 8px 20px #173e3213;
}
.hud p {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0;
  padding: 0 13px;
  color: #173e32;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 720;
}
.hud p + p {
  border-left: 1px solid #173e3240;
}
.hud p > span:last-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--forest);
  background: #dae5d1;
  font-size: 1.35rem;
  line-height: 1;
}
.heart-icon {
  color: #bc4b4b;
  background: #f2d9d2;
}
.hud strong {
  color: var(--forest);
  font-size: 0.9rem;
}
.hud .lives {
  display: flex;
  gap: 3px;
  color: #c94e4d;
  font-size: 1.1rem;
  letter-spacing: 0;
  padding-top: 3px;
}
.life-pip {
  font-style: normal;
  line-height: 1;
}
.life-pip.empty {
  color: #d8aaa7;
}
.life-pip.half {
  color: transparent;
  background: linear-gradient(90deg, #c94e4d 50%, #d8aaa7 50%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hud .life-stat {
  margin: -4px 8px -4px -4px;
  padding: 4px 10px;
  border: 1px solid #d99a8c75;
  border-radius: 14px;
  background: #fff3ee;
  box-shadow: 0 5px 16px #733c2d10;
}
.hud .lives.lost-life {
  animation: heart-hit 0.45s ease;
}

.game-card {
  width: min(100%, 790px);
  justify-self: center;
  padding: 6.8% 8.5% 9.2%;
  background: url("assets/cadre-jeu.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 18px 30px #173e3222);
}
.board-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  border: 4px solid #082c23;
  border-radius: 3px;
  background: var(--forest);
  box-shadow:
    0 0 0 3px #af9562,
    inset 0 0 34px #04191255;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
  color: var(--paper);
  background: #082c23d2;
  backdrop-filter: blur(3px);
}
.overlay.hidden {
  display: none;
}
.overlay h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
}
.overlay p {
  color: var(--mint);
}
.overlay button {
  padding: 12px 23px;
  border: 0;
  border-radius: 13px;
  color: var(--dark);
  background: var(--paper);
  cursor: pointer;
  font-weight: 780;
}
.pause {
  display: none;
  position: absolute;
  right: 14px;
  top: 14px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  cursor: pointer;
  font-weight: 850;
}
.gold-note {
  display: none;
  position: absolute;
  left: 50%;
  top: 15px;
  padding: 8px 13px;
  border-radius: 99px;
  background: var(--ochre);
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 8px 22px #071a1540;
}
.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle, transparent 28%, #cf253b9c 100%), #b20f262b;
}
.board-wrap.damage {
  animation: board-shake 0.43s ease;
}
.board-wrap.damage .damage-flash {
  animation: damage-flash 0.52s ease-out;
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: center;
  gap: clamp(40px, 8vw, 120px);
  width: min(1240px, calc(100% - 48px));
  margin: auto;
  padding: clamp(72px, 10vw, 130px) 0;
  border-top: 1px solid var(--line);
}
.controls h2,
.rules-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 3.5vw, 3.7rem);
  line-height: 1.03;
  letter-spacing: -0.05em;
}
.controls > div > p:last-child {
  font-size: 1.05rem;
  line-height: 1.75;
}
.pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(2, 64px);
  gap: 9px;
  justify-content: center;
}
.pad button {
  border: 1px solid var(--forest);
  border-radius: 18px;
  color: var(--forest);
  background: var(--paper);
  box-shadow: 0 6px 0 var(--sage);
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 800;
}
.pad button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--sage);
}
.pad button:nth-child(1) {
  grid-column: 2;
}
.pad button:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}
.pad button:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}
.pad button:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}

.game-rules {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 clamp(80px, 10vw, 130px);
}
.rules-heading {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 70px;
  align-items: end;
  margin-bottom: 42px;
  padding-top: clamp(72px, 9vw, 110px);
  border-top: 1px solid var(--line);
}
.rules-heading .overline {
  grid-column: 1 / -1;
  margin-bottom: 0;
}
.rules-heading > p:last-child {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.75;
}
.rule-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.rule-cards article {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdf7b8;
}
.rule-cards h3 {
  margin: 16px 0 8px;
  font-size: 1.05rem;
}
.rule-cards p {
  margin: 0;
  color: #38564d;
  font-size: 0.92rem;
  line-height: 1.6;
}
.rule-symbol {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: var(--forest);
  background: var(--mint);
  font-size: 1.2rem;
  font-weight: 900;
}
.fruit-symbol,
.gold-symbol,
.trap-symbol {
  position: relative;
}
.fruit-symbol::before,
.gold-symbol::before {
  content: "";
  width: 20px;
  height: 22px;
  border-radius: 45% 48% 52% 50%;
  background: var(--coral);
  box-shadow: inset -3px -3px #9e44355c;
}
.fruit-symbol::after,
.gold-symbol::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 6px;
  top: 8px;
  right: 8px;
  border-radius: 100% 0;
  background: #7e9b6f;
  transform: rotate(-25deg);
}
.gold-symbol {
  background: #f4e4b8;
}
.gold-symbol::before {
  background: #e2aa34;
  box-shadow:
    0 0 8px #d9a44199,
    inset -3px -3px #a9752050;
}
.trap-symbol {
  background: #eadbed;
}
.trap-symbol::before {
  content: "";
  width: 19px;
  height: 23px;
  border-radius: 48%;
  background: var(--purple);
  box-shadow: inset -3px -3px #38223d66;
}
.trap-symbol::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 8px;
  top: 7px;
  border-top: 3px solid #8da476;
  border-radius: 50%;
}
.heart-rule-symbol {
  color: #c94e4d;
  background: #f2d9d2;
}
.rock-symbol {
  color: #706c60;
  background: #e1ddcf;
}
.portal-symbol {
  color: #f7f0c9;
  background: var(--forest);
}
.level-symbol {
  color: var(--paper);
  background: var(--coral);
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 30px clamp(24px, 5vw, 78px);
  color: var(--mint);
  background: var(--dark);
  font-size: 0.82rem;
}
footer p {
  margin: 0;
  font-weight: 700;
}
footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 24px;
}
footer a {
  color: inherit;
  font-weight: 700;
  text-underline-offset: 4px;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--ochre);
  outline-offset: 4px;
}

@keyframes heart-hit {
  0%,
  100% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.25);
    color: #8d2030;
  }
  65% {
    transform: scale(0.9);
  }
}
@keyframes board-shake {
  0%,
  100% {
    transform: translate(0);
  }
  20% {
    transform: translate(-8px, 3px);
  }
  40% {
    transform: translate(7px, -3px);
  }
  60% {
    transform: translate(-5px, -2px);
  }
  80% {
    transform: translate(4px, 2px);
  }
}
@keyframes damage-flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 1120px) {
  .hero {
    min-height: auto;
    padding-bottom: 120px;
  }
  .hero-inner {
    grid-template-columns: 1fr;
  }
  .intro {
    width: min(100%, 760px);
    margin: auto;
    padding-left: 0;
    text-align: center;
  }
  .primary,
  .quick-rules {
    margin-left: auto;
    margin-right: auto;
  }
  .game-column {
    width: min(100%, 860px);
    margin: 0 auto;
  }
  .game-card {
    width: min(100%, 860px);
  }
}
@media (max-width: 900px) {
  .rules-heading {
    grid-template-columns: 1fr;
  }
  .rule-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 700px) {
  header {
    height: 66px;
  }
  .header-note {
    display: none;
  }
  .hero {
    padding: 48px 12px 90px;
    background-position: 44% bottom;
  }
  h1 {
    font-size: clamp(2.75rem, 15vw, 4.2rem);
  }
  h1 br {
    display: none;
  }
  .primary {
    width: calc(100% - 24px);
  }
  .hud {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 0;
    width: calc(100% - 12px);
  }
  .hud p:nth-child(3) {
    border-left: 0;
  }
  .hud .life-stat {
    margin: -8px 5px;
  }
  .game-card {
    padding: 7.2% 7.2% 7.6%;
  }
  .board-wrap {
    border-width: 3px;
    box-shadow: 0 0 0 2px #af9562;
  }
  .controls {
    grid-template-columns: 1fr;
    width: calc(100% - 36px);
    padding: 72px 0;
  }
  .pad {
    order: -1;
  }
  .game-rules {
    width: calc(100% - 36px);
  }
  .rule-cards {
    grid-template-columns: 1fr;
  }
  .rules-heading {
    gap: 18px;
    margin-bottom: 28px;
  }
  footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }
  footer nav {
    justify-content: flex-start;
    gap: 16px 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    transition: none !important;
  }
  .board-wrap.damage,
  .board-wrap.damage .damage-flash {
    animation: none;
  }
}
