:root {
  --ink: #3b2a20; --cream: #fff7e8; --peach: #f6c9a0; --coral: #e2574c; --gold: #f2c14e; --mint: #6bbf7a; --sky: #4f8fd9;
  --panel: rgba(255, 247, 232, 0.92); --shadow: 0 6px 0 rgba(59, 42, 32, 0.18);
  font-family: ui-rounded, "Nunito", "Trebuchet MS", system-ui, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6ead6; overscroll-behavior: none; }
body { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: crosshair; }
#view:focus-visible { box-shadow: inset 0 0 0 3px var(--sky); }

h1, h2, p, ul, dl { margin: 0; }
button, .button {
  font: inherit; font-weight: 800; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); border-radius: 999px;
  padding: 0.6em 1.3em; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); touch-action: manipulation;
}
button:hover, .button:hover { background: #ffe9c4; }
button:active, .button:active, button.held { transform: translateY(3px); box-shadow: 0 3px 0 rgba(59, 42, 32, 0.18); }
button.primary { background: var(--gold); font-size: 1.15rem; }
:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }

#arcadeNav { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); z-index: 50; display: flex; gap: 8px; align-items: flex-start; max-width: calc(100vw - 84px); }
#arcadeBack, #helpPanel summary {
  background: var(--panel); border: 3px solid var(--ink); border-radius: 999px; padding: 0.45em 0.95em; font-weight: 800; font-size: 0.9rem;
  color: var(--ink); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; box-shadow: var(--shadow); white-space: nowrap;
}
#helpPanel summary { list-style: none; }
#helpPanel summary::-webkit-details-marker { display: none; }
#arcadeHelp { position: absolute; left: 0; top: 54px; width: min(420px, calc(100vw - 20px)); max-height: calc(100vh - 80px); overflow: auto; background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); font-size: 0.92rem; line-height: 1.45; user-select: text; -webkit-user-select: text; }
#arcadeHelp p + p { margin-top: 0.6em; }
code { background: #f3e1bf; border-radius: 6px; padding: 0 0.3em; }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
#statusPanel, #miniHud, #grandmaStatus, #carryStatus, #prompt, #toast { background: var(--panel); border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); }
#statusPanel { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 70px; padding: 8px 14px; min-width: 150px; text-align: right; }
#staminaBar, .meter { height: 10px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; margin-top: 6px; }
#staminaBar { margin-top: 0; }
#staminaFill, .meter i { display: block; height: 100%; width: 100%; background: var(--mint); transform-origin: left center; }
#staminaBar.winded #staminaFill { background: var(--coral); }
#location { font-size: 0.82rem; font-weight: 800; margin-top: 4px; }
#pauseBtn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 50px; height: 50px; padding: 0; font-size: 1rem; letter-spacing: 0.1em; }
#grandmaStatus { position: absolute; top: 96px; right: max(10px, env(safe-area-inset-right)); padding: 6px 12px; font-size: 0.85rem; font-weight: 800; }
#carryStatus { position: absolute; top: 136px; right: max(10px, env(safe-area-inset-right)); padding: 6px 12px; font-size: 0.85rem; font-weight: 800; background: var(--gold); }
#prompt { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); padding: 10px 20px; font-weight: 900; font-size: 1.1rem; background: var(--gold); text-align: center; animation: pulse 0.7s infinite alternate; }
#prompt.tip { background: var(--panel); font-size: 0.95rem; font-weight: 800; animation: none; max-width: min(520px, calc(100vw - 24px)); width: max-content; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1.5px rgba(59, 42, 32, 0.55); }
#toast { position: absolute; z-index: 12; left: 50%; bottom: 100px; transform: translate(-50%, 12px); padding: 10px 20px; font-weight: 900; font-size: 1.15rem; text-align: center; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; width: max-content; max-width: min(520px, calc(100vw - 24px)); }
/* Touch controls own the bottom of the screen, so toasts move under the top panels there. */
body.touch #toast { bottom: auto; top: 210px; }
body.touch.mini #toast { top: 190px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
/* Eyes closing for a nap: the game sets the opacity from how deeply the cat is asleep. */
#napVeil { position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(40, 28, 46, 0.35) 20%, rgba(24, 16, 30, 0.96) 100%); }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.12); } }

#miniHud { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 70px; padding: 6px 14px 8px; text-align: center; width: min(270px, calc(100vw - 90px)); }
#miniHud h2 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
#miniScore { font-size: 1.35rem; font-weight: 900; line-height: 1.1; }
#miniInfo { font-weight: 800; font-size: 0.9rem; }
#miniHelp { position: absolute; text-align: center; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); padding: 8px 16px; font-size: 0.9rem; font-weight: 700; background: var(--panel); border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); }
#miniMeter { height: 16px; margin-top: 8px; }
#miniMeterFill { background: linear-gradient(90deg, var(--mint) 0 60%, var(--gold) 60% 93%, var(--coral) 93%); transform: scaleX(0); }
.mini-buttons { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.mini-buttons button { font-size: 0.78rem; padding: 0.2em 0.8em; white-space: nowrap; }
body.mini #grandmaStatus, body.mini #carryStatus, body.mini #crosshair, body.mini #statusPanel, body.mini #prompt { display: none; }

.overlay { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 64px 14px 14px; background: rgba(59, 42, 32, 0.45); overflow: auto; }
.overlay.solid { background: #f6c9a0; }
.card { background: var(--cream); border: 4px solid var(--ink); border-radius: 28px; padding: 22px 26px; width: min(460px, 100%); box-shadow: 0 10px 0 rgba(59, 42, 32, 0.25); text-align: center; }
.card.wide { width: min(760px, 100%); }
.card h1 { font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.05; color: var(--coral); text-shadow: 3px 3px 0 var(--gold); }
.card h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 12px 0 4px; }
.eyebrow { font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.78rem; }
.lead { margin: 10px 0 14px; font-size: 1.02rem; line-height: 1.45; }
.small { font-size: 0.85rem; line-height: 1.4; margin-top: 10px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; text-align: left; margin-bottom: 14px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 0.88rem; }
.keys dt { font-weight: 900; white-space: nowrap; }
.keys dd { margin: 0; }
.stack { display: grid; gap: 10px; justify-items: stretch; margin-top: 6px; }
#loading.failed { background: #fff; }
#loading.failed .card { box-shadow: none; }
#noscript { position: absolute; inset: auto 0 40% 0; z-index: 60; text-align: center; padding: 16px; font-weight: 800; background: var(--cream); }

#touch { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
#stickZone, #lookZone { position: absolute; bottom: 0; pointer-events: auto; touch-action: none; }
#stickZone { left: 0; width: 42%; height: 62%; --stick-x: 90px; --stick-y: calc(100% - 100px); }
#lookZone { right: 0; width: 58%; top: 70px; }
#stickBase { position: absolute; left: var(--stick-x); top: var(--stick-y); width: 116px; height: 116px; margin: -58px; border-radius: 50%; border: 3px solid rgba(59, 42, 32, 0.6); background: rgba(255, 247, 232, 0.35); }
#stickZone.active #stickBase { background: rgba(255, 247, 232, 0.55); }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; background: var(--gold); border: 3px solid var(--ink); transform: translate(-50%, -50%); }
#touchButtons { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(64px, calc(env(safe-area-inset-bottom) + 54px)); display: grid; grid-template-columns: auto auto; gap: 10px; align-items: end; pointer-events: none; }
#touchButtons button { pointer-events: auto; width: 68px; height: 68px; padding: 0; border-radius: 50%; font-size: 0.85rem; background: rgba(255, 247, 232, 0.88); touch-action: none; }
#touchButtons #btnAction { width: 84px; height: 84px; background: var(--gold); font-size: 1rem; grid-column: 2; grid-row: 2; }
#btnSprint { grid-column: 1; grid-row: 1; } #btnJump { grid-column: 1; grid-row: 2; }
/* Throw sits over the Paw and only shows while there is something to throw or knock off, so its place never shifts the others. */
#touchButtons #btnThrow { grid-column: 2; grid-row: 1; justify-self: center; background: var(--coral); color: #fff; }
#touchButtons #btnThrow.unused, body.mini #btnThrow { visibility: hidden; }
body.mini #btnJump, body.mini #btnSprint { visibility: hidden; }

@media (max-width: 720px), (max-height: 520px) {
  #statusPanel { right: 66px; min-width: 120px; padding: 6px 10px; }
  #arcadeBack, #helpPanel summary { font-size: 0.78rem; padding: 0.4em 0.7em; }
  #grandmaStatus { top: 84px; font-size: 0.76rem; } #carryStatus { top: 118px; font-size: 0.76rem; }
  #toast, body.touch #toast { bottom: auto; top: 156px; font-size: 0.95rem; padding: 7px 14px; } body.mini #toast, body.touch.mini #toast { top: 200px; }
  #miniHud h2 { display: none; } #miniMeter { height: 12px; margin-top: 4px; } .mini-buttons { margin-top: 5px; } .mini-buttons button { min-height: 44px; padding: 0 0.8em; }
  #prompt { font-size: 0.95rem; top: 52%; } #prompt.tip { font-size: 0.8rem; padding: 7px 12px; }
  #miniHud { top: 62px; right: max(10px, env(safe-area-inset-right)); width: min(230px, calc(100vw - 20px)); padding: 4px 10px 6px; } #miniScore { font-size: 1.1rem; } #miniInfo { font-size: 0.78rem; } #miniHelp { font-size: 0.76rem; padding: 5px 10px; bottom: max(8px, env(safe-area-inset-bottom)); }
  body.mini #miniHelp { width: min(560px, calc(100vw - 230px)); left: max(10px, env(safe-area-inset-left)); transform: none; }
  .columns { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 22px; } .lead { font-size: 0.92rem; }
}
@media (max-width: 420px) {
  #arcadeBack { max-width: 128px; white-space: normal; line-height: 1.1; font-size: 0.72rem; }
  #statusPanel { min-width: 96px; }
}
@media (prefers-reduced-motion: reduce) { #prompt { animation: none; } #toast { transition: none; } }
