/* P'tit Crayon — tablet games: big touch targets, no zoom on double tap, same cheerful look as the site */
@font-face { font-family: "Fredoka"; src: url("fonts/fredoka.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Andika"; src: url("fonts/andika-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
:root { --bg: #fff8ec; --text: #3b2f4a; --muted: #8b7f99; --border: #f0dfbf; --purple: #9b5de5; --pink: #ff6f91; --green: #2fa84f; --yellow: #f5b400; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: "Fredoka", system-ui, sans-serif; color: var(--text); background: var(--bg) radial-gradient(circle at 1px 1px, #f3e2c2 1.5px, transparent 0) 0 0 / 22px 22px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
#game { min-height: 100%; max-width: 1100px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }

.g-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 12px; }
.g-top h1 { margin: 0; font-size: 1.3rem; font-weight: 600; color: var(--purple); }
.g-home, .g-say { min-width: 56px; height: 56px; border-radius: 28px; border: 3px solid var(--border); background: #fff; font-size: 1.4rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; text-decoration: none; color: var(--text); }
.g-stars { display: flex; gap: 6px; font-size: 2.4rem; line-height: 1; }
.g-stars span, .g-big-stars span { color: #e8dcc6; }
.g-stars span.on, .g-big-stars span.on { color: var(--yellow); text-shadow: 0 2px 0 #c98f00; }
.g-stars span.miss { color: #f2c4cf; }

.g-menu { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 10px; }
.g-menu h2 { margin: 0; font-size: 1.8rem; }
.g-games { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; width: 100%; }
.g-game { display: flex; flex-direction: column; align-items: center; gap: 6px; background: #fff; border: 4px solid var(--border); border-radius: 26px; padding: 14px; box-shadow: 0 5px 0 var(--border); }
.g-game img { width: 100%; max-width: 300px; border-radius: 14px; }
.g-game b { font-size: 1.5rem; }
.g-game small { color: var(--muted); font-size: 1rem; text-align: center; }
.g-game.on { border-color: var(--purple); box-shadow: 0 5px 0 #6f3db3; }
.g-levels { display: flex; gap: 10px; }
.g-level { min-width: 96px; height: 60px; border-radius: 30px; border: 3px solid var(--border); background: #fff; font-size: 1.3rem; font-weight: 600; }
.g-level.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.g-play { min-width: 220px; height: 84px; border: 0; border-radius: 42px; background: var(--green); color: #fff; font-size: 2rem; font-weight: 700; box-shadow: 0 6px 0 #1f7a38; }
.g-play:active, .g-game:active, .g-ans:active { transform: translateY(3px); }
.g-note, .g-wait { color: var(--muted); font-size: 1.1rem; text-align: center; }
.g-wait { margin: 25vh auto 0; display: flex; flex-direction: column; align-items: center; gap: 16px; font-size: 1.5rem; }

.g-q { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 20px; }
.g-help { margin: 0; font-size: 1.5rem; font-weight: 500; text-align: center; }
.g-pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 18px; max-width: 900px; background: #fff; border: 4px solid var(--border); border-radius: 28px; padding: 22px; }
.g-pile .gpic { width: clamp(56px, 11vw, 110px); height: clamp(56px, 11vw, 110px); }
.g-pile.n11 .gpic, .g-pile.n12 .gpic, .g-pile.n13 .gpic, .g-pile.n14 .gpic, .g-pile.n15 .gpic { width: clamp(46px, 8.5vw, 84px); height: clamp(46px, 8.5vw, 84px); }
.g-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; }
.g-ans { background: #fff; border: 5px solid var(--border); border-radius: 30px; box-shadow: 0 6px 0 var(--border); transition: background .15s, border-color .15s; }
.g-num { width: clamp(110px, 17vw, 160px); height: clamp(110px, 17vw, 160px); font: 400 clamp(3.4rem, 7vw, 5rem) "Andika", Arial, sans-serif; }
.g-picbtn { width: clamp(140px, 21vw, 210px); height: clamp(140px, 21vw, 210px); padding: 14px; }
.g-picbtn .gpic { width: 100%; height: 100%; object-fit: contain; }
.g-ans.good { background: #e3f7e8; border-color: var(--green); box-shadow: 0 6px 0 #1f7a38; animation: pop .4s; }
.g-ans.bad { border-color: #e0475e; animation: shake .45s; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.g-end { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.g-big-stars { display: flex; gap: 10px; font-size: clamp(3.5rem, 10vw, 6rem); line-height: 1; }
.g-big-stars span.on { animation: pop .5s both; }
.g-end h2 { margin: 6px 0 0; font-size: 2.4rem; color: var(--purple); }
.g-end p { margin: 0; font-size: 1.3rem; color: var(--muted); }
.g-end-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-top: 16px; }
.g-other { height: 84px; border-radius: 42px; border: 4px solid var(--border); background: #fff; padding: 0 26px; font-size: 1.3rem; font-weight: 600; }
@media (max-width: 560px) { .g-top h1 { font-size: 1rem; } .g-stars { font-size: 1.8rem; } }

/* choose, then validate */
.g-ans.sel { border-color: var(--purple); box-shadow: 0 6px 0 #6f3db3; background: #f4eefe; transform: translateY(-3px); }
.g-ans.hint { animation: glow 1.2s ease-in-out infinite; border-color: var(--yellow); }
@keyframes glow { 50% { box-shadow: 0 0 0 10px rgba(245, 180, 0, .35), 0 6px 0 #c98f00; } }
.g-ok { min-width: 240px; height: 80px; border: 0; border-radius: 40px; background: var(--green); color: #fff; font-size: 1.9rem; font-weight: 700; box-shadow: 0 6px 0 #1f7a38; }
.g-ok:disabled { background: #d9d2c4; box-shadow: 0 6px 0 #bdb4a3; color: #fff; }
.g-ok:not(:disabled) { animation: pop .35s; }
/* sparkles where the screen is touched */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.spark { position: absolute; width: calc(12px * var(--s)); height: calc(12px * var(--s)); margin: calc(-6px * var(--s)); border-radius: 50%; background: var(--c); animation: spark .8s cubic-bezier(.2, .7, .3, 1) forwards; }
.spark.star { background: none; color: var(--c); font-size: calc(20px * var(--s)); width: auto; height: auto; margin: -12px; line-height: 1; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.3) rotate(160deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .spark { display: none; } }

/* ---------- unicorn games */
.g-ico { position: relative; display: flex; align-items: center; justify-content: center; height: 150px; width: 100%; background: linear-gradient(#f4eefe, #fff); border-radius: 14px; }
.g-ico img { width: 110px; height: 110px; }
.g-ico img + img { width: 70px; height: 70px; margin-left: -18px; margin-top: 40px; }
.g-ico-uni svg { width: 200px; height: 150px; }
.g-games { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important; }
.g-game > img { height: 150px; object-fit: contain; }
.g-title { font-size: 1.3rem; font-weight: 600; color: var(--purple); }
/* the drawing */
.unicorn .z { stroke: #3b2f4a; stroke-width: 2.2; stroke-linejoin: round; transition: fill .15s; }
.unicorn .dot { fill: #3b2f4a; }
.unicorn .ln { fill: none; stroke: #3b2f4a; stroke-width: 2; stroke-linecap: round; }
.unicorn.om .z { stroke: none; }
/* journey: rainbow + clouds + castle, the unicorn hops from cloud to cloud */
.g-board { position: relative; width: 100%; max-width: 900px; margin: 0 auto; }
.rainbow { display: block; width: 72%; margin: 0 auto -18px; }
.rainbow .arc { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke .5s; }
.rainbow .arc.new { animation: arcin .8s; }
@keyframes arcin { from { stroke-dasharray: 0 400; } to { stroke-dasharray: 400 0; } }
.rainbow.big { width: min(560px, 90%); }
.g-path { position: relative; height: 92px; display: grid; grid-template-columns: repeat(8, 1fr); align-items: end; }
.cloud img { width: 100%; max-width: 86px; display: block; margin: 0 auto; }
.castle img { width: 100%; max-width: 96px; display: block; margin: 0 auto; }
.g-uni { position: absolute; bottom: 30px; left: calc((100% / 8) * var(--at)); width: calc(100% / 8); transition: left .7s cubic-bezier(.3, 1.4, .5, 1); pointer-events: none; }
.g-uni img { width: 74px; height: 74px; display: block; margin: 0 auto; }
.g-uni.hop img { animation: hop .7s; }
@keyframes hop { 40% { transform: translateY(-38px) rotate(-8deg); } 100% { transform: none; } }
.g-model { background: #fff; border: 4px solid var(--purple); border-radius: 24px; padding: 10px; }
.g-model .gpic { width: 120px; height: 120px; }
.gpic.r90 { transform: rotate(90deg); } .gpic.r180 { transform: rotate(180deg); } .gpic.r270 { transform: rotate(270deg); }
.g-end-voyage h2 { max-width: 640px; }
.g-castle-end { position: relative; }
.g-castle-end > img { width: 180px; height: 180px; }
.g-uni-dance { position: absolute; left: -90px; bottom: 0; }
.g-uni-dance img { width: 120px; height: 120px; animation: dance 1s ease-in-out infinite; }
@keyframes dance { 50% { transform: translateY(-22px) rotate(-6deg); } }
/* feed the unicorn */
.g-feed { flex: 1; display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; align-items: center; }
.g-pilebox { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: #fff; border: 4px dashed var(--border); border-radius: 26px; padding: 16px; }
.treat { touch-action: none; cursor: grab; display: flex; justify-content: center; }
.treat img { width: clamp(56px, 8vw, 84px); height: clamp(56px, 8vw, 84px); pointer-events: none; }
.treat.taken { visibility: hidden; }
.ghost { position: fixed; z-index: 60; pointer-events: none; transform: scale(1.15); filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .2)); }
.ghost img { width: 100%; height: 100%; }
.g-unibox { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; background: linear-gradient(#f4eefe, #fff); border: 4px solid #e3d5fb; border-radius: 30px; padding: 12px; }
.feed-uni { width: 100%; max-width: 380px; height: auto; }
.g-unibox.munch .feed-uni { animation: munch .45s; }
@keyframes munch { 30% { transform: scale(1.06, .95); } 60% { transform: scale(.97, 1.04); } }
.g-unibox.nope .feed-uni { animation: shake .5s; }
.g-unibox.happy .feed-uni { animation: dance .6s 2; }
.g-bubble { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid #e3d5fb; border-radius: 22px; padding: 6px 16px; font-size: 1.6rem; }
.g-want { display: flex; align-items: center; gap: 10px; }
.g-want b { font: 400 2.6rem/1 "Andika", Arial, sans-serif; }
.g-dots { color: var(--purple); letter-spacing: 2px; font-size: 1.5rem; }
.g-dots.need { color: #2fa84f; } .g-dots.too { color: #e0475e; }
.g-bub-pic { width: 46px; height: 46px; }
.g-belly { min-height: 64px; display: flex; align-items: center; justify-content: center; }
.g-fed { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.g-fed img { width: 40px; height: 40px; animation: pop .3s; }
.g-belly-empty { color: var(--muted); font-size: 1.1rem; }
.g-feed-btns { display: flex; justify-content: center; gap: 16px; padding: 14px 0 4px; }
.g-other:disabled { opacity: .45; }
/* colouring */
.g-modes { display: flex; gap: 8px; }
.g-modes .g-level { min-width: 0; height: 52px; padding: 0 16px; font-size: 1.05rem; }
.g-color { flex: 1; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.g-palette { display: grid; grid-template-columns: repeat(2, 54px); gap: 10px; }
.g-pen { width: 54px; height: 54px; border-radius: 50%; border: 4px solid #fff; background: var(--pen); box-shadow: 0 0 0 2px var(--border); font-size: 1.4rem; }
.g-pen.on { box-shadow: 0 0 0 4px var(--purple); transform: scale(1.1); }
.g-pen.gomme { background: #fff; }
.g-canvas { position: relative; background: #fff; border: 4px solid var(--border); border-radius: 28px; padding: 10px; display: flex; justify-content: center; }
.g-canvas > svg { width: 100%; max-height: 62vh; height: auto; touch-action: manipulation; }
.g-mini { position: absolute; right: 10px; bottom: 10px; width: 26%; background: #fff; border: 3px solid #e3d5fb; border-radius: 16px; padding: 4px; pointer-events: none; }
.g-mini svg { width: 100%; height: auto; }
.g-drawings { display: grid; gap: 8px; }
.g-dr { width: 70px; height: 62px; border-radius: 16px; border: 3px solid var(--border); background: #fff; padding: 4px; }
.g-dr img { width: 100%; height: 100%; object-fit: contain; }
.g-dr .g-ico-uni svg { width: 100%; height: 100%; }
.g-dr.on { border-color: var(--purple); }
@media (max-width: 760px) {
  .g-feed { grid-template-columns: 1fr; }
  .g-color { grid-template-columns: 1fr; }
  .g-palette { grid-template-columns: repeat(6, 48px); justify-content: center; }
  .g-drawings { grid-template-columns: repeat(7, 1fr); }
}

/* our own unicorn on the board / end / menu, model beside the palette */
.g-uni .uni-sm { width: 96px; height: auto; display: block; margin: 0 auto; }
.g-uni.hop .uni-sm { animation: hop .7s; }
.g-uni-dance .uni-dance { width: 150px; height: auto; animation: dance 1s ease-in-out infinite; }
.g-uni-dance { left: -130px; }
.g-ico-uni.small svg { width: 120px; height: 100px; }
.g-side { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.g-mini { position: static; width: 128px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.g-mini small { color: var(--muted); font-size: .85rem; }
.g-ico img + .g-ico-uni, .g-ico .g-ico-uni + img { margin-left: -14px; }
