* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; position: fixed; inset: 0;
  overscroll-behavior: none; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-family: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', system-ui, sans-serif;
  background: #7ec8ff; color: #33334d;
}
img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
button { font: inherit; border: 0; background: none; color: inherit; cursor: pointer; touch-action: none; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; }

#home {
  --top: calc(64px + env(safe-area-inset-top));
  --bot: max(12px, env(safe-area-inset-bottom));
  --hh: min(19dvh, 34vw, 240px);
  --bs: min(10dvh, 18vw, 124px);
  --dg: min(2.2vw, 16px);
  --dw: 0px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  background: url(../assets/img/bg_home.webp) center / cover, linear-gradient(#8fd3ff, #c8f7c5);
  padding: var(--top) max(12px, env(safe-area-inset-right)) var(--bot) max(12px, env(safe-area-inset-left));
}
.grid {
  display: grid; gap: min(3vw, 2dvh); flex: none;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, (100dvh - var(--top) - var(--bot) - var(--hh) - 28px) * .74);
}
@media (orientation: landscape) {
  #home { flex-direction: row; --hh: min(30dvh, 230px); --bs: min(12dvh, 104px); --dw: max(var(--hh) * .955, var(--bs) * 2 + var(--dg)); }
  .grid { grid-template-columns: repeat(4, 1fr); width: min(100% - var(--dw) - 40px, (100dvh - var(--top) - var(--bot) - 12px) * 1.32); }
}
@media (orientation: landscape) and (max-height: 500px) {
  #home { --hh: min(36dvh, 150px); --bs: min(16dvh, 64px); --dg: 10px; }
  .grid { width: min(100% - var(--dw) - 28px, (100dvh - var(--top) - var(--bot) - 10px) * 1.32); }
}
@media (orientation: landscape) and (max-height: 500px) and (min-aspect-ratio: 2/1) {
  .grid { grid-template-columns: repeat(6, 1fr); width: min(100% - var(--dw) - 28px, (100dvh - var(--top) - var(--bot) - 10px) * 2.9); }
}
.tile {
  position: relative; aspect-ratio: 1; border-radius: 26%;
  background: radial-gradient(circle at 30% 25%, #fff8, transparent 60%), var(--c);
  box-shadow: 0 6px 0 #0002, inset 0 -6px 0 #0001;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: tileIn .45s cubic-bezier(.3,1.6,.5,1) both;
  transition: transform .12s;
}
.tile:active { transform: scale(.92) translateY(3px); }
.tile img { width: 72%; height: 66%; object-fit: contain; filter: drop-shadow(0 3px 2px #0002); }
.tile span { font-size: clamp(11px, 2.6dvmin, 18px); font-weight: 800; opacity: .75; margin-top: 2%; }

#game { background: #fff; }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }

#back {
  position: absolute; z-index: 50;
  top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left));
  width: 54px; height: 54px; border-radius: 50%;
  background: #ffffffb0; box-shadow: 0 3px 8px #0002;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #556; opacity: .7;
}
#back svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
#back .ring { fill: none; stroke: #ff6b8b; stroke-width: 8; stroke-linecap: round; }
#back.holding { opacity: 1; transform: scale(1.1); }
#hint {
  position: absolute; z-index: 50; left: max(72px, calc(env(safe-area-inset-left) + 72px)); top: max(22px, calc(env(safe-area-inset-top) + 12px));
  background: #000a; color: #fff; padding: 6px 12px; border-radius: 14px; font-size: 14px; font-weight: 700; pointer-events: none;
}

#gate {
  z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #fff6, transparent 60%), linear-gradient(160deg, #ffb3c7, #9ad8ff 55%, #b5f5c8);
}
#play {
  width: min(46dvmin, 260px); height: min(46dvmin, 260px); border-radius: 50%;
  background: #ff5a7a; color: #fff; font-size: min(20dvmin, 110px); padding-left: 3%;
  box-shadow: 0 10px 0 #c93d5c, 0 18px 40px #0003;
  animation: pulse 1.4s ease-in-out infinite;
}
html.splashing #play { visibility: hidden; }

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.fx-dot, .fx-char, .fx-ripple { position: absolute; border-radius: 50%; will-change: transform, opacity; }
.fx-char { border-radius: 0; line-height: 1; text-shadow: 0 2px 3px #0002; }
.fx-ripple { border: 4px solid #fff; box-shadow: 0 0 0 2px #0001; }
