@font-face {
  font-family: 'Luckiest Guy';
  src: url('../assets/fonts/LuckiestGuy-Regular.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #2a2140;
  --ink-soft: #6c6485;
  --cream: #fffaf0;
  --gold: #ffc53a;
  --orange: #ff8a1f;
  --orange-d: #c85f12;
  --green: #3cbf5c;
  --red: #ef4a4a;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --disp: 'Luckiest Guy', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --hud-scale: 1;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #5ec2fb;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
  font-family: var(--disp); color: var(--ink);
}
body { position: fixed; inset: 0; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font-family: var(--disp); -webkit-user-select: none; user-select: none; touch-action: manipulation; }

/* when the host pauses us, freeze every CSS animation as well */
html.frozen *, html.frozen *::before, html.frozen *::after { animation-play-state: paused !important; transition: none !important; }

/* ---------- HUD (top-left; the top-right corner belongs to the host mute button) ---------- */
#hud {
  position: fixed; z-index: 5; display: flex; align-items: center; gap: 6px;
  top: calc(var(--sat) + 10px); left: calc(var(--sal) + 10px);
  transform: scale(var(--hud-scale)); transform-origin: top left;
  pointer-events: none; opacity: 0; transition: opacity .25s;
}
#hud.show { opacity: 1; }
.hbtn {
  pointer-events: auto; width: 44px; height: 44px; border: 0; border-radius: 14px; padding: 0;
  background: rgba(255, 250, 240, .95); box-shadow: 0 4px 0 rgba(30, 20, 50, .25); cursor: pointer;
  display: grid; place-items: center;
}
.hbtn svg { width: 22px; height: 22px; fill: var(--ink); }
.hbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(30, 20, 50, .25); }
.chip {
  height: 48px; border-radius: 16px; background: rgba(255, 250, 240, .95); box-shadow: 0 4px 0 rgba(30, 20, 50, .22);
  display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 10px; min-width: 62px;
}
.chip small { font-size: 10px; letter-spacing: 1.5px; color: var(--ink-soft); line-height: 1; margin-top: 3px; }
.chip b { font-size: 24px; line-height: 1; font-weight: 400; margin-top: 2px; }
.chip b i { font-style: normal; font-size: 14px; color: var(--ink-soft); }
#chipStars { flex-direction: row; gap: 5px; min-width: 58px; }
#chipStars .star { width: 22px; height: 22px; fill: var(--gold); stroke: #b47e0c; stroke-width: 1.2; }
#chipStars b { margin-top: 5px; }
#dial { position: relative; width: 58px; height: 58px; border-radius: 50%; background: rgba(255, 250, 240, .97); box-shadow: 0 4px 0 rgba(30, 20, 50, .22); }
#dialRing { position: absolute; inset: 0; width: 100%; height: 100%; }
.dial-core { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dial-core b { font-size: 22px; line-height: 1; font-weight: 400; margin-top: 4px; transition: transform .15s; }
.dial-core b.bump { transform: scale(1.3); }
.dial-core small { font-size: 8.5px; letter-spacing: 1px; color: var(--ink-soft); line-height: 1; }

/* ---------- transient text ---------- */
#banner {
  position: fixed; z-index: 6; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(.9); opacity: 0;
  display: flex; flex-direction: column; align-items: center; text-align: center; pointer-events: none;
  color: #fff; text-shadow: 0 3px 0 rgba(20, 10, 40, .45); transition: opacity .3s, transform .3s; white-space: nowrap;
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner small { font-size: 16px; letter-spacing: 3px; margin-bottom: 6px; }
#banner b { font-size: clamp(34px, 9vw, 60px); font-weight: 400; line-height: 1.05; }
#banner span { font-size: 20px; letter-spacing: 2px; background: rgba(20, 10, 40, .35); border-radius: 12px; padding: 5px 12px 2px; margin-top: 4px; text-shadow: none; }
#banner em { font-style: normal; font-size: 13px; letter-spacing: 3px; margin-top: 14px; opacity: .85; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .35; } }

#shout {
  position: fixed; z-index: 6; left: 50%; top: 30%; transform: translate(-50%, -50%); pointer-events: none;
  font-size: clamp(40px, 11vw, 76px); color: var(--gold); white-space: nowrap;
  text-shadow: 0 4px 0 #b3560f, 0 8px 18px rgba(0, 0, 0, .25); opacity: 0;
}
#shout.show { animation: shout 1.5s ease-out forwards; }
@keyframes shout { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-8deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(3deg); } 30% { transform: translate(-50%, -50%) scale(1) rotate(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }

#tip, #coach {
  position: fixed; z-index: 6; left: 50%; top: calc(var(--hud-bottom, 80px) + 4px); transform: translateX(-50%) translateY(-12px);
  width: max-content; max-width: min(90vw, 460px); padding: 10px 16px 7px; border-radius: 16px; text-align: center; pointer-events: none;
  background: rgba(42, 33, 64, .86); color: #fff; font-size: 15px; letter-spacing: .5px; line-height: 1.25;
  opacity: 0; transition: opacity .25s, transform .25s;
}
#tip.show, #coach.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#coach { background: rgba(255, 138, 31, .95); box-shadow: 0 4px 0 var(--orange-d); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 64px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  background: rgba(30, 22, 52, .45); overflow: hidden;
}
.screen.show { display: flex; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#title { background: linear-gradient(180deg, rgba(40, 90, 150, .15), rgba(30, 22, 52, .55)); }

.card {
  width: min(92vw, 400px); max-height: 100%; overflow: hidden; background: var(--cream); border-radius: 26px; padding: 22px 20px 20px;
  box-shadow: 0 8px 0 rgba(30, 20, 50, .3), 0 18px 40px rgba(0, 0, 0, .25); text-align: center; animation: pop .32s cubic-bezier(.2, 1.4, .4, 1);
}
.card.wide { width: min(94vw, 520px); }
.card.narrow { width: min(86vw, 300px); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.card h2 { margin: 0; font-size: clamp(32px, 9vw, 46px); font-weight: 400; line-height: 1; color: var(--orange); text-shadow: 0 3px 0 rgba(200, 95, 18, .25); }
.card h2.bad { color: var(--red); }
.card h2.gold { color: #f0a800; }
.sub { margin: 8px 0 0; font-size: 15px; letter-spacing: 1.5px; color: var(--ink-soft); }
.stars3 { display: flex; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.stars3 i {
  width: 58px; height: 58px; display: block; opacity: 0; transform: scale(0);
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.6l2.9 6 6.6.8-4.9 4.6 1.3 6.5L12 17.3l-5.9 3.2 1.3-6.5L2.5 9.4l6.6-.8z' fill='%23e4dccb' stroke='%23c9bfa9' stroke-width='1'/%3E%3C/svg%3E");
}
.stars3 i:nth-child(2) { transform: scale(0) translateY(-8px); width: 66px; height: 66px; margin-top: -8px; }
.stars3 i.on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.6l2.9 6 6.6.8-4.9 4.6 1.3 6.5L12 17.3l-5.9 3.2 1.3-6.5L2.5 9.4l6.6-.8z' fill='%23ffc53a' stroke='%23b47e0c' stroke-width='1.1'/%3E%3C/svg%3E"); }
.stars3 i.pop { animation: starpop .38s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes starpop { from { opacity: 0; transform: scale(0) rotate(-30deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.stats { display: flex; gap: 8px; justify-content: center; margin: 10px 0 16px; }
.stats div { flex: 1; max-width: 104px; background: #f1e9d8; border-radius: 14px; padding: 8px 4px 5px; }
.stats small { display: block; font-size: 11px; letter-spacing: 1.5px; color: var(--ink-soft); }
.stats b { display: block; font-size: 26px; font-weight: 400; line-height: 1.1; }
#resBest { color: #f0a800; font-family: system-ui, sans-serif; font-weight: 700; font-size: 22px; line-height: 1.3; letter-spacing: 1px; }
.row { display: flex; gap: 10px; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn {
  border: 0; border-radius: 18px; padding: 14px 18px 10px; font-size: 20px; letter-spacing: 1px; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, #ffb52e, var(--orange)); box-shadow: 0 5px 0 var(--orange-d); min-width: 124px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--orange-d); }
.btn:disabled { opacity: .6; }
.btn.alt { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #cfc3aa; }
.btn.alt:active { box-shadow: 0 2px 0 #cfc3aa; }
.btn.big { font-size: 26px; padding: 16px 30px 12px; min-width: 230px; }
.btn.small { font-size: 14px; padding: 9px 12px 6px; min-width: 0; border-radius: 12px; }
.btn.ghost { background: rgba(255, 255, 255, .22); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.btn:focus-visible, .hbtn:focus-visible, .tile:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* title */
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(94vw, 460px); }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .86; transform: rotate(-3deg); }
.logo .l1 { font-size: clamp(54px, 17vw, 92px); color: #fff; text-shadow: 0 5px 0 #2a6fb0, 0 10px 22px rgba(0, 0, 0, .2); }
.logo .l2 { font-size: clamp(64px, 21vw, 112px); color: var(--gold); text-shadow: 0 6px 0 #b3560f, 0 12px 24px rgba(0, 0, 0, .2); }
.tag { margin: 0; color: #fff; font-size: 17px; letter-spacing: 1.5px; text-shadow: 0 2px 0 rgba(20, 10, 40, .35); }
.course { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; width: 100%; }
.tile {
  border: 0; border-radius: 12px; background: rgba(255, 250, 240, .95); box-shadow: 0 3px 0 rgba(30, 20, 50, .25);
  padding: 6px 0 4px; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; align-items: center;
}
.tile b { font-size: 20px; font-weight: 400; line-height: 1; }
.tile span { font-size: 10px; letter-spacing: 1px; color: #e0a400; line-height: 1.2; font-family: system-ui, sans-serif; }
.tile.locked { background: rgba(255, 255, 255, .35); color: rgba(42, 33, 64, .5); cursor: default; box-shadow: none; }
.tile.next { outline: 3px solid var(--orange); }
.title-foot { display: flex; gap: 10px; align-items: center; }
.pill { background: rgba(42, 33, 64, .6); color: #fff; border-radius: 12px; padding: 8px 12px 5px; font-size: 16px; letter-spacing: 1px; }

/* course complete */
.big-stars { margin: 10px 0 8px; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.big-stars b { font-size: 64px; font-weight: 400; color: #f0a800; line-height: 1; }
.big-stars small { font-size: 18px; color: var(--ink-soft); letter-spacing: 1px; }
.scorecard { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 16px; }
.scorecard div { background: #f1e9d8; border-radius: 10px; padding: 5px 0 3px; }
.scorecard b { display: block; font-size: 15px; font-weight: 400; }
.scorecard span { display: block; font-size: 11px; color: #e0a400; font-family: system-ui, sans-serif; letter-spacing: 1px; }

/* short landscape screens (phones on their side) */
@media (orientation: landscape) and (max-height: 520px) {
  .screen { padding-top: calc(var(--sat) + 12px); padding-bottom: calc(var(--sab) + 10px); }
  #title .title-wrap { width: min(80vw, 640px); display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'logo course' 'tag course' 'play foot'; column-gap: 26px; row-gap: 8px; align-items: center; }
  #title .logo { grid-area: logo; } #title .tag { grid-area: tag; font-size: 14px; }
  #title #btnPlay { grid-area: play; min-width: 200px; } #title .course { grid-area: course; grid-template-columns: repeat(4, 1fr); }
  #title .title-foot { grid-area: foot; justify-content: center; }
  .logo .l1 { font-size: 54px; } .logo .l2 { font-size: 66px; }
  .card { padding: 14px 18px 14px; width: min(70vw, 420px); }
  .card h2 { font-size: 34px; }
  .stars3 { margin: 6px 0 2px; } .stars3 i { width: 44px; height: 44px; } .stars3 i:nth-child(2) { width: 50px; height: 50px; }
  .stats { margin: 6px 0 10px; } .stats b { font-size: 22px; }
  .big-stars { margin: 4px 0; } .big-stars b { font-size: 44px; }
  .scorecard { grid-template-columns: repeat(12, 1fr); margin-bottom: 10px; }
  .btn { padding: 11px 16px 8px; font-size: 18px; }
  .stack { gap: 7px; margin-top: 10px; }
  #banner { top: 42%; }
}
@media (min-width: 700px) and (min-height: 700px) {
  .title-wrap { width: min(80vw, 580px); gap: 18px; }
  .logo .l1 { font-size: 118px; } .logo .l2 { font-size: 144px; }
  .tag { font-size: 21px; }
  .btn.big { font-size: 30px; min-width: 300px; }
  .course { gap: 10px; } .tile { padding: 10px 0 7px; border-radius: 14px; } .tile b { font-size: 28px; } .tile span { font-size: 13px; }
  .pill { font-size: 19px; } .btn.small { font-size: 16px; }
  .card { width: min(80vw, 460px); padding: 28px 26px 24px; }
  .card.wide { width: min(86vw, 600px); }
}
