/* Pear Presser — the desktop / laptop / landscape-tablet layout ("wide").
 *
 * Phones keep the layout from style.css untouched. From 1024 x 560 upwards the page becomes a
 * web game: a slim site bar on top, the play field (world, HUD, pear) on the left and a dock on
 * the right that always shows one panel, with the candy tab strip above it.
 *
 * The breakpoint lives here and only here: --dock-w is 0 on phones and the dock width on wide
 * screens. The scripts read it (PP.dockW) to decide which layout is active, so CSS and JS can
 * never disagree. Loaded last, so equal-specificity rules here win over style.css. */

:root { --dock-w: 0px; --bar-h: 0px; }
#sitebar { display: none; }
#press-hint { display: none; }

@media (min-width: 1024px) and (min-height: 560px) { :root { --dock-w: 400px; --bar-h: 52px; --nav-h: 84px; } }
@media (min-width: 1280px) and (min-height: 560px) { :root { --dock-w: 440px; } }
@media (min-width: 1600px) and (min-height: 560px) { :root { --dock-w: 480px; } }

@media (min-width: 1024px) and (min-height: 560px) {
  body { background: #173d22; }

  /* ---------- site bar ---------- */
  #sitebar { position: fixed; top: 0; left: 0; right: 0; height: var(--bar-h); z-index: 40; display: flex; align-items: center; gap: 4px; padding: 0 14px 3px 12px;
    background: radial-gradient(rgba(35,52,26,.07) 1.2px, transparent 1.3px) 0 0 / 16px 16px, linear-gradient(180deg, #fffef4, #ffeeb0);
    border-bottom: 3px solid var(--ink); box-shadow: inset 0 2px 0 #fff; font-family: var(--display); -webkit-user-select: none; user-select: none; }
  .sb-logo { display: inline-flex; align-items: center; gap: 8px; margin-right: 14px; padding: 2px 8px 2px 2px; border-radius: 14px; text-decoration: none; transition: transform .15s cubic-bezier(.3,1.7,.5,1); }
  .sb-logo img { width: 36px; height: 36px; display: block; border-radius: 10px; filter: drop-shadow(0 2px 0 rgba(35,52,26,.35)); transition: transform .2s cubic-bezier(.3,1.7,.5,1); }
  .sb-logo span { font-weight: 700; font-size: 23px; line-height: 1; letter-spacing: .3px; color: #c9f24f; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 2.5px 0 var(--ink); white-space: nowrap; }
  .sb-links { display: flex; align-items: center; gap: 2px; }
  .sb-links a { display: inline-flex; align-items: center; min-height: 34px; padding: 3px 13px; border-radius: 999px; border: 2.5px solid transparent; font-weight: 600; font-size: 15.5px; color: var(--ink); text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .09s; }
  .sb-space { flex: 1; }
  .sb-right { display: flex; align-items: center; gap: 10px; }
  .sb-right .chip-gems { min-height: 36px; }
  .sb-right .chip-gems { min-width: 0; padding-right: 14px; }
  .sb-right .chip-gems .chip-plus { display: none; }              /* on desktop the shop has its own button */
  .sb-shop { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 4px 18px 4px 13px; border-radius: 999px; border: 2.5px solid var(--ink); cursor: pointer;
    font-family: var(--display); font-weight: 600; font-size: 16px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
    background: radial-gradient(circle at 16% 24%, rgba(255,255,255,.8) 0 5%, rgba(255,255,255,0) 6%), linear-gradient(180deg, #ffd35a, #ff7a1a);
    box-shadow: 0 3px 0 var(--ink), inset 0 -4px 0 rgba(0,0,0,.16), inset 0 2px 0 rgba(255,255,255,.55); transition: transform .12s, filter .12s; }
  .sb-shop span { -webkit-text-stroke: 0; font-size: 17px; }
  .sb-shop:hover { transform: translateY(-1.5px); filter: brightness(1.06); }
  .sb-shop:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink), inset 0 -2px 0 rgba(0,0,0,.16); }
  body[data-panel="shop"] .sb-shop { box-shadow: 0 3px 0 var(--ink), 0 0 0 3px #fff8b0, 0 0 12px 3px rgba(255,170,60,.7), inset 0 -4px 0 rgba(0,0,0,.16), inset 0 2px 0 rgba(255,255,255,.55); }
  #fs-btn { width: 38px; height: 36px; border-radius: 12px; background: linear-gradient(180deg, #fffef4, #ffe58f); box-shadow: 0 3px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.8); }
  #fs-btn svg { display: block; }
  #fs-btn .fs-off, #fs-btn[aria-pressed="true"] .fs-on { display: none; }
  #fs-btn[aria-pressed="true"] .fs-off { display: inline; }
  body[data-panel="shop"] .sb-right .chip-gems { box-shadow: 0 3px 0 var(--ink), 0 0 0 3px #fff8b0, 0 0 12px 3px rgba(255,120,190,.7), inset 0 2px 0 rgba(255,255,255,.8); }

  /* ---------- play field ---------- */
  #app { inset: var(--bar-h) var(--dock-w) 0 0; padding: 14px 22px 14px; }
  #hud { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 5px 12px; max-width: 1040px; position: relative; }
  .hud-row { grid-column: 1; grid-row: 1; min-width: 0; }
  .hud-spacer { display: none; }
  .chip-world { min-height: 44px; padding-right: 16px; }
  .chip-text b { font-size: 15.5px; }
  .chip-text small { font-size: 12px; }
  .hud-quick { display: contents; }
  .hud-quick .juice-card { grid-column: 2; grid-row: 1; }
  .hud-quick .quest-chip { grid-column: 3; grid-row: 1 / span 2; justify-self: end; margin-right: 76px; }
  .hud-quick .arcade-btn { grid-column: 3; grid-row: 1 / span 2; justify-self: end; }
  .quick .tile { width: 54px; height: 54px; border-radius: 18px; }
  .quick small { font-size: 12px; }
  .juice-amount { font-size: 52px; }
  .juice-amount.is-long { font-size: 42px; }
  .juice-label { font-size: 13px; }
  .rates-row { grid-column: 1 / -1; grid-row: 2; margin-top: 0; pointer-events: none; }
  .rate { font-size: 13.5px; padding: 4px 14px; }
  .rate b { font-size: 15.5px; }
  /* active effects stack down the left edge instead of pushing the pear down */
  .buffs { position: absolute; left: 0; top: 54px; flex-direction: column; align-items: flex-start; gap: 5px; min-height: 0; overflow: visible; }
  body[data-panel="arcade"] .quick.arcade-btn .tile { box-shadow: 0 3px 0 var(--ink), 0 0 0 3px #fff8b0, 0 0 12px 3px rgba(255,246,150,.8), inset 0 -5px 0 rgba(0,0,0,.16), inset 0 2px 0 rgba(255,255,255,.55); }

  #pear-zone { min-height: 96px; }
  #banner { top: 26px; }
  #hud-low { max-width: 460px; padding-bottom: 0; }
  .level-card { padding: 8px 13px 8px; }
  .level-top { font-size: 15.5px; }
  .level-reward { font-size: 12.5px; }
  .rw .ico { font-size: 14px; }
  #power-bar { max-width: 460px; padding-bottom: 4px; }

  #press-hint { display: block; position: absolute; left: 0; right: 0; bottom: 0; margin: 0; text-align: center; pointer-events: none; z-index: 2;
    font-family: var(--display); font-weight: 600; font-size: 15.5px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; animation: hint-bob 1.8s ease-in-out infinite; }
  #press-hint kbd { display: inline-block; margin: 0 2px; padding: 0 9px 1px; border-radius: 8px; border: 2px solid var(--ink); background: linear-gradient(180deg, #fffef4, #ffe58f); box-shadow: 0 2.5px 0 var(--ink);
    font: inherit; font-size: 13.5px; color: var(--ink); -webkit-text-stroke: 0; }
  @keyframes hint-bob { 50% { transform: translateY(-4px); } }

  #edge-glow { inset: var(--bar-h) var(--dock-w) 0 0; }
  #toasts { top: calc(var(--bar-h) + 10px); right: var(--dock-w); }
  .toast { font-size: 15px; }

  /* ---------- dock: tab strip + the panel that is always open ---------- */
  #nav { position: fixed; top: var(--bar-h); right: 0; left: auto; width: var(--dock-w); max-width: none; height: calc(var(--nav-h) + 3px); min-height: 0; margin: 0; padding: 0 8px;
    grid-template-columns: repeat(6, 1fr); border: 0; border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); border-radius: 0; }
  #nav .nav-btn[data-tab="press"] { display: none; }
  #nav .nav-btn { font-size: 11.5px; min-height: var(--nav-h); padding-top: 21px; }
  #nav .nav-btn::before { top: 11px; }
  #nav .badge { top: 4px; }
  #panels .panel { top: calc(var(--bar-h) + var(--nav-h) + 3px); bottom: 0; left: auto; right: 0; width: var(--dock-w); transform: none; border-left: 3px solid var(--ink); border-right: 0;
    animation: dock-in .18s ease-out; }
  @keyframes dock-in { from { opacity: .35; } }
  .panel-head { padding: 9px 14px 9px 16px; min-height: 58px; }
  .panel-head h2 { font-size: 25px; }
  .panel-body { padding: 12px 8px 26px 14px; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #bfae6c transparent; }
  .panel-tools { padding: 10px 14px 0; }
  #panel-arcade .panel-body { scrollbar-color: #7d55d6 transparent; }
  #panel-shop .panel-body { scrollbar-color: #e58fba transparent; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
  .st-tabs { flex-wrap: wrap; overflow: visible; padding-bottom: 6px; }   /* no sideways scrolling with a mouse */
  /* Shop and Arcade open in the dock too; their close button becomes "back to the last tab" */
  #panels [data-close-panel] { order: -1; width: 40px; height: 40px; flex: none; }
  #panels [data-close-panel] .ico { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11.2 3.6l2.5 2.5-4.1 4.100H21v3.600H9.600l4.100 4.100-2.500 2.500L2.800 12z'/%3E%3C/svg%3E"); }
  /* optional ad boosts: the sheet has room to be a little wider; the Boosts tile itself needs no change (css/ads.css) */
  dialog.ads-dlg { width: min(94vw, 440px); }

  /* ---------- arcade games: a phone-shaped cabinet in the middle of the window ---------- */
  #mg-root { inset: 0; margin: auto; width: min(480px, calc(100vw - 32px)); height: min(900px, calc(100vh - 36px)); background: none; border-radius: 30px; padding: 5px 5px 3px; }
  #mg-root::before { content: ""; position: fixed; inset: 0; z-index: -2; background: radial-gradient(ellipse at 50% 45%, rgba(24,40,16,.8), rgba(8,14,6,.93) 75%); }
  #mg-root::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: linear-gradient(170deg, var(--c1, #7ed957), var(--c2, #2e9e4f));
    border: 3px solid var(--ink); box-shadow: 0 7px 0 var(--ink), 0 0 0 6px rgba(255,255,255,.14), 0 26px 70px rgba(0,0,0,.55); }
  #mg-root.is-challenge { box-shadow: none; }
  #mg-root.is-challenge::after { box-shadow: inset 0 0 0 5px #f0483a, 0 7px 0 var(--ink), 0 0 0 6px rgba(255,255,255,.14), 0 26px 70px rgba(0,0,0,.55); }
  #mg-root .mg-top { padding: 10px 12px 8px 14px; }
  #mg-root .mg-stage { cursor: default; }
}

