:root{
  --sky-1:#EAF8F5; --sky-2:#CDF0E7;
  --mint:#2DD4BF; --mint-dark:#159E8C;
  --coral:#FF6B6B; --coral-dark:#E14F4F;
  --sun:#FFC93D; --sun-dark:#E6A800;
  --navy:#1D3557; --navy-soft:#3E5C82;
  --white:#FFFFFF; --ink:#12233B;
  --shadow:0 8px 20px rgba(29,53,87,0.18);
  --r-lg:28px; --r-md:18px;
}
*{box-sizing:border-box;}
html,body{
  margin:0; padding:0; height:100%; overflow:hidden;
  font-family:'Nunito',sans-serif; color:var(--ink);
  background:radial-gradient(circle at 20% 10%, var(--sky-2), var(--sky-1) 60%);
  -webkit-tap-highlight-color:transparent; user-select:none;
}
h1,h2,h3{ font-family:'Baloo 2',cursive; margin:0; }
button{ font-family:'Baloo 2',cursive; cursor:pointer; border:none; }

#stage{
  position:relative; width:100vw; height:100vh; height:100dvh; overflow:hidden;
  background-image:url("assets/ui/background.png");
  background-size:cover; background-position:center;
}

#video{
  position:absolute; inset:0; width:100%; height:100%; object-fit:cover;
  transform:scaleX(-1); opacity:0; transition:opacity .5s ease; z-index:0;
}
body.cam-on #video{ opacity:1; }
#veil{
  position:absolute; inset:0; z-index:1; pointer-events:none;
  background:radial-gradient(circle at 50% 45%, rgba(234,248,245,0.42) 0%, rgba(234,248,245,0.72) 55%, var(--sky-1) 100%);
  transition:opacity .4s ease;
}
body.calibrating #veil{ opacity:0.30; }

#game-canvas{ position:absolute; inset:0; z-index:2; }
#fx-canvas{ position:absolute; inset:0; z-index:3; pointer-events:none; }

/* ---------- HUD ---------- */
#hud{
  position:absolute; top:0; left:0; right:0; z-index:8;
  display:none; align-items:center; justify-content:space-between;
  padding:12px 18px; gap:10px;
}
body.playing #hud{ display:flex; }
.chip{
  display:flex; align-items:center; gap:7px; background:var(--white);
  border-radius:999px; padding:7px 15px; box-shadow:0 3px 10px rgba(29,53,87,0.16);
  font-family:'Baloo 2',cursive; font-weight:800; font-size:19px; color:var(--navy);
}
#mute{ cursor:pointer; font-size:11px; letter-spacing:.7px; color:var(--navy-soft); }
.chip .ic{ font-size:11px; font-weight:800; letter-spacing:.7px; color:var(--navy-soft); }
.chip.lives{ gap:5px; padding:6px 13px; }
.chip.lives canvas{ display:block; }

#track-warn{
  position:absolute; left:50%; bottom:28px; transform:translateX(-50%); z-index:8;
  background:var(--coral); color:var(--white); border-radius:999px;
  padding:10px 22px; font-weight:800; font-size:15px; box-shadow:var(--shadow);
  opacity:0; transition:opacity .25s ease; pointer-events:none; white-space:nowrap;
}
#track-warn.show{ opacity:1; }

/* ---------- SCREENS ---------- */
.screen{
  position:absolute; inset:0; z-index:10;
  display:none; flex-direction:column; align-items:center; justify-content:center;
  padding:24px; text-align:center; gap:4px;
}
.screen.active{ display:flex; }

