* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: 'Segoe UI', system-ui, sans-serif; color: #ecfbf8; background: #062b3c; }
body { margin: 0; background: radial-gradient(ellipse at 12% 0%, #12536a, transparent 55%), #062b3c; min-height: 100vh; }
main { max-width: 1080px; margin: auto; padding: 24px 30px 18px; }
button { font: inherit; font-weight: 650; min-height: 48px; border: 1px solid #78bbc482; border-radius: 14px; background: #164e62; color: #f0ffff; padding: 10px 17px; cursor: pointer; }
button:hover { background: #23697c; }
button:focus-visible { outline: 3px solid #ffe4a1; outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed="true"] { background: #c8eee5; color: #123c48; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.eyebrow { font-size: 10px; letter-spacing: .2em; color: #a5d7d5; margin: 0 0 6px; }
h1 { font-family: Georgia, serif; font-weight: 400; letter-spacing: -.04em; font-size: 46px; margin: 0; line-height: 1.1; }
.tools { display: flex; gap: 8px; }
.play-shell { border: 1px solid #8fe1d83b; border-radius: 22px; overflow: hidden; background: #063e52; box-shadow: 0 18px 54px #001e304a; }
.readout { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 24px; background: #092f40; min-height: 80px; }
.form-label { display: flex; gap: 13px; align-items: center; }
.caption { display: block; color: #abd0d1; font-size: 10px; letter-spacing: .1em; margin-bottom: 4px; }
.form-label strong { font-size: 21px; font-weight: 650; }
.capture-total { display: block; color: #d3e7cd; font-size: 13px; margin-top: 3px; }
.capture-total b { color: #efffcf; }
.form-icon { width: 25px; height: 31px; background: #7ce4ff; border: 2px solid #ecfcff; border-radius: 70% 35% 65% 50%; transform: rotate(-25deg); }
.form-icon.green { background: #bce86b; border-radius: 2px; transform: rotate(20deg); }
.form-icon.yellow { background: #ffd450; border-radius: 4px; transform: rotate(20deg); }
.form-icon.angler { background: #cb875e; border-radius: 60% 80% 50% 35%; transform: rotate(-10deg); }
.form-icon.umbrella { background: #efa6ac; border-radius: 70% 70% 30% 30%; }
.form-icon.cookie,.form-icon.viper,.form-icon.telescope { background: #b9cddd; border-radius: 80% 45%; }
#creature-progress { text-align: right; }
.circuits { text-align: right; }
.circuits > div { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.circle { display: inline-grid; place-items: center; border: 1px solid #9bc2ce; border-radius: 50%; width: 27px; height: 27px; font-weight: 600; font-size: 13px; }
.circle.filled { color: #103849; background: #a3e9ef; border-color: #a3e9ef; }
#count { margin-left: 4px; min-width: 40px; font-size: 14px; }
.scene { position: relative; background: #0c6781; }
.corner-form { position: absolute; left: 8px; top: 8px; pointer-events: none; display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #a9ddd4; border-radius: 10px; background: #082f40; font-size: 13px; }
.corner-form #form { font-size: inherit; }
.corner-form #form-icon { width: 12px; height: 15px; }
.phase { display:inline-block; margin-left:10px; color:#d7eceb; font-size:12px; }
.secret { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; background:#082f40f5; padding:12px; text-align:center; }
.secret[hidden] { display:none; }
.secret p { margin:0; line-height:1.55; font-size:18px; }
.form-icon.serpent,.form-icon.bloop,.form-icon.eater,.form-icon.maja { background:#a6b9c8; border-radius:60% 60% 30% 30%; }
.form-icon.dragon { background:#45baf1; border-radius:60% 30% 40% 30%; }
.form-icon.bird { border-radius:65% 30%; }
.form-icon.dangerous { background:#9d233d; border-color:#f5a4b4; }
.dragon-scene { position:absolute;inset:0;background:#092e49;display:grid;grid-template-rows:minmax(0,1fr) auto auto;justify-items:center;gap:6px;padding:8px; }
.dragon-scene[hidden] { display:none; }
.dragon-scene #dragon-picture,.dragon-scene #shore-picture { width:100%;height:100%;min-height:0;max-height:none;object-fit:contain;aspect-ratio:auto; }
.dragon-scene p { margin:0;text-align:center;font-size:16px;line-height:1.3; }
.dragon-scene button { min-height:48px;padding:8px 12px; }
@media (orientation:landscape) and (max-height:600px) {
  .dragon-scene { grid-template-columns:55% 1fr;grid-template-rows:1fr 1fr;gap:4px 8px;align-items:center; }
  .dragon-scene #dragon-picture,.dragon-scene #shore-picture { grid-row:1 / 3; }
  .dragon-scene p { align-self:end; }
  .dragon-scene button { align-self:start;min-width:0; }
}
@media (max-width:620px) { .secret p { font-size:16px;line-height:1.45; } }
@media (orientation:landscape) and (max-height:600px) { .secret { gap:6px;padding:8px; } .secret p { font-size:14px;line-height:1.35; } }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 12 / 7; }
.veil { position: absolute; inset: 0; background: #04384ba6; backdrop-filter: blur(5px); display: grid; place-items: center; padding: 16px; }
.veil[hidden] { display: none; }
.intro { text-align: center; border: 1px solid #88d3d86b; border-radius: 24px; background: #093b4fee; padding: 24px 36px; box-shadow: 0 20px 60px #02283870; }
.intro-drop { margin: 0 auto 14px; width: 28px; height: 35px; background: #87e6ff; border: 2px solid #e8feff; border-radius: 70% 35% 65% 50%; transform: rotate(-25deg); }
h2 { font: 400 30px Georgia, serif; margin: 0 0 12px; }
.intro p { line-height: 1.7; margin: 0 0 18px; color: #d4efee; }
.primary { background: #caead1; color: #143f42; min-width: 164px; border: 0; }
.primary:hover { background: #e0f9dd; }
#hint { margin: 12px 0 0; font-size: 12px; color: #a4cece; }
.instructions { padding: 12px 24px 14px; background: #0d4253; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.instructions p { margin: 0; font-size: 18px; font-weight: 650; }
.instructions span { font-size: 13px; color: #c3e0df; }
.instructions > div { flex-shrink:0; }
.instructions > div:first-child { flex-shrink:1; min-width:0; }
#food-hint:not([hidden]) { display:block; margin-top:4px; color:#fff3c3; font-size:13px; }
#next-secret:not([hidden]) { display:block; color:#fff1b8; }
.controls { display: flex; justify-content: space-between; align-items: center; padding: 16px 12px 0; gap: 16px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: #c1dfdf; max-width: 370px; }
.legend span { display: inline-flex; gap: 8px; align-items: center; }
.legend small { flex-basis: 100%; font-size: 11px; color: #95b7bc; }
.control-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.control-buttons button { min-width: 48px; padding-inline: 10px; }
#tilt-status { color: #c1dfdf; line-height: 1.4; }
.drop-key { width: 13px; height: 16px; background: #7bdfff; border: 1px solid white; border-radius: 70% 35% 65% 50%; transform: rotate(-25deg); }
.chemical-key { width: 15px; height: 15px; background: #bce86b; border: 1px solid #dfffa4; clip-path: polygon(50% 0,65% 26%,100% 18%,85% 52%,100% 82%,65% 77%,50% 100%,36% 77%,0 82%,15% 52%,0 18%,35% 26%); }
.movement { display: flex; align-items: center; gap: 22px; }
.key-hint { color: #99bfc4; font-size: 11px; letter-spacing: .12em; }
.pad { display: grid; grid-template-columns: repeat(3,48px); grid-template-rows: repeat(2,48px); gap: 5px; }
.pad button { touch-action: none; user-select: none; -webkit-user-select: none; padding: 0; font-size: 25px; border-radius: 13px; }
.pad button.held { background: #a9e7e5; color: #083c50; }
.up { grid-area: 1 / 2; }.left { grid-area: 2 / 1; }.right { grid-area: 2 / 3; }.down { grid-area: 2 / 2; }
.pad-centre { grid-area: 1 / 1; opacity: 0; }
@media (max-width: 620px) {
  main { padding: 14px 10px; }
  .masthead { margin-bottom: 14px; }
  h1 { font-size: 34px; }.eyebrow { font-size: 8px; letter-spacing: .12em; }
  .tools { gap: 6px; }.tools button { padding: 8px 10px; font-size: 12px; }
  .readout { padding: 10px 12px; min-height: 74px; }.caption { font-size: 8px; }.form-label { gap: 8px; }.form-label strong { font-size: 16px; }
  .form-icon { width: 20px; height: 26px; }.circle { width: 24px; height: 24px; }.circuits > div { gap: 5px; }
  .scene { min-height: 270px; }canvas { height: 270px; object-fit: contain; }
  .intro { padding: 16px 20px; }.intro-drop { display: none; }h2 { font-size: 24px; }.intro p { font-size: 14px; line-height: 1.55; margin-bottom: 12px; }
  .instructions { display: block; padding: 11px 12px; min-height: 70px; }.instructions p { font-size: 16px; margin-bottom: 4px; }
  .instructions span { font-size: 12px; }.controls { padding: 14px 3px 0; gap: 8px; }.legend { font-size: 12px; gap: 10px; max-width: 170px; }
  .movement { gap: 0; }.key-hint { display: none; }
}
@media (orientation: landscape) and (max-height: 600px) {
  main { padding: 10px 16px; max-width: 1080px; display: grid; grid-template-columns: 1fr 178px; gap: 8px 12px; }
  .masthead { grid-column: 1 / -1; margin: 0; }h1 { font-size: 28px; }.eyebrow { display: none; }
  .play-shell { border-radius: 16px; }.readout { padding: 7px 14px; min-height: 60px; }.form-label strong { font-size: 17px; }
  .scene { min-height: 0; }canvas { height: max(150px, calc(100dvh - 214px)); object-fit: contain; }
  .instructions { padding: 8px 14px; min-height: 58px; display: block; }.instructions p { font-size: 15px; }.instructions span { font-size: 12px; }
  .controls { display: flex; flex-direction: column-reverse; justify-content: center; padding: 0; gap: 14px; }.key-hint { display: none; }
  .legend { font-size: 11px; gap: 9px; }.legend small { font-size: 10px; }.intro { padding: 8px 16px; }.intro-drop,#hint { display: none; }
  h2 { font-size: 21px; margin-bottom: 4px; }.intro p { font-size: 12px; line-height: 1.4; margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
@media (min-width: 621px) and (min-height: 601px) {
  canvas { max-height: calc(100dvh - 400px); object-fit: contain; }
}
@media (max-width: 360px) {
  h1 { font-size: 28px; }.eyebrow { display: none; }.masthead { gap: 8px; }
}
@media (max-width: 620px) and (max-height: 680px) and (orientation: portrait) {
  .scene { min-height: 205px; }canvas { height: 205px; }
  .intro { padding: 12px 18px; }h2 { font-size: 22px; }.intro p { line-height: 1.45; }
  #hint { display: none; }.controls { padding-top: 10px; align-items: flex-start; }.legend { gap: 4px; }
}
