/* FulleRulle Snowstorm: clipped panels, teal bars, skewed speed streaks, Kanit italic, cyan glow. */
:root { --navy:#001824; --teal:#009CB4; --glow:#00C8D4; --deep:#00546C; --white:#FCFCFC; --gold:#D8A848; --gold2:#F0C860; --red:#FF6B5E; --panel:rgba(2,26,40,.9); --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #00080d; color: var(--white); font-family: Kanit, "Arial Narrow", sans-serif; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#stage { position: fixed; left: 50%; top: 0; height: 100%; width: min(100vw, 66vh); transform: translateX(-50%); background: var(--navy); overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

.screen, .overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: calc(var(--sat) + 16px) 18px calc(var(--sab) + 16px); }
.screen { background: linear-gradient(180deg, rgba(0,18,28,.42) 0%, rgba(0,18,28,.72) 52%, rgba(0,12,20,.93) 100%); }
#levels.screen { background: linear-gradient(180deg, rgba(0,18,28,.82), rgba(0,12,20,.94)); }
/* drifting speed streaks (the FulleRulle motif) behind every screen */
.screen::before { content: ""; position: absolute; inset: -20% -40%; background:
    repeating-linear-gradient(115deg, transparent 0 70px, rgba(0,200,212,.07) 70px 96px, transparent 96px 150px, rgba(0,156,180,.06) 150px 164px);
  animation: drift 14s linear infinite; pointer-events: none; }
