/* Firefly Jar: a ballpoint-pen night drawn on cream paper. Blue ink, doubled wobbly lines, hatching, light washes. */
:root {
  --paper: #f3ead6; --card: #fffaf0; --ink: #283a8c; --ink2: #3b53b8; --muted: #4a5191; --wash-y: #ffd36f; --wash-c: #ef8a7a; --wash-s: #9cc3ee; --wash-m: #9fd8b5;
  --glow: #f2ff7a; --gold: #f2b51d; --warn: #9c3a1f;
  --hand: Caveat, "Chalkboard SE", "Comic Sans MS", cursive;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --wob: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --wob2: 18px 225px 18px 255px / 255px 18px 225px 18px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); }
body { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 3px dashed var(--ink2); outline-offset: 3px; }
.gi { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none; font-style: normal; }
.gi svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* a pen retrace: a second, slightly shifted outline makes every border look drawn twice */
.inked { position: relative; border: 2px solid var(--ink); border-radius: var(--wob); }
.inked::after { content: ""; position: absolute; inset: -4px -2px -3px -3px; border: 1.3px solid var(--ink); border-radius: var(--wob2); opacity: .45; pointer-events: none; transform: rotate(-.6deg); }

.app { position: relative; display: flex; flex-direction: column; height: 100dvh; max-width: 1100px; margin: 0 auto; padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; justify-self: start; min-height: 44px; min-width: 44px; padding-right: 10px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 700; }
.title { text-align: center; }
.title h1 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 34px; line-height: .95; color: var(--ink); text-shadow: 1px 1px 0 var(--card); }
.title h1::after { content: ""; display: block; height: 6px; margin: 0 8% -2px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'%3E%3Cpath d='M2 3.5 Q30 1 60 3.2 T118 2.6' fill='none' stroke='%23f2b51d' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.title p { margin: 3px 0 0; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--muted); }
.tools-top { justify-self: end; display: flex; gap: 4px; }
.icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--wob); color: var(--ink); background: var(--card); border: 2px solid var(--ink); box-shadow: 1.5px 2px 0 var(--ink); transition: background-color .22s ease, box-shadow .22s ease; }
.icon[aria-pressed="true"] { background: #fff3c4; box-shadow: 1.5px 2px 0 var(--ink), 0 0 12px rgba(255, 211, 111, .55); }
.icon .gi { width: 26px; height: 26px; }
.icon:active { translate: 0 2px; box-shadow: 0 0 0 var(--ink); }

.hud { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 6px 2px 6px; font-weight: 800; } /* same height with or without the pause button, so the meadow never resizes */
.count { font-size: 17px; min-width: 64px; }
.count b { font-family: var(--hand); font-size: 30px; line-height: .8; color: var(--ink); }
.moon-track { position: relative; flex: 1; height: 10px; border-radius: var(--wob); border: 1.6px solid var(--ink); background: repeating-linear-gradient(-55deg, transparent 0 4px, rgba(40, 58, 140, .22) 4px 5px); }
.moon-track i { position: absolute; top: 50%; left: 0; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: radial-gradient(circle at 38% 35%, #fffef2, #fff1b8 72%, #edd288); border: 2px solid var(--ink); box-shadow: 1px 1px 0 var(--ink), 0 0 10px rgba(255, 238, 160, .75); }
.sky-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.sky-chip .gi { width: 22px; height: 22px; }
.chain { min-width: 34px; text-align: right; font-family: var(--hand); font-size: 26px; line-height: .8; color: var(--ink2); text-shadow: 0 0 8px rgba(255, 211, 111, .7); }

.stage { position: relative; flex: 1; min-height: 240px; overflow: hidden; background: #222d68; touch-action: none; user-select: none; -webkit-user-select: none; border: 2.5px solid var(--ink); border-radius: 26px 18px 30px 20px / 20px 30px 18px 26px; box-shadow: 2px 3px 0 rgba(40, 58, 140, .55), inset 0 0 28px rgba(10, 14, 48, .35); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.kbd .stage:has(canvas:focus) { outline: 3px dashed var(--ink2); outline-offset: 3px; }
.pause { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--ink); border: 2px solid var(--ink); box-shadow: 1.5px 2px 0 var(--ink); }
.pause .gi { width: 26px; height: 26px; }
.pause[hidden] { display: none; }
.status { min-height: 1.35em; margin: 6px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; font-size: 15px; font-weight: 600; color: var(--ink); }
.save-note { margin: 2px 0 0; font-size: 13px; font-weight: 600; text-align: center; color: var(--warn); }
.save-note:empty { display: none; }

/* ---------- cards on paper ---------- */
.card { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); width: min(calc(100% - 24px), 460px); background: var(--card); color: var(--ink); z-index: 3; border-radius: 22px 14px 26px 16px / 16px 26px 14px 22px; box-shadow: 3px 4px 0 rgba(40, 58, 140, .35); }
.card-body { position: relative; max-height: calc(100dvh - 116px); overflow: auto; padding: 16px 18px 14px; overscroll-behavior: contain; }
.card[hidden] { display: none; }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.frame path { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
.frame .a { stroke-width: 2.4; }
.frame .b { stroke-width: 1.3; opacity: .5; }
.frame.draw path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw-on .7s cubic-bezier(.5, .1, .3, 1) forwards; }
.frame.draw .b { animation-delay: .18s; }
@keyframes draw-on { to { stroke-dashoffset: 0; } }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.kicker { margin: 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; color: var(--muted); }
.kid .mk-chip { color: var(--ink) !important; border-color: var(--ink) !important; background: #fff1bd !important; max-width: 46vw; min-height: 44px; }
.kid .mk-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card h2 { margin: 2px 0 6px; font-family: var(--hand); font-size: 40px; line-height: .95; font-weight: 700; }
.sky-line { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; padding: 5px 10px; font-size: 15px; font-weight: 600; background: rgba(156, 195, 238, .35); border-radius: var(--wob); }
.sky-line .gi { width: 28px; height: 28px; }
.sky-line:empty { display: none; }
.rules { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.rules li { display: flex; align-items: center; gap: 10px; font-size: 15px; line-height: 1.3; }
.rules li[hidden] { display: none; }
.ico { flex: none; width: 32px; height: 32px; border-radius: 50%; background: #3a4790; position: relative; border: 2px solid var(--ink); }
.ico::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 1.4px solid var(--ink); }
.ico.glow::after { background: var(--glow); box-shadow: 0 0 8px 5px rgba(242, 255, 122, .75); }
.ico.dim::after { background: #8a8f6a; }
.ico.gold::after { background: #ffcf4a; box-shadow: 0 0 8px 5px rgba(255, 207, 74, .8); }
.ico.rare::after { background: #8fb6ff; box-shadow: 0 0 8px 5px rgba(255, 159, 191, .75); }
.ico.wish::after { inset: 6px; border-radius: 0; border: 0; background: #fff3a6; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.ico.moth::after { inset: 8px 5px; border-radius: 40% 40% 50% 50%; background: #b3a99c; }
.goal { margin: 6px 0 8px; font-size: 16px; line-height: 1.4; }
.goal span { color: var(--muted); }
.wish-next { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.wish-next:empty { display: none; }
.wish-next .gi { width: 22px; height: 22px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions button, .more button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 50px; padding: 0 20px; border: 2px solid var(--ink); border-radius: var(--wob); font-weight: 800; font-size: 17px; background: #f1ead7; color: var(--ink); box-shadow: 2px 3px 0 var(--ink); }
.actions button::after, .more button::after { content: ""; position: absolute; inset: -4px -2px -3px -3px; border: 1.2px solid var(--ink); border-radius: var(--wob2); opacity: .4; pointer-events: none; }
.actions .primary { background: var(--wash-y); }
.actions button:active, .more button:active { box-shadow: 0 0 0 var(--ink); translate: 1px 2px; }
.actions button[hidden] { display: none; }
.more { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.more button { min-height: 46px; padding: 0 14px; font-size: 15px; background: var(--card); box-shadow: 1.5px 2px 0 var(--ink); }
.more .gi { width: 26px; height: 26px; }
.more b { font-weight: 700; color: var(--muted); }
.stars { display: flex; gap: 6px; margin: 0 0 6px; }
.stars .gi { width: 40px; height: 40px; }
#done-line { margin: 0 0 8px; font-size: 16px; line-height: 1.4; }
.finds { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.finds:empty { display: none; }
.finds li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; font-size: 15px; font-weight: 600; line-height: 1.3; border: 1.6px dashed var(--ink); border-radius: var(--wob); background: rgba(255, 211, 111, .25); }
.finds .gi { width: 28px; height: 28px; }
.swatch { flex: none; display: inline-block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); background: radial-gradient(circle, var(--c, #ffd36f) 0 32%, #3a4790 70%); box-shadow: 0 0 6px 2px var(--c, #ffd36f); }
.club { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; padding: 8px 12px; min-height: 48px; border-radius: var(--wob); border: 2px dashed var(--ink); background: #fff1bd; color: var(--ink); font-weight: 700; font-size: 15px; text-decoration: none; }
.club .gi { width: 28px; height: 28px; }
.club[hidden] { display: none; }

/* ---------- sheets: nights, shelf, journal ---------- */
.sheet { width: min(calc(100vw - 24px), 500px); max-height: 88dvh; padding: 14px 16px 16px; border: 2.5px solid var(--ink); border-radius: 22px 14px 26px 16px / 16px 26px 14px 22px; background: var(--card); color: var(--ink); box-shadow: 4px 5px 0 rgba(40, 58, 140, .4); overscroll-behavior: contain; }
.sheet::backdrop { background: rgba(40, 46, 90, .45); }
.sheet[open] { animation: sheet-in .38s cubic-bezier(.34, 1.4, .64, 1); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) rotate(-1deg) scale(.97); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; font-family: var(--hand); font-size: 36px; line-height: 1; }
.sheet-note { margin: 4px 0 10px; font-size: 15px; line-height: 1.4; }
.sub { margin: 12px 0 6px; font-family: var(--hand); font-size: 28px; line-height: 1; }
.sub span { font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--muted); }
.nights-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.nights-list button { position: relative; width: 100%; min-height: 72px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: var(--wob); background: #f1ead7; text-align: left; display: flex; flex-direction: column; gap: 3px; font-size: 14px; box-shadow: 1.5px 2px 0 var(--ink); }
.nights-list button b { font-size: 15px; }
.nights-list button[aria-current="true"] { background: var(--card); border-width: 3px; box-shadow: 3px 4px 0 var(--ink); }
.nights-list button[aria-current="true"] b { background: linear-gradient(transparent 60%, rgba(156, 195, 238, .7) 60%); }
.nights-list button:disabled { background: transparent; color: var(--muted); border-style: dashed; cursor: default; box-shadow: none; }
.nights-list .st { display: flex; align-items: center; gap: 2px; font-weight: 600; }
.nights-list .st .gi { width: 20px; height: 20px; }
#shelf-art { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; border: 2px solid var(--ink); border-radius: 16px 10px 18px 12px; background: #3a4790; }
.shelf-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.shelf-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1.6px solid var(--ink); border-radius: var(--wob); font-size: 14px; line-height: 1.3; }
.shelf-list li.unfound { border-style: dashed; color: var(--muted); }
.shelf-list li.unfound .swatch { background: repeating-linear-gradient(-45deg, transparent 0 3px, rgba(40, 58, 140, .35) 3px 4px); box-shadow: none; }
.shelf-list b { display: block; font-size: 15px; color: var(--ink); }
.wish-list, .journal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wish-list li { display: flex; align-items: center; gap: 8px; font-size: 15px; line-height: 1.3; }
.wish-list li .gi { width: 26px; height: 26px; }
.wish-list li.done { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(40, 58, 140, .5); }
.journal-list li { padding: 8px 10px; border-bottom: 1.5px dashed rgba(40, 58, 140, .45); font-size: 15px; line-height: 1.35; }
.journal-list li b { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.journal-list li b .gi { width: 24px; height: 24px; }
.journal-list li small { color: var(--muted); font-size: 13px; font-weight: 600; }
.journal-list p { margin: 2px 0 0; font-family: var(--hand); font-size: 22px; line-height: 1.1; }
.journal-list .empty { border: 0; color: var(--muted); }

@media (hover: hover) {
  .icon:hover, .more button:hover { background: #fff1bd; }
  .actions button:hover { filter: brightness(1.03); }
  .nights-list button:not(:disabled):hover { background: #fff1bd; }
}
@media (min-width: 340px) { .rules { grid-template-columns: 1fr 1fr; column-gap: 10px; } .rules li { font-size: 14px; gap: 8px; } }
@media (min-width: 560px) { .rules li { font-size: 15px; } }
@media (min-width: 900px) and (min-height: 600px) { .hud { font-size: 18px; } .title h1 { font-size: 40px; } }
@media (max-width: 380px) { .sky-chip span { display: none; } .title h1 { font-size: 30px; } }
@media (max-height: 520px) {
  .title p { display: none; } .title h1 { font-size: 28px; } .hud { margin: 2px; }
  .card { top: calc(50% + 26px); width: min(calc(100% - 24px), 660px); } .card-body { max-height: calc(100dvh - 64px); padding: 10px 14px; }
  .wish-next { margin-bottom: 6px; } .sky-line { margin-bottom: 4px; }
  .card h2 { font-size: 30px; } .rules { gap: 3px; } .rules li { font-size: 14px; } .ico { width: 28px; height: 28px; } .ico::after { inset: 7px; }
  .sheet { max-height: 94dvh; }
  /* landscape phones: the main buttons and the shelf/journal row sit together right after the goal, the rest scrolls below */
  .card .card-body { display: flex; flex-flow: row wrap; align-items: center; column-gap: 8px; }
  .card .card-body > * { flex: 0 0 100%; } .card .card-body > .actions, .card .card-body > .more { flex: none; display: flex; margin: 0 0 6px; }
  .card .actions { order: 2; } .card .more { order: 2; } .card .more button { min-height: 44px; padding: 0 10px; }
  #intro .goal { order: 1; margin: 2px 0 6px; } #intro .rules { order: 3; } #intro .wish-next { order: 4; margin-top: 4px; } #intro .goal span { display: none; }
  #done .stars, #done-line { order: 1; } #done-finds { order: 3; grid-template-columns: 1fr 1fr; margin: 2px 0 0; } #done-club { order: 4; margin-top: 8px; }
  .stars .gi { width: 30px; height: 30px; } #done-line { margin-bottom: 6px; }
  .card-top { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .frame.draw path { animation: none; stroke-dashoffset: 0; }
  .sheet[open] { animation: none; }
}
