/* Block Blast — styles. Tokens from design.md (Astra). */
:root {
  --B: min(calc(100vw - 32px), 420px);
  --board: var(--B);
  --ui-font: "Nunito", "Arial Rounded MT Bold", sans-serif;
  --display: "Lilita One", "Arial Rounded MT Bold", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: linear-gradient(180deg, #1A2A6C 0%, #2B3F8F 100%) fixed;
  color: #fff; font-family: var(--ui-font);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation;
}
body::before { /* subtle pattern */
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .06;
  background-image: radial-gradient(circle at 25% 25%, #fff 1.2px, transparent 1.6px), radial-gradient(circle at 75% 75%, #fff 1.2px, transparent 1.6px);
  background-size: 34px 34px;
}
[hidden] { display: none !important; }
#safe { position: fixed; top: 0; left: 0; width: 0; height: 0; visibility: hidden;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.screen { position: fixed; inset: 0; }
button { font: inherit; color: inherit; }

/* ---------- buttons ---------- */
.button {
  box-sizing: border-box; width: 100%; min-height: 56px; padding: 12px 24px;
  border: 2px solid #ffffff66; border-radius: 18px;
  font: 900 max(19px, calc(var(--board) * .052))/1.1 var(--ui-font);
  color: #fff; text-shadow: 0 2px 2px #12342755;
  touch-action: manipulation; cursor: pointer;
  transition: transform 90ms ease, filter 90ms ease;
}
.button--primary {
  background: linear-gradient(#A0EC69 0%, #63D34C 42%, #37AF43 100%);
  box-shadow: 0 5px 0 #23763C, 0 9px 16px #06133240, inset 0 2px 0 #DBFFAD99;
}
.button--secondary {
  background: linear-gradient(#729FF4 0%, #4779DC 45%, #345FC0 100%);
  box-shadow: 0 5px 0 #243D88, 0 9px 16px #06133240, inset 0 2px 0 #C2D8FF88;
}
.button:active { transform: translateY(3px); filter: brightness(.94); }
.button:disabled { filter: grayscale(1); opacity: .55; cursor: default; }
.button:focus-visible, .switch input:focus-visible + .track, .icon-btn:focus-visible, .node:focus-visible {
  outline: 3px solid #FFF1A0; outline-offset: 4px;
}
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; padding: 0;
  border: 0; background: transparent; cursor: pointer; border-radius: 14px;
}
.icon-btn svg { width: calc(var(--B) * .060); height: calc(var(--B) * .060); min-width: 24px; min-height: 24px; filter: drop-shadow(0 2px 2px #08133b80); }
.icon-btn:active { transform: scale(.92); }

/* ---------- home ---------- */
#home { display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 16px); }
.home-gear { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: max(10px, calc(50vw - var(--B) / 2 - 8px)); }
.logo { width: min(calc(var(--B) * .98), 92vw); height: auto; margin-top: -2vh;
  filter: drop-shadow(0 10px 18px #06133166); animation: logoIn 700ms cubic-bezier(.16,1,.3,1) both, bob 4s ease-in-out 700ms infinite; }
.home-buttons { width: calc(var(--B) * .78); display: grid; gap: 20px; margin-top: calc(var(--B) * .08); }
.home-best { display: flex; align-items: center; gap: 10px; margin-top: 24px;
  font: 900 max(20px, calc(var(--B) * .06))/1 var(--ui-font); text-shadow: 0 2px 3px #08133b80; }
.home-best .crown { width: 36px; height: 27px; }
@keyframes logoIn { from { opacity: 0; transform: scale(.8) translateY(-20px); } }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-.6deg); } }

/* ---------- game HUD ---------- */
#cv { position: fixed; inset: 0; touch-action: none; display: block; }
#hud { position: absolute; pointer-events: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: calc(var(--B) * .11); }
.topbar > * { pointer-events: auto; }
.best { display: flex; align-items: center; gap: calc(var(--B) * .015);
  font: 900 calc(var(--B) * .045)/1.1 var(--ui-font); color: #FFE88A; text-shadow: 0 2px 2px #08133b80;
  font-variant-numeric: tabular-nums; padding-left: 4px; }
.best .crown { width: calc(var(--B) * .072); height: calc(var(--B) * .054); }
.best.flash .crown { animation: crownPop 900ms cubic-bezier(.16,1,.3,1); }
@keyframes crownPop { 30% { transform: scale(1.5) rotate(-12deg); filter: drop-shadow(0 0 10px #FFE478); } }
.level-label { font: 400 calc(var(--B) * .062)/1 var(--display); letter-spacing: .5px; text-shadow: 0 3px 0 #13235080; padding-left: 4px; }
.scorebox { height: calc(var(--B) * .20); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.score { font: 400 calc(var(--B) * .145)/1 var(--display); color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 calc(var(--B) * .008) calc(var(--B) * .012) #08133B80; will-change: transform; }
.score.small { font-size: calc(var(--B) * .095); }
.goals { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.goal { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 18px; background: #13234FCC;
  font: 900 20px/1 var(--ui-font); color: #fff; box-shadow: inset 0 1px 0 #ffffff22; transition: transform 160ms; }
.goals.big .goal { font-size: calc(var(--B) * .065); padding: 10px 16px; border-radius: 22px; }
.goals.big .goal canvas { width: calc(var(--B) * .09); height: calc(var(--B) * .09); }
.goal canvas, .goal svg { width: 28px; height: 28px; }
.goal.bump { transform: scale(1.18); }
.goal.done { color: #ACFF93; }

/* ---------- modal ---------- */
.backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: #060D2BB8; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade 200ms ease both; }
.modal { box-sizing: border-box; width: min(100%, 360px); max-height: calc(100% - 8px); overflow: auto; padding: 28px 24px 30px;
  border: 2px solid #98B5FF66; border-radius: 28px; color: #fff; text-align: center;
  background: linear-gradient(180deg, #3558A6, #203A7B); box-shadow: 0 18px 48px #030A2D99, inset 0 2px 0 #B9D1FF44;
  animation: modalIn 220ms cubic-bezier(.16,1,.3,1) both; }
.modal-title { margin: 0 0 14px; font: 400 calc(var(--B) * .085)/1.05 var(--display); letter-spacing: .5px;
  text-shadow: 0 3px 0 #13235099; }
.modal-label { font: 800 calc(var(--B) * .040)/1.2 var(--ui-font); color: #C9D8FF; text-transform: uppercase; letter-spacing: 1px; }
.modal-score { font: 400 calc(var(--B) * .120)/1.05 var(--display); text-shadow: 0 4px 0 #13235099; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.modal-best { font: 900 calc(var(--B) * .05)/1.2 var(--ui-font); color: #FFE88A; display: flex; justify-content: center; align-items: center; gap: 8px; }
.modal-best .crown { width: 30px; height: 22px; }
.modal-crown { width: 64px; height: 48px; display: block; margin: 0 auto 4px; animation: crownIn 900ms cubic-bezier(.16,1,.3,1) both; filter: drop-shadow(0 0 14px #FFE47899); }
.new-best { font: 400 calc(var(--B) * .07)/1 var(--display); color: #FFE478; margin-bottom: 8px; text-shadow: 0 3px 0 #7a4b0f88; animation: pulse 1.2s ease-in-out infinite; }
.modal-text { font: 800 17px/1.35 var(--ui-font); color: #DCE6FF; margin: 4px 0 0; }
.modal-actions { display: grid; gap: 16px; margin-top: 24px; }
.modal .goals { margin: 6px 0 4px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.9); } }
@keyframes fade { from { opacity: 0; } }
@keyframes crownIn { 0% { opacity: 0; transform: scale(.2) rotate(-30deg); } 60% { opacity: 1; transform: scale(1.25) rotate(8deg); } }
@keyframes pulse { 50% { transform: scale(1.07); } }

/* ---------- settings sheet ---------- */
.sheet-backdrop { place-items: end center; padding: 0; }
.settings-sheet { box-sizing: border-box; width: min(100%, 460px); padding: 12px 24px calc(28px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0; background: linear-gradient(#3558A6, #203A7B); box-shadow: 0 -8px 32px #030A2D66; color: #fff;
  animation: sheetIn 260ms cubic-bezier(.16,1,.3,1) both; }
.handle { width: 40px; height: 5px; border-radius: 3px; background: #FFFFFF55; margin: 0 auto 16px; }
.sheet-title { margin: 0 0 6px; font: 400 28px/1.1 var(--display); text-align: center; }
.setting-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px;
  font: 800 20px/1.2 var(--ui-font); border-bottom: 1px solid #FFFFFF18; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 58px; height: 44px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.track { position: absolute; top: 6px; left: 0; width: 58px; height: 32px; border-radius: 16px; background: #142858;
  box-shadow: inset 0 2px 4px #050D2B99; pointer-events: none; transition: background 160ms ease; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(#FFFFFF, #DCE8FF); box-shadow: 0 2px 4px #06133166; transition: transform 160ms cubic-bezier(.22,1,.36,1); }
.switch input:checked + .track { background: #53CF60; }
.switch input:checked + .track::after { transform: translateX(26px); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.sheet-close { margin-top: 16px; min-height: 48px; }
@keyframes sheetIn { from { transform: translateY(100%); } }

/* ---------- adventure map ---------- */
#map { display: flex; flex-direction: column; }
.map-header { display: flex; align-items: center; gap: 8px; width: min(100%, calc(var(--B) * .92 + 24px)); margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 4px 8px; }
.map-header h1 { flex: 1; margin: 0; font: 400 30px/1 var(--display); text-shadow: 0 3px 0 #13235080; }
.map-progress { font: 900 18px/1 var(--ui-font); background: #13234FCC; padding: 8px 14px; border-radius: 18px; }
.map-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 12px calc(env(safe-area-inset-bottom) + 24px); overscroll-behavior: contain; touch-action: pan-y; }
.chapter { width: calc(var(--B) * .92); margin: 0 auto 24px; padding: 20px; border-radius: 24px; background: #243F80;
  border: 2px solid #668BD066; box-shadow: 0 10px 24px #06133140; }
.chapter.locked { opacity: .55; filter: saturate(.6); }
.chapter-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.chapter-head canvas { width: calc(var(--B) * .10); height: calc(var(--B) * .10); flex: none; }
.chapter-title { font: 400 calc(var(--B) * .065)/1.05 var(--display); }
.chapter-sub { font: 800 14px/1.2 var(--ui-font); color: #C9D8FF; }
.picture { position: relative; aspect-ratio: 1; border-radius: 18px; overflow: hidden; box-shadow: 0 6px 16px #06133166, inset 0 0 0 2px #ffffff22; background: #13234F; }
.picture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picture .covers { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.cover { display: grid; place-items: center; background: linear-gradient(145deg, #2B4690f0, #1A2D66f5); border: 1px solid #ffffff1c;
  font: 400 calc(var(--B) * .07)/1 var(--display); color: #ffffff55; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity 600ms ease, transform 600ms cubic-bezier(.16,1,.3,1); }
.cover.open { opacity: 0; transform: scale(1.25) rotate(4deg); }
.path { position: relative; height: calc(var(--B) * .23 * 9); margin-top: 6px; }
.path svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.path polyline { fill: none; stroke: #759BDD66; stroke-width: calc(var(--B) * .022); stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.node { position: absolute; width: calc(var(--B) * .16); height: calc(var(--B) * .16); margin: calc(var(--B) * -.08) 0 0 calc(var(--B) * -.08);
  border-radius: 50%; border: calc(var(--B) * .008) solid #8594B2; background: linear-gradient(#67799F, #435779);
  box-shadow: 0 calc(var(--B) * .012) calc(var(--B) * .018) #08133380, inset 0 3px 0 #ffffff33;
  font: 400 calc(var(--B) * .06)/1 var(--display); color: #fff; text-shadow: 0 2px 0 #0a1a4a66; display: grid; place-items: center; cursor: pointer; padding: 0; }
.node svg { width: calc(var(--B) * .055); height: calc(var(--B) * .055); }
.node.done { background: linear-gradient(#84DF71, #39A954); border-color: #BEF3A5; }
.node.current { background: linear-gradient(#FFE68A, #FFB840); border-color: #FFF5BC; color: #7a4210; text-shadow: 0 1px 0 #fff6; animation: halo 1200ms ease-in-out infinite; }
.node.locked { cursor: default; }
.node:active:not(.locked) { transform: scale(.94); }
.node .stars { position: absolute; bottom: -6px; right: -4px; width: 22px; height: 22px; }
@keyframes halo { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 #FFE89666, 0 calc(var(--B) * .012) calc(var(--B) * .018) #08133380; }
  50% { transform: scale(1.10); box-shadow: 0 0 calc(var(--B) * .035) calc(var(--B) * .012) #FFE89699, 0 calc(var(--B) * .012) calc(var(--B) * .018) #08133380; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 100ms !important; animation-iteration-count: 1 !important; transition-duration: 100ms !important; }
  .logo { animation: none; }
}
