@import url("fonts/fonts.css");

:root {
  --paper: #F4EEDF;
  --pink: #FF4F9A;
  --yellow: #FFC93C;
  --teal: #1FA6A0;
  --navy: #23264A;
  --overprint: #6B4E8C;
  --col: min(100%, 480px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--navy);
  font-family: "Nunito", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

/* ---- paper backdrop with halftone dots + decoration (desktop) ---- */
#paper {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: var(--paper);
  background-image: url("assets/halftone.webp");
  background-size: 220px 220px;
  background-repeat: repeat;
  z-index: 0;
}
#paper img.deco {
  position: absolute;
  display: none;
  pointer-events: none;
  user-select: none;
}
@media (min-width: 560px) {
  #paper img.deco { display: block; }
  #paper .deco-boat {
    width: 340px;
    left: -70px; top: 4%;
    transform: rotate(-8deg);
    opacity: .95;
  }
  #paper .deco-flower {
    width: 300px;
    right: -60px; bottom: 2%;
    transform: rotate(12deg);
    opacity: .95;
  }
  #paper .deco-flower2 {
    width: 190px;
    left: -40px; bottom: 8%;
    transform: rotate(-14deg);
    opacity: .85;
  }
}

/* ---- grain over everything ---- */
#grain {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: .08;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- the play column ---- */
#game {
  position: relative;
  width: var(--col);
  height: 100dvh;
  height: 100vh;
  margin: 0 auto;
  z-index: 10;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--navy);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#game canvas { display: block; width: 100% !important; height: 100% !important; }

/* ---- HUD ---- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 62px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--paper);
  filter: drop-shadow(0 3px 0 rgba(35,38,74,.18));
  clip-path: polygon(0 0, 100% 0, 100% 84%, 97% 100%, 94% 86%, 91% 100%, 88% 86%, 85% 100%, 82% 86%, 79% 100%, 76% 86%, 73% 100%, 70% 86%, 67% 100%, 64% 86%, 61% 100%, 58% 86%, 55% 100%, 52% 86%, 49% 100%, 46% 86%, 43% 100%, 40% 86%, 37% 100%, 34% 86%, 31% 100%, 28% 86%, 25% 100%, 22% 86%, 19% 100%, 16% 86%, 13% 100%, 10% 86%, 7% 100%, 4% 86%, 1% 100%, 0 86%);
}
#hud .brand { position: absolute; inset: 0; pointer-events: none; }
.hud-score, .hud-lives { display: flex; align-items: center; gap: 7px; }
.hud-score img { width: 30px; height: 30px; }
.hud-score .num {
  font-family: "Unbounded", sans-serif;
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  transition: transform .12s ease;
}
.hud-score .num.pop { transform: scale(1.25); }
.hud-level {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(-3deg);
  width: 43px; height: 43px;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  font-family: "Unbounded", sans-serif;
  font-weight: 900;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 3px 3px 0 var(--navy);
}
.hud-lvl {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 6px;
}
.hud-lvl .hud-level { position: static; transform: rotate(-3deg); flex: none; }
.hud-goal { display: flex; flex-direction: column; gap: 3px; width: 54px; }
.hud-goal-lbl, .hud-goal-num {
  font-family: "Unbounded", sans-serif; font-weight: 800; font-size: 10px; line-height: 1; color: var(--navy);
}
.hud-goal-lbl { text-transform: uppercase; letter-spacing: .04em; }
.hud-goal-bar {
  display: block; height: 7px; border-radius: 4px;
  background: rgba(35,38,74,.15); overflow: hidden;
}
.hud-goal-bar i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .2s ease; }
.over-level {
  font-family: "Unbounded", sans-serif; font-weight: 700; font-size: 15px; color: var(--pink);
}
.hud-lives img { height: 30px; width: auto; }
.hud-lives img.lost { opacity: .22; filter: grayscale(.4); }

/* ---- overlays ---- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 12px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  background-color: var(--paper);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.screen.hidden { display: none; }

/* start */
.title {
  position: relative;
  margin: 4px 0 10px;
  font-family: "Unbounded", sans-serif;
  font-weight: 900;
  font-size: clamp(32px, min(12vw, 11.5vh), 56px);
  line-height: .94;
  max-width: 100%;
  text-align: center;
  letter-spacing: -1.5px;
  color: var(--pink);
  text-shadow: 5px 5px 0 var(--teal);
  transform: rotate(-3deg);
  flex: 0 0 auto;
}
.title .dash { display: block; }
.rules {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px;
  background: var(--paper);
  border: 3px solid var(--navy);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--teal);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}
