/* Puzlarte. Made for phones: one column, 16px side gutter, big touch targets. On a computer the same layout sits centred. */
:root {
  --paper: #FBF6EC; --card: #FFFDF8; --ink: #22213A; --soft: #5B5A70; --line: #E6DCC8;
  --panel: #1C1F45; --panel2: #14163A; --gold: #E3A72F; --lc: #1E8A6E;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: #EFE7D6; -webkit-text-size-adjust: 100%; }
body { margin: 0 auto; max-width: 480px; min-height: 100vh; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font: 500 16px/1.45 var(--body); }
body.playing { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 16px;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font: 700 22px/1 var(--display); }
.logo img { border-radius: 7px; }
.langs { display: flex; gap: 2px; padding: 3px; background: #F1E9D8; border-radius: 999px; }
.langs button { min-width: 36px; height: 30px; padding: 0 8px; border-radius: 999px; font: 800 12px/1 var(--body); color: var(--soft); }
.langs button[aria-pressed="true"] { background: var(--panel); color: #fff; }

/* home */
.home, .pz { padding: 20px 16px 28px; }
.home h1 { font-size: 27px; line-height: 1.14; }
.chips { display: flex; gap: 8px; margin: 16px -16px 0; padding: 2px 16px 12px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font: 700 14px/1 var(--body); white-space: nowrap; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--lc); }
.chip[aria-pressed="true"] { background: var(--panel); border-color: var(--panel); color: #fff; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; margin-top: 4px; }
.card { display: flex; flex-direction: column; min-width: 0; }
.thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 9px; background: var(--panel); border-radius: 14px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.tick { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: var(--panel); }
.tick svg { width: 15px; height: 15px; stroke-width: 3.2; }
.card b { margin-top: 8px; font: 700 16px/1.2 var(--display); }
.meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font: 700 12.5px/1.2 var(--body); color: var(--lc); }
.steps { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; flex: none; }
.steps i { width: 3.5px; border-radius: 1px; background: color-mix(in srgb, var(--lc) 28%, transparent); }
.steps i.on { background: var(--lc); }
.make { margin-top: 28px; padding: 18px; border-radius: 16px; background: var(--panel); color: #fff; }
.make h2 { margin-top: 10px; font-size: 21px; line-height: 1.15; }
.make p { margin-top: 6px; color: #C9CBE4; font-size: 15px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--gold); color: var(--panel); font: 800 11.5px/1.2 var(--body); letter-spacing: .04em; text-transform: uppercase; }
.foot { margin-top: 26px; text-align: center; color: var(--soft); font-size: 13.5px; }

/* puzzle page */
.backlink { display: inline-flex; align-items: center; gap: 2px; height: 36px; margin: -8px 0 6px -6px; padding-right: 8px; font: 700 14.5px/1 var(--body); color: var(--soft); }
.backlink svg { width: 20px; height: 20px; }
.hero { display: grid; place-items: center; padding: 12px; background: var(--panel); border-radius: 18px; }
.hero img { width: auto; max-height: 62vh; height: auto; }
.pz .lvl { margin-top: 14px; font-size: 13.5px; }
.pz h1 { margin-top: 4px; font-size: 31px; line-height: 1.08; }
.block { margin-top: 26px; }
.block h2 { font-size: 21px; }
.block p { margin-top: 2px; color: var(--soft); font-size: 14.5px; }
.sizes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 12px; }
.size { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 68px; padding: 8px 2px;
  border-radius: 14px; background: var(--panel); color: #fff; text-align: center; }
.size:active { transform: scale(.97); }
.size b { font: 700 23px/1 var(--display); }
.size span { font: 700 10.5px/1.1 var(--body); color: #C9CBE4; }
.size em { position: absolute; top: -6px; right: -4px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: var(--panel); }
.size em svg { width: 12px; height: 12px; stroke-width: 3.4; }
.pcards { display: grid; gap: 9px; margin-top: 12px; }
.pcard { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 72px; padding: 12px 14px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); }
.pcard:active { background: #F6EFDF; }
.ptx { min-width: 0; }
.pt { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.pt b { font: 700 18px/1.15 var(--display); }
.tag { padding: 3px 8px; border-radius: 999px; font: 800 10.5px/1.2 var(--body); letter-spacing: .03em; text-transform: uppercase; color: #fff; background: #B7791F; }
.pcard.big .tag { background: #1E8A6E; }
.pcard.giant .tag { background: #2F6FB6; }
.ptx > span { display: block; margin-top: 4px; color: var(--soft); font-size: 13.5px; }
.pdl { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 54px; color: var(--ink); font: 800 11.5px/1 var(--body); }
.pdl svg { width: 24px; height: 24px; }

/* game */
.loading { position: fixed; inset: 0; background: var(--panel2); }
.game { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; background: var(--panel2); color: #fff;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; padding-bottom: env(safe-area-inset-bottom); }
.gbar { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 12px 0 6px; flex: none; }
.gbtn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.gbtn svg { width: 24px; height: 24px; }
.gname { flex: 1; min-width: 0; font: 700 18px/1.1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gstat { display: flex; align-items: baseline; gap: 9px; font: 800 15px/1 var(--body); font-variant-numeric: tabular-nums; }
.gstat b { color: var(--gold); }
.gstat span { color: #C9CBE4; min-width: 36px; text-align: right; }
.gboard { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 14px; }
.gboard.zoomed { display: block; overflow: auto; -webkit-overflow-scrolling: touch; }
.gboard canvas { display: block; }
.gtools { display: flex; justify-content: center; gap: 8px; padding: 2px 12px 10px; flex: none; }
.gchip { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; background: rgba(255,255,255,.09); font: 700 13px/1 var(--body); color: #DADCF0; }
.gchip svg { width: 17px; height: 17px; }
.gchip[aria-pressed="true"] { background: var(--gold); color: var(--panel); }
.gtray { position: relative; flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: max-content; align-items: center; gap: 8px; padding: 10px 14px;
  height: 162px; background: var(--panel); border-top: 1px solid rgba(255,255,255,.1); overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; scrollbar-width: none; }
.gtray::-webkit-scrollbar { display: none; }
.gtray[data-rows="1"] { grid-template-rows: 1fr; }
.gtray[data-rows="2"] { grid-template-rows: 1fr 1fr; }
.gpiece { display: grid; place-items: center; touch-action: pan-x; }
.gpiece canvas { display: block; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
.gpiece.lifted { opacity: .22; }
.gtip { flex: none; align-self: center; margin: 0 0 9px; padding: 5px 12px; border-radius: 999px; background: var(--gold); color: var(--panel); font: 800 12.5px/1.2 var(--body); }
.gtip[hidden] { display: none; }
.gfloat { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); will-change: transform; }
.gtray.won { display: block; height: auto; overflow: visible; padding: 16px 16px 20px; }
.gwin-card { position: relative; display: grid; gap: 9px; text-align: center; }
.gwin-card h2 { font-size: 27px; color: var(--gold); }
.gwin-card p { margin-bottom: 6px; color: #DADCF0; font-weight: 700; }
.btn { display: block; width: 100%; height: 50px; border-radius: 14px; font: 800 16px/1 var(--body); }
.btn.gold { background: var(--gold); color: var(--panel); }
.btn.line { border: 2px solid rgba(255,255,255,.35); color: #fff; }
.btn.ghost { height: 40px; color: #C9CBE4; }
.gwin-burst { position: absolute; left: 50%; top: 8px; width: 0; height: 0; pointer-events: none; }
.gwin-burst i { position: absolute; width: 8px; height: 8px; border-radius: 2px; background: var(--gold); animation: burst 900ms ease-out both; }
.gwin-burst i:nth-child(3n) { background: #1E8A6E; } .gwin-burst i:nth-child(3n+1) { background: #C0532B; } .gwin-burst i:nth-child(4n) { background: #2F6FB6; }
.gwin-burst i:nth-child(1) { --a: 0deg; } .gwin-burst i:nth-child(2) { --a: 26deg; } .gwin-burst i:nth-child(3) { --a: 52deg; } .gwin-burst i:nth-child(4) { --a: 78deg; }
.gwin-burst i:nth-child(5) { --a: 104deg; } .gwin-burst i:nth-child(6) { --a: 130deg; } .gwin-burst i:nth-child(7) { --a: 156deg; } .gwin-burst i:nth-child(8) { --a: 182deg; }
.gwin-burst i:nth-child(9) { --a: 208deg; } .gwin-burst i:nth-child(10) { --a: 234deg; } .gwin-burst i:nth-child(11) { --a: 260deg; } .gwin-burst i:nth-child(12) { --a: 286deg; }
.gwin-burst i:nth-child(13) { --a: 312deg; } .gwin-burst i:nth-child(14) { --a: 338deg; }
@keyframes burst { from { transform: rotate(var(--a)) translateY(0) scale(1); opacity: 1; } to { transform: rotate(var(--a)) translateY(-130px) scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .gwin-burst { display: none; } .size:active { transform: none; } }
