*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#102f22;color:#fff2d1;font-family:system-ui,sans-serif}body{height:100dvh;display:flex;flex-direction:column}.game-header{height:66px;min-height:66px;display:flex;align-items:center;justify-content:space-between;padding:6px max(12px,env(safe-area-inset-right)) 6px max(12px,env(safe-area-inset-left));background:linear-gradient(#234b35,#102f22);border-bottom:1px solid #bc954d;z-index:4}.game-header a,.game-header button,#buttons-toggle{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:9px 13px;color:#fff0c6;background:#315940;border:1px solid #b59755;border-radius:12px;text-decoration:none;font-weight:600}.game-header h1{font-family:Georgia,serif;font-size:23px;line-height:1.05;margin:0;text-align:center;font-weight:400}.game-header h1 small{display:block;font:8px system-ui;letter-spacing:3px;margin-bottom:4px}.game-header button{font-size:23px;width:45px}#game-content{position:relative;flex:1;min-height:0;overflow:hidden;background:#285c39}canvas{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;display:block;user-select:none;-webkit-user-select:none}#game-content>p:first-child{position:absolute;z-index:3;left:50%;transform:translateX(-50%);top:15%;width:min(88%,460px);background:#fff6dff5;border:1px solid #bf9b4c;color:#21452d;border-radius:20px;padding:17px 21px;font-size:15px;line-height:1.5;text-align:center;box-shadow:0 12px 35px #082a2c3d;margin:0}.levels{position:absolute;z-index:3;left:50%;transform:translateX(-50%);bottom:24%;display:flex;gap:10px}.levels button{min-height:52px;min-width:110px;border:1px solid #e4c17b;border-radius:16px;background:#fff5d9;color:#244a32;font-size:16px;padding:12px}.levels button[aria-pressed=true]{background:#244e36;color:#fff4cf;box-shadow:0 0 0 3px #f0ce77}.pig-score{position:absolute;z-index:2;top:8px;left:10px;right:10px;text-align:center;font-size:13px;background:#173d29e8;border:1px solid #d5b56677;border-radius:12px;padding:10px 65px 10px 10px;margin:0;pointer-events:none}.pig-start{position:absolute;z-index:4;bottom:10%;left:50%;transform:translateX(-50%);min-height:56px;min-width:190px;padding:13px 22px;border-radius:17px;border:2px solid #f4d28b;background:linear-gradient(#39724b,#17472d);color:#fff4d4;font-size:18px;font-weight:750;box-shadow:0 7px 16px #12351c77}.pig-start:disabled{opacity:.65}.survival-pause{top:10px;right:13px;left:auto;bottom:auto;transform:none;min-width:0;min-height:34px;padding:7px 10px;font-size:11px;box-shadow:none;border-width:1px;border-radius:9px}#game-content>p:last-child{display:none}.run-controls{position:absolute;z-index:3;bottom:9px;left:50%;transform:translateX(-50%);display:flex;gap:12px;width:min(92%,460px)}.run-controls button{flex:1;min-height:56px;border:1px solid #d9b86b;border-radius:17px;background:#173d29e8;color:#fff6d9;font-size:16px;font-weight:bold;touch-action:manipulation}.run-controls[hidden],button[hidden]{display:none!important}#game-content[data-state=playing]>p:first-child,#game-content[data-state=playing]>.levels,#game-content[data-state=paused]>p:first-child,#game-content[data-state=paused]>.levels,#game-content[data-state=ended]>p:first-child,#game-content[data-state=ended]>.levels{display:none}.game-bottom{min-height:65px;display:flex;gap:12px;align-items:center;padding:7px 12px calc(7px + env(safe-area-inset-bottom));background:#102f22;border-top:1px solid #b9974c77;z-index:4}.game-bottom p{font-size:11px;line-height:1.4;margin:0;flex:1}#buttons-toggle{font-size:11px;white-space:nowrap;padding:7px 10px}a:focus-visible,button:focus-visible{outline:3px solid #fff0a4;outline-offset:3px}@media(orientation:landscape) and (max-height:600px){.game-header{height:48px;min-height:48px}.game-header h1{font-size:19px}.game-header h1 small{font-size:6px}.game-bottom{min-height:46px;padding-top:3px;padding-bottom:3px}.game-bottom p{font-size:10px}#game-content>p:first-child{top:21%;left:25%;width:40%;font-size:12px;padding:11px}.levels{left:74%;bottom:46%}.pig-start{left:74%;bottom:16%}.survival-pause{left:auto;bottom:auto}.levels button{min-width:90px;min-height:44px;font-size:13px}}