.rule { display: flex; align-items: center; gap: 14px; }
.rule .picto {
  flex: 0 0 auto;
  width: 58px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  gap: 3px;
}
.rule .picto img {
  width: 40px; height: 40px; object-fit: contain;
  filter: drop-shadow(2px 2px 0 rgba(31,166,160,.45));
}
.rule .picto.two img { width: 30px; height: 30px; }
.rule .txt {
  font-weight: 700;
  font-size: clamp(18px, 4.8vw, 20px);
  line-height: 1.2;
  color: var(--navy);
}
.rules .sep { height: 2px; background: rgba(35,38,74,.18); border-radius: 2px; }

.hero {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  flex: 1 1 auto;
  justify-content: center;
}
.hero-boat {
  width: min(76vw, 320px, 30vh);
  filter: drop-shadow(6px 6px 0 var(--teal));
}
.hero-waves {
  width: min(90vw, 410px);
  height: min(56px, 7vh);
  margin-top: -12px;
  background-image: url("assets/currents.webp");
  background-size: 170px 170px;
  background-repeat: repeat-x;
  opacity: .75;
}

/* big round play button */
.btn-round {
  position: relative;
  flex: 0 0 auto;
  width: clamp(96px, 15vh, 128px);
  height: clamp(96px, 15vh, 128px);
  border: 0;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 7px 7px 0 var(--navy);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn-round:active, .btn-round.press { transform: translate(7px, 7px); box-shadow: 0 0 0 var(--navy); }
.btn-round .tri {
  width: 0; height: 0;
  border-style: solid;
  border-width: 17px 0 17px 29px;
  border-color: transparent transparent transparent #fff;
  margin-left: 6px;
}
.btn-round .lbl {
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
}
.play-wrap { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 0 0 auto; }

/* pill buttons (game over) */
.btn {
  position: relative;
  border: 0;
  cursor: pointer;
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: 24px;
  color: #fff;
  background: var(--pink);
  border-radius: 999px;
  padding: 18px 30px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 4px 4px 0 var(--navy);
  transition: transform .08s ease, box-shadow .08s ease;
  min-height: 64px;
  min-width: 64px;
}
.btn:active, .btn.press { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--navy); }
.btn .tri {
  width: 0; height: 0;
  border-style: solid;
  border-width: 13px 0 13px 22px;
  border-color: transparent transparent transparent #fff;
}
.btn .arrow {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 4px solid #fff;
  position: relative;
}
.btn .arrow::after {
  content: "";
  position: absolute;
  left: 7px; top: -4px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
}
.spacer { display: none; }

/* game over */
#over { justify-content: flex-start; }
#over .bank-bg {
  position: absolute;
  inset: 0;
  background-image: url("assets/gameover.webp");
  background-size: 100% auto;
  background-position: center top;
  background-repeat: no-repeat;
  z-index: 0;
}
#over .bank-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(244,238,223,0) 30%, rgba(244,238,223,.75) 44%, rgba(244,238,223,.98) 54%);
}
#over .inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 46vh;
}
.over-title {
  font-family: "Unbounded", sans-serif;
  font-weight: 900;
  font-size: clamp(22px, 6.5vw, 32px);
  color: var(--navy);
  text-shadow: 3px 3px 0 var(--yellow);
  transform: rotate(-2deg);
}
.final { display: flex; align-items: center; gap: 12px; }
.final img { width: 56px; height: 56px; }
.final .big {
  font-family: "Unbounded", sans-serif;
  font-weight: 900;
  font-size: clamp(64px, 22vw, 104px);
  line-height: 1;
  color: var(--navy);
}
.best {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--teal);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px 8px 10px;
  font-weight: 700;
  font-size: 17px;
  box-shadow: 3px 3px 0 var(--navy);
}
.best img { width: 26px; height: 26px; }
.best b { font-family: "Unbounded", sans-serif; font-weight: 800; font-size: 19px; }
#over .play-wrap { margin-top: 4px; }

/* short screens */
@media (max-height: 800px) {
  .screen { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .title { text-shadow: 5px 5px 0 var(--teal); margin-bottom: 2px; }
  .rule { gap: 12px; }
  .rule .picto { width: 50px; height: 42px; }
  .rule .picto img { width: 34px; height: 34px; }
  .rule .picto.two img { width: 26px; height: 26px; }
  .rules { gap: 8px; padding: 12px; box-shadow: 5px 5px 0 var(--teal); }
  .rule .txt { font-size: clamp(16px, 4.4vw, 18px); }
  .hero-waves { background-size: 140px 140px; }
}

/* very short screens */
@media (max-height: 640px) {
  .screen { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); gap: 6px; }
  .title { font-size: clamp(28px, min(12vw, 11vh), 50px); }
  .rules { padding: 10px; gap: 6px; }
  .rule { gap: 10px; }
  .rule .txt { font-size: 16px; }
  .rule .picto { width: 42px; height: 34px; }
  .rule .picto img { width: 30px; height: 30px; }
  .rule .picto.two img { width: 23px; height: 23px; }
  .hero-boat { width: min(66vw, 230px, 26vh); }
  .hero-waves { height: min(40px, 6vh); }
}