.screen > * { position: relative; }
@keyframes drift { to { transform: translateX(150px); } }
.overlay { justify-content: center; background: radial-gradient(90% 70% at 50% 45%, rgba(0,16,26,.78), rgba(0,6,12,.9)); z-index: 5; animation: fade .18s ease-out; }
.overlay.clear { background: transparent; pointer-events: none; animation: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.logo.big { width: 64%; margin-top: 6vh; filter: drop-shadow(0 0 20px rgba(0,200,212,.5)); animation: rise .6s cubic-bezier(.2,.9,.3,1.2) both, glowpulse 3.2s ease-in-out .6s infinite; }
.logo.small { height: 34px; }
@keyframes glowpulse { 50% { filter: drop-shadow(0 0 30px rgba(0,230,240,.85)); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
h1 { margin: 2vh 0 0; font: italic 800 clamp(42px, 13vw, 68px)/1 Kanit, sans-serif; letter-spacing: .02em; background: linear-gradient(180deg, #ffffff 30%, #9BEFFA 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #00546C) drop-shadow(0 0 22px rgba(0,200,212,.6)); animation: rise .6s .12s cubic-bezier(.2,.9,.3,1.2) both; }
h2 { font: italic 800 26px Kanit; margin: 10px 0 8px; text-shadow: 0 0 14px rgba(0,200,212,.5); }
.tag { margin: 12px 0 0; color: #bfeaf4; font-weight: 500; text-align: center; max-width: 82%; padding: 6px 16px; background: rgba(0,16,26,.6); clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); animation: rise .6s .22s both; }
.stack { margin-top: auto; margin-bottom: 8vh; width: min(82%, 330px); display: flex; flex-direction: column; gap: 12px; }
.stack > * { animation: rise .55s both; } .stack > :nth-child(1) { animation-delay: .32s; } .stack > :nth-child(2) { animation-delay: .4s; } .stack > :nth-child(3) { animation-delay: .48s; }

.btn { position: relative; font: italic 800 20px Kanit, sans-serif; letter-spacing: .02em; color: var(--white); background: linear-gradient(180deg, rgba(0,110,138,.9), rgba(0,70,92,.92)); border: 0; padding: 14px 40px 14px 22px; min-height: 54px; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%); border-left: 5px solid var(--teal); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), inset 0 -3px 0 rgba(0,0,0,.28); text-align: left; width: 100%; transition: transform .08s, filter .15s; }
.btn::after { content: ""; position: absolute; right: 16px; top: 50%; width: 11px; height: 11px; margin-top: -7px; border-top: 3px solid currentColor; border-right: 3px solid currentColor; transform: rotate(45deg); opacity: .75; }
.btn:active { transform: scale(.975); filter: brightness(1.15); }
.btn.primary { background: linear-gradient(180deg, #2fe3ee, #00A9BD); color: #00131c; border-left-color: #fff; animation-name: rise, ctapulse; animation-duration: .55s, 2.4s; animation-delay: .32s, 1.2s; animation-iteration-count: 1, infinite; animation-fill-mode: both, none; }
@keyframes ctapulse { 50% { filter: brightness(1.18) drop-shadow(0 0 10px rgba(0,230,240,.7)); } }
.btn.ghost { background: linear-gradient(180deg, rgba(4,34,50,.86), rgba(0,20,32,.9)); font-weight: 500; font-style: normal; }
.card .btn.primary { animation: ctapulse 2.4s 1s infinite; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(0,200,212,.8); background: radial-gradient(circle at 35% 30%, rgba(0,90,115,.95), rgba(0,24,36,.92)); color: #fff; font: 800 16px Kanit; cursor: pointer; display: grid; place-items: center; box-shadow: 0 0 12px rgba(0,200,212,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.round:active { transform: scale(.93); }
.ver { position: absolute !important; right: 12px; bottom: calc(var(--sab) + 8px); font-size: 11px; color: #5d8fa0; }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#pauseBtn { position: absolute; right: 12px; top: calc(var(--sat) + 10px); pointer-events: auto; font-size: 13px; letter-spacing: 1px; }

.bar { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.tabs { display: flex; gap: 8px; width: 100%; }
.tab { flex: 1; position: relative; font: italic 800 17px Kanit; color: #9fd9e6; background: linear-gradient(180deg, rgba(4,34,50,.85), rgba(0,20,32,.9)); border: 0; border-bottom: 3px solid rgba(255,255,255,.1); padding: 11px 0 9px; cursor: pointer; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%); }
.tab.on { color: #fff; border-bottom-color: var(--glow); background: linear-gradient(180deg, rgba(0,110,138,.95), rgba(0,60,80,.95)); box-shadow: 0 6px 16px -6px var(--glow); }
.tab[data-d=medium].on { border-bottom-color: var(--gold2); box-shadow: 0 6px 16px -6px var(--gold2); } .tab[data-d=hard].on { border-bottom-color: var(--red); box-shadow: 0 6px 16px -6px var(--red); }
.note { font-size: 13px; color: #9fd9e6; margin: 8px 0 6px; min-height: 18px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; width: 100%; overflow-y: auto; flex: 1; padding: 6px 2px 96px; touch-action: pan-y; scrollbar-width: none; }
.grid::-webkit-scrollbar { display: none; }
.lv { position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: linear-gradient(160deg, rgba(0,100,128,.85), rgba(0,52,70,.9)); border: 0; color: #fff; font: italic 800 21px Kanit; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), inset 0 -3px 0 rgba(0,0,0,.25); }
.lv::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--teal); }
.lv small { font-size: 11px; letter-spacing: 1px; color: var(--gold2); font-style: normal; text-shadow: 0 1px 2px #000; }
.lv.sel { background: linear-gradient(160deg, #38e6f0, #00A0B8); color: #00131c; box-shadow: 0 0 16px rgba(0,230,240,.7), inset 0 1px 0 rgba(255,255,255,.5); transform: scale(1.06); z-index: 1; }
.lv.sel::before { background: #fff; } .lv.sel small { color: #00131c; }
.lv.lock { opacity: .45; cursor: default; filter: grayscale(.6); }
.dock { position: absolute !important; left: 0; right: 0; bottom: 0; padding: 22px 18px calc(var(--sab) + 14px); background: linear-gradient(0deg, #001018 55%, rgba(0,16,24,0)); }

.card { position: relative; width: min(88%, 380px); background: linear-gradient(180deg, rgba(5,40,58,.96), var(--panel)); padding: 26px 22px 20px; display: flex; flex-direction: column; gap: 11px; text-align: center; border-left: 5px solid var(--glow);
  clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 26px, 100% 100%, 0 100%); box-shadow: inset 0 0 0 1px rgba(0,200,212,.3); pointer-events: auto; animation: pop .28s cubic-bezier(.2,.9,.3,1.25); overflow: hidden; }
.card::before { content: ""; position: absolute; right: 0; top: 0; width: 120px; height: 100%; background: repeating-linear-gradient(115deg, transparent 0 18px, rgba(0,200,212,.10) 18px 30px); pointer-events: none; }
.card > * { position: relative; }
@keyframes pop { from { opacity: 0; transform: scale(.88) translateY(14px); } to { opacity: 1; transform: none; } }
.card.wide { width: min(92%, 420px); text-align: left; }
.card h3 { margin: 0; font: italic 800 29px Kanit; text-align: center; text-shadow: 0 0 16px rgba(0,200,212,.55); }
.card p { margin: 0 0 6px; font-weight: 500; color: #d3edf4; line-height: 1.38; }
.step { font-size: 13px; color: var(--glow); letter-spacing: 3px; font-weight: 500; }
.stars { font-size: 50px; letter-spacing: 8px; color: var(--gold2); text-shadow: 0 0 18px rgba(240,200,96,.75), 0 3px 0 #7a5a10; text-align: center; min-height: 58px; }
.stars span { display: inline-block; animation: starpop .5s cubic-bezier(.2,1.6,.4,1) both; }
.stars span:nth-child(2) { animation-delay: .22s; } .stars span:nth-child(3) { animation-delay: .44s; }
.stars .off { color: rgba(255,255,255,.18); text-shadow: none; animation: none; }
@keyframes starpop { from { opacity: 0; transform: scale(2.4) rotate(-30deg); } to { opacity: 1; transform: none; } }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-weight: 500; }
.row input[type=range] { width: 55%; accent-color: var(--glow); height: 28px; }
.row input:not([type]), .row input[type=text], .row select { width: 55%; padding: 9px 10px; background: rgba(0,0,0,.4); color: #fff; border: 1px solid var(--teal); font: 500 16px Kanit; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%); }
.row.chk input { width: 26px; height: 26px; accent-color: var(--glow); }
.introCard { margin: 0 auto; text-align: center; animation: intro 1.5s ease-out both; }
#introDiff { font: 500 18px Kanit; letter-spacing: 8px; color: var(--glow); text-transform: uppercase; }
#introLv { font: italic 800 clamp(52px, 16vw, 90px) Kanit; background: linear-gradient(180deg, #fff 30%, #9BEFFA); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #00546C) drop-shadow(0 0 24px rgba(0,200,212,.7)); }
@keyframes intro { 0% { opacity: 0; transform: scale(.5) skewX(-12deg); } 18% { opacity: 1; transform: scale(1.06) skewX(-8deg); } 28% { transform: scale(1) skewX(-8deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.12) skewX(-8deg); } }
#toast { position: absolute; left: 50%; bottom: calc(var(--sab) + 96px); transform: translateX(-50%); background: var(--panel); padding: 11px 20px; font-weight: 500; border-left: 4px solid var(--glow); z-index: 9; max-width: 88%; text-align: center; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%); animation: pop .2s; }

/* puzzles */
.dock { display: flex; flex-direction: column; gap: 10px; }
.dock .btn.ghost small, #bPuzN { font-style: normal; font-weight: 500; opacity: .8; margin-left: 6px; }
.grid { padding-bottom: 150px; }
.pzgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; overflow-y: auto; flex: 1; padding: 4px 2px 20px; touch-action: pan-y; scrollbar-width: none; }
.pzgrid::-webkit-scrollbar { display: none; }
.pz { padding: 0; border: 0; background: rgba(2,26,40,.9); color: #fff; text-align: left; cursor: pointer; clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%); box-shadow: inset 0 0 0 1px rgba(0,200,212,.3); }
.pz canvas { width: 100%; display: block; aspect-ratio: 5 / 3; }
.pz .lab { padding: 7px 9px 9px; display: flex; flex-direction: column; gap: 1px; }
.pz .lab b { font: italic 800 14px Kanit; } .pz .lab small { font-size: 11px; color: #9fd9e6; letter-spacing: .5px; }
.pz.ready { box-shadow: 0 0 0 2px var(--gold2), 0 0 16px rgba(240,200,96,.6); animation: ctapulse 1.8s infinite; }
.pz.done .lab small { color: #B6FF5A; }
#asBoard { display: block; margin: 4px auto 0; background: #04141f; box-shadow: 0 0 0 2px rgba(0,200,212,.5), 0 8px 24px rgba(0,0,0,.5); touch-action: manipulation; }
#asBoard.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.tray { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; width: 100%; }
.tp { width: 60px; height: 90px; box-shadow: 0 0 0 2px rgba(255,255,255,.35); cursor: pointer; transition: transform .1s; }
.tp.sel { transform: translateY(-8px) scale(1.12); box-shadow: 0 0 0 3px var(--gold2), 0 0 16px rgba(240,200,96,.8); }
.asdone { margin-top: 14px; text-align: center; width: 100%; animation: pop .35s; }
.asdone h3 { margin: 0 0 4px; font: italic 800 24px Kanit; text-shadow: 0 0 16px rgba(0,200,212,.6); }
.asdone p { margin: 0 0 8px; color: #d3edf4; font-weight: 500; }
.asdone .reward { color: var(--gold2); font-weight: 800; font-style: italic; }
.piece { display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(0,16,26,.6); padding: 8px 12px; text-align: left; }
.piece canvas { width: 42px; height: 63px; box-shadow: 0 0 0 2px var(--gold2); animation: starpop .6s .5s both cubic-bezier(.2,1.6,.4,1); }
.piece span { font-weight: 500; font-size: 14px; color: #d3edf4; }

#puzzles.screen, #assemble.screen { background: linear-gradient(180deg, rgba(0,16,26,.9), rgba(0,10,18,.96)); }

/* score on the result card */
.score { margin: 2px 0 8px; font: italic 800 22px Kanit; color: var(--gold2); text-shadow: 0 0 12px rgba(240,200,96,.4); }
.score small { font-weight: 500; font-size: 13px; color: #9fd9e6; text-shadow: none; }
.score em { color: #B6FF5A; font-style: italic; font-size: 14px; }
