:root {
  --ink: #3a2a1c;
  --cream: #fff8ec;
  --pumpkin: #e8731a;
  --pumpkin-dark: #c85c0c;
  --line: rgba(58, 42, 28, .14);
  --shadow: 0 6px 22px rgba(40, 24, 8, .22);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3f5; color: var(--ink); overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
[hidden] { display: none !important; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

button { font: inherit; color: inherit; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* top row */
#score {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 10px;
  background: var(--cream); border-radius: 999px; box-shadow: var(--shadow); font-weight: 800; font-size: 18px;
}
#score i { width: 18px; height: 18px; border-radius: 50%; background: var(--pumpkin); box-shadow: inset -3px -2px 0 rgba(0, 0, 0, .14); }
#tools { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
#tools button {
  width: 40px; height: 40px; border-radius: 50%; background: var(--cream); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
#tools button:active { transform: scale(.94); }
#b-sound.off .wave { display: none; }
#b-sound.off { opacity: .6; }
#b-key.need { color: var(--pumpkin); }

#banner {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  padding: 9px 18px; background: var(--ink); color: var(--cream); border-radius: 999px;
  font-weight: 800; font-size: 17px; white-space: nowrap; box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) { #banner { top: calc(max(12px, env(safe-area-inset-top)) + 52px); } }

#big {
  position: fixed; left: 0; right: 0; top: 26%; text-align: center; pointer-events: none;
  font-weight: 900; font-size: clamp(40px, 9vw, 92px); color: var(--cream);
  text-shadow: 0 4px 0 var(--pumpkin-dark), 0 10px 28px rgba(40, 24, 8, .45);
  animation: pop .45s cubic-bezier(.2, 1.5, .4, 1) both;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* dock */
#dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom)); width: min(640px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px;
}
#chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; touch-action: pan-x; }
#chips::-webkit-scrollbar { display: none; }
#chips button {
  flex: none; padding: 7px 13px; border-radius: 999px; background: rgba(255, 248, 236, .86);
  font-weight: 700; font-size: 14px; white-space: nowrap; backdrop-filter: blur(6px);
}
#chips button:active { background: var(--cream); transform: scale(.96); }
#ask {
  display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--cream);
  border-radius: 999px; box-shadow: var(--shadow);
}
#q {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 18px; font-weight: 600;
  color: var(--ink); padding: 10px 6px 10px 16px; user-select: text; -webkit-user-select: text;
}
#q::placeholder { color: rgba(58, 42, 28, .45); }
#mic, #go { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; }
#mic { background: transparent; }
#mic.on { background: #d23b2f; color: #fff; animation: pulse 1s infinite; }
#go { background: var(--pumpkin); color: #fff; }
#go:active { background: var(--pumpkin-dark); }
#go .dots { display: none; gap: 3px; }
#go .dots b { width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: dot 1s infinite; }
#go .dots b:nth-child(2) { animation-delay: .15s; }
#go .dots b:nth-child(3) { animation-delay: .3s; }
.busy #go svg { display: none; }
.busy #go .dots { display: flex; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes pulse { 50% { transform: scale(1.08); } }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 112px);
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; background: var(--cream); border-radius: 18px;
  box-shadow: var(--shadow); font-weight: 700; font-size: 18px; text-align: center; pointer-events: none;
  animation: rise .25s ease-out both;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* touch controls */
#stick {
  position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 124px);
  width: 124px; height: 124px; border-radius: 50%; background: rgba(255, 248, 236, .38); border: 2px solid rgba(255, 248, 236, .7);
  touch-action: none;
}
#knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: var(--cream); box-shadow: var(--shadow); }
#jump {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 136px);
  width: 92px; height: 92px; border-radius: 50%; background: var(--pumpkin); color: #fff; font-weight: 900; font-size: 18px;
  box-shadow: 0 6px 0 var(--pumpkin-dark), var(--shadow); touch-action: none;
}
#jump:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pumpkin-dark); }