.hero{ line-height:0; display:flex; justify-content:center; filter:drop-shadow(0 10px 14px rgba(29,53,87,0.25)); animation:bob 2.6s ease-in-out infinite; }
@keyframes bob{ 0%,100%{transform:translateY(0) rotate(-3deg);} 50%{transform:translateY(-10px) rotate(3deg);} }
.spin{ animation:spin 1.4s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

.wordmark{ font-size:clamp(40px,9vw,68px); font-weight:800; color:var(--navy); text-shadow:3px 3px 0 var(--mint); margin:6px 0 0; }
#logo{ width:min(460px,80vw); height:auto; display:block; margin:4px 0 0; }
.tagline{ font-size:clamp(15px,3.2vw,19px); font-weight:700; color:var(--navy-soft); margin:4px 0 22px; }
.screen-title{ font-size:clamp(28px,6vw,38px); color:var(--navy); }
.screen-sub{ font-size:clamp(15px,3vw,18px); font-weight:700; color:var(--navy-soft); margin:6px 0 18px; }
.privacy{ font-size:12.5px; font-weight:700; color:var(--navy-soft); max-width:340px; line-height:1.5; margin-top:18px; }

.btn{ padding:15px 34px; border-radius:999px; font-size:20px; font-weight:700; box-shadow:var(--shadow); transition:transform .12s ease; }
.btn:active{ transform:scale(0.96); }
.btn:disabled{ opacity:0.45; cursor:not-allowed; box-shadow:none; }
.btn-primary{ background:linear-gradient(180deg,var(--mint),var(--mint-dark)); color:var(--white); }
.btn-secondary{ background:var(--white); color:var(--navy); border:2px solid var(--sky-2); }
.btn-ghost{ background:transparent; color:var(--navy-soft); font-weight:700; font-size:15px; text-decoration:underline; padding:10px; }
.mode-stack{ display:flex; flex-direction:column; gap:11px; align-items:center; }
.actions{ display:flex; flex-direction:column; align-items:center; gap:6px; margin-top:18px; }

.panel{
  width:min(440px,92vw); background:rgba(255,255,255,0.96);
  border-radius:var(--r-lg); padding:16px 20px; box-shadow:var(--shadow);
  backdrop-filter:blur(6px);
}
.status{ display:flex; align-items:center; gap:10px; font-weight:800; font-size:15px; color:var(--navy-soft); }
.status .dot{ width:11px; height:11px; border-radius:50%; background:var(--sun); flex:0 0 auto; box-shadow:0 0 0 4px rgba(255,201,61,0.25); }
.status.ok .dot{ background:var(--mint); box-shadow:0 0 0 4px rgba(45,212,191,0.25); }
.status.bad .dot{ background:var(--coral); box-shadow:0 0 0 4px rgba(255,107,107,0.25); }
.cal-row{ margin-top:14px; }
.cal-row label{ display:flex; justify-content:space-between; font-weight:800; font-size:13.5px; color:var(--navy); margin-bottom:7px; }
.cal-row label span{ color:var(--mint-dark); }
.cal-row input[type=range]{ width:100%; -webkit-appearance:none; appearance:none; height:8px; border-radius:999px; background:var(--sky-2); outline:none; }
.cal-row input[type=range]::-webkit-slider-thumb{ -webkit-appearance:none; appearance:none; width:24px; height:24px; border-radius:50%; background:var(--mint); border:3px solid var(--white); box-shadow:0 2px 6px rgba(29,53,87,0.3); cursor:pointer; }
.cal-hint{ font-size:13px; line-height:1.5; color:var(--navy-soft); font-weight:600; margin:9px 0 0; }
.cal-hint b{ color:var(--mint-dark); }
.cycle-row{ display:flex; align-items:center; gap:9px; margin-top:13px; font-weight:800; font-size:14px; color:var(--navy); cursor:pointer; }
.cycle-row input{ width:19px; height:19px; accent-color:var(--mint); cursor:pointer; }
.swatch-row{ display:flex; align-items:center; justify-content:space-between; margin-top:14px; font-weight:800; font-size:14px; color:var(--navy); }
.swatch{ width:44px; height:26px; border-radius:999px; border:3px solid var(--white); box-shadow:0 2px 8px rgba(29,53,87,0.3); }

/* aiming circle for wand calibration.
   The panel used to sit in the middle of the screen, directly on top of the
   circle the player is asked to hold their marker in. The controls are now
   docked at the bottom and the circle is left completely clear. */
#screen-wand{ justify-content:flex-start; padding-top:22px; padding-bottom:18px; }
#screen-wand .panel{ margin-top:auto; }
#screen-wand .actions{ margin-top:12px; }

#cal-target{
  position:absolute; left:0; right:0; top:16%; height:46%;
  display:flex; align-items:center; justify-content:center;
  pointer-events:none; z-index:-1;
}
.cal-ring{
  width:min(260px,44vw); aspect-ratio:1; border-radius:50%;
  border:5px dashed rgba(21,158,140,0.9);
  box-shadow:0 0 0 9999px rgba(234,248,245,0.45),
             inset 0 0 0 3px rgba(255,255,255,0.5);
}