/* ---------- medium play fields (1024 to 1279 wide): everything stacked, slightly smaller numbers ---------- */
@media (min-width: 1024px) and (max-width: 1279.98px) and (min-height: 560px) {
  #app { padding: 12px 16px 10px; }
  .juice-amount { font-size: 46px; }
  .juice-amount.is-long { font-size: 36px; }
  #power-bar { min-height: 60px; padding-top: 4px; }
  .buffs { top: 112px; }
  .buff { font-size: 12px; }
  /* notices drop into the free middle of the site bar, so they never cover the juice counter */
  #toasts { top: 4px; left: 430px; right: 168px; padding: 0; gap: 5px; }
  .toast { padding: 2px 12px 2px 5px; gap: 7px; font-size: 13.5px; line-height: 1.2; border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.3); }
  .toast .ti { width: 30px; height: 30px; font-size: 16px; }
  .toast canvas { width: 34px; height: 34px; }
  .toast small { font-size: 11.5px; }
}

/* ---------- roomy play fields (1280 and wider): level card and powers share one row under the pear,
   active effects stack on the left instead of pushing the pear down ---------- */
@media (min-width: 1280px) and (min-height: 560px) {
  #app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px) auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 14px; padding: 16px 26px 18px; }
  #hud, #pear-zone { grid-column: 1 / -1; }
  #hud-low { grid-column: 2; grid-row: 3; align-self: center; max-width: none; margin: 0; }
  #power-bar { grid-column: 3; grid-row: 3; align-self: center; width: auto; max-width: 400px; margin: 0; padding: 6px 2px 8px; gap: 8px; }
  .power-hint { display: block; max-width: 210px; text-align: left; line-height: 1.2; }
  .pwb { flex-basis: 52px; font-size: 25px; }
  .juice-amount { font-size: 60px; }
  .juice-amount.is-long { font-size: 48px; }
  .buffs { top: 58px; gap: 6px; }
  .buff { font-size: 13.5px; padding: 3px 11px 3px 8px; }
  /* notices slide in at the lower left of the play field, clear of the juice counter and the pear */
  #toasts { top: auto; bottom: 112px; left: 26px; right: auto; padding: 0; align-items: flex-start; flex-direction: column-reverse; max-width: 290px; }
  .toast { animation-name: toast-in-l, toast-out-l; }
  @keyframes toast-in-l { from { transform: translateX(-30px); opacity: 0; } }
  @keyframes toast-out-l { to { transform: translateX(-20px); opacity: 0; } }
}
@media (min-width: 1500px) and (min-height: 560px) {
  #app { grid-template-columns: minmax(0, 1fr) minmax(240px, 420px) auto minmax(0, 1fr); column-gap: 20px; }
  #power-bar { max-width: 460px; }
  .pwb { flex-basis: 54px; }
}
@media (min-width: 1600px) and (min-height: 560px) {
  .grid3 { grid-template-columns: repeat(4, 1fr); }
  .panel-body { padding-left: 16px; padding-right: 10px; }
}
/* short desktop windows: tighten the play field so the pear keeps its room */
@media (min-width: 1024px) and (min-height: 560px) and (max-height: 699.98px) {
  #app { padding-top: 10px; padding-bottom: 10px; }
  .juice-label { display: none; }
  .level-reward { display: none; }
  .quick small { display: none; }
}

