:root {
  --bg: #f4eee2; --card: #fffaf0; --tile: #e4d9c5; --ink: #1b1f2a; --accent: #ff6b57;
  --good: #22b8a7; --gold: #ffc93c; --muted: rgba(27, 31, 42, .62); --line: rgba(27, 31, 42, .14);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.35; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  transition: background-color .35s ease;
}
body.dark { --muted: rgba(255, 255, 255, .68); --line: rgba(255, 255, 255, .18); }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; max-width: 560px; margin: 0 auto; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 18px calc(14px + var(--safe-b)); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--card); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); flex: none; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px 0 10px; border-radius: 999px; background: var(--card); border: 2.5px solid var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.coin { width: 18px; height: 18px; border-radius: 50%; background: var(--gold); border: 2.5px solid var(--ink); display: inline-block; position: relative; flex: none; }
.coin::after { content: ""; position: absolute; left: 3px; top: 2px; width: 4px; height: 4px; border-radius: 50%; background: rgba(255, 255, 255, .85); }

/* home */
.hero { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 0; padding: 8px 0 14px; }
#logo { image-rendering: pixelated; max-width: 100%; flex: none; }
#teaser { width: 100%; flex: 1 1 auto; min-height: 90px; max-height: 360px; }
.tagline { margin: 0; font-weight: 700; color: var(--muted); letter-spacing: .01em; text-align: center; }
.home-actions { display: flex; flex-direction: column; gap: 12px; padding-bottom: 6px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1 1 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 52px; padding: 0 18px; border-radius: 16px; font-weight: 800; font-size: 17px; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); background: var(--card); color: var(--ink); text-decoration: none; transition: transform .06s ease, box-shadow .06s ease; }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.btn em { font-style: normal; font-weight: 800; opacity: .6; font-size: 14px; }
.btn.primary { background: var(--accent); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
body.dark .btn.primary { color: #1b1f2a; text-shadow: none; }
.btn.big { min-height: 68px; font-size: 24px; flex-direction: column; gap: 0; line-height: 1.05; }
.btn.big small { font-size: 13px; font-weight: 700; opacity: .9; letter-spacing: .04em; text-transform: uppercase; }
.btn.small { min-height: 44px; font-size: 15px; padding: 0 13px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
.btn.small:active { transform: translateY(3px); }
.btn.ghost { background: var(--card); }
.btn.danger { background: #e5484d; color: #fff; }
.btn.link { border: 0; box-shadow: none; background: none; min-height: 40px; color: var(--muted); font-weight: 700; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.card.daily { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border-radius: 18px; background: var(--card); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); text-align: left; }
.card.daily:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.card.daily .pix { width: 54px; height: 54px; border-radius: 12px; background: var(--tile); flex: none; }
.daily-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.daily-text b { font-size: 17px; }
.daily-text span { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.streak { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 18px; }
.flame { width: 16px; height: 20px; display: inline-block; background: #ff8a3d; border: 2.5px solid var(--ink); border-radius: 60% 60% 55% 55% / 75% 75% 40% 40%; transform: rotate(0deg); position: relative; }
.flame::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 1px; height: 7px; background: var(--gold); border-radius: 50% 50% 45% 45%; }
.streak.cold { opacity: .4; }
.get-app { text-align: center; font-weight: 800; color: var(--ink); padding: 6px; font-size: 14.5px; }

/* game */
.title { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-width: 0; }
.title b { font-size: 18px; }
.title span { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.hearts { display: flex; gap: 4px; min-width: 44px; justify-content: flex-end; }
.heart-ic, .hearts i { width: 22px; height: 20px; display: inline-block; background: #e5484d; -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'><path d='M12 21S1 14.5 1 7.200C1 3.5 3.8 1 7 1c2.1 0 3.9 1.1 5 2.800C13.1 2.1 14.9 1 17 1c3.2 0 6 2.5 6 6.200C23 14.5 12 21 12 21Z'/></svg>") center/contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'><path d='M12 21S1 14.5 1 7.200C1 3.5 3.8 1 7 1c2.1 0 3.9 1.1 5 2.800C13.1 2.1 14.9 1 17 1c3.2 0 6 2.5 6 6.200C23 14.5 12 21 12 21Z'/></svg>") center/contain no-repeat; transition: transform .25s ease, background-color .25s ease; }
.hearts i.lost { background: var(--line); transform: scale(.82); }
.hearts i.pop { animation: heartpop .45s ease; }
@keyframes heartpop { 0% { transform: scale(1); } 35% { transform: scale(1.5) rotate(-12deg); } 100% { transform: scale(.82); } }
#board-wrap { flex: 1 1 auto; position: relative; min-height: 0; margin: 6px -18px; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.coach { margin: 8px 0 0; padding: 10px 14px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 15px; text-align: center; animation: rise .3s ease; }
.pointer { position: absolute; width: 46px; height: 46px; margin: -6px 0 0 -8px; pointer-events: none; z-index: 3; animation: tapme 1s ease-in-out infinite; }
.pointer::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent); opacity: .9; }
.pointer::after { content: ""; position: absolute; left: 14px; top: 14px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }
@keyframes tapme { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.72); opacity: .75; } }
.gamebar { display: flex; align-items: center; gap: 10px; }
.progress { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress .bar { width: 100%; height: 10px; border-radius: 99px; background: var(--tile); border: 2px solid var(--ink); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--good); transition: width .3s ease; }

/* sheets */
.sheet-wrap { position: absolute; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgba(15, 17, 24, .5); animation: fade .2s ease; padding: 0; }
.sheet-wrap.solid { background: var(--bg); align-items: center; }
.sheet { width: 100%; max-height: 92%; overflow: auto; background: var(--bg); color: var(--ink); border-radius: 26px 26px 0 0; border-top: 2.5px solid var(--ink); padding: 20px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; animation: rise .28s cubic-bezier(.2, .9, .3, 1.15); }
.sheet-wrap.solid .sheet { border: 0; animation: none; }
.sheet-wrap.full .sheet { height: 100%; max-height: 100%; border-radius: 0; border: 0; padding-top: calc(12px + var(--safe-t)); }
.sheet.center { align-items: center; text-align: center; }
.sheet.center .btn { width: 100%; }
.sheet.center .row { width: 100%; }
.sheet h2 { margin: 0; font-size: 26px; line-height: 1.1; letter-spacing: -.01em; }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-head h2 { flex: 1; }
.muted { color: var(--muted); margin: 0; font-weight: 600; }
.tiny { font-size: 12.5px; text-align: center; }
.scroll { overflow: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(26px); opacity: 0; } to { transform: none; opacity: 1; } }

.ribbon { font-size: 12.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pix { image-rendering: pixelated; }
.pix.big { width: 176px; height: 176px; border-radius: 22px; background: var(--card); border: 2.5px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
.note { margin: 0; font-size: 21px; font-weight: 800; color: var(--accent); }
.stars { display: flex; gap: 6px; }
.stars i { width: 30px; height: 30px; background: var(--line); -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m12 1.8 3.1 6.5 7.1.900-5.2 4.9 1.3 7.100L12 17.700l-6.3 3.500L7 14.1 1.8 9.200l7.1-.900Z'/></svg>") center/contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m12 1.8 3.1 6.5 7.1.900-5.2 4.9 1.3 7.100L12 17.700l-6.3 3.500L7 14.1 1.8 9.200l7.1-.900Z'/></svg>") center/contain no-repeat; }
.stars i.on { background: var(--gold); animation: starin .4s cubic-bezier(.2, .9, .3, 1.6) backwards; }
.stars i.on:nth-child(2) { animation-delay: .12s; } .stars i.on:nth-child(3) { animation-delay: .24s; }
@keyframes starin { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.res-rows { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.res-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-radius: 12px; background: var(--card); border: 2px solid var(--line); font-weight: 700; font-size: 15px; }
.res-row b { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.broken { width: 64px; height: 58px; background: #e5484d; -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'><path d='M12 21S1 14.5 1 7.200C1 3.5 3.8 1 7 1c2.1 0 3.9 1.1 5 2.800l-2 4 4 2.5-3 4 1 6.700ZM13.5 3c1-1.2 2.3-2 3.5-2 3.2 0 6 2.5 6 6.2 0 5.8-7 11.3-9.8 13.100l-.700-5.5 3.3-4.5-4.2-2.600Z'/></svg>") center/contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'><path d='M12 21S1 14.5 1 7.200C1 3.5 3.8 1 7 1c2.1 0 3.9 1.1 5 2.800l-2 4 4 2.5-3 4 1 6.700ZM13.5 3c1-1.2 2.3-2 3.5-2 3.2 0 6 2.5 6 6.2 0 5.8-7 11.3-9.8 13.100l-.700-5.5 3.3-4.5-4.2-2.600Z'/></svg>") center/contain no-repeat; }
#btn-revive { flex-direction: row; }
#btn-revive .heart-ic { background: #fff; width: 18px; height: 16px; }
#btn-revive small { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; background: rgba(0, 0, 0, .18); padding: 3px 9px; border-radius: 99px; }

/* gallery */
.pack h3 { margin: 18px 2px 10px; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; display: flex; justify-content: space-between; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cell { aspect-ratio: 1; border-radius: 14px; background: var(--card); border: 2.5px solid var(--ink); display: grid; place-items: center; position: relative; overflow: hidden; }
.cell.locked { border-color: var(--line); background: transparent; }
.cell canvas { width: 78%; height: 78%; image-rendering: pixelated; }
.cell .q { font-size: 22px; font-weight: 800; color: var(--line); }
.cell .mini { position: absolute; bottom: 3px; left: 0; right: 0; display: flex; justify-content: center; gap: 1px; }
.cell .mini i { width: 9px; height: 9px; background: var(--gold); -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m12 1.8 3.1 6.5 7.1.900-5.2 4.9 1.3 7.100L12 17.700l-6.3 3.500L7 14.1 1.8 9.200l7.1-.900Z'/></svg>") center/contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='m12 1.8 3.1 6.5 7.1.900-5.2 4.9 1.3 7.100L12 17.700l-6.3 3.500L7 14.1 1.8 9.200l7.1-.900Z'/></svg>") center/contain no-repeat; }

/* gift */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { padding: 9px 14px; border-radius: 99px; border: 2.5px solid var(--ink); background: var(--card); font-weight: 800; font-size: 14.5px; }
.chip.on { background: var(--ink); color: var(--bg); }
#gift-art { width: 96px; height: 96px; }
.present { width: 110px; height: 100px; position: relative; margin: 8px 0 6px; animation: wobble 1.6s ease-in-out infinite; }
.present::before { content: ""; position: absolute; left: 6px; right: 6px; top: 34px; bottom: 0; background: var(--accent); border: 3px solid var(--ink); border-radius: 8px; }
.present::after { content: ""; position: absolute; left: 0; right: 0; top: 18px; height: 24px; background: var(--accent); border: 3px solid var(--ink); border-radius: 8px; }
.present i { position: absolute; left: 50%; top: 18px; bottom: 0; width: 18px; margin-left: -9px; background: var(--gold); border-left: 3px solid var(--ink); border-right: 3px solid var(--ink); z-index: 1; }
.present i::before, .present i::after { content: ""; position: absolute; top: -20px; width: 26px; height: 18px; border: 3px solid var(--ink); background: var(--gold); border-radius: 60% 60% 20% 60%; }
.present i::before { right: 6px; transform: rotate(-12deg); } .present i::after { left: 6px; transform: scaleX(-1) rotate(-12deg); }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-4px); } }

/* themes */
.themes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; padding-top: 12px; }
.theme { border-radius: 18px; border: 2.5px solid var(--ink); overflow: hidden; display: flex; flex-direction: column; background: var(--card); box-shadow: 0 4px 0 var(--ink); text-align: left; }
.theme:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.theme canvas { width: 100%; height: 96px; display: block; }
.theme .meta { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; font-weight: 800; border-top: 2.5px solid var(--ink); }
.theme .meta span { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; }
.theme.on .meta { background: var(--ink); color: var(--bg); }

/* settings */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 2.5px solid var(--ink); font-weight: 800; }
.toggle input { display: none; }
.toggle i { width: 50px; height: 30px; border-radius: 99px; border: 2.5px solid var(--ink); background: var(--tile); position: relative; transition: background-color .2s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.toggle input:checked + i { background: var(--good); }
.toggle input:checked + i::after { transform: translateX(20px); }
.how { text-align: left; margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-weight: 600; }

.toast { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 800; font-size: 14.5px; z-index: 40; white-space: nowrap; animation: rise .25s ease; pointer-events: none; }

/* store screenshots: captions are rendered in the page */
body.shot .shotcap { display: block !important; position: absolute; left: 0; right: 0; top: calc(var(--safe-t) + 26px); text-align: center; font-size: 33px; line-height: 1.08; font-weight: 800; letter-spacing: -.02em; padding: 0 22px; z-index: 30; color: var(--ink); }
body.shot .shotcap small { display: block; font-size: 16px; font-weight: 700; color: var(--muted); margin-top: 8px; letter-spacing: 0; }
body.shot .screen { padding-top: calc(132px + var(--safe-t)); }
body.shot .sheet-wrap { background: rgba(15, 17, 24, .28); }
body.shot .sheet-wrap.full .sheet { padding-top: calc(150px + var(--safe-t)); }
body.shot.shot-sheet .shotcap { color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
body.shot.shot-sheet .shotcap small { color: rgba(255, 255, 255, .9); }
body.shot * { animation-duration: .001s !important; animation-delay: 0s !important; }

@media (max-height: 640px) {
  .btn.big { min-height: 58px; font-size: 21px; }
  .pix.big { width: 132px; height: 132px; }
  .sheet { gap: 9px; padding-top: 16px; }
}
