/* ============ Family Arcade — global styles ============ */
html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  background: #2b1b5e;
  font-family: -apple-system, "SF Pro Rounded", "Trebuchet MS", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; -webkit-user-select: none; user-select: none; touch-action: none; border: none; cursor: pointer; }
#app { position: fixed; inset: 0; width: 100%; height: 100%; }

/* Screens cross-fade with a gentle zoom for juicy transitions */
.screen {
  position: absolute; inset: 0; width: 100%; height: 100%;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}
.screen.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s;
}
.hidden { display: none !important; }
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ============ WHO'S PLAYING ============ */
#screen-who { background: linear-gradient(160deg, #7c4dff 0%, #b04dff 40%, #ff4d9d 75%, #ffb74d 100%); }
.who-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2.5vh; padding: 4vh 4vw; z-index: 2;
}
.app-title {
  margin: 0; font-size: clamp(28px, 6vw, 58px); font-weight: 900; color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,0.18), 0 10px 24px rgba(0,0,0,0.3);
  animation: title-bob 3s ease-in-out infinite;
}
@keyframes title-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.who-sub { margin: 0; font-size: clamp(18px, 3.4vw, 28px); font-weight: 700; color: rgba(255,255,255,0.92); }
.player-cards { display: flex; gap: 3.5vw; flex-wrap: wrap; justify-content: center; }
.player-card {
  width: clamp(180px, 32vw, 260px); min-height: 180px;
  border-radius: 30px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 10px 0 rgba(0,0,0,0.2), 0 18px 34px rgba(0,0,0,0.28);
  transition: transform 0.1s ease;
}
.player-card:active { transform: translateY(6px) scale(0.98); box-shadow: 0 4px 0 rgba(0,0,0,0.2), 0 8px 18px rgba(0,0,0,0.25); }
.player-charlotte { background: linear-gradient(160deg, #ab47ff, #6a1fd0); }
.player-harriet { background: linear-gradient(160deg, #ff9142, #e64a19); }
.player-icon { font-size: clamp(56px, 10vw, 92px); line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25)); }
.player-name { font-size: clamp(22px, 4vw, 34px); font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,0.2); }

/* floating decorations */
.float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.floaty { position: absolute; font-size: clamp(22px, 4vw, 40px); opacity: 0.75; animation: floaty 7s ease-in-out infinite; }
.f1 { left: 8%;  top: 16%; animation-delay: 0s; }
.f2 { left: 85%; top: 12%; animation-delay: -1.5s; }
.f3 { left: 14%; top: 74%; animation-delay: -3s; }
.f4 { left: 80%; top: 70%; animation-delay: -4.5s; }
.f5 { left: 46%; top: 8%;  animation-delay: -2.2s; }
.f6 { left: 55%; top: 84%; animation-delay: -5.5s; }
@keyframes floaty {
  0%,100% { transform: translateY(0) rotate(-6deg); }
  50%     { transform: translateY(-24px) rotate(6deg); }
}

/* ============ HUBS ============ */
.hub-charlotte { background: linear-gradient(160deg, #6a1fd0 0%, #ab47ff 45%, #ff7ac8 100%); }
.hub-harriet  { background: linear-gradient(160deg, #e64a19 0%, #ff9142 45%, #ffd54f 100%); }
.hub-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4vh; padding: 4vh 4vw;
}
.hub-title {
  margin: 0; font-size: clamp(24px, 5vw, 48px); font-weight: 900; color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,0.16), 0 8px 20px rgba(0,0,0,0.25);
  text-align: center;
}
.game-cards { display: flex; flex-direction: column; gap: 3vh; width: min(560px, 90vw); }
@media (orientation: landscape) {
  .game-cards { flex-direction: row; width: min(880px, 92vw); }
  .hub-title { font-size: clamp(22px, 4.6vh, 40px); }
}
.game-card {
  flex: 1 1 0; min-height: 150px; border-radius: 28px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 10px 0 rgba(0,0,0,0.18), 0 16px 30px rgba(0,0,0,0.25);
  transition: transform 0.1s ease;
}
.game-card:active { transform: translateY(6px) scale(0.98); box-shadow: 0 4px 0 rgba(0,0,0,0.18), 0 8px 16px rgba(0,0,0,0.25); }
.gc-blockworld { background: linear-gradient(160deg, #55c57a, #2f9e44); }
.gc-skyjump   { background: linear-gradient(160deg, #4d96ff, #1c6fd6); }
.gc-gokart    { background: linear-gradient(160deg, #ff5e57, #c81d25); }
.gc-bubblepop { background: linear-gradient(160deg, #4dd0e1, #1f7a8c); }
.game-icon { font-size: clamp(48px, 9vw, 80px); line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25)); }
.game-label { font-size: clamp(20px, 4vw, 32px); font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,0.2); }

.switch-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  min-height: 62px; padding: 8px 20px; border-radius: 20px;
  background: rgba(255,255,255,0.92); color: #333;
  font-size: 17px; font-weight: 800; z-index: 100;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
.switch-btn:active { transform: scale(0.95); }

/* ============ SHARED GAME UI ============ */
.home-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; border: 4px solid #ffd166; font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3); z-index: 1000; padding: 0;
}
.home-btn:active { transform: scale(0.92); }

.overlay {
  position: absolute; inset: 0; z-index: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; text-align: center; color: #fff;
}
.overlay h2 { margin: 0; font-size: clamp(24px, 6vw, 40px); text-shadow: 0 3px 0 rgba(0,0,0,0.2); }
.overlay p { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.4; }
.big-btn {
  min-width: 220px; min-height: 70px; border-radius: 20px;
  font-size: 21px; font-weight: 800; color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,0.2), 0 10px 18px rgba(0,0,0,0.25);
  transition: transform 0.08s ease;
}
.big-btn:active { transform: translateY(4px) scale(0.99); box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 5px 10px rgba(0,0,0,0.25); }
.diff-green { background: #2f9e44; }
.diff-amber { background: #f4a300; }
.diff-red   { background: #e63946; }
.diff-blue  { background: #457b9d; }
.best-list { font-size: 15px; font-weight: 700; margin-top: 4px; opacity: 0.92; }

.friendly-error {
  position: absolute; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #8ecdf5, #4d96ff);
}
.friendly-error-inner {
  background: #fff; border-radius: 24px; padding: 30px 24px; text-align: center;
  max-width: 80vw; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  font-size: 20px; font-weight: 700; color: #333;
}
.fe-emoji { font-size: 64px; }

#confetti-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 5000; display: none;
}

/* ============ BLOCK WORLD ============ */
#screen-blockworld { background: #8ecdf5; }
.crosshair {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  color: #fff; font-size: 26px; font-weight: 900; text-shadow: 0 0 4px rgba(0,0,0,0.6);
  pointer-events: none; z-index: 400;
}
.bw-mode-toggle {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px;
  min-height: 64px; padding: 8px 18px; border-radius: 20px; border: 4px solid #fff;
  font-size: 18px; font-weight: 800; color: #fff; background: #2f9e44; z-index: 900;
  transition: background 0.2s ease;
}
.bw-mode-toggle.mode-break { background: #e63946; }
.bw-reset-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  min-height: 60px; min-width: 150px; padding: 6px 14px; border-radius: 18px; border: 3px solid #fff;
  background: rgba(40,40,40,0.55); color: #fff; font-size: 14px; font-weight: 800; z-index: 900;
  overflow: hidden; text-align: center;
}
.bw-reset-btn span { position: relative; z-index: 2; }
.reset-fill { position: absolute; left: 0; bottom: 0; height: 100%; width: 0%; background: rgba(230,57,70,0.65); z-index: 1; }
.joystick {
  position: absolute; left: 20px; bottom: max(20px, env(safe-area-inset-bottom));
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255,255,255,0.28); border: 4px solid rgba(255,255,255,0.55);
  z-index: 500; touch-action: none;
}
.joystick-knob {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 70px; height: 70px; border-radius: 50%;
  background: rgba(255,255,255,0.9); box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  pointer-events: none;
}
.round-action-btn {
  position: absolute; right: 20px; bottom: max(20px, env(safe-area-inset-bottom));
  width: 100px; height: 100px; border-radius: 50%;
  background: #ffb703; border: 4px solid #fff; color: #fff;
  font-size: 15px; font-weight: 900; z-index: 500;
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}
.round-action-btn:active { transform: scale(0.92); }
.palette {
  position: absolute; top: 88px; left: 50%; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  width: min(300px, 90vw); z-index: 900;
}
.bw-swatch {
  width: 60px; height: 60px; border-radius: 14px; border: 4px solid rgba(255,255,255,0.7);
  box-shadow: 0 3px 6px rgba(0,0,0,0.3); padding: 0;
  transition: transform 0.12s ease;
}
.bw-swatch.selected { border-color: #fff; box-shadow: 0 0 0 4px #ffd166, 0 3px 6px rgba(0,0,0,0.4); transform: scale(1.08); }

/* ============ SKY JUMP ============ */
#screen-skyjump { background: #63b7f0; }
.sj-touch-zone { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 100; touch-action: none; }
.sj-overlay { background: linear-gradient(160deg, rgba(76,110,245,0.93), rgba(124,77,255,0.93)); }
#sj-hud {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  font-size: clamp(22px, 5vw, 32px); font-weight: 900; color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4); z-index: 700; pointer-events: none;
}

/* ============ GO-KART ============ */
#screen-gokart { background: #6ec6ff; }
.gk-overlay { background: linear-gradient(160deg, rgba(230,57,70,0.93), rgba(255,145,66,0.93)); }
.gk-results { background: linear-gradient(160deg, rgba(81,207,102,0.93), rgba(45,140,90,0.93)); }
#gk-hud {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  text-align: center; z-index: 700; pointer-events: none;
  color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
#gk-lap { font-size: clamp(18px, 4vw, 26px); font-weight: 900; }
#gk-timer { font-size: clamp(15px, 3vw, 20px); font-weight: 700; }
.gk-steer-zone {
  position: absolute; bottom: 0; top: 40%; width: 38%;
  z-index: 500; touch-action: none;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: max(26px, env(safe-area-inset-bottom));
}
.gk-steer-zone span {
  font-size: 44px; opacity: 0.55;
  background: rgba(255,255,255,0.25); border-radius: 50%;
  width: 84px; height: 84px; display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s ease, opacity 0.1s ease;
}
.gk-steer-zone.pressed span { transform: scale(1.15); opacity: 0.95; }

/* ============ BUBBLE POP ============ */
#screen-bubblepop { background: #103a4d; }
.bp-overlay { background: linear-gradient(160deg, rgba(77,208,225,0.93), rgba(31,122,140,0.93)); }
.bp-gameover { background: linear-gradient(160deg, rgba(255,146,43,0.93), rgba(230,57,70,0.93)); }
#bp-hud {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 90px;
  z-index: 700; pointer-events: none;
  color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  font-size: clamp(18px, 4vw, 26px); font-weight: 900;
}
