/* Raptoku: a sunny prehistoric morning. Warm cream paper, deep cocoa outlines, soft meadow colours for the patches,
   Titan One for the loud words and Nunito for the rest (both with every Polish letter). Phone first: portrait, one
   hand, the tools at the bottom where the thumb is. Nothing ever scrolls. */
@font-face { font-family: 'Titan One'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/titan-one-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Titan One'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/titan-one-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url(fonts/nunito-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url(fonts/nunito-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url(fonts/nunito-latin-ext-800-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url(fonts/nunito-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #3A2A22;
  --ink-soft: #6B564A;
  --paper: #FFF9EE;
  --cream: #FFF4DF;
  --leaf: #5DBB63;
  --leaf-dark: #2F8A3E;
  --sun: #FFC93C;
  --coral: #FF7A59;
  --sky: #8FD3F4;
  --red: #E5484D;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font: 700 16px/1.3 Nunito, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; }
body { background: radial-gradient(120% 70% at 50% 0%, #FFFDF6 0%, var(--cream) 55%, #FBE6C2 100%); position: fixed; inset: 0;
  display: grid; grid-template-rows: auto auto 1fr auto; grid-template-areas: "top" "tip" "board" "controls";
  padding: calc(6px + var(--st)) calc(10px + var(--sr)) calc(8px + var(--sb)) calc(10px + var(--sl)); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

/* ---------- the top: menu, where you are, eggs placed, sound ---------- */
#top { grid-area: top; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; min-height: 52px; }
.icon { width: 48px; height: 48px; border-radius: 16px; border: 3px solid var(--ink); background: var(--paper); display: grid; place-items: center; padding: 0;
  box-shadow: 0 3px 0 var(--ink); }
.icon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.icon svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#sound .spk { fill: var(--ink); stroke: none; }
#sound .cross { display: none; }
#sound.off .wave { display: none; }
#sound.off .cross { display: inline; }
#title { display: grid; justify-items: center; line-height: 1.05; min-width: 0; }
#place { font: 800 13px Nunito, sans-serif; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; letter-spacing: .02em; }
#status { display: inline-flex; align-items: center; gap: 12px; }
#count { display: inline-flex; align-items: center; gap: 6px; font: 26px/1.1 'Titan One', sans-serif; transition: transform .15s; }
#count small { font-size: 17px; color: var(--ink-soft); margin-left: -3px; }
#count.bump { transform: scale(1.12); }
#count.full span { color: var(--leaf-dark); }
.egg-ico { display: inline-block; width: 18px; height: 23px; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; background: radial-gradient(circle at 35% 30%, #fff 0 14%, #F6EBD6 15% 60%, #E3CFA9);
  border: 2.5px solid var(--ink); }

/* ---------- the tip line over the board ---------- */
#tip { grid-area: tip; margin: 4px auto 0; min-height: 44px; max-width: 520px; display: grid; place-items: center; text-align: center; font: 800 15px/1.25 Nunito, sans-serif;
  color: var(--ink); padding: 0 6px; }
#tip.hint { color: #7A3E00; }
#tip .x { display: inline-block; font: 15px 'Titan One', sans-serif; color: var(--ink-soft); }

/* ---------- the board ---------- */
#board-wrap { grid-area: board; position: relative; min-height: 0; display: grid; place-items: center; }
#board { display: block; touch-action: none; cursor: pointer; }
/* the valley's baby, peeking over the board where a tall screen leaves room */
#mum { position: absolute; pointer-events: none; display: none; }
#mum.on { display: block; }

/* ---------- the tools at the bottom (thumb reach) ---------- */
#controls { grid-area: controls; display: flex; justify-content: center; gap: 12px; padding-top: 8px; }
.tool { flex: 1 1 0; max-width: 150px; min-height: 64px; border-radius: 20px; border: 3px solid var(--ink); background: var(--paper); box-shadow: 0 4px 0 var(--ink);
  display: grid; justify-items: center; align-content: center; gap: 2px; padding: 4px 6px; }
.tool svg { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tool span { font: 800 13px Nunito, sans-serif; white-space: nowrap; }
.tool.main { background: var(--sun); }
.tool.main .bulb { fill: #FFF3B0; }
.tool:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tool[disabled] { opacity: .45; pointer-events: none; }
.tool.wait { opacity: .6; pointer-events: none; }

/* ---------- the loading cover and the studio's name ---------- */
#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 16px; text-align: center;
  background: radial-gradient(circle at 50% 38%, #FFFDF5, #FFE7B8 70%, #F9CF86); }
body.ready #loading { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s, visibility 0s .35s; }
body:not(.ready) #top, body:not(.ready) #controls, body:not(.ready) #board-wrap, body:not(.ready) #tip { visibility: hidden; }
#loading .logo { font: clamp(40px, 11vw, 88px)/1 'Titan One', sans-serif; color: var(--sun); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink); visibility: hidden; white-space: nowrap; }
body:not(.ready) #loading .logo.ok { visibility: visible; }
#loading .tag { font-style: normal; font-weight: 800; font-size: 17px; max-width: 320px; }
#loading small { margin-top: 10px; font: 13px 'Titan One', sans-serif; opacity: .6; letter-spacing: .08em; }
#loading .egg { position: relative; width: 66px; height: 82px; margin-bottom: 8px; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; border: 4px solid var(--ink);
  background: radial-gradient(circle at 34% 28%, #fff 0 12%, #E9F7D8 13% 55%, #BFE3A1); animation: wobble 1.1s ease-in-out infinite; transform-origin: 50% 90%; }
#loading .egg b { position: absolute; inset: 0; border-radius: inherit; background:
  radial-gradient(circle at 62% 40%, #6FB65A 0 7%, transparent 8%), radial-gradient(circle at 38% 62%, #6FB65A 0 6%, transparent 7%), radial-gradient(circle at 66% 72%, #6FB65A 0 5%, transparent 6%); }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-9deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
#studio { position: fixed; right: calc(12px + var(--sr)); bottom: calc(4px + var(--sb)); margin: 0; z-index: 3; font: 11px 'Titan One', sans-serif; opacity: .45; pointer-events: none; transition: opacity .8s; }
#studio.gone { opacity: 0; }

/* ---------- cards ---------- */
#overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: calc(10px + var(--st)) calc(10px + var(--sr)) calc(10px + var(--sb)) calc(10px + var(--sl));
  background: rgba(58, 42, 34, .42); }
#overlay[hidden] { display: none; }
.card { width: min(440px, 100%); max-height: 100%; overflow: auto; background: var(--paper); border: 4px solid var(--ink); border-radius: 26px; padding: 14px 16px 16px;
  box-shadow: 0 8px 0 var(--ink); text-align: center; animation: card-in .35s cubic-bezier(.2,1.5,.4,1); overscroll-behavior: contain; touch-action: pan-y; }
.card.wide { width: min(560px, 100%); }
@keyframes card-in { from { transform: scale(.7) translateY(20px); opacity: 0; } }
.card h2 { margin: 0 0 6px; font: 30px/1.1 'Titan One', sans-serif; color: var(--sun); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.card h3 { margin: 10px 0 4px; font: 16px 'Titan One', sans-serif; }
.card p { margin: 6px 0; }
.kicker { margin: 0 0 2px; font: 800 13px Nunito, sans-serif; color: var(--ink-soft); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.card > .row:last-child { position: sticky; bottom: -16px; background: var(--paper); padding: 6px 0 4px; z-index: 1; }
.btn { min-height: 54px; min-width: 130px; padding: 8px 18px; border-radius: 18px; border: 3px solid var(--ink); background: var(--sun); font: 19px 'Titan One', sans-serif;
  box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.ghost { background: #fff; font-size: 17px; }
.btn.green { background: var(--leaf); color: #fff; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }
/* a rewarded ad: the same size as the plain button next to it, never smaller */
.btn.reward { background: #fff; font-size: 17px; }
.row.pair .btn { flex: 1 1 0; min-width: 0; max-width: 220px; }
.btn.wait { opacity: .6; pointer-events: none; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.studio-line { margin: 10px 0 0; font: 11px 'Titan One', sans-serif; opacity: .45; }

/* the focus guard: the game inside a portal's frame lost the keyboard */
#focus-guard { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(58, 42, 34, .35); border: 0; padding: 0; }
#focus-guard[hidden] { display: none; }

/* ---------- the nest list of a valley ---------- */
.vhead { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 6px; }
.vhead h2 { font-size: 24px; }
.vhead .icon { font: 28px/1 'Titan One', sans-serif; }
.vhead .icon[disabled] { opacity: .3; }
.lvgrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 8px; }
.lv { aspect-ratio: 1; min-height: 36px; border-radius: 12px; border: 2.5px solid var(--ink); background: #fff; font: 15px 'Titan One', sans-serif; padding: 0; display: grid; place-items: center;
  box-shadow: 0 2px 0 var(--ink); }
.lv.done { background: #DFF3C8; }
.lv.done i { width: 15px; height: 19px; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; border: 2px solid var(--ink); background: #fff; position: relative; }
.lv.done i::after { content: ''; position: absolute; left: -2px; right: -2px; top: 38%; height: 0; border-top: 2px solid var(--ink); transform: rotate(-8deg); }
.lv.cur { background: var(--sun); }
.lv[disabled] { opacity: .35; box-shadow: none; }
.lv:active { transform: translateY(2px); box-shadow: none; }
@media (max-width: 360px) { .lvgrid { gap: 4px; } .lv { min-height: 30px; font-size: 13px; border-radius: 9px; } }

/* ---------- the nursery ---------- */
.nursery { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.nest-card { display: grid; justify-items: center; border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; padding: 2px 2px 4px; min-width: 0; }
.nest-card canvas { width: 100%; height: auto; }
.nest-card b { font: 800 11px/1.1 Nunito, sans-serif; text-align: center; overflow-wrap: anywhere; }
.nest-card small { font: 13px 'Titan One', sans-serif; color: var(--leaf-dark); }
.nest-card.locked { background: #F3EBDD; }
@media (max-width: 420px) { .nursery { grid-template-columns: repeat(5, 1fr); } .nest-card b { font-size: 9.5px; } }
canvas.baby { display: block; margin: 0 auto; }
.card > canvas.baby { width: 160px; height: 120px; }
.rules-pic { display: block; width: 100%; max-width: 300px; height: auto; margin: 4px auto; }

/* ---------- a wide, low screen (a phone on its side) ----------
   The board in the middle, as tall as the screen allows; on the left the menu and sound buttons, where you are and the
   tip; on the right the tools in a column. (At the end of the file so it wins over the rules above.) */
@media (orientation: landscape) and (max-height: 560px) {
  body { grid-template-columns: minmax(0, 1fr) min(calc(100vh - 16px - var(--st) - var(--sb)), calc(100vw - 250px)) minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) min(calc(100dvh - 16px - var(--st) - var(--sb)), calc(100vw - 250px)) minmax(0, 1fr);
    grid-template-rows: auto 1fr; grid-template-areas: "top board controls" "tip board controls"; column-gap: 10px; }
  #top { grid-template-columns: 48px 48px; grid-template-areas: "menu sound" "title title"; justify-content: center; align-self: start; row-gap: 6px; }
  #menu { grid-area: menu; } #sound { grid-area: sound; } #title { grid-area: title; }
  #place { white-space: normal; text-align: center; font-size: 12px; }
  #tip { align-self: start; margin-top: 8px; max-width: 240px; font-size: 13px; }
  #controls { flex-direction: column; justify-content: center; align-items: center; padding: 0; gap: 10px; }
  .tool { flex: 0 0 auto; width: min(120px, 100%); min-height: 56px; }
}
@media (orientation: landscape) and (max-height: 400px) {
  .tool { min-height: 48px; } .tool svg { width: 22px; height: 22px; } .tool span { font-size: 12px; }
  #count { font-size: 22px; }
}

/* ---------- low screens: tighter cards, so every card fits without scrolling ---------- */
@media (max-height: 560px) {
  .card { padding: 8px 14px 10px; border-width: 3px; box-shadow: 0 5px 0 var(--ink); }
  .card.wide, .card.rules { width: min(680px, 100%); }
  .card h2 { font-size: 22px; margin-bottom: 2px; }
  .card p { margin: 3px 0; font-size: 14px; line-height: 1.25; }
  .row { margin-top: 6px; gap: 8px; }
  .btn { min-height: 42px; font-size: 16px; padding: 4px 14px; }
  .btn.ghost { font-size: 15px; }
  .card > canvas.baby { width: 100px; height: 75px; }
  .rules-pic { display: none; }
  .card.rules .txt { column-count: 2; column-gap: 18px; text-align: left; }
  .vhead { grid-template-columns: 40px 1fr 40px; }
  .vhead .icon { width: 40px; height: 40px; }
  .vhead h2 { font-size: 20px; }
  .lvgrid { grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 4px; }
  .lv { aspect-ratio: auto; height: 34px; min-height: 0; font-size: 13px; border-radius: 9px; }
  .nest-card canvas { max-height: 52px; }
  .nursery { gap: 4px; }
  .studio-line { margin-top: 4px; }
}
@media (max-height: 400px) {
  .card h2 { font-size: 19px; }
  .card p { font-size: 13px; }
  .btn { min-height: 38px; }
  .lv { height: 28px; }
  .nest-card canvas { max-height: 40px; }
  .card > canvas.baby { width: 72px; height: 54px; }
  .kicker { font-size: 12px; }
}
@media (max-width: 340px) { .card p { font-size: 14.5px; line-height: 1.25; } .card h2 { font-size: 26px; } }

/* the hearts: three per nest, a wrong egg takes one */
#hearts { display: inline-flex; gap: 2px; }
#hearts i { display: block; width: 20px; height: 20px; transition: transform .2s, opacity .2s; }
#hearts svg { width: 100%; height: 100%; fill: #E5484D; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
#hearts i.lost { opacity: .35; transform: scale(.8); }
#hearts i.lost svg { fill: #D9CFC2; }
#hearts.hit { animation: heart-hit .45s; }
@keyframes heart-hit { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
#tip[data-kind="bad"] { color: #B4232F; }
@media (max-width: 340px) { #hearts i { width: 17px; height: 17px; } #status { gap: 8px; } }
@media (orientation: landscape) and (max-height: 560px) { #status { flex-direction: column; gap: 2px; } }
@media (max-height: 600px) { .rules-pic { display: none; } }
/* narrow phones: two buttons in a row keep their words inside (long words in German, French, Italian, Portuguese) */
@media (max-width: 380px) { .row.pair .btn { padding-left: 6px; padding-right: 6px; font-size: 15px; } .row.pair .btn.ghost { font-size: 14px; } }
@media (max-width: 340px) { .row.pair .btn, .row.pair .btn.ghost { font-size: 13px; white-space: normal; line-height: 1.1; } }
@media (max-height: 700px) { .rules-pic { display: none; } }
