/* Hearthleaf Cafe: game UI. Scoped under #cafe-wrap so it never touches the site frame. */
#cafe-wrap{--ink:#3b2616;--cream:#fbeed2;--wood:#6b4a30;--gold:#e9a23b;--green:#3d8b5a;--red:#c0392b;--glass:rgba(40,24,14,.82);position:relative;margin:0 auto;width:100%}
#cafe-wrap .cf-stage{position:relative;display:flex;flex-direction:column;width:min(100%,calc(86svh * .6));min-width:min(100%,300px);aspect-ratio:9/15;margin:0 auto;background:#9ec9e8;border-radius:14px;overflow:hidden;color:var(--cream);font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;font-size:14px;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;box-shadow:0 4px 18px rgba(0,0,0,.25)}
#cafe-wrap button{font:inherit;color:inherit;border:0;cursor:pointer;touch-action:manipulation}
#cafe-wrap button:focus-visible{outline:3px solid #fff;outline-offset:-3px}
#cafe-wrap #cf-canvas{flex:1 1 auto;min-height:0;width:100%;display:block;touch-action:none;background:#9ec9e8}
.cf-hud{flex:none;background:var(--glass);padding:4px 8px 4px}
.cf-row{display:flex;align-items:center;gap:8px;min-height:30px}
.cf-money{font-weight:800;font-size:18px;color:#ffd77a;min-width:70px}
.cf-stars{flex:1;text-align:center;color:#ffd24a;font-size:15px;letter-spacing:1px;white-space:nowrap}
.cf-clock{font-size:12px;opacity:.9;white-space:nowrap}
.cf-lv{font-weight:700;font-size:13px;min-width:38px}
.cf-xp{flex:1;height:8px;background:rgba(255,255,255,.2);border-radius:5px;overflow:hidden}
.cf-xp i{display:block;height:100%;width:0;background:linear-gradient(90deg,#7bd88f,#e9d24b)}
#cafe-wrap .cf-ib{min-width:44px;min-height:44px;padding:0 6px;border-radius:10px;background:rgba(255,255,255,.14);font-weight:700;font-size:13px}
.cf-banner{position:absolute;left:8px;right:8px;top:96px;padding:5px 10px;border-radius:9px;background:rgba(192,57,43,.9);text-align:center;font-weight:700;font-size:12px;opacity:0;pointer-events:none;transition:opacity .25s}
.cf-banner.on{opacity:1}
.cf-tip{position:absolute;left:12px;right:12px;bottom:70px;padding:8px 12px;border-radius:12px;background:rgba(255,255,255,.95);color:var(--ink);font-weight:700;font-size:13px;text-align:center;box-shadow:0 2px 10px rgba(0,0,0,.3);pointer-events:none;z-index:6}
.cf-float{position:absolute;inset:0;pointer-events:none;z-index:7}
.cf-fl{position:absolute;transform:translate(-50%,0);font-weight:800;font-size:15px;color:#fff;text-shadow:0 1px 3px #000,0 0 6px #000;white-space:nowrap}
.cf-fl.cash{color:#9cf0a8}.cf-fl.perfect{color:#ffe066;font-size:22px}.cf-fl.bad{color:#ff9b8a}
.cf-toasts{position:absolute;left:10px;right:10px;top:132px;display:flex;flex-direction:column;gap:6px;align-items:center;pointer-events:none;z-index:8}
.cf-toast{background:var(--glass);padding:7px 12px;border-radius:10px;font-size:12.5px;text-align:center;max-width:94%}
.cf-marker{position:absolute;left:10px;right:10px;bottom:68px;background:var(--glass);border-radius:14px;padding:8px 10px 10px;z-index:9}
.cf-marker[hidden]{display:none}
.cf-mlabel{font-size:12px;text-align:center;margin-bottom:6px;font-weight:700}
.cf-track{position:relative;height:30px;background:#2a1b10;border-radius:8px;overflow:hidden;touch-action:manipulation}
.cf-zone{position:absolute;top:0;bottom:0;background:rgba(80,200,120,.55);border-left:2px solid #7ff0a0;border-right:2px solid #7ff0a0}
.cf-zone b{position:absolute;left:50%;top:0;bottom:0;width:3px;margin-left:-1px;background:#d6ffd8}
.cf-needle{position:absolute;top:0;bottom:0;left:0;width:4px;background:#fff;box-shadow:0 0 6px #fff;will-change:transform}
#cafe-wrap .cf-stop{display:block;width:100%;margin-top:8px;min-height:54px;border-radius:12px;background:var(--gold);color:#3b2000;font-weight:900;font-size:20px;letter-spacing:2px}
.cf-actions{flex:none;display:grid;grid-template-columns:repeat(6,1fr);gap:4px;padding:5px 6px calc(5px + env(safe-area-inset-bottom,0px));background:var(--glass)}
#cafe-wrap .cf-act{position:relative;min-height:56px;border-radius:10px;background:var(--wood);font-weight:700;font-size:12px;display:flex;align-items:center;justify-content:center;padding:0 2px}
#cafe-wrap .cf-act.cf-alt{background:#4d5f78}
#cafe-wrap .cf-act:disabled{opacity:.4}
#cafe-wrap .cf-act.hot{background:#e9a23b;color:#3b2000;animation:cfpulse .8s infinite alternate}
.cf-act i{position:absolute;top:2px;right:4px;font-style:normal;font-size:11px;background:#c0392b;color:#fff;border-radius:9px;min-width:17px;padding:0 4px;text-align:center}
.cf-act i:empty{display:none}
@keyframes cfpulse{to{transform:scale(1.05)}}
.cf-sheet{position:absolute;left:0;right:0;bottom:0;max-height:78%;overflow:auto;background:#fff7e6;color:var(--ink);border-radius:18px 18px 0 0;padding:12px 14px calc(14px + env(safe-area-inset-bottom,0px));z-index:12;box-shadow:0 -4px 20px rgba(0,0,0,.35)}
.cf-sheet[hidden]{display:none}
.cf-sh{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}
.cf-sh h2{font-size:18px;margin:0}
#cafe-wrap .cf-sheet button{background:#e9dcc0;color:var(--ink);border-radius:10px;min-height:44px;padding:0 14px;font-weight:700}
#cafe-wrap .cf-sheet button.cf-primary{background:var(--green);color:#fff;flex:1}
#cafe-wrap .cf-sheet button:disabled{opacity:.45}
#cafe-wrap .cf-sheet button.on{background:var(--wood);color:#fff}
#cafe-wrap .cf-sheet button.danger{background:var(--red);color:#fff}
.cf-sheet h3{font-size:14px;margin:10px 0 4px}
.cf-sub{font-size:12.5px;margin:6px 0;color:#5b4632}
.cf-note{font-size:12.5px;margin:6px 0;padding:6px 8px;background:#fff0c4;border-radius:8px}
.cf-ev{margin:8px 0;padding:8px 10px;border-radius:10px;background:#e3efe6;display:flex;flex-direction:column;gap:2px;font-size:12.5px}
.cf-btns{display:flex;gap:8px;margin-top:10px}
.cf-list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:5px}
.cf-list li{background:#f2e6c9;border-radius:8px;padding:6px 8px;font-size:12.5px;display:grid;grid-template-columns:1fr auto;gap:0 8px}
.cf-list li small{grid-column:1/3;color:#6b5640}
.cf-list li.done{background:#d6ecd6}
.cf-tbl{width:100%;border-collapse:collapse;font-size:14px;margin:6px 0}
.cf-tbl td{padding:4px 2px;border-bottom:1px solid #e6d8b8}.cf-tbl td:last-child{text-align:right;font-weight:700}
.cf-tbl .pos td:last-child{color:#2a7a45}.cf-tbl .neg td:last-child{color:var(--red)}
.cf-money2{font-weight:800;margin:2px 0 6px}
.cf-tabs{display:flex;gap:4px;margin-bottom:6px;overflow-x:auto}
.cf-tabs button{flex:1;padding:0 6px!important;font-size:12.5px}
.cf-scroll{display:flex;flex-direction:column;gap:6px;max-height:48svh;overflow:auto}
.cf-item{display:flex;justify-content:space-between;align-items:center;gap:8px;background:#f2e6c9;border-radius:10px;padding:7px 8px}
.cf-item.owned{opacity:.65}
.cf-item b{display:block;font-size:13.5px}.cf-item small{display:block;font-size:11.5px;color:#6b5640}.cf-item em{display:block;font-size:11.5px;color:var(--red);font-style:normal}
#cafe-wrap .cf-sheet .cf-buy{min-width:74px;background:var(--green);color:#fff}
.cf-set{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid #e6d8b8}
.cf-seg{display:flex;gap:4px}
.cf-fallback{position:absolute;left:10px;right:10px;top:96px;padding:10px;border-radius:10px;background:#fff7e6;color:var(--ink);font-size:13px;display:flex;flex-direction:column;gap:4px;z-index:5}
.cf-fallback[hidden]{display:none}
#cf-bigrow{display:flex;justify-content:center;margin:0 0 .6rem}
#cf-big{min-height:44px;padding:0 18px;border-radius:10px;border:0;background:#6b4a30;color:#fff;font-weight:700;font-size:14px;cursor:pointer}
/* Play big: fixed overlay fallback when the Fullscreen API is missing (iPhone Safari) */
#cafe-wrap.cafe-big{position:fixed;inset:0;z-index:9999;background:#1a110a;margin:0;display:flex;align-items:center;justify-content:center}
#cafe-wrap.cafe-big .cf-stage{width:100%;height:100%;aspect-ratio:auto;border-radius:0;max-width:none}
html.cafe-lock,html.cafe-lock body{overflow:hidden!important;overscroll-behavior:none}
@media (orientation:landscape) and (max-height:520px){
  #cafe-wrap.cafe-big .cf-stage{flex-direction:row}
  #cafe-wrap.cafe-big .cf-hud{width:210px;flex:none;order:2;display:flex;flex-direction:column;justify-content:flex-start;padding:6px}
  #cafe-wrap.cafe-big .cf-actions{order:3;width:150px;flex:none;grid-template-columns:1fr 1fr;align-content:center}
  #cafe-wrap.cafe-big #cf-canvas{order:1}
  #cafe-wrap.cafe-big .cf-banner{top:8px;right:370px}
  #cafe-wrap.cafe-big .cf-toasts{top:44px;right:370px}
  #cafe-wrap.cafe-big .cf-tip{bottom:8px;right:370px}
  #cafe-wrap.cafe-big .cf-marker{bottom:8px;right:370px}
  #cafe-wrap.cafe-big .cf-sheet{left:12%;right:12%;max-height:92%}
}
@media (prefers-reduced-motion:reduce){#cafe-wrap .cf-act.hot{animation:none}}
.cafe-guide{max-width:44rem;margin:1.5rem auto;padding:1rem;line-height:1.7;color:#1e293b}
.cafe-guide h2{font-size:1.35rem;margin-bottom:.6rem}.cafe-guide h3{font-size:1.05rem;margin:1.2rem 0 .4rem}.cafe-guide p,.cafe-guide ul{margin:.6rem 0}.cafe-guide ul{padding-left:1.3rem}
.cf-grade{display:flex;align-items:center;gap:10px;margin:2px 0 6px}.cf-grade b{display:inline-flex;align-items:center;justify-content:center;width:52px;height:52px;border-radius:14px;font-size:30px;background:#e6d8b8;color:#4a3320;animation:cf-pop .5s ease-out}.cf-grade span{font-size:12.5px;color:#5b4632}.cf-grade.gA b{background:#2a7a45;color:#fff}.cf-grade.gB b{background:#d9a441;color:#3b2a14}.cf-grade.gC b{background:#e6d8b8}.cf-grade.gD b{background:#c9b99a}
.cf-rec{font-size:13.5px;font-weight:700;margin:4px 0;padding:6px 8px;background:#dff3e4;color:#1f5c35;border-radius:8px}.cf-next{font-size:13px;margin:6px 0;color:#4a3320}
@keyframes cf-pop{0%{transform:scale(.4)}70%{transform:scale(1.12)}100%{transform:scale(1)}}
@media (prefers-reduced-motion:reduce){.cf-grade b{animation:none}}

/* Full screen on phones: shell stage (.game-wrap) is filled by the cafe. */
html.pip-immersive .game-wrap,html.pip-native .game-wrap{display:flex;flex-direction:column;padding:0;background:#1a110a}
html.pip-immersive #cf-bigrow,html.pip-native #cf-bigrow,html.pip-immersive .cf-set:has([data-do="big"]),html.pip-native .cf-set:has([data-do="big"]),html.pip-immersive .hub-bar,html.pip-native .hub-bar,html.pip-immersive .playyard-ad,html.pip-native .playyard-ad,html.pip-immersive .below-content,html.pip-native .below-content,html.pip-immersive .ad-well,html.pip-native .ad-well,html.pip-immersive .cafe-guide,html.pip-native .cafe-guide{display:none!important}
html.pip-immersive #cafe-wrap,html.pip-native #cafe-wrap{flex:1 1 auto;min-height:0;width:100%;margin:0;display:flex;align-items:center;justify-content:center}
html.pip-immersive #cafe-wrap .cf-stage,html.pip-native #cafe-wrap .cf-stage{width:100%;height:100%;max-width:none;aspect-ratio:auto;border-radius:0;box-shadow:none;padding-top:env(safe-area-inset-top,0px)}
html.pip-immersive #cafe-wrap .cf-act,html.pip-native #cafe-wrap .cf-act{min-height:56px}
@media (orientation:landscape) and (max-height:520px){
  html.pip-immersive #cafe-wrap .cf-stage,html.pip-native #cafe-wrap .cf-stage{flex-direction:row;padding-top:0}
  html.pip-immersive #cafe-wrap .cf-hud,html.pip-native #cafe-wrap .cf-hud{width:210px;flex:none;order:2;display:flex;flex-direction:column;justify-content:flex-start;padding:6px}
  html.pip-immersive #cafe-wrap .cf-actions,html.pip-native #cafe-wrap .cf-actions{order:3;width:150px;flex:none;grid-template-columns:1fr 1fr;align-content:center}
  html.pip-immersive #cafe-wrap #cf-canvas,html.pip-native #cafe-wrap #cf-canvas{order:1}
  html.pip-immersive #cafe-wrap .cf-banner,html.pip-native #cafe-wrap .cf-banner{top:8px;right:370px}
  html.pip-immersive #cafe-wrap .cf-toasts,html.pip-native #cafe-wrap .cf-toasts{top:44px;right:370px}
  html.pip-immersive #cafe-wrap .cf-tip,html.pip-native #cafe-wrap .cf-tip{bottom:8px;right:370px}
  html.pip-immersive #cafe-wrap .cf-marker,html.pip-native #cafe-wrap .cf-marker{bottom:8px;right:370px}
  html.pip-immersive #cafe-wrap .cf-sheet,html.pip-native #cafe-wrap .cf-sheet{left:12%;right:12%;max-height:92%}
}
/* Finish: depth on HUD and buttons, vignette over the scene */
#cafe-wrap .cf-stage::after{content:'';position:absolute;inset:0;pointer-events:none;box-shadow:inset 0 0 60px rgba(40,20,5,.28);z-index:2}
.cf-hud{background:linear-gradient(180deg,rgba(58,36,20,.9),rgba(34,20,10,.88));border-bottom:1px solid rgba(255,214,140,.25)}
#cafe-wrap .cf-act{background:linear-gradient(180deg,#85603f,#6b4a30);box-shadow:0 2px 0 #3d2714,inset 0 1px 0 rgba(255,255,255,.22);transition:transform .12s ease,filter .12s}
#cafe-wrap .cf-act:active{transform:translateY(2px);box-shadow:0 0 0 #3d2714;filter:brightness(.95)}
#cafe-wrap .cf-act.cf-alt{background:linear-gradient(180deg,#60758f,#4d5f78)}
#cafe-wrap .cf-act.hot{background:linear-gradient(180deg,#f3b655,#e9a23b)}

/* Full screen fit pass: title hidden, stage fills the shell stage, canvas takes the remaining space. */
html.pip-immersive .game-wrap,html.pip-native .game-wrap{padding:0!important;overflow:hidden!important;min-height:0}
html.pip-immersive .game-wrap .game-title,html.pip-native .game-wrap .game-title,html.pip-immersive .game-header,html.pip-native .game-header,html.pip-immersive .game-wrap noscript,html.pip-native .game-wrap noscript{display:none!important}
html.pip-immersive #cafe-wrap,html.pip-native #cafe-wrap{align-items:stretch;overflow:hidden}
html.pip-immersive #cafe-wrap .cf-stage,html.pip-native #cafe-wrap .cf-stage{height:auto;min-height:0;align-self:stretch;padding-top:0}
html.pip-immersive #cafe-wrap #cf-canvas,html.pip-native #cafe-wrap #cf-canvas{flex:1 1 0;min-height:0;min-width:0;width:100%;height:auto}
html.pip-immersive #cafe-wrap .cf-hud,html.pip-native #cafe-wrap .cf-hud{padding-top:calc(4px + env(safe-area-inset-top,0px))}
@media (orientation:landscape) and (max-height:520px){
  html.pip-immersive #cafe-wrap .cf-stage,html.pip-native #cafe-wrap .cf-stage{flex-direction:row}
  html.pip-immersive #cafe-wrap #cf-canvas,html.pip-native #cafe-wrap #cf-canvas{flex:1 1 0;width:0;height:100%;min-width:0}
  html.pip-immersive #cafe-wrap .cf-hud,html.pip-native #cafe-wrap .cf-hud{padding-top:6px;overflow:hidden}
  html.pip-immersive #cafe-wrap .cf-actions,html.pip-native #cafe-wrap .cf-actions{padding-bottom:5px;grid-auto-rows:minmax(48px,1fr)}
  html.pip-immersive #cafe-wrap .cf-act,html.pip-native #cafe-wrap .cf-act{min-height:48px}
  html.pip-immersive #cafe-wrap .cf-sheet,html.pip-native #cafe-wrap .cf-sheet{overflow:auto;max-height:94%}
  html.pip-immersive #cafe-wrap .cf-scroll,html.pip-native #cafe-wrap .cf-scroll{max-height:55svh}
}
html.pip-immersive #cafe-wrap .cf-sheet[hidden],html.pip-native #cafe-wrap .cf-sheet[hidden],html.pip-immersive #cafe-wrap .cf-marker[hidden],html.pip-native #cafe-wrap .cf-marker[hidden]{display:none}