/* ---------- mouse and keyboard affordances (any width, only where a real pointer hovers) ---------- */
@media (hover: hover) and (pointer: fine) {
  a, .chest, .switch, input[type="range"], .glint { cursor: pointer; }
  .btn:disabled, .btn.is-off { cursor: not-allowed; }
  .btn:hover:not(:active):not(:disabled):not(.is-off) { filter: brightness(1.07) saturate(1.05); transform: translateY(-1.5px); box-shadow: 0 5.5px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.55), inset 0 -3px 0 var(--lip); }
  .icon-btn:hover:not(:active), .chip-world:hover:not(:active), .chip-gems:hover:not(:active) { transform: translateY(-1.5px); filter: brightness(1.05); }
  .level-card { transition: transform .12s cubic-bezier(.3,1.7,.5,1), filter .15s; }
  .level-card:hover:not(:active) { transform: translateY(-2px); filter: brightness(1.04); }
  .level-card:active { transform: translateY(1px) scale(.99); }
  #nav .nav-btn:hover:not(.is-active):not(:active)::before { transform: translateY(-3px) scale(1.07); filter: brightness(1.08); }
  #nav .nav-btn:hover:not(.is-active):not(:active) .ico { transform: translateY(-3px) scale(1.07); }
  .quick:hover:not(:active) .tile { transform: translateY(-3px) scale(1.06); filter: brightness(1.08); }
  .pwb { transition: transform .12s cubic-bezier(.3,1.7,.5,1), filter .15s; }
  .pwb:hover:not(:active):not(.is-cool) { filter: brightness(1.12); }
  .pwb:hover:not(:active):not(.is-ready) { transform: translateY(-2px); }
  .seg button:hover:not(.is-on) { background: rgba(255,255,255,.55); color: var(--ink); }
  .st-tab:hover:not(:active) { transform: translateY(-2px); filter: brightness(1.04); }
  .col-card { transition: transform .12s cubic-bezier(.3,1.7,.5,1), filter .15s; }
  .col-card:hover:not(:active) { transform: translateY(-3px); filter: brightness(1.04); }
  .ch-head:hover:not(:active) { transform: translateY(-2px); filter: brightness(1.06); }
  .node:hover { filter: brightness(1.1); transform: scale(1.12); }
  .node { transition: transform .12s cubic-bezier(.3,1.7,.5,1); }
  .switch:hover { filter: brightness(1.06); }
  button.q-facewrap:hover:not(:active) { transform: scale(1.07) rotate(4deg); }
  .ex-choice:hover:not(:active) { transform: translateY(-2px); filter: brightness(1.04); }
  .ex-chests button:hover:not(:active) { transform: scale(1.1) rotate(-4deg); }
  .m-tile:hover i { box-shadow: inset 0 0 0 2.5px rgba(255,255,255,.75); }
  .card.up-card:not(.is-locked), .st-card, .ar-machine, .pw-card:not(.is-locked), .world-card { transition: transform .14s cubic-bezier(.3,1.5,.5,1), box-shadow .15s; }
  .card.up-card:not(.is-locked):not(.just-bought):hover, .pw-card:not(.is-locked):hover, .q-card:not(.q-locked):not(.q-done):hover { box-shadow: 0 4px 0 var(--paper-deep), 0 4px 0 2.5px var(--ink), 0 0 0 4px rgba(255,255,255,.85); }
  .st-card:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.9); }
  .ar-machine:not(.is-locked):hover { transform: translateY(-2px); box-shadow: 0 7px 0 #0b0420, 0 0 0 2px var(--c1), 0 0 22px 0 var(--c1); }
  .sb-logo:hover { transform: translateY(-1px); }
  .sb-logo:hover img { transform: rotate(-8deg) scale(1.08); }
  .sb-links a:hover { background: #fff; border-color: var(--ink); box-shadow: 0 2.5px 0 var(--ink); }
  .sb-links a:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
}
.sb-logo:focus-visible, .sb-links a:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; box-shadow: none; }