.survival-result{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:32px;background:radial-gradient(ellipse at 18% 22%,#967044 0 8%,transparent 9%),radial-gradient(ellipse at 88% 70%,#9f734a 0 14%,transparent 15%),radial-gradient(ellipse at 70% 15%,#a47c50 0 12%,transparent 13%),#68472deF;color:#fff2d4}.survival-result[hidden]{display:none}.survival-result h2{font:bold clamp(60px,17vw,110px) Georgia,serif;text-shadow:0 6px #3d271d;margin:0;transform:rotate(-5deg)}.survival-result p{max-width:320px;font-size:18px;line-height:1.5}.survival-result button{min-height:60px;min-width:200px;border:3px solid #ffdf91;border-radius:22px;background:linear-gradient(#4c8750,#235931);color:#fff4ce;font-size:22px;font-weight:800;box-shadow:0 8px #392d1e;cursor:pointer}

.survival-direction{position:absolute!important;z-index:3;top:58px;left:10px;right:10px;margin:0;padding:10px;border-radius:12px;background:#fff1caf5;color:#21492e;text-align:center;font-weight:800;font-size:16px;pointer-events:none}.survival-direction[hidden]{display:none!important}.survival-countdown{position:absolute;inset:0;z-index:5;display:grid;place-items:center;background:#173d2955;color:#fff6d6;font:bold clamp(54px,15vw,96px) Georgia;text-shadow:0 6px #21442b;pointer-events:none}.survival-countdown[hidden]{display:none}

/* Keep the intro readable in short landscape game screens. */
@media(orientation:landscape) and (max-height:600px){#game-content>p:first-child{top:8%;max-height:84%;overflow-y:auto;overscroll-behavior:contain}}

/* Keep touch controls below the action, not on top of the farmer or obstacles. */
.game-bottom{display:grid;gap:7px;padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
.game-bottom-row{display:flex;gap:12px;align-items:center;min-width:0;width:100%}
.game-bottom .touch-dock{position:static;transform:none;width:min(100%,460px);justify-self:center;gap:8px}
.game-bottom .touch-dock button{min-width:0;min-height:48px;padding:6px 2px;font-size:clamp(12px,3.6vw,16px)}
.game-bottom .touch-dock button:first-child,.game-bottom .touch-dock button:last-child{flex:1}
.game-bottom .touch-dock button:nth-child(2){flex:1.25;background:linear-gradient(#447954,#254e34)}
.game-bottom .touch-dock button:active{background:#567350;transform:translateY(1px)}
/* Short landscape viewports need more screen for the track. */
@media(orientation:landscape) and (max-height:600px){
.game-bottom{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}
.game-bottom .touch-dock{width:100%}
.game-bottom .touch-dock[hidden]+.game-bottom-row{grid-column:1/-1}
.game-bottom .touch-dock button{min-height:44px;font-size:13px}
}
.game-bottom .touch-dock button{display:flex;align-items:center;justify-content:center;gap:.35rem;background:linear-gradient(145deg,#292741,#1b302f);border-color:#a88761;color:#fff3da;letter-spacing:.035em}
.game-bottom .touch-dock button svg{width:20px;height:20px;flex:none;color:#f3cb87}
.game-bottom .touch-dock button:nth-child(2){background:linear-gradient(145deg,#493a64,#2e4750);border-color:#f0c67f}
.game-bottom .touch-dock button:active{background:#665170}

/* Farm badge controls: clear glyphs, distinct key colors and tactile depth. */
.game-bottom .touch-dock button{
  border-radius:14px;box-shadow:inset 0 1px 0 #fff5c854,0 3px 0 #10291f,0 5px 7px #122c2c66;
}
.game-bottom .touch-dock button:first-child,.game-bottom .touch-dock button:last-child{
  background:linear-gradient(#c7ee94,#87c471);color:#132c22;border-color:#e5f6b3;
}
.game-bottom .touch-dock button:nth-child(2){
  background:linear-gradient(#ffe49d,#f2aa62);color:#31221a;border-color:#ffecc4;
}
.game-bottom .touch-dock button svg{color:currentColor}
.game-bottom .touch-dock button:active{
  transform:translateY(2px);box-shadow:inset 0 1px 0 #ffffff40,0 1px 0 #10291f;
}