/* start */
#start {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(rgba(40, 24, 8, 0) 30%, rgba(40, 24, 8, .34));
}
#start h1 {
  margin: 0 0 18px; font-size: clamp(52px, 12vw, 120px); font-weight: 900; color: var(--cream); letter-spacing: -.01em;
  text-shadow: 0 5px 0 var(--pumpkin-dark), 0 14px 34px rgba(40, 24, 8, .5);
}
#play {
  padding: 16px 64px; border-radius: 999px; background: var(--pumpkin); color: #fff; font-weight: 900; font-size: 26px;
  box-shadow: 0 6px 0 var(--pumpkin-dark), var(--shadow);
}
#play:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pumpkin-dark); }
button.quiet { background: transparent; font-weight: 800; font-size: 16px; padding: 10px 18px; border-radius: 999px; }
#start .quiet { color: var(--cream); text-shadow: 0 2px 8px rgba(40, 24, 8, .6); }

/* dialogs */
dialog {
  border: 0; border-radius: 22px; padding: 22px; background: var(--cream); color: var(--ink); box-shadow: var(--shadow);
  width: min(400px, calc(100vw - 32px)); font: inherit;
}
dialog::backdrop { background: rgba(40, 24, 8, .4); }
dialog h2 { margin: 0 0 14px; font-size: 22px; font-weight: 900; }
dialog label { display: block; font-size: 13px; font-weight: 800; margin: 12px 0 5px; opacity: .7; }
dialog input, dialog select {
  width: 100%; font: inherit; font-size: 17px; font-weight: 600; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; color: var(--ink); outline: 0; user-select: text; -webkit-user-select: text;
}
dialog input:focus, dialog select:focus { border-color: var(--pumpkin); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog .row button:not(.quiet) { background: var(--pumpkin); color: #fff; font-weight: 900; padding: 11px 24px; border-radius: 999px; }
dialog .note { margin: 10px 0 0; font-size: 13px; font-weight: 600; opacity: .6; }

#credit {
  position: fixed; right: 8px; bottom: 4px; font-size: 10px; font-weight: 600; color: rgba(255, 255, 255, .8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6); pointer-events: none;
}
@media (max-height: 520px) {
  #chips { display: none; }
  #stick { bottom: 76px; }
  #jump { bottom: 84px; }
  #toast { bottom: 76px; }
}

/* action buttons: one column on the right, on every device */
#jump b, #fling b, #hop b { display: block; line-height: 1.1; }
#jump i, #fling i, #hop i { display: block; font-style: normal; font-size: 11px; font-weight: 800; opacity: .8; margin-top: 2px; }
#jump i:empty { display: none; }
.touch #fling i, .touch #hop i { display: none; }
#jump.fly { background: #3d7dd8; box-shadow: 0 6px 0 #2a5ca8, var(--shadow); }
#jump.fly:active { box-shadow: 0 2px 0 #2a5ca8; }
#fling {
  position: fixed; right: calc(max(18px, env(safe-area-inset-right)) + 4px); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 244px);
  width: 84px; height: 84px; border-radius: 50%; background: var(--ink); color: var(--cream); font-weight: 900; font-size: 17px;
  box-shadow: 0 6px 0 #1f150c, var(--shadow); touch-action: none;
}
#fling:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f150c; }
#hop {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 344px);
  width: 92px; padding: 10px 0; border-radius: 999px; background: var(--cream); color: var(--ink); font-weight: 900; font-size: 16px;
  box-shadow: 0 5px 0 #d9cdb6, var(--shadow); touch-action: none;
}
#hop:active { transform: translateY(3px); box-shadow: 0 2px 0 #d9cdb6; }
#tip {
  position: fixed; left: 50%; top: calc(max(12px, env(safe-area-inset-top)) + 54px); transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px)); padding: 10px 18px; background: var(--ink); color: var(--cream); border-radius: 16px;
  font-weight: 800; font-size: 17px; text-align: center; pointer-events: none; box-shadow: var(--shadow); animation: rise .25s ease-out both;
}
@media (max-width: 560px) { #tip { top: calc(max(12px, env(safe-area-inset-top)) + 104px); } }
kbd {
  display: inline-block; min-width: 26px; padding: 3px 7px; border-radius: 7px; background: var(--cream); color: var(--ink); font: inherit; font-size: 13px; font-weight: 900;
  text-align: center; box-shadow: 0 2px 0 #d9cdb6;
}
#keys {
  position: fixed; left: max(14px, env(safe-area-inset-left)); top: calc(max(12px, env(safe-area-inset-top)) + 54px); display: flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 800; color: var(--cream); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); pointer-events: none;
}
#keys span { margin: 0 10px 0 4px; }
@media (max-width: 900px) { #keys { display: none; } }
@media (min-width: 901px) { body:not(.touch) #tip { top: calc(max(12px, env(safe-area-inset-top)) + 90px); } }
.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.how li { display: grid; grid-template-columns: 128px 1fr; align-items: center; gap: 12px; }
.how em { font-style: normal; font-weight: 700; font-size: 16px; }
.how kbd { background: #fff; border: 2px solid var(--line); box-shadow: none; margin-right: 3px; }
.touch .desk, body:not(.touch) .tch { display: none; }
#chips button.mine { background: var(--pumpkin); color: #fff; }
#b-help svg circle { fill: currentColor; }

.farms { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#start .farms { margin-top: 10px; max-width: min(640px, 92vw); }
.farms button {
  padding: 11px 18px; border-radius: 999px; background: var(--cream); color: var(--ink); font-weight: 800; font-size: 16px; box-shadow: var(--shadow);
}
.farms button:active { transform: scale(.96); }
dialog .farms { justify-content: flex-start; margin-bottom: 8px; }
dialog .farms button { background: #fff; border: 2px solid var(--line); box-shadow: none; padding: 9px 14px; font-size: 15px; }
dialog #addr { margin-top: 8px; }
.gate { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 900; }
.gate input { width: 110px; text-align: center; font-size: 22px; }
@media (max-height: 520px) {
  #fling { bottom: 186px; width: 72px; height: 72px; }
  #hop { bottom: 268px; padding: 7px 0; }
  #keys { display: none; }
}

/* who is playing */
#who { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 9px; border-right: 2px solid var(--line); }
#who:empty { display: none; }
@media (max-width: 560px) {
  #who { display: none; }
  #tools { gap: 5px; }
  #tools button { width: 34px; height: 34px; }
  #tools svg { width: 19px; height: 19px; }
}

/* design your turkey */
#designer {
  position: fixed; z-index: 6; right: max(14px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); bottom: max(14px, env(safe-area-inset-bottom));
  width: 340px; display: flex; flex-direction: column; gap: 12px; padding: 18px;
  background: var(--cream); border-radius: 22px; box-shadow: var(--shadow);
}
#designer[hidden] { display: none; }
#designer .dz-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#designer h3 { margin: 14px 0 7px; font-size: 13px; font-weight: 800; opacity: .6; }
#designer h3:first-child { margin-top: 0; }
#dz-name {
  width: 100%; padding: 12px 16px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 20px; font-weight: 900; outline: 0; user-select: text; -webkit-user-select: text;
}
#dz-name:focus { border-color: var(--pumpkin); }
.pills, .swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.pills button { padding: 8px 13px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 800; font-size: 14px; }
.pills button.on { background: var(--ink); border-color: var(--ink); color: var(--cream); }
.swatches .sw { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--cream); box-shadow: 0 0 0 2px var(--line); }
.swatches .sw.on { box-shadow: 0 0 0 3px var(--ink); }
#dz-tail .sw { width: 58px; border-radius: 999px; }
#designer .row { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
#designer .row .quiet { padding: 10px 12px; font-size: 15px; }
#dz-remove { margin-right: auto; }
#dz-done { background: var(--pumpkin); color: #fff; font-weight: 900; padding: 12px 28px; border-radius: 999px; }
#dz-done:active { background: var(--pumpkin-dark); }
body.designing :is(#dock, #stick, #jump, #fling, #hop, #keys, #tip, #toast, #tools, #score, #banner, #big) { display: none !important; }
@media (max-width: 760px) {
  #designer { left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 54vh; border-radius: 22px 22px 0 0; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); gap: 10px; }
  #dz-name { padding: 9px 14px; font-size: 18px; }
}

/* farm names */
dialog .farm { display: inline-flex; align-items: stretch; border: 2px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
dialog .farm button { border: 0; border-radius: 0; }
dialog .farm .pen { display: grid; place-items: center; padding: 0 11px 0 9px; border-left: 2px solid var(--line); opacity: .55; }
dialog .farm .pen svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
dialog .farm .pen:active { opacity: 1; }
#farm-remove { margin-right: auto; }