/* ---------- reduced motion ---------- */
.fx-low #panels .panel { animation: none; }
@media (prefers-reduced-motion: reduce) {
  #panels .panel, #press-hint { animation: none; }
  .sb-logo, .sb-logo img, .level-card, .pwb, .col-card, .node, .st-card, .ar-machine { transition: none; }
}

/* Boosts sits in the tile row with Quest and Arcade: Quest, Boosts, Arcade */
@media (min-width: 1024px) and (min-height: 560px) {
  .hud-quick .quest-chip { margin-right: 152px; }
  .hud-quick .quick.boost-btn { position: relative; top: auto; right: auto; grid-column: 3; grid-row: 1 / span 2; justify-self: end; margin-right: 76px; }
}

/* Daily joins the tile row. With the Boosts tile: Quest, Boosts, Daily, Arcade. Without it: Quest, Daily, Arcade. */
@media (min-width: 1024px) and (min-height: 560px) {
  .hud-quick .quick.daily-btn { grid-column: 3; grid-row: 1 / span 2; justify-self: end; margin-right: 76px; }
  .has-boosts .hud-quick .quest-chip { margin-right: 228px; }
  .has-boosts .hud-quick .quick.boost-btn { margin-right: 152px; }
}
/* Four tiles on a narrow desktop window: closer together, then smaller, so the row stays clear of the juice counter. */
@media (min-width: 1024px) and (max-width: 1359.98px) and (min-height: 560px) {
  .has-boosts .hud-quick .quick { width: 60px; }
  .has-boosts .hud-quick .quick.daily-btn { margin-right: 64px; }
  .has-boosts .hud-quick .quick.boost-btn { margin-right: 128px; }
  .has-boosts .hud-quick .quest-chip { margin-right: 192px; }
}
@media (min-width: 1024px) and (max-width: 1139.98px) and (min-height: 560px) {
  .has-boosts .hud-quick .quick { width: 50px; }
  .has-boosts .hud-quick .quick .tile { width: 46px; height: 46px; border-radius: 16px; }
  .has-boosts .hud-quick .quick .tile .ico { font-size: 24px; }
  .has-boosts .hud-quick .quick small { font-size: 10.5px; -webkit-text-stroke-width: 2.5px; }
  .has-boosts .hud-quick .quick.daily-btn { margin-right: 54px; }
  .has-boosts .hud-quick .quick.boost-btn { margin-right: 108px; }
  .has-boosts .hud-quick .quest-chip { margin-right: 162px; }
}
@media (min-width: 1024px) and (max-width: 1139.98px) and (min-height: 560px) {
  .has-boosts .juice-amount.is-long { font-size: 36px; }      /* a very long number makes room for the fourth tile */
}