/* ---------- RULES ---------- */
.rules-grid{ display:flex; gap:18px; flex-wrap:wrap; justify-content:center; width:min(980px,96vw); margin-top:10px; }
.rule-col{ flex:1 1 300px; background:var(--white); border-radius:var(--r-lg); padding:16px 14px; box-shadow:var(--shadow); border-top:7px solid var(--mint); }
.rule-col.bad{ border-top-color:var(--coral); }
.rule-head{ font-family:'Baloo 2',cursive; font-weight:800; font-size:19px; color:var(--mint-dark); margin-bottom:12px; }
.rule-col.bad .rule-head{ color:var(--coral-dark); }
.rule-items{ display:flex; flex-wrap:wrap; gap:9px; justify-content:center; }
.rule-item{ width:96px; display:flex; flex-direction:column; align-items:center; gap:3px; }
.rule-item .em{ line-height:0; display:flex; justify-content:center; }
.rule-item .lb{ font-size:11.5px; font-weight:800; color:var(--navy-soft); line-height:1.25; }
.rule-note{ font-size:14px; font-weight:700; color:var(--navy-soft); margin-top:16px; }

/* ---------- SCORECARD ---------- */
.card{ width:min(520px,94vw); background:var(--white); border-radius:var(--r-lg); padding:22px; box-shadow:var(--shadow); max-height:92vh; overflow:auto; }
.card-tooth{ line-height:0; display:flex; justify-content:center; }
.stat-grid{ display:flex; gap:10px; justify-content:center; margin:16px 0; }
.stat{ flex:1; background:var(--sky-1); border-radius:var(--r-md); padding:12px 6px; }
.stat-num{ font-family:'Baloo 2',cursive; font-size:28px; font-weight:800; color:var(--navy); }
.stat-lbl{ font-size:11.5px; font-weight:800; color:var(--navy-soft); text-transform:uppercase; letter-spacing:.4px; }
.cat-row{ display:flex; align-items:center; gap:12px; padding:11px 4px; border-top:1px solid var(--sky-2); text-align:left; }
.cat-name{ flex:1; font-weight:800; font-size:15px; color:var(--navy); }
.cat-score{ font-family:'Baloo 2',cursive; font-weight:800; font-size:17px; color:var(--mint-dark); }
.cat-stars{ display:flex; gap:2px; align-items:center; }
.cat-stars canvas{ display:block; }
.cat-row canvas{ display:block; flex:0 0 auto; }
.palm-hint{ display:none; margin-top:14px; font-size:13.5px; font-weight:800; color:var(--mint-dark); }
.palm-hint.show{ display:block; }
.palm-bar{ height:7px; border-radius:999px; background:var(--sky-2); margin-top:7px; overflow:hidden; }
.palm-bar div{ height:100%; width:0; background:var(--mint); border-radius:999px; transition:width .1s linear; }
.tip{ background:var(--sky-1); border-radius:var(--r-md); padding:13px 15px; font-size:14px; font-weight:700; color:var(--navy); line-height:1.5; margin-top:14px; }

@media (max-width:600px){
  .rule-item{ width:78px; }
}
