:root { --cream: #fff6df; --ink: #6b5536; --teal: #2fbfae; --gold: #f6c343; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd6ee; color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#clock { position: absolute; left: max(16px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); color: #fff; text-shadow: 0 2px 4px #0005; display: flex; flex-direction: column; }
#clock b { font-size: 30px; line-height: 1; }
#clock span { font-size: 15px; margin-top: 3px; }
#stars, #pocket { position: absolute; background: #fff6dfee; border-radius: 22px; padding: 7px 15px; font-size: 18px; font-weight: 700; box-shadow: 0 3px 0 #0002; }
#stars { right: max(16px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); }
#pocket { right: max(16px, env(safe-area-inset-right)); top: calc(max(14px, env(safe-area-inset-top)) + 46px); display: flex; gap: 11px; }
#stars i { color: var(--gold); font-style: normal; }
#pocket:empty { display: none; }
#map { pointer-events: auto; cursor: pointer; position: absolute; left: max(16px, env(safe-area-inset-left)); top: calc(max(14px, env(safe-area-inset-top)) + 64px); width: 160px; height: 120px; border-radius: 14px; border: 4px solid #fff6df; box-shadow: 0 3px 0 #0002; }

#hint { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #fff6dfee; border-radius: 22px; padding: 8px 18px; font-size: 18px; font-weight: 700; white-space: nowrap; pointer-events: none; }
#hint:empty { display: none; }
#toast { position: fixed; left: 50%; top: 18%; transform: translate(-50%, -8px); background: var(--teal); color: #fff; border-radius: 20px; padding: 10px 20px; font-size: 20px; font-weight: 700; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

#dialog { touch-action: pan-y; position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(760px, calc(100% - 32px)); max-height: calc(100% - 40px); overflow: auto; background: var(--cream); border-radius: 44px; padding: 28px 38px 22px; box-shadow: 0 6px 0 #0002; cursor: pointer; }
#name { position: sticky; top: -14px; display: inline-block; background: var(--teal); color: #fff; font-weight: 700; padding: 4px 16px; border-radius: 15px; font-size: 18px; margin-bottom: 8px; }
#say { font-size: 23px; line-height: 1.5; font-weight: 600; min-height: 2.6em; }
#say .step { display: block; font-size: 20px; }
#next { text-align: center; color: var(--gold); font-size: 20px; animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
#answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
#answers:empty { display: none; }
#answers button { font: inherit; font-size: 24px; font-weight: 700; color: var(--ink); background: #fff; border: 3px solid #eadcb9; border-radius: 22px; padding: 10px; min-height: 66px; cursor: pointer; }
#answers button:hover, #answers button:focus-visible { border-color: var(--teal); outline: none; }
#answers button.right { background: #c9f3d4; border-color: #4bb96c; }
#answers button.wrong { background: #fbd5cc; border-color: #df7a62; }
.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; margin: 0 .12em; font-size: .86em; }
.fr i { font-style: normal; display: block; padding: 0 .2em; }
.fr i:first-child { border-bottom: 2px solid currentColor; }

#stick, #act { display: none; position: fixed; }
.touch #stick { display: block; left: max(24px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); touch-action: none; width: 130px; height: 130px; border-radius: 50%; background: #fff4; border: 3px solid #fff8; }
#nub { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: #fffc; }
.touch #act { display: block; right: max(28px, env(safe-area-inset-right)); bottom: max(36px, env(safe-area-inset-bottom)); touch-action: none; width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--gold); color: #fff; font: inherit; font-size: 30px; font-weight: 800; box-shadow: 0 4px 0 #0003; }
.touch #hint { bottom: 170px; }

#title { position: fixed; inset: 0; display: grid; place-items: center; background: #7fd0eab0; padding: 16px; overflow: auto; touch-action: pan-y; }
.card { width: min(520px, 100%); background: var(--cream); border-radius: 36px; padding: 28px; text-align: center; box-shadow: 0 6px 0 #0002; }
.card h1 { margin: 0 0 8px; font-size: 42px; color: #3a9f6a; }
.card p { font-size: 19px; line-height: 1.4; margin: 8px 0; }
.card .keys, .card .thumbs { font-size: 15px; opacity: .85; }
.card .thumbs, .touch .card .keys { display: none; }
.touch .card .thumbs { display: block; }
#who { display: block; width: min(280px, 100%); margin: 10px auto; font: inherit; font-size: 20px; font-weight: 700; text-align: center; color: var(--ink); background: #fff; border: 3px solid #eadcb9; border-radius: 18px; padding: 8px 12px; outline: none; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
#who:focus { border-color: var(--teal); }
#start { font: inherit; font-size: 24px; font-weight: 700; color: #fff; background: var(--teal); border: 0; border-radius: 24px; padding: 10px 44px; margin: 8px; cursor: pointer; box-shadow: 0 4px 0 #0002; }

@media (max-width: 600px) {
  #dialog { padding: 20px 20px 14px; border-radius: 28px; bottom: 10px; }
  #say { font-size: 19px; }
  #answers button { font-size: 20px; min-height: 56px; }
  #map { width: 112px; height: 84px; }
  #clock b { font-size: 24px; }
}

.touch #dialog:not([hidden]) ~ #stick, .touch #dialog:not([hidden]) ~ #act { display: none; }
#animals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
#animals[hidden] { display: none; }
#animals button { font: inherit; font-size: 16px; font-weight: 700; color: var(--ink); background: #fff; border: 3px solid #eadcb9; border-radius: 18px; padding: 4px 2px 6px; cursor: pointer; min-width: 0; }
#animals canvas { display: block; width: 100%; aspect-ratio: 1; }
#animals button.on { border-color: var(--teal); background: #d6f5ef; }
#map.big { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, calc(100vw - 32px), calc((100dvh - 32px) * 4 / 3)); height: auto; aspect-ratio: 4 / 3; z-index: 5; }
@media (max-height: 500px) {
  #map { width: 112px; height: 84px; }
  .card { padding: 12px 20px; border-radius: 26px; }
  .card h1 { font-size: 28px; margin: 0; }
  .card p { font-size: 15px; margin: 2px 0; }
  .card > p:first-of-type { display: none; }
  #who { margin: 4px auto; padding: 4px 10px; }
  #animals { grid-template-columns: repeat(4, 76px); justify-content: center; }
  #start { padding: 5px 36px; margin: 4px; font-size: 20px; }
}
@media (max-height: 500px) { .touch #hint { bottom: 20px; } }
@media (max-height: 400px) {
  #clock span { display: none; }
  .touch .card .thumbs { display: none; }
  .card h1 { font-size: 22px; }
  #animals { grid-template-columns: repeat(4, 60px); }
  #animals button { font-size: 13px; padding: 2px 0 3px; }
  #pickwho { display: none; }
  #map { width: 96px; height: 72px; top: calc(max(14px, env(safe-area-inset-top)) + 32px); }
}

/* From the Home Screen, iOS leaves the page short of the screen by the status bar's height. */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html, body { height: 100lvh; }
}
