/* Kids Arcade shell styles */
:root {
  --sky-top: #7cc6fe;
  --sky-bottom: #d8f1ff;
  --ink: #2b2d42;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sky-top);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Kid-proofing: no text selection, callouts, tap flashes, or pinch/double-tap zoom. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: none;
}

img, svg { -webkit-user-drag: none; user-drag: none; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.screen {
  position: fixed;
  inset: 0;
}
.screen[hidden] { display: none; }

/* ---------- Launcher ---------- */
#launcher {
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 70%, #b7e4a0 70.1%, #8fd16f);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 24px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 24px);
  overflow-y: auto;
  touch-action: pan-y;
}

.sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute;
  width: 160px; height: 50px;
  background: #fff;
  border-radius: 50px;
  opacity: 0.85;
  animation: drift 60s linear infinite;
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: #fff; border-radius: 50%;
}
.cloud::before { width: 70px; height: 70px; top: -35px; left: 25px; }
.cloud::after { width: 90px; height: 90px; top: -50px; left: 60px; }
.c1 { top: 12%; left: -200px; animation-duration: 70s; }
.c2 { top: 30%; left: -200px; animation-duration: 95s; animation-delay: -40s; transform: scale(0.7); }
.c3 { top: 6%; left: -200px; animation-duration: 120s; animation-delay: -80s; transform: scale(0.5); }
@keyframes drift { to { translate: calc(100vw + 400px) 0; } }

.title {
  position: relative;
  margin: 8px 0 20px;
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,0.12);
  white-space: nowrap;
}
.title span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.title span:nth-child(odd) { color: #ffd166; }
.title span:nth-child(3n) { color: #ff8fab; }
.title span:nth-child(4n) { color: #fff; }
.title span:nth-child(2) { animation-delay: .1s } .title span:nth-child(3) { animation-delay: .2s }
.title span:nth-child(4) { animation-delay: .3s } .title span:nth-child(5) { animation-delay: .4s }
.title span:nth-child(6) { animation-delay: .5s } .title span:nth-child(7) { animation-delay: .6s }
.title span:nth-child(8) { animation-delay: .7s } .title span:nth-child(9) { animation-delay: .8s }
.title span:nth-child(10) { animation-delay: .9s }
@keyframes bob { 50% { transform: translateY(-6px); } }

.tiles {
  position: relative;
  width: 100%;
  max-width: 1100px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 40vw), 300px));
  justify-content: center;
  gap: clamp(16px, 3vw, 32px);
  padding-bottom: 24px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 36px;
  background: var(--tile, #ffd166);
  box-shadow: 0 10px 0 rgba(0,0,0,0.15), 0 16px 30px rgba(0,0,0,0.12);
  overflow: hidden;
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.tile img { width: 82%; height: 82%; object-fit: contain; pointer-events: none; }
.tile .label {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center; font-weight: 800; font-size: 18px;
  color: rgba(0,0,0,0.45);
}
.tile:active, .tile.pressed { transform: translateY(6px) scale(0.97); box-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.tile.launch { animation: launch 0.35s ease forwards; }
@keyframes launch { 50% { transform: scale(1.08) rotate(-2deg); } 100% { transform: scale(1.04); } }

.offline-dot {
  position: fixed;
  right: calc(var(--safe-r) + 10px);
  bottom: calc(var(--safe-b) + 10px);
  width: 10px; height: 10px; border-radius: 50%;
  background: #bbb;
  opacity: 0.6;
}
.offline-dot.ready { background: #2a9d8f; }

/* ---------- Game screen ---------- */
#game { background: #fff; }
.stage { position: absolute; inset: 0; overflow: hidden; }

/* Home button: hold ~1.2s to leave. A quick tap just wiggles. */
.home {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: calc(var(--safe-l) + 12px);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 100;
  opacity: 0.75;
}
.home svg { width: 100%; height: 100%; display: block; }
.home .ring-bg { fill: none; stroke: rgba(0,0,0,0.08); stroke-width: 6; }
.home .ring {
  fill: none; stroke: #ff8fab; stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 176; stroke-dashoffset: 176;
  transform: rotate(-90deg); transform-origin: 32px 32px;
}
.home .house { fill: #5a5f7a; }
.home.holding { opacity: 1; }
.home.holding .ring { stroke-dashoffset: 0; transition: stroke-dashoffset var(--hold, 1.2s) linear; }
.home.wiggle { animation: wiggle 0.4s ease; }
@keyframes wiggle { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

@media (prefers-reduced-motion: reduce) {
  .cloud, .title span { animation: none; }
}
