:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: #263f34;
  background: #eaf1eb;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #ab792b; outline-offset: 4px; }
[hidden] { display: none !important; }

.game {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #fcfdfa;
  overflow: hidden;
  position: relative;
}
.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: #52685c;
  background: #eaf1eb;
  font-size: .9375rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility 0s linear .18s;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #cbd8cd;
  border-top-color: #52685c;
  border-radius: 50%;
  animation: loading-spin .8s linear infinite;
}
.is-loading .scene, .is-loading .controls { visibility: hidden; }
.is-loading .loading-screen { opacity: 1; visibility: visible; pointer-events: auto; transition: none; }
.scene {
  flex: 1;
  min-height: 270px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #c7d7bb;
}
.meadow { position: absolute; width: 100%; height: 100%; object-fit: cover; object-position: center; user-select: none; }
.sky-shade { position: absolute; inset: 0 0 65%; background: linear-gradient(#07100b30, transparent); }
.flowers { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.flower { position: absolute; width: 9%; height: 18%; object-fit: contain; object-position: center bottom; transform: translateX(-50%); user-select: none; opacity: .94; filter: saturate(.85) brightness(.94); mask-image: linear-gradient(to bottom, #000 0%, #000 82%, transparent 100%); }
.reed { position: absolute; z-index: 1; left: 85%; bottom: 24%; width: 10%; height: 17%; padding: 0; border: 0; appearance: none; background: none; transform: scale(1.2); transform-origin: center bottom; }
.reed::after { content: ""; position: absolute; inset: -8px; }
.reed img { width: 100%; height: 100%; display: block; object-fit: contain; object-position: center bottom; pointer-events: none; user-select: none; mask-image: linear-gradient(to bottom, #000 0%, #000 75%, transparent 100%); }
.reed-bubble { position: absolute; z-index: 100; width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 11px 16px; border-radius: 16px; color: #294637; background: #fcfdfa; box-shadow: 0 4px 18px #12261926; text-align: center; font-size: 1rem; font-weight: 500; line-height: 1.7; pointer-events: none; }
.reed-bubble span { display: block; }
.reed-bubble::after { content: ""; position: absolute; top: 100%; left: var(--tail-x, 50%); transform: translateX(-50%); border: 9px solid transparent; border-top: 14px solid #fcfdfa; border-bottom: 0; }
.reed-bubble[data-placement="below"]::after { top: auto; bottom: 100%; border-top: 0; border-bottom: 14px solid #fcfdfa; }
.question-sign { position: absolute; z-index: 2; width: 88%; max-width: 420px; aspect-ratio: 2 / 1; top: clamp(38px, 10.5vw, 50px); left: 50%; transform: translateX(-50%); pointer-events: none; }
.sign-art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.sign-trigger { position: absolute; inset: 5.5% 3.5% auto; height: 28.2%; border: 0; padding: 0; background: none; pointer-events: auto; }
h1 {
  position: absolute;
  inset: 5.5% 7% auto;
  height: 28.2%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  text-align: center;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: clamp(1rem, 4.7vw, 1.375rem);
  font-weight: 700;
  color: #291d10;
  letter-spacing: .025em;
  line-height: 1.4;
}
.animals { position: absolute; inset: 0; pointer-events: none; }
.animal { position: absolute; padding: 0; border: 0; appearance: none; background: none; transform: translateX(-50%); pointer-events: auto; }
.animal::before { content: ""; position: absolute; width: 67%; height: 7%; left: 16%; bottom: 0; border-radius: 50%; background: #28331e50; filter: blur(3px); }
.animal img { width: 100%; height: 100%; display: block; position: relative; object-fit: contain; object-position: center bottom; pointer-events: none; user-select: none; }
.animal.crane { width: 18%; height: 28%; }
.animal.turtle { width: 18%; height: 14%; }
.animal.flip img { transform: scaleX(-1); }

.controls {
  flex: none;
  position: relative;
  z-index: 3;
  padding: 13px 25px max(18px, env(safe-area-inset-bottom));
  background: #fcfdfa;
  border-radius: 24px 24px 0 0;
  margin-top: -17px;
  box-shadow: 0 -8px 28px #2133210b;
}
.answer-wrap { height: 66px; width: 112px; margin: 0 auto 18px; display: flex; justify-content: center; align-items: center; position: relative; border-bottom: 1px solid #b9c5bb; }
.answer { font-size: 2.15rem; line-height: 1.2; font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.caret { display: none; }
.answer:empty + .caret { display: block; height: 25px; width: 1.5px; background: #819084; animation: blink 1.25s ease-in-out infinite; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.key { min-height: 51px; border: 1px solid #dfe6dc; border-radius: 12px; color: #2c4437; background: #f4f7f0; box-shadow: 0 2px 0 #e9eee5; font-size: 1.45rem; font-weight: 400; display: flex; align-items: center; justify-content: center; transition: background .14s, transform .14s; }
.key:active { transform: translateY(2px); box-shadow: none; background: #e4ecde; }
.key svg { width: 24px; height: 24px; }
.key-delete { background: transparent; border-color: transparent; box-shadow: none; color: #647368; }
.key-submit { background: #294c3b; border-color: #294c3b; color: #fff; box-shadow: 0 2px 0 #203c2f; }
.key-submit:active { background: #1f3d2f; }
.key-submit:disabled { opacity: .4; }
.answer-wrap.invalid { animation: shake .36s ease-in-out; border-color: #ad6157; color: #ad6157; }
.success { padding: 17px 0 2px; text-align: center; }
.success h2 { margin: 0 0 17px; font-size: 1.1rem; font-weight: 600; line-height: 1.7; outline: none; }
.thanks-message { margin: 24px 0 14px; font-size: 1rem; line-height: 1.85; overflow-wrap: anywhere; }
.thanks-message a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.creator-credit { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; font-size: .875rem; line-height: 1.8; }
.creator-credit a { color: #294c3b; text-underline-offset: 3px; overflow-wrap: anywhere; }
.success-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 10px; }
.share-button, .replay-button { min-height: 49px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-radius: 12px; text-decoration: none; }
.share-button { min-width: 115px; padding: 11px 15px; flex-shrink: 0; background: #263f34; color: white; font-size: .9375rem; font-weight: 500; }
.replay-button { flex: 1 0 auto; max-width: 240px; padding: 11px 15px; border: 1px solid #b7c6b8; color: #294637; background: #fcfdfa; font-size: .9375rem; font-weight: 500; }
.replay-button svg { width: 19px; height: 19px; flex-shrink: 0; }
.game.solved .scene { min-height: 270px; }
.game.solved .keypad { display: none; }
.game.solved .answer-wrap { margin-bottom: 0; height: 47px; }
.game.solved .controls { padding-top: 18px; }

.incorrect-dialog {
  width: min(320px, calc(100% - 48px));
  margin: auto;
  padding: 32px 23px 24px;
  border: 1px solid #e1e8dc;
  border-radius: 22px;
  color: #263f34;
  background: #fcfdfa;
  text-align: center;
  box-shadow: 0 20px 70px #10261933;
}
.incorrect-dialog::backdrop { background: #142b235e; backdrop-filter: blur(3px); }
.incorrect-dialog h2 { margin: 0 0 26px; font-size: 1.4rem; line-height: 1.5; font-weight: 600; }
.incorrect-hint { margin: 0 0 20px; text-align: left; }
.incorrect-hint summary { padding: 12px 16px; border: 1px solid #b7c6b8; border-radius: 12px; background: #f4f7f0; font-size: 1rem; cursor: pointer; }
.incorrect-hint summary:focus-visible { outline: 3px solid #ab792b; outline-offset: 4px; }
.incorrect-hint p { margin: 14px 4px 0; font-size: 1rem; line-height: 1.85; overflow-wrap: anywhere; }
.retry-button { width: 100%; min-height: 52px; padding: 13px 12px; border: 0; border-radius: 12px; color: #fff; background: #294c3b; font-size: 1rem; font-weight: 500; }
.retry-button:active { background: #1f3d2f; }

.caption-dialog { width: min(340px, calc(100% - 32px)); margin: auto; padding: 26px 24px 22px; border: 1px solid #e1e8dc; border-radius: 22px; color: #263f34; background: #fcfdfa; box-shadow: 0 20px 70px #10261933; }
.caption-dialog::backdrop { background: #142b235e; backdrop-filter: blur(3px); }
.caption-dialog h2 { margin: 0 0 15px; font-size: 1.25rem; line-height: 1.5; }
.caption-dialog p { margin: 0 0 22px; font-size: 1rem; line-height: 1.85; overflow-wrap: anywhere; }
.caption-close { display: block; width: 100%; min-height: 46px; border: 1px solid #b7c6b8; border-radius: 12px; color: #294637; background: #f4f7f0; font-size: 1rem; }
.caption-close:active { background: #e4ecde; }

@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes loading-spin { to { transform: rotate(360deg); } }
@media (hover: hover) { .key:not(:disabled):hover { background: #e6edde; } .key-submit:not(:disabled):hover { background: #365f4b; } .share-button:hover { background: #365f4b; } .replay-button:hover { background: #eff4e9; } }
@media (min-width: 600px) {
  body { padding: 28px; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; background: radial-gradient(ellipse at top, #eff4eb, #d8e3d7); }
  .game { height: min(860px, calc(100dvh - 56px)); min-height: 680px; border-radius: 26px; box-shadow: 0 24px 80px #1b352c1a, 0 0 0 1px #ffffffaa; }
  .controls { padding-inline: 35px; padding-bottom: 25px; }
  .key { min-height: 55px; }
}
@media (max-height: 690px) and (max-width: 599px) {
  .controls { padding: 9px 22px max(12px, env(safe-area-inset-bottom)); }
  .answer-wrap { height: 47px; margin-bottom: 12px; }
  .key { min-height: 46px; border-radius: 10px; }
  .keypad { gap: 7px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
