:root{
  --s: 1.6;   
  --pink:        #ef4d7a;
  --pink-deep:   #c22a5c;
  --yellow:      #f6c81a;
  --yellow-deep: #d9a300;
  --idle:        #e7e7ea;
  --cream:       #f4ecd8;
  --ink:         #241a17;
  --board-line:  rgba(36,26,23,0.35);
  --bg-top:      #ffe873;
  --bg-bottom:   #e63a86;
}

*{ box-sizing: border-box; }

body{
  margin:0;
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
  padding: 24px;
}

main{ width: calc(260px * var(--s)); max-width: 100%; text-align: center; }

header h1{
  font-size: calc(24px * var(--s));
  letter-spacing: 1px;
  margin: 0 0 calc(4px * var(--s));
}

#message{
  font-size: calc(14px * var(--s));
  font-weight: bold;
  min-height: calc(20px * var(--s));
  margin: 0 0 calc(10px * var(--s));
}

.lid{
  width: calc(176px * var(--s));
  height: calc(30px * var(--s));
  margin: 0 auto;
  background: var(--ink);
  border-radius: calc(10px * var(--s)) calc(10px * var(--s)) calc(4px * var(--s)) calc(4px * var(--s));
  position: relative;
  z-index: 3;
}
.lid::after{
  content:"";
  position:absolute;
  top: calc(-8px * var(--s));
  left:50%;
  transform: translateX(-50%);
  width: calc(34px * var(--s));
  height: calc(12px * var(--s));
  background: var(--ink);
  border-radius: calc(6px * var(--s));
}

#grille{
  width: calc(176px * var(--s));
  height: calc(176px * var(--s));
  margin: calc(-4px * var(--s)) auto 0;
  background: var(--idle);
  border: calc(5px * var(--s)) solid var(--ink);
  border-top: none;
  border-radius: 0 0 calc(22px * var(--s)) calc(22px * var(--s));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  position: relative;
  overflow: hidden;
  transition: background 700ms ease;
  z-index: 2;
}

#grille.win-fraise{ background: linear-gradient(180deg, var(--pink), var(--pink-deep)); }
#grille.win-banane{ background: linear-gradient(180deg, var(--yellow), var(--yellow-deep)); }
#grille.tie{
  background: linear-gradient(90deg, var(--pink) 0%, var(--pink) 48%, var(--yellow) 52%, var(--yellow) 100%);
  animation: swirl 1400ms ease-in-out;
}
@keyframes swirl{
  0%   { filter: hue-rotate(0deg); }
  50%  { filter: hue-rotate(25deg) saturate(1.3); }
  100% { filter: hue-rotate(0deg); }
}

.case{
  position: relative;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor: pointer;
  color: transparent;
  font-size: 0;
}
.case:nth-child(n+4){ border-top: 2px solid var(--board-line); }
.case:nth-child(3n+2),.case:nth-child(3n+3){ border-left: 2px solid var(--board-line); }


.piece{
  display:inline-block;
  font-size: calc(28px * var(--s));
  line-height: 1;
  transform: scale(0);
  animation: pop-in 260ms cubic-bezier(.34,1.56,.64,1) forwards;
}
.piece.fraise{
  width: calc(26px * var(--s));
  height: calc(26px * var(--s));
  background: url('../img/fraise.png') center/contain no-repeat;
}
.piece.banane{
  width: calc(26px * var(--s));
  height: calc(26px * var(--s));
  background: url('../img/banane.png') center/contain no-repeat;
}
.piece.fraise::before,
.piece.banane::before{
  content: "";
}

@keyframes pop-in{
  0%   { transform: scale(0) rotate(-25deg); }
  70%  { transform: scale(1.15) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.case.win-cell .piece{
  animation: pop-in 260ms cubic-bezier(.34,1.56,.64,1) forwards, pulse 420ms ease-in-out 2;
}
@keyframes pulse{
  0%,100%{ filter: drop-shadow(0 0 0 rgba(255,255,255,0)); transform: scale(1); }
  50%{ filter: drop-shadow(0 0 10px rgba(255,255,255,0.9)); transform: scale(1.25); }
}

.piece.en-vol{
  position: fixed;
  animation: none !important;
  transition: transform 650ms cubic-bezier(.5,-0.2,.7,.3), opacity 650ms ease-in;
  z-index: 50;
  pointer-events: none;
}


.bulle{
  position:absolute;
  bottom: calc(-10px * var(--s));
  width: calc(8px * var(--s));
  height: calc(8px * var(--s));
  background: rgba(255,255,255,0.55);
  border-radius: 50%;
  animation: monte 1600ms ease-in forwards;
  z-index: 1;
}
@keyframes monte{
  0%   { opacity: 0; transform: translateY(0) scale(0.6); }
  15%  { opacity: .9; }
  100% { opacity: 0; transform: translateY(calc(-150px * var(--s))) scale(1.1); }
}

nav{
  width: calc(210px * var(--s));
  margin: 0 auto;
  padding: calc(10px * var(--s)) 0;
  background: var(--cream);
  border: calc(5px * var(--s)) solid var(--ink);
  border-top: none;
  border-radius: 0 0 calc(16px * var(--s)) calc(16px * var(--s));
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0% 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  gap: calc(14px * var(--s));
}

#power{
  width: calc(42px * var(--s));
  height: calc(42px * var(--s));
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  border: none;
  font-size: calc(16px * var(--s));
  cursor: pointer;
  box-shadow: 0 calc(3px * var(--s)) 0 #000;
}
#power:active{ transform: translateY(2px); box-shadow: 0 1px 0 #000; }

#lumiere{
  width: calc(14px * var(--s));
  height: calc(14px * var(--s));
  border-radius: 50%;
  background: #a33;
  box-shadow: 0 0 6px 1px rgba(200,40,40,0.6);
  transition: background 200ms ease, box-shadow 200ms ease;
}
#lumiere.on{
  background: #3ecb4f;
  box-shadow: 0 0 8px 2px rgba(62,203,79,0.85);
  animation: clignote 1.4s ease-in-out infinite;
}
@keyframes clignote{
  0%,100%{ opacity: 1; }
  50%{ opacity: .55; }
}

#replay{
  font-size: calc(12px * var(--s));
  padding: calc(6px * var(--s)) calc(10px * var(--s));
  border-radius: calc(8px * var(--s));
  border: 2px solid var(--ink);
  background: #fff;
  cursor: pointer;
}