/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 1.2rem;
  background: #1a1030;
  color: #fff;
  /* stop pull-to-refresh / bounce interfering while shaking */
  overscroll-behavior: none;
}

#stage {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.haru-head {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 400px;
  height: 100%;
  width: 100%;
  max-width: 400px;

  & img { aspect-ratio: 1 / 1; position: absolute; animation: reveal 0.3s ease-out both; }
  & .level-1 { z-index: 1; animation-delay: .2s; width: 100%; }
  & .level-2 { z-index: 2; animation-delay: .4s; width: 87%; }
  & .level-3 { z-index: 3; animation-delay: .6s; width: 74%; }
  & .level-4 { z-index: 4; animation-delay: .8s; width: 61%; }
  & .level-5 { z-index: 5; animation-delay: 1.1s; width: 55%; }
  & .level-6 { z-index: 6; animation-delay: 1s; width: 61%; animation-name: pop-in; animation-duration: .1s; }
}
@keyframes pop-in {
  from {opacity: 0;}
  to {opacity:1;}
}
.haru-head .head {
  position: relative;
  z-index: 2;
  width: 65%;
}

.screen.is-active { display: flex; }

button {
  font: inherit;
  padding: 0.75rem 1.5rem;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
#greeting {
  background-image: url('assets/poka-dot.svg');
  background-repeat: repeat;
}
#fallback {
  border: none;
  border-radius: none;
  text-decoration: underline;
  padding: 0;
  opacity: .5;
}

/* Little wobble while waiting, nudges people to shake */
.hint { font-size: 1.4rem; animation: wobble 1.6s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-6deg); }
  75%      { transform: rotate(6deg); }
}

/* ---------- Fortune (shared layout) ---------- */
.fortune {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  animation: reveal 0.6s ease-out both;
}
@keyframes reveal {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.fortune__graphic { max-width: 60vw; height: auto; }
.fortune__title   { margin: 0; font-size: 2rem; }
.fortune__message { margin: 0; max-width: 28ch; font-size: 1.25rem; line-height: 1.4; }

/* ---------- Per-fortune themes (design these yourself) ---------- */
.fortune--crayon {
  background: radial-gradient(circle at 50% 30%, #3b3f87, #0d1033);
  background-image: url('assets/crayon-shin-chan-crayon-shin-chan-dance.gif');
  background-repeat: repeat;
  background-size: 40%;
  background-position: center center;
  color: #f4f1ff;

  & .fortune__title,
  & .fortune__message {
    color: black;
    background-color: rgba(255,255,255,.8);
  }
  & button {
    background: red;
  }
}

.fortune--peach {
  background: linear-gradient(160deg, #ffd86b, #ff8a5c);
  background-image: url('assets/bouncy-peach.gif');
  background-repeat: repeat;
  background-size: 40%;
  background-position: center center;
  color: #c66d12;
  background-color: #FCEFE3;
  text-shadow: -1px -1px 6px #e0c0a1;

  & button {
    background: #e0c0a1;
  }
}

.fortune--ugly-chiikawa {
  background: radial-gradient(circle at 50% 30%, #3b3f87, #0d1033);
  color: #f4f1ff;

  & .fan {
    overflow: hidden;
    opacity: .2;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: -1;

    & img {
      animation: rotate 2s linear infinite both;
      height: 125%;
    }
  }
}
@keyframes rotate {
  from { transform: rotate(0deg); }
  to {transform: rotate(30deg); }
}

.cover {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: -1;

  & img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
.fortune--crybaby {
  background: linear-gradient(160deg, #ffd86b, #ff8a5c);
  color: #3a1c00;
}
.fortune--chiikawa {
  color: white;
  text-shadow: 2px 2px 4px black;

  & .cover img{
    object-position: 87%;
  }
}
.fortune--bubu {
  color: black;
  background: linear-gradient(160deg, white 66%,#FDC5B9);
}
.fortune--cardboard {
  color: white;
}
.fortune--shark {
  & .fortune__title,
  & .fortune__message,
  & button {
    position: relative;
    z-index: 10;
    text-shadow: -1px -1px 6px black;
  }
  & button {
    background-color: #245866;
  }
}

.fortune--yakiniku {
  background-color: #FDE3EF;
  color: #E35B54;
  & p { color: #2A2D53; }
  & .background {
    opacity: .25;
    position: absolute;
    z-index: -1;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(15deg) ;
    width: 200vw;
    height: 200vh;
    background-image: url('assets/sake.svg');
    background-repeat: repeat;
    background-position: center center;
  }
}

.ocean {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;

  & img {
    height: auto;
    width: 120%;
    left: -10%;
    position: absolute;
    animation: ocean 2s ease-in-out infinite alternate;

    &.layer-1 { bottom: -7vh; z-index: 5;}
    &.layer-2 { bottom: 13vh; z-index: 4; animation-delay: .3s;}
    &.layer-3 { bottom: 33vh; z-index: 3; animation-delay: .6s;}
    &.shark { bottom: 33vh; left: 10vw; z-index: 3; width: 30vw;}
    &.layer-4 { bottom: 53vh; z-index: 2; animation-delay: .9s;}
  }
}
@keyframes ocean {
  from { transform: translate(0,0); }
  to { transform: translate(20px,10px); }
}

.rain img { 
  position: absolute;
  top: -100%; 
  animation: rain 1.5s ease-out infinite both;
  z-index: -1;
  backdrop-filter: blur(5px);

  &.left-1 { left: 10%;}
  &.left-2 { left: 25%;}
  &.left-3 { left: 55%;}
  &.left-4 { left: 78%;}
  &.left-5 { left: 80%;}
}
@keyframes rain {
  from { top:-100%; }
  to { top: 110%; }
}

.blur { filter: blur(5px); animation-duration: 2s !important; opacity: .8;}
.delay-1 { animation-delay: .3s !important;}
.delay-2 { animation-delay: .5s !important; }
.delay-3 { animation-delay: .7s !important; }
.delay-4 { animation-delay: 1s !important; }
.delay-5 { animation-delay: 1.2s !important; }