/* Lantern Bay — one self-hosted variable font, no third parties. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/fredoka.woff2) format('woff2');
}

:root {
  --bg: #eef0f6;
  --ink: #2f2a3d;
  --muted: #6a6280;
  --accent: #ffd23f;
  --accent-ink: #4a3a00;
  --go: #4ccc5a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #1d1826; overflow: hidden; font-family: 'Fredoka', system-ui, sans-serif; color: var(--ink); }
body { display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }

#stage { position: relative; width: 100vw; height: 100vh; height: 100dvh; max-width: 560px; background: var(--bg); overflow: hidden; }
@media (min-aspect-ratio: 3/4) { #stage { width: calc(100dvh * 0.56); max-width: 560px; } }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ===== HUD ===== */
#hud { position: absolute; inset: 0; pointer-events: none; padding-top: var(--safe-top); }
.hud-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px calc(10px + var(--sp-menu-w, 0px)) 8px 10px; }   /* the Sleepy Pines corner stays clear */
.hud-right { justify-self: end; }
.coins { pointer-events: auto; justify-self: start; display: flex; gap: 6px; align-items: center; background: #3b3450; color: #fff; font-weight: 700; padding: 4px 12px 4px 6px; border-radius: 14px; font-size: 15px; box-shadow: 0 2px 0 #211c2e; }
.coin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, #f5b800 70%); box-shadow: inset 0 0 0 2px #d69a00; vertical-align: -3px; flex: none; }
.big-coin { width: 34px; height: 34px; box-shadow: inset 0 0 0 4px #d69a00; }
.level-title { color: #fff; font-weight: 700; font-size: 22px; letter-spacing: .02em; text-shadow: 0 2px 0 #4a4466, 0 0 10px rgba(0,0,0,.25); white-space: nowrap; }
.bug { pointer-events: auto; border: 0; border-radius: 10px; background: #2f2a3d; color: #7dff8a; font: 700 11px monospace; padding: 6px 8px; cursor: pointer; }
#speedBtn { pointer-events: auto; position: absolute; right: 8px; top: calc(var(--safe-top) + 19%); border: 0; border-radius: 10px; padding: 4px 9px; background: #fff; color: #3b3450; display: flex; flex-direction: column; align-items: center; line-height: 1; box-shadow: 0 3px 0 #c9c4d8; cursor: pointer; transform: skewX(-8deg); }
#speedBtn b { font-size: 16px; } #speedBtn small { font-size: 8px; letter-spacing: .06em; color: #e38a00; }

.rush-bar { position: absolute; left: 50%; top: calc(var(--safe-top) + 6px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: #3b3450; border-radius: 16px; padding: 5px 10px; box-shadow: 0 3px 0 #211c2e; color: #fff; }
.rush-clock { font-weight: 700; font-size: 22px; min-width: 52px; text-align: center; }
.rush-clock.low { color: #ff6b5e; animation: pulse .5s ease-in-out infinite alternate; }
.rush-meter { width: 70px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
.rush-meter i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff9a3c, #ffd23f); border-radius: 4px; transition: width .2s linear; }
.rush-score { display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 700; font-size: 18px; min-width: 40px; }
.rush-score small { font-size: 9px; letter-spacing: .08em; opacity: .7; margin-top: 2px; }
@keyframes pulse { to { transform: scale(1.12); } }

.boosters { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 10px); display: flex; justify-content: center; align-items: flex-end; gap: 14px; }
.booster { pointer-events: auto; position: relative; width: 62px; height: 62px; border: 3px solid #fff; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #7ec8ff, #2d7fd6 75%); box-shadow: 0 4px 0 #1d5fa6, 0 4px 10px rgba(0,0,0,.25); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.booster svg { width: 28px; height: 28px; transform: translateY(-4px); }
.booster[data-booster="refresh"] { background: radial-gradient(circle at 50% 35%, #ff9a6b, #e04b2d 75%); box-shadow: 0 4px 0 #a8321d, 0 4px 10px rgba(0,0,0,.25); }
.booster[data-booster="sort"] { background: radial-gradient(circle at 50% 35%, #d49cff, #8b3fd6 75%); box-shadow: 0 4px 0 #612a9a, 0 4px 10px rgba(0,0,0,.25); }
.booster label { position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 700; letter-spacing: .04em; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.5); pointer-events: none; }
.booster .count { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; background: #4ccc5a; border: 2px solid #fff; color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.booster.active { outline: 4px solid var(--accent); outline-offset: 2px; animation: pulse .5s ease-in-out infinite alternate; }
.booster:disabled { filter: grayscale(.8); opacity: .6; }
.booster:active, .gear:active { transform: translateY(2px); }
.gear { pointer-events: auto; width: 46px; height: 46px; border: 3px solid #fff; border-radius: 50%; background: #2d7fd6; box-shadow: 0 4px 0 #1d5fa6; cursor: pointer; margin-bottom: 8px; padding: 8px; }
.gear svg { width: 100%; height: 100%; display: block; }
.menu { pointer-events: auto; position: absolute; right: 12px; bottom: calc(var(--safe-bottom) + 86px); background: #fff; border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 4; }
.menu button { border: 0; background: #eef0f6; border-radius: 10px; padding: 10px 16px; font: 700 14px 'Fredoka', sans-serif; color: var(--ink); cursor: pointer; text-align: left; }

/* ===== title ===== */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-top) + 6vh) 20px calc(var(--safe-bottom) + 5vh);
  background: linear-gradient(180deg, rgba(238,240,246,.35) 0%, rgba(238,240,246,.55) 45%, rgba(238,240,246,.8) 100%);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); z-index: 3; }
.title-top { display: flex; justify-content: center; width: 100%; }
.logo { border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: .82; padding: 0; animation: bob 3.2s ease-in-out infinite; touch-action: manipulation; }
.logo .mascot { width: min(58vw, 230px); height: auto; margin-bottom: 4px; filter: drop-shadow(0 6px 0 rgba(40,30,70,.12)); }
.logo span { font-weight: 700; font-size: min(22vw, 92px); letter-spacing: .01em; paint-order: stroke fill; -webkit-text-stroke: 10px #fff; }
.logo .w1 { color: #ff5a4e; text-shadow: 0 7px 0 #b83a30, 0 10px 18px rgba(40,30,70,.25); transform: rotate(-4deg); }
.logo .w2 { color: #3d8bff; text-shadow: 0 7px 0 #2857a8, 0 10px 18px rgba(40,30,70,.25); transform: rotate(3deg) translateX(10px); }
.logo.squish { animation: squish .18s ease-out; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes squish { 0% { transform: scale(1); } 40% { transform: scale(1.06, .92); } 100% { transform: scale(1); } }
.title-bottom { display: flex; flex-direction: column; align-items: center; width: min(320px, 100%); }
.title-bottom .sub { margin-top: 10px; color: var(--muted); font-size: 15px; font-weight: 600; }
.play { font-size: 30px !important; padding: 18px !important; border-radius: 22px !important; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.title-icons { display: flex; gap: 12px; margin-top: 18px; }
.roundicon { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: var(--ink); font-size: 20px; box-shadow: 0 3px 0 #c9c4d8; cursor: pointer; }
.roundicon.off { color: #b5acc4; text-decoration: line-through; }
.bugicon { font: 700 11px monospace; color: #2b9439; }

/* ===== mode select ===== */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; background: #fff; border-radius: 26px 26px 0 0; padding: 10px 16px calc(var(--safe-bottom) + 16px); box-shadow: 0 -10px 30px rgba(40,30,70,.2); display: flex; flex-direction: column; gap: 10px; animation: sheetIn .28s cubic-bezier(.2,.9,.3,1.1); }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
.grabber { width: 44px; height: 5px; border-radius: 3px; background: #d9d6e4; align-self: center; margin-bottom: 2px; }
.mode { position: relative; display: flex; align-items: center; gap: 14px; border: 0; border-radius: 20px; padding: 14px 16px; color: #fff; text-align: left; cursor: pointer; min-height: 74px; }
.mode svg { width: 52px; height: 52px; flex: none; }
.mode-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mode b { font-size: 22px; line-height: 1.1; }
.mode-text span { font-size: 14px; opacity: .92; margin-top: 2px; }
.mode .chev { font-size: 34px; line-height: 1; opacity: .8; }
.mode:active { transform: translateY(3px); }
.mode.journey { background: linear-gradient(135deg, #4ea0ff, #2d6fd6); box-shadow: 0 5px 0 #1f50a0; }
.mode.daily { background: linear-gradient(135deg, #ffad4a, #f07a1a); box-shadow: 0 5px 0 #b65610; }
.mode.rush { background: linear-gradient(135deg, #ff6b5e, #d6382d); box-shadow: 0 5px 0 #9a2419; }
.prog { display: block; height: 7px; background: rgba(255,255,255,.3); border-radius: 4px; margin-top: 7px; overflow: hidden; width: 80%; }
.prog i { display: block; height: 100%; width: 0; background: #ffd23f; border-radius: 4px; }
.badge { font-style: normal; font-weight: 700; font-size: 13px; background: rgba(255,255,255,.25); border-radius: 10px; padding: 3px 8px; white-space: nowrap; }
.badge:empty { display: none; }
.back { border: 0; background: none; color: var(--muted); font: 700 16px 'Fredoka', sans-serif; padding: 6px; cursor: pointer; }

/* ===== cards ===== */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(29, 24, 38, .6); padding: 20px; z-index: 5; }
.card { background: #fff; border-radius: 22px; padding: 26px 22px; width: min(320px, 100%); text-align: center; box-shadow: 0 12px 30px rgba(0,0,0,.25); animation: pop .3s cubic-bezier(.2,.9,.3,1.3); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.card.result { background: linear-gradient(#fff6d8, #ffe39a); border: 4px solid #5aa9ff; box-shadow: 0 0 0 4px #2d6fc9, 0 12px 30px rgba(0,0,0,.35); padding-top: 34px; position: relative; }
.ribbon { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); background: linear-gradient(#5aa9ff, #2d6fc9); color: #fff; font-weight: 700; font-size: 22px; padding: 8px 28px; border-radius: 14px; border: 3px solid #fff; box-shadow: 0 3px 0 #1d4f94; white-space: nowrap; }
.ribbon.red { background: linear-gradient(#ff7a6b, #d6382d); box-shadow: 0 3px 0 #9a2419; }
.welldone { margin: 6px 0 4px; font-size: 34px; color: #ff8a1f; text-shadow: 0 3px 0 #b85a00; paint-order: stroke fill; -webkit-text-stroke: 5px #fff; }
.reward-label { font-size: 12px; letter-spacing: .12em; color: #8a6a20; font-weight: 700; margin-top: 6px; }
.reward { font-size: 28px; font-weight: 700; margin: 6px 0 12px; display: flex; justify-content: center; align-items: center; gap: 8px; color: #4a3a00; background: rgba(255,255,255,.5); border-radius: 14px; padding: 8px; }
.big-score { font-size: 44px; }
.gift { font-size: 14px; font-weight: 600; color: #4a3a00; margin-bottom: 8px; }
.gift span { display: inline-block; background: #4ccc5a; color: #fff; border-radius: 8px; padding: 0 6px; margin-left: 4px; }
.streak { font-weight: 700; color: #e0701a; margin-bottom: 6px; }
.streak:empty { display: none; }
.big { display: block; width: 100%; border: 0; border-radius: 16px; padding: 14px; font: 700 20px 'Fredoka', sans-serif; letter-spacing: .04em; background: var(--go); color: #fff; box-shadow: 0 5px 0 #2f9d3c; cursor: pointer; margin-top: 10px; }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #2f9d3c; }
.big.alt { background: var(--accent); color: var(--accent-ink); box-shadow: 0 5px 0 #c99f00; font-size: 16px; }
.big.blue { background: #2d7fd6; box-shadow: 0 5px 0 #1d5fa6; font-size: 17px; }
.big.purple { background: #8b3fd6; box-shadow: 0 5px 0 #612a9a; font-size: 17px; }
.link { border: 0; background: none; color: #8a6a20; font: 700 15px 'Fredoka', sans-serif; margin-top: 12px; cursor: pointer; padding: 4px 10px; }
.card.teach { position: relative; padding-top: 20px; }
.card.teach canvas { width: 200px; height: 110px; display: block; margin: 0 auto 6px; }
.card.teach h3 { margin: 4px 0 6px; font-size: 24px; }
.card.teach p { margin: 0 0 6px; color: var(--muted); font-size: 16px; line-height: 1.35; }
.new-pill { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: #ff5a4e; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .1em; padding: 4px 14px; border-radius: 10px; border: 3px solid #fff; }

/* ===== debug ===== */
.debug { position: absolute; left: 8px; right: 8px; top: calc(var(--safe-top) + 8px); z-index: 8; max-height: 52%; display: flex; flex-direction: column; background: rgba(24,20,34,.94); color: #e8e6f0; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font: 13px/1.3 ui-monospace, Menlo, Consolas, monospace; }
.dbg-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.1); }
.dbg-head b { color: #7dff8a; font-size: 14px; }
.dbg-head span { flex: 1; opacity: .6; font-size: 11px; }
.dbg-head button { border: 0; background: rgba(255,255,255,.12); color: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.dbg-info { padding: 6px 10px; font-size: 11px; color: #b9b4cc; white-space: pre-wrap; border-bottom: 1px solid rgba(255,255,255,.08); }
.dbg-body { overflow-y: auto; padding: 6px 10px 10px; }
.dbg-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.dbg-row label { width: 56px; color: #9a95ad; font-size: 12px; }
.dbg-row input { background: #3a3450; border: 1px solid #554d70; color: #fff; border-radius: 6px; padding: 5px 6px; font: inherit; width: 74px; }
.dbg-row input[type="date"] { width: 140px; color-scheme: dark; }
.dbg-row button { background: #4a4266; border: 0; color: #fff; border-radius: 7px; padding: 6px 9px; font: inherit; cursor: pointer; }
.dbg-row button:active { background: #6a5f92; }
.dbg-row button.danger { background: #8a2c2c; }
.dbg-toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; margin: 8px 0; }
.dbg-toggles label { display: flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; }

#autotest-result, #uitest-result { position: absolute; left: 0; bottom: 0; font: 11px monospace; color: #000; background: #fff; padding: 2px 4px; z-index: 9; max-width: 100%; word-break: break-all; }

/* the modes on the title (no PLAY step) */
.mode-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.menu button.primary { background: var(--ink); color: #fff; }
/* short, wide screens (a phone held sideways): logo on the left, the modes on the right */
@media (orientation: landscape) and (max-height: 560px) {
  #title { flex-direction: row; justify-content: center; gap: 4vw; }
  #title .title-top { width: auto; }
  #title .logo .mascot { width: min(26vh, 150px); }
  #title .logo span { font-size: min(15vh, 64px); -webkit-text-stroke: 7px #fff; }
  #title .title-bottom { width: min(340px, 46vw); }
  #title .mode { min-height: 56px; padding: 8px 14px; }
  #title .mode svg { width: 38px; height: 38px; }
  #title .mode b { font-size: 18px; }
  #title .title-icons { margin-top: 8px; }
}

/* ===== Lantern Bay: a calm harbour at dusk. Softer, warmer colours; the puzzle colours stay clear. ===== */
:root { --bg: #e8dccf; --ink: #33304a; --muted: #6f6680; --accent: #f6cd4a; --accent-ink: #4a3a10; --go: #3fa38f; }
html, body { background: #1e2433; }
.coins { background: #3f4a66; box-shadow: 0 2px 0 #262d42; }
.booster { background: radial-gradient(circle at 50% 35%, #8ccbe6, #3d86c4 75%); box-shadow: 0 4px 0 #2a6597, 0 4px 10px rgba(0,0,0,.2); }
.booster[data-booster="refresh"] { background: radial-gradient(circle at 50% 35%, #ffbf8a, #e0794a 75%); box-shadow: 0 4px 0 #a9562f, 0 4px 10px rgba(0,0,0,.2); }
.booster[data-booster="sort"] { background: radial-gradient(circle at 50% 35%, #c9b0f0, #8d6bd0 75%); box-shadow: 0 4px 0 #65499e, 0 4px 10px rgba(0,0,0,.2); }
.booster label { font-size: 10.5px; bottom: -4px; }
.booster .count { background: #3fa38f; }
.gear { background: #3f7a95; box-shadow: 0 4px 0 #2b566b; }
.overlay { background: rgba(30, 36, 51, .55); }
.card.result { background: linear-gradient(#fffaf0, #f6e7c8); border: 4px solid #7fb6c8; box-shadow: 0 0 0 4px #3f7a95, 0 12px 30px rgba(0,0,0,.3); }
.ribbon { background: linear-gradient(#5fa6bd, #3f7a95); box-shadow: 0 3px 0 #2b566b; }
.ribbon.dusk { background: linear-gradient(#b48ac8, #8a63a8); box-shadow: 0 3px 0 #634579; }
.welldone { color: #e8914a; text-shadow: 0 3px 0 #a9612b; }
.big { box-shadow: 0 5px 0 #2b7666; }
.big:active { box-shadow: 0 2px 0 #2b7666; }
.big.blue { background: #3d86c4; box-shadow: 0 5px 0 #2a6597; }
.big.purple { background: #8d6bd0; box-shadow: 0 5px 0 #65499e; }
.mode.journey { background: linear-gradient(135deg, #5fa6bd, #3f7a95); box-shadow: 0 5px 0 #2b566b; }
.mode.daily { background: linear-gradient(135deg, #f6b65e, #e08a3c); box-shadow: 0 5px 0 #a8642a; }
.mode.rush { background: linear-gradient(135deg, #b48ac8, #8a63a8); box-shadow: 0 5px 0 #634579; }
.logo span { -webkit-text-stroke: 9px #fff8ec; }
.logo .w1 { color: #e8914a; text-shadow: 0 6px 0 #a9612b, 0 10px 18px rgba(40,30,70,.2); font-size: min(15vw, 66px); transform: rotate(-3deg); }
.logo .w2 { color: #3f86b0; text-shadow: 0 6px 0 #2a5e80, 0 10px 18px rgba(40,30,70,.2); transform: rotate(2deg); }
.roundicon { background: #fffaf0; box-shadow: 0 3px 0 #cbbca8; }
@media (orientation: landscape) and (max-height: 560px) { #title .logo .w1 { font-size: min(11vh, 48px); } }
