.duck_game {
  --duck_edge:clamp(16px,2.5vw,48px);
  background:var(--paper);
  min-height:100svh;
  color:var(--ink);
}
.duck_nav {
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:8px 16px;
  min-height:72px;
  padding:10px var(--duck_edge);
  border-bottom:1px solid var(--line);
}
.duck_crumb,.duck_nav_actions { display:flex; align-items:center; gap:16px; }
.duck_crumb { padding:0; }
.duck_crumb a { display:inline-flex; align-items:center; min-height:44px; font-size:14px; }
.duck_crumb a:hover { text-decoration:underline; }
.duck_crumb strong {
  padding-left:14px;
  border-left:1px solid var(--line);
  color:var(--green_dark);
  font-size:19px;
  letter-spacing:-.06em;
}
.duck_nav_actions { font-size:13px; font-weight:650; }
.duck_nav_actions select {
  min-height:40px;
  max-width:11em;
  border:1px solid var(--line);
  border-radius:var(--radius_sm);
  background:var(--surface);
  color:var(--ink);
  padding:5px 8px;
}
.duck_layout {
  display:grid;
  grid-template-columns:minmax(280px,min(32%,480px)) minmax(0,1fr);
  min-height:calc(100svh - 72px);
}
.duck_controls { align-self:center; min-width:0; padding:clamp(22px,3.1vw,58px) var(--duck_edge); }
.duck_intro h1 { color:var(--green_dark); font-size:clamp(28px,3.15vw,54px); line-height:1.18; letter-spacing:-.07em; }
.duck_intro p { margin-top:12px; font-size:clamp(15px,1.2vw,19px); line-height:1.65; }
.duck_form { display:grid; gap:12px; margin-block:clamp(20px,4vh,40px) 12px; }
.duck_code_heading { display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:2px 8px; }
.duck_code_label { font-size:13px; font-weight:750; color:var(--green_dark); }
.duck_key_tip { color:var(--muted); font-size:12px; line-height:1.5; }
.duck_editor {
  min-width:0;
  display:grid;
  gap:5px;
  padding:16px;
  border-radius:var(--radius_sm);
  background:var(--editor);
  color:var(--code);
  box-shadow:0 4px 0 rgb(36 59 53 / .12);
}
.duck_editor code { font:14px/1.4 var(--mono); color:var(--code_muted); }
.duck_editor .duck_fixed_declaration { margin-left:16px; }
.duck_input {
  display:block;
  width:calc(100% - 8px);
  min-width:0;
  min-height:46px;
  margin-left:8px;
  resize:vertical;
  max-height:35vh;
  border:1px solid rgb(224 234 222 / .32);
  border-radius:6px;
  outline-offset:2px;
  padding:8px;
  background:rgb(0 0 0 / .16);
  color:var(--code);
  font:16px/1.45 var(--mono);
}
.duck_input::placeholder { color:var(--code_muted); }
.duck_input:focus-visible { outline:2px solid var(--mint); }
.duck_values { display:flex; gap:6px; flex-wrap:wrap; }
.duck_values_label { align-self:center; font-size:12px; font-weight:650; color:var(--muted); }
.duck_value {
  min-height:40px;
  border:1px solid var(--line);
  border-radius:8px;
  padding:6px 10px;
  background:var(--surface);
  color:var(--ink);
  font:650 13px var(--mono);
}
.duck_value:hover,.duck_value[aria-pressed="true"] { background:var(--mint); border-color:var(--green); }
.duck_value[aria-pressed="true"] { box-shadow:inset 0 0 0 1px var(--green); }
.duck_actions { display:flex; align-items:center; gap:6px 8px; flex-wrap:wrap; }
.duck_actions .button { min-height:44px; padding:8px clamp(9px,1.1vw,18px); }
.duck_actions .editor_submit { background:var(--green); color:var(--surface); }
.duck_actions .editor_submit:hover:not(:disabled) { background:var(--green_dark); color:var(--surface); }
.duck_actions .duck_next:disabled { color:var(--muted); background:var(--paper); border-color:var(--line); opacity:.85; }
.duck_actions .duck_next:not(:disabled) { background:var(--green_dark); color:var(--surface); border-color:var(--green_dark); }
.duck_actions .duck_next:focus-visible { outline-offset:3px; }
.duck_actions .editor_reset { color:var(--muted); min-height:40px; }
.duck_game .feedback { margin-top:12px; }
.duck_game .feedback:empty { display:none; }
.duck_game .feedback strong:last-child { margin:0; }
.duck_help { margin-top:12px; }
.duck_help #hint_button {
  width:auto;
  min-height:44px;
  margin:0;
  padding:4px 0;
  background:none;
  border:0;
  color:var(--green_dark);
  font-size:13px;
  font-weight:750;
}
.duck_help #hint_button:hover:not(:disabled) { text-decoration:underline; text-underline-offset:4px; }
.duck_help #hint_count { margin-left:4px; color:var(--muted); font:12px var(--mono); }
.duck_arena {
  position:relative;
  isolation:isolate;
  min-width:0;
  align-self:stretch;
  margin:12px 12px 12px 0;
  overflow:hidden;
  border-radius:var(--radius_lg);
  background:var(--mint);
}
.duck_arena #preview_host,.duck_stage { position:absolute; inset:0; }
.duck_stage {
  overflow:hidden;
  container-type:size;
  background:var(--mint) url('../../public/assets/duck-garden-stage.webp') center / cover no-repeat;
}
.duck_count {
  position:absolute;
  top:clamp(12px,2.2vw,32px);
  right:clamp(12px,2.2vw,32px);
  display:flex;
  align-items:baseline;
  gap:9px;
  padding:6px 15px;
  border:1px solid rgb(36 59 53 / .14);
  border-radius:99px;
  box-shadow:0 2px 8px rgb(36 59 53 / .12);
  background:var(--paper);
  color:var(--green_dark);
  font-size:13px;
  font-weight:700;
  pointer-events:none;
}
.duck_count_value { font:700 15px var(--mono); }
.duck_arena:is(.is_ready,.is_complete) .duck_count { background:var(--green_dark); color:var(--surface); }
.duck_track.layout_stage {
  position:absolute;
  top:49%;
  left:3%;
  width:94%;
  height:38%;
  --duck_size:clamp(32px,11.4cqi,160px);
}
.duck_track .layout_layer { gap:clamp(2px,.65cqi,8px); }
.duck_track .layout_layer [data-item] {
  flex:0 0 var(--duck_size);
  width:var(--duck_size);
  height:var(--duck_size);
  background:none;
  border-radius:0;
  box-shadow:none;
  outline:none;
  opacity:1;
}
.duck_track .duck_sprite { width:100%; height:100%; object-fit:contain; pointer-events:none; }
.duck_track .is_actual .duck_sprite { transform:translateY(-24%); filter:drop-shadow(1px 2px 2px rgb(57 69 25 / .24)); }
.duck_stage[data-ready="true"] .is_actual .duck_sprite { transform:translateY(-18%); }
.duck_arena.is_complete .is_actual .duck_sprite { animation:settle_duck 320ms var(--ease); }
.duck_track .is_target .duck_sprite { filter:drop-shadow(1px 3px 2px rgb(57 69 25 / .25)); }
.duck_stage[data-field] .duck_track {
  --duck_gap:clamp(2px,.65cqi,8px);
  --duck_size:min(12cqi,19cqh,120px);
  top:28%;
  height:64%;
}
.duck_stage[data-field] .layout_layer { gap:var(--duck_gap); }
/* 세 마리를 세로로 놓은 뒤 네 번째가 다음 열로 가도록, 둥지 크기와 같은 단위로 높이를 정한다. */
.duck_stage[data-field="columns"] .duck_track {
  --column_height:calc(3.5 * var(--duck_size) + 2 * var(--duck_gap));
  top:calc(60% - var(--column_height) / 2);
  height:var(--column_height);
}
.duck_figure { position:relative; display:block; width:100%; height:100%; }
.duck_track [data-number]::after {
  position:absolute;
  z-index:1;
  left:50%;
  bottom:0;
  transform:translateX(-50%);
  display:grid;
  place-items:center;
  width:clamp(12px,3.2cqh,24px);
  height:clamp(12px,3.2cqh,24px);
  border:1px solid var(--green_dark);
  border-radius:50%;
  background:var(--paper);
  color:var(--green_dark);
  content:attr(data-number);
  font:700 clamp(9px,2.4cqh,15px)/1 var(--mono);
}
.duck_figure[data-number]::after {
  top:-8%;
  bottom:auto;
  left:16%;
  background:var(--green_dark);
  color:var(--surface);
}
.duck_stage[data-ready="true"] .is_target [data-number]::after { visibility:hidden; }
.nest_ruler {
  position:absolute;
  top:91%;
  width:var(--nest_gap);
  height:4px;
  border:1px solid var(--ink);
  border-top:0;
  color:var(--ink);
  font:700 clamp(9px,1.6cqh,12px)/1.35 var(--mono);
  white-space:nowrap;
  pointer-events:none;
}
.nest_ruler::after {
  content:attr(data-measure);
  position:absolute;
  top:100%;
  left:50%;
  transform:translateX(-50%);
  border-radius:3px;
  background:var(--paper);
  padding-inline:2px;
}
.nest_ruler[data-side="right"] { left:100%; }
.nest_ruler[data-side="left"] { right:100%; }
@keyframes settle_duck {
  0% { transform:translateY(-18%); }
  40% { transform:translateY(-30%); }
  78% { transform:translateY(-15%) scale(1.03,.96); }
  100% { transform:translateY(-18%); }
}

