@font-face { font-family: "Luckiest Guy"; src: url("fonts/luckiest-guy.woff2") format("woff2"); font-display: block; }
:root {
  --night: #170F38; --dusk: #2B1A5E; --plum: #2A1650; --ink: #FFF4D6;
  --gold: #FFC93C; --gold-hi: #FFF1A8; --gold-lo: #A8620E;
  --red: #E0304F; --red-lip: #9E1F3A; --blue: #3B8FEA; --blue-lip: #1F4F9A;
  --display: "Luckiest Guy", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --gold-grad: linear-gradient(#FFF1A8, #FFC93C 45%, #E09A1C 55%, #A8620E);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
#safe { position: fixed; top: var(--sat); bottom: var(--sab); left: var(--sal); right: var(--sar); pointer-events: none; visibility: hidden; }
.hidden { display: none !important; }

/* ---------- buttons: glossy, with a lip and a light sweep ---------- */
button { font-family: var(--display); border: 0; cursor: pointer; color: #fff; touch-action: manipulation; letter-spacing: 0.5px; }
button:active { transform: translateY(3px); }
.big { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 74px; padding: 10px 18px; margin: 8px 0 14px; border-radius: 24px;
  border: 3px solid #FFE38A; }
.big::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent); transform: skewX(-20deg); animation: sweep 3.2s ease-in-out infinite; }
.big.coral { background: linear-gradient(#FF7A8A, #E0304F 60%, #C21E40); box-shadow: 0 6px 0 var(--red-lip), 0 12px 30px rgba(224,48,79,0.45), inset 0 3px 0 rgba(255,255,255,0.35); }
.big.blue { background: linear-gradient(#6FB6FF, #3B8FEA 60%, #2A6FC9); box-shadow: 0 6px 0 var(--blue-lip), 0 12px 26px rgba(59,143,234,0.35), inset 0 3px 0 rgba(255,255,255,0.35); min-height: 62px; }
.big.blue::after { animation-delay: 1.6s; }
.big.gold { color: #3A1204; background: linear-gradient(#FFF1A8, #FFC93C 50%, #E09A1C); box-shadow: 0 6px 0 #7A4508, 0 12px 30px rgba(255,201,60,0.5), inset 0 3px 0 rgba(255,255,255,0.6); border-color: #FFF6C8; animation: glowpulse 1.2s ease-in-out infinite alternate; }
.big.gold .b1 { text-shadow: 0 2px 0 rgba(255,255,255,0.6); }
.big:active { box-shadow: 0 2px 0 var(--red-lip); }
.b-txt { display: flex; flex-direction: column; align-items: flex-start; }
.big .b1 { font-size: 30px; line-height: 1; text-shadow: 0 3px 0 rgba(90,10,30,0.55); }
.big.blue .b1 { font-size: 22px; text-shadow: 0 3px 0 rgba(10,30,90,0.5); }
.big .b2 { font-family: var(--font); font-size: 13px; font-weight: 800; opacity: 0.95; margin-top: 3px; letter-spacing: 0; }
.big canvas { width: 58px; height: 58px; flex: none; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.25)); }
.mid { flex: 1; padding: 12px 8px; margin: 5px 0; border-radius: 16px; font-size: 16px; color: var(--gold);
  background: linear-gradient(#34226E, #221450); border: 2px solid rgba(255,201,60,0.55); box-shadow: 0 4px 0 #120828; }
.mid.small { flex: none; padding: 9px 14px; font-size: 14px; }
.mid.wide { width: 100%; }
.row { display: flex; gap: 10px; width: 100%; }

/* ---------- screens: the porch at night ---------- */
.screen { position: fixed; inset: 0; z-index: 10; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: calc(var(--sat) + 10px) 18px calc(var(--sab) + 14px);
  background:
    radial-gradient(1.5px 1.5px at 12% 8%, #FFF6D8 50%, transparent 51%), radial-gradient(1px 1px at 72% 14%, #FFF6D8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 4%, #FFF6D8 50%, transparent 51%), radial-gradient(1px 1px at 88% 30%, #FFF6D8 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 26%, #FFF6D8 50%, transparent 51%), radial-gradient(1.5px 1.5px at 60% 22%, #FFF6D8 50%, transparent 51%),
    radial-gradient(120% 60% at 50% 105%, #E0607A 0%, rgba(224,96,122,0) 60%),
    linear-gradient(#0E0A2C, #2B1A5E 55%, #5A2A72); }
.wrap { width: 100%; max-width: 390px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
#title .wrap { min-height: 100%; justify-content: center; }
#title.first .more { display: none; }
.more { width: 100%; }

/* the logo sits on a marquee sign */
.sign { position: relative; width: 100%; padding: 18px 10px 20px; margin: 4px 0 10px; border-radius: 28px; background: var(--gold-grad); box-shadow: 0 8px 0 #5A300A, 0 18px 40px rgba(255,160,60,0.3); }
.sign::before { content: ''; position: absolute; inset: 8px; border-radius: 20px; background: radial-gradient(circle at 50% 30%, #3A2378, #1B0F3C 75%); }
.sign .bulbs { position: absolute; inset: 3px; border-radius: 25px; pointer-events: none;
  background:
    radial-gradient(circle, #FFF7C8 2.2px, rgba(255,230,140,0.55) 3.4px, transparent 6px) 0 0 / 22px 22px repeat-x,
    radial-gradient(circle, #FFF7C8 2.2px, rgba(255,230,140,0.55) 3.4px, transparent 6px) 11px 100% / 22px 22px repeat-x;
  animation: chase 0.6s steps(2) infinite; }
.sign > * { position: relative; }
#logo-art { display: block; width: 300px; height: 92px; margin: 0 auto; }
.logo { margin: -2px 0 0; font-family: var(--display); font-weight: 400; line-height: 0.95; text-align: center; letter-spacing: 1px;
  filter: drop-shadow(0 4px 0 #7A1E4A) drop-shadow(0 0 16px rgba(255,190,80,0.45)); }
.logo span { display: block; -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo .l1 { font-size: 66px; background-image: linear-gradient(#FFF6C0, #FFC93C 50%, #FF8A3D); transform: rotate(-4deg) translateX(-26px); }
.logo .l2 { font-size: 60px; background-image: linear-gradient(#FFD1E8, #FF5FA2 55%, #D6246E); transform: rotate(3deg) translateX(30px); margin-top: -6px; }
.tag { margin: 10px 0 6px; font-size: 15px; font-weight: 800; text-align: center; color: #FFE9B8; }
.foot { font-size: 11px; opacity: 0.45; margin-top: 8px; text-align: center; }

.card { width: 100%; background: linear-gradient(#2E1C66, #1E1248); border: 2px solid rgba(255,201,60,0.45); border-radius: 18px; box-shadow: 0 5px 0 #0C0620; padding: 12px 14px; margin: 8px 0; }
.card-h { font-family: var(--display); font-size: 15px; color: var(--gold); margin-bottom: 4px; letter-spacing: 0.5px; }
#missions, .res-missions { list-style: none; margin: 0; padding: 0; width: 100%; }
#missions li, .res-missions li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; font-weight: 800; }
#missions li + li { border-top: 1px solid rgba(255,244,214,0.1); }
.m-txt { flex: 1; }
.m-prog { font-family: var(--display); font-size: 14px; color: var(--gold); white-space: nowrap; letter-spacing: 0.5px; }
.m-done .m-txt { text-decoration: line-through; opacity: 0.5; }
.m-done .m-prog { color: #6BE3A0; }
.tick { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid rgba(255,201,60,0.5); display: grid; place-items: center; font-size: 13px; color: #1B0F3C; font-weight: 900; }
.m-done .tick, .res-missions .done .tick { background: #6BE3A0; border-color: #6BE3A0; }

.level-bar, .res-pal { width: 100%; display: flex; align-items: center; gap: 12px; background: linear-gradient(#2E1C66, #1E1248); border: 2px solid rgba(255,201,60,0.45); border-radius: 18px; padding: 8px 14px; margin: 6px 0; box-shadow: 0 5px 0 #0C0620; }
.level-bar canvas, .res-pal canvas { width: 50px; height: 50px; flex: none; }
.lb-txt { flex: 1; min-width: 0; }
.lb-top { font-family: var(--display); font-size: 16px; color: #FFF4D6; letter-spacing: 0.5px; }
.lb-sub { font-size: 12px; font-weight: 700; opacity: 0.7; margin-top: 3px; }
.bar { height: 14px; border-radius: 7px; background: #120828; border: 2px solid rgba(255,201,60,0.5); overflow: hidden; margin-top: 4px; }
.bar.wide { width: 100%; }
.bar i { display: block; height: 100%; width: 0; border-radius: 5px; background: repeating-linear-gradient(115deg, rgba(255,255,255,0.28) 0 8px, transparent 8px 16px), linear-gradient(90deg, #FF4D8D, #FFC93C);
  background-size: 32px 100%, 100% 100%; animation: stripes 0.8s linear infinite; transition: width 1s cubic-bezier(.2,.8,.2,1); }

.head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
.head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 28px; color: var(--gold); text-shadow: 0 3px 0 #7A1E4A; }
.spacer { width: 64px; }
.sub { font-size: 14px; font-weight: 700; opacity: 0.85; text-align: center; margin: 6px 0 12px; line-height: 1.35; }
.pal-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; }
.pal-group { grid-column: 1 / -1; font-family: var(--display); font-size: 15px; color: var(--gold); margin: 10px 0 0; text-transform: uppercase; }
.pal-card { position: relative; min-width: 0; background: radial-gradient(circle at 50% 35%, #3E2A86, #1E1248 70%); border: 2px solid rgba(255,201,60,0.45); border-radius: 18px; box-shadow: 0 5px 0 #0C0620; padding: 8px 6px 10px; display: flex; flex-direction: column; align-items: center; color: var(--ink); }
.pal-card.on { border-color: #FFE38A; box-shadow: 0 5px 0 #0C0620, 0 0 22px rgba(255,201,60,0.55); }
.pal-card.on::after { content: 'PLAYING'; position: absolute; top: 4px; right: 4px; font-size: 8px; color: #fff; background: var(--red); padding: 2px 6px; border-radius: 8px; }
.pal-card canvas { width: 62px; height: 62px; }
.pal-card .newtag { position: absolute; top: 4px; left: 4px; font-size: 9px; color: #3A1204; background: var(--gold-grad); padding: 2px 5px; border-radius: 6px; }
.pal-card.weekly { border-color: #FF8AC0; }
.pal-card .pn { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-card .pl { font-family: var(--font); font-size: 11px; font-weight: 800; opacity: 0.7; letter-spacing: 0; }
.pal-card.locked .pn { opacity: 0.5; }
.pal-card .bar { width: 80%; height: 8px; border-width: 1px; }

/* ---------- sheets: a marquee card ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(8,4,24,0.55);
  padding: calc(var(--sat) + 10px) 14px calc(var(--sab) + 10px); animation: fade 0.18s ease-out; }
#unlock { z-index: 25; }
.sheet { position: relative; width: 100%; max-width: 370px; max-height: 100%; overflow-y: auto; border-radius: 28px; padding: 22px 18px 16px;
  background: radial-gradient(circle at 50% 0%, #3A2378, #1B0F3C 70%); border: 4px solid transparent;
  background-clip: padding-box; box-shadow: 0 0 0 4px #FFC93C, 0 0 0 7px #A8620E, 0 10px 0 7px #4A2508, 0 24px 50px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; align-items: center; animation: pop-in 0.26s cubic-bezier(.2,1.5,.4,1); }
.sheet.mega::before { content: ''; position: absolute; left: 50%; top: 90px; width: 560px; height: 560px; margin: -280px 0 0 -280px; pointer-events: none; opacity: 0.22;
  background: repeating-conic-gradient(#FFE680 0 9deg, transparent 9deg 22.5deg); animation: spin 8s linear infinite; }
.sheet > * { position: relative; }
.sheet h2 { margin: 4px 0 8px; font-family: var(--display); font-weight: 400; font-size: 30px; color: var(--gold); text-shadow: 0 3px 0 #7A1E4A; }
.kicker { font-family: var(--display); font-size: 18px; letter-spacing: 1px; color: #FF8AC0; }
.score-big { font-family: var(--display); font-size: 62px; line-height: 1; margin: 6px 0 2px; font-variant-numeric: tabular-nums;
  background: linear-gradient(#FFF6C0, #FFC93C 50%, #E0801C); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #5A1E4A); }
.score-big.landed { animation: thump 0.35s cubic-bezier(.2,1.8,.4,1); }
.badge { font-family: var(--display); font-size: 20px; letter-spacing: 1px; padding: 6px 18px 4px; border-radius: 999px; color: #3A1204;
  background: var(--gold-grad); box-shadow: 0 4px 0 #7A4508, 0 0 20px rgba(255,201,60,0.5); animation: wobble 0.6s ease-in-out infinite alternate; }
.badge.mega { font-size: 24px; background: linear-gradient(#FFD1E8, #FF5FA2 55%, #D6246E); color: #fff; text-shadow: 0 2px 0 #7A1E4A; box-shadow: 0 4px 0 #7A1E4A, 0 0 26px rgba(255,95,162,0.7); }
.near { font-size: 14px; font-weight: 800; margin: 8px 0 2px; text-align: center; color: #9FD0FF; min-height: 1px; }
.rank { font-size: 13px; font-weight: 800; opacity: 0.8; margin: 6px 0 0; text-align: center; color: var(--gold); }
.res-missions { margin: 6px 0; }
.res-missions li { padding: 3px 0; font-size: 13px; }
.res-missions .done { color: #6BE3A0; }
.res-missions .done .m-prog { color: #6BE3A0; }
#pd-art, #un-art { width: 150px; height: 150px; filter: drop-shadow(0 0 24px rgba(255,201,60,0.45)); }
.pd-lv { font-size: 14px; font-weight: 800; opacity: 0.8; }
.pd-power { background: #120828; border: 2px solid rgba(255,201,60,0.4); border-radius: 16px; padding: 10px 14px; margin: 12px 0 4px; width: 100%; text-align: center; }
.pd-power b { display: block; font-family: var(--display); font-weight: 400; font-size: 20px; color: #FF8AC0; letter-spacing: 0.5px; }
.pd-power span { font-size: 14px; font-weight: 700; }
.unlock::before { content: ''; position: absolute; left: 50%; top: 120px; width: 600px; height: 600px; margin: -300px 0 0 -300px; pointer-events: none; opacity: 0.25;
  background: repeating-conic-gradient(#FFE680 0 9deg, transparent 9deg 22.5deg); animation: spin 8s linear infinite; }
#reel { width: 310px; height: 140px; margin: 6px 0; }
.box-reveal { display: flex; flex-direction: column; align-items: center; width: 100%; animation: pop-in 0.3s cubic-bezier(.2,1.6,.4,1); }
.week-card { display: flex; align-items: center; gap: 12px; text-align: left; color: var(--ink); font-family: var(--font); letter-spacing: 0; }
.week-card canvas { width: 56px; height: 56px; flex: none; }
.wk-txt { display: flex; flex-direction: column; }
.wk-name { font-family: var(--display); font-size: 20px; color: #FF8AC0; }
.how { font-size: 13px; font-weight: 700; line-height: 1.4; margin-top: 10px; opacity: 0.9; }
.how div { margin: 5px 0; }
.how b { color: var(--gold); }

input { font-family: var(--font); font-size: 18px; font-weight: 800; width: 100%; padding: 12px 14px; margin: 5px 0; border-radius: 14px; border: 2px solid rgba(255,201,60,0.5); background: #120828; color: var(--ink); user-select: text; -webkit-user-select: text; }
.err { color: #FF8A94; font-size: 13px; font-weight: 800; min-height: 16px; margin: 4px 0; text-align: center; }
.hint { font-size: 13px; font-weight: 700; opacity: 0.7; text-align: center; list-style: none; }
.tabs { display: flex; gap: 8px; width: 100%; margin-bottom: 8px; }
.tab { flex: 1; padding: 9px; border-radius: 12px; font-size: 16px; color: var(--gold); background: #120828; border: 2px solid rgba(255,201,60,0.35); }
.tab.on { background: var(--gold-grad); color: #3A1204; }
.scores-card { max-height: 88vh; }
#board { list-style: none; padding: 0; margin: 0; width: 100%; overflow-y: auto; max-height: 55vh; touch-action: pan-y; }
#board li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-weight: 800; font-size: 15px; }
#board li:nth-child(odd) { background: rgba(255,255,255,0.06); }
#board li.me { background: rgba(255,201,60,0.25); }
#board li:nth-child(1) .n { color: var(--gold); }
#board .n { width: 26px; opacity: 0.7; font-family: var(--display); font-size: 15px; }
#board .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board .w { font-family: var(--display); color: var(--gold); letter-spacing: 0.5px; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--sab) + 90px); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { max-width: min(340px, 88vw); text-align: center; pointer-events: auto; background: #120828; border: 2px solid var(--gold); color: var(--ink); padding: 9px 16px; border-radius: 16px; font-size: 14px; font-weight: 800;
  display: flex; align-items: center; gap: 12px; animation: toast-in 0.2s ease-out; }
.toast button { background: var(--gold-grad); color: #3A1204; padding: 5px 12px; border-radius: 10px; font-size: 14px; }
.toast.out { opacity: 0; transform: translateY(8px); transition: 0.3s; }

@keyframes fade { from { opacity: 0; } }
@keyframes glowpulse { from { filter: brightness(1); } to { filter: brightness(1.12); } }
@keyframes pop-in { from { transform: scale(0.8); opacity: 0; } }
@keyframes wobble { from { transform: rotate(-3deg) scale(1); } to { transform: rotate(3deg) scale(1.07); } }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
@keyframes sweep { 0%, 55% { left: -60%; } 100% { left: 130%; } }
@keyframes chase { to { background-position: 11px 0, 0 100%; } }
@keyframes stripes { to { background-position: 32px 0, 0 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes thump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
button, .lb-top, .card-h, .kicker, .head h2, .sheet h2, .pd-power b, .badge, .pal-card .pn, .m-prog, #board .w, #board .n { text-transform: uppercase; }
.big .b2, .pal-card .pl, .week-card, .week-card .lb-sub { text-transform: none; }
.week-card .card-h, .week-card .wk-name { text-transform: uppercase; }
@media (prefers-reduced-motion: reduce) { .big::after, .sign .bulbs, .sheet.mega::before, .unlock::before, .badge { animation: none; } }