@media (max-width:740px) {
  .duck_game { --duck_edge:clamp(12px,4vw,24px); }
  .duck_nav { min-height:54px; padding-block:4px; }
  .duck_crumb,.duck_nav_actions { gap:8px; }
  .duck_crumb strong { padding-left:8px; font-size:16px; }
  .duck_layout {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    grid-template-areas:"intro" "arena" "form" "feedback" "help";
    align-content:start;
    gap:12px;
    min-height:0;
    padding:14px var(--duck_edge) 24px;
  }
  .duck_controls { display:contents; }
  .duck_intro { grid-area:intro; }
  .duck_intro h1 { font-size:clamp(24px,6.25vw,34px); }
  .duck_intro p { margin-top:4px; font-size:14px; }
  .duck_arena {
    grid-area:arena;
    height:clamp(145px,33svh,340px);
    margin:0;
    border-radius:var(--radius);
  }
  .duck_count { top:10px; right:10px; padding:4px 11px; }
  .duck_track.layout_stage { --duck_size:clamp(32px,12cqi,86px); }
  .duck_form { grid-area:form; gap:8px; margin:0; }
  .duck_editor { padding:10px 12px; gap:2px; }
  .duck_input { min-height:40px; }
  .duck_value { min-height:44px; }
  .duck_help { grid-area:help; margin:0; }
  .duck_game .feedback { grid-area:feedback; margin:0; }
  .duck_game .feedback.is_success {
    padding:8px 12px;
  }
  .duck_game.is_keyboard_open .duck_layout { gap:6px; padding-block:6px; }
  .duck_game.is_keyboard_open .duck_arena { height:clamp(90px,calc(var(--duck-visible-height,100dvh) * .25),155px); }
  .duck_game.is_keyboard_open .duck_intro p { display:none; }
}
@media (max-width:420px) {
  .duck_nav,.duck_nav_actions { column-gap:6px; }
  .duck_nav_actions select { width:85px; min-width:0; }
  .duck_values_label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .duck_nav_actions .duck_level { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
}
@media (max-width:360px) {
  .duck_nav { padding-inline:10px; }
  .duck_crumb { gap:4px; }
  .duck_crumb a { font-size:12px; }
  .duck_crumb strong { padding-left:5px; font-size:15px; }
  .duck_nav_actions select { width:74px; }
}
@media (max-width:740px) and (max-height:720px) {
  .duck_arena:has(.duck_stage[data-field]) .duck_count {
    top:4px;
    right:8px;
    padding:1px 8px;
    font-size:11px;
    line-height:1.3;
  }
  .duck_arena:has(.duck_stage[data-field]) .duck_count_value { font-size:12px; }
  .duck_layout { gap:6px; padding-block:8px; }
  .duck_arena { height:clamp(120px,24svh,172px); }
  .duck_intro p { line-height:1.4; }
  .duck_form { gap:6px; }
  .duck_editor { padding:6px 12px; gap:0; }
  .duck_input { max-height:80px; }
  .duck_game .duck_value { min-height:40px; padding-inline:5px; font-size:12px; }
}
@media (min-width:741px) and (max-height:540px) {
  .duck_nav { min-height:44px; padding-block:0; }
  .duck_game { display:flex; flex-direction:column; height:100svh; }
  .duck_layout { position:relative; flex:1; min-height:0; grid-template-rows:minmax(0,1fr); grid-template-columns:minmax(330px,35%) minmax(0,1fr); }
  .duck_controls { align-self:stretch; min-height:0; padding:8px 14px; overflow-y:auto; }
  .duck_intro h1 { font-size:24px; }
  .duck_intro p { margin-top:2px; font-size:13px; line-height:1.4; }
  .duck_form { gap:5px; margin:8px 0 0; }
  .duck_values_label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .duck_game .duck_value { padding-inline:5px; font-size:12px; }
  .duck_editor { gap:0; padding:5px 10px; }
  .duck_input { min-height:34px; max-height:76px; padding:4px 8px; }
  .duck_help { margin:0; }
  .duck_arena { margin:6px 6px 6px 0; }
  .duck_game .feedback.is_success {
    position:absolute;
    right:16px;
    bottom:20px;
    z-index:1;
    display:flex;
    align-items:center;
    gap:12px;
    padding:6px 8px 6px 12px;
  }
}
