/* Kolobok Winter Workshop — isolated, responsive scene */
#screen-tree.page-bg { display:block; overflow-x:hidden!important; overflow-y:auto!important; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
#screen-tree .tree-page { width:min(1260px,100%); max-width:none; min-height:max-content; margin:0 auto; padding:18px clamp(12px,2vw,28px) calc(var(--nav-height,82px) + 34px + env(safe-area-inset-bottom,0px)); box-sizing:border-box; }
.tree-workshop-top { display:flex; align-items:center; justify-content:space-between; gap:18px; margin:0 0 16px; }
#screen-tree .tree-heading { min-width:0; }
#screen-tree .tree-heading>span { display:block; color:#91e6ff; font-size:9px; font-weight:1000; letter-spacing:2px; }
#screen-tree .tree-heading h2 { margin:5px 0; color:#f7fbff; font-size:clamp(21px,3vw,30px); font-weight:1000; letter-spacing:-.7px; }
#screen-tree .tree-heading p { color:#9fb3ce; font-size:11px; }
.tree-mode-actions { flex:0 0 auto; display:flex; align-items:center; gap:8px; }
.tree-edit-button,.tree-exit-button { min-height:44px; padding:0 18px; border-radius:14px; font-size:10px; font-weight:1000; letter-spacing:.7px; color:#1c2438; background:linear-gradient(110deg,#ffe49b,#ffb74d); box-shadow:0 8px 25px #ffbd5a33; transition:transform .2s,filter .2s,box-shadow .2s; }
.tree-edit-button:active,.tree-exit-button:active { transform:scale(.96); filter:brightness(1.1); }
.tree-exit-button { color:#dff6ff; background:linear-gradient(135deg,#203c5b,#14233a); border:1px solid #8adfff66; }
.tree-workshop { display:grid; grid-template-columns:minmax(0,1fr) minmax(300px,360px); align-items:start; gap:18px; }
.tree-stage-column { min-width:0; }
#screen-tree .tree-scene { position:relative; isolation:isolate; width:100%; height:clamp(460px,60vh,620px); min-height:460px; overflow:hidden; display:flex; align-items:center; justify-content:center; border:1px solid #8bdfff38; border-radius:26px; background:radial-gradient(ellipse at 50% 30%,#244b73 0%,#10243f 43%,#0a1328 100%); box-shadow:0 22px 60px #0008,inset 0 1px #ffffff20; perspective:1000px; }
#screen-tree .tree-scene::before { content:""; position:absolute; inset:0; z-index:-1; opacity:.62; background:radial-gradient(circle at 12% 18%,#d9f4ff 0 1px,transparent 2px),radial-gradient(circle at 77% 14%,#d9f4ff 0 1px,transparent 2px),radial-gradient(circle at 85% 58%,#d9f4ff 0 1px,transparent 2px),radial-gradient(circle at 22% 68%,#d9f4ff 0 1px,transparent 2px),radial-gradient(ellipse at 50% 100%,#7ed7ff1c,transparent 52%); background-size:113px 127px,151px 173px,181px 137px,197px 157px,100% 100%; }
.tree-scene-stars { position:absolute; inset:0; pointer-events:none; opacity:.4; background:radial-gradient(1px 1px at 20% 22%,#fff,transparent),radial-gradient(1px 1px at 73% 35%,#fff,transparent),radial-gradient(2px 2px at 86% 76%,#dff7ff,transparent),radial-gradient(1px 1px at 13% 80%,#fff,transparent); background-size:180px 160px; animation:treeStarDrift 24s linear infinite; }
#tree-snow-canvas { position:absolute; inset:0; z-index:10; display:block; pointer-events:none; }
#screen-tree .holiday-tree { position:relative; width:min(76%,390px); height:min(84%,490px); max-height:490px; flex:0 1 auto; transform:rotateX(7deg) rotateY(var(--tree-tilt,0deg)); transform-origin:50% 92%; transform-style:preserve-3d; filter:drop-shadow(0 25px 24px #0008); transition:transform .35s ease; }
#screen-tree .tree-layer { position:absolute; left:50%; transform:translateX(-50%) rotateX(5deg); border:0!important; background:radial-gradient(ellipse at 45% 20%,#72e5b4aa 0%,transparent 31%),radial-gradient(ellipse at 75% 54%,#002e2680 0%,transparent 42%),url("../img/tree-tier.svg") center/100% 100% no-repeat; filter:drop-shadow(0 12px 7px #0008); transform-style:preserve-3d; }
#screen-tree .tree-layer::before { content:""; position:absolute; inset:8% 9% 12%; border-radius:48%; background:repeating-linear-gradient(168deg,transparent 0 13px,#9dffd01a 14px 16px,transparent 17px 26px); mix-blend-mode:screen; opacity:.8; }
#screen-tree .tree-layer::after { content:""; position:absolute; inset:0; background:linear-gradient(112deg,#b5ffda1c 0%,transparent 35%,#001d1b42 78%,transparent 100%); clip-path:polygon(50% 0,100% 100%,0 100%); }
#screen-tree .layer-one { top:5%; width:39%; height:29%; z-index:5; }
#screen-tree .layer-two { top:18%; width:59%; height:35%; z-index:4; }
#screen-tree .layer-three { top:33%; width:79%; height:39%; z-index:3; }
#screen-tree .layer-four { top:49%; width:98%; height:42%; z-index:2; }
#screen-tree .tree-branch { position:absolute; top:auto; left:0!important; bottom:0; width:100%!important; height:17px; border-radius:50%; background:linear-gradient(180deg,#54c894 0%,#08724e 48%,#03422f 100%); box-shadow:0 7px 0 #033a2d,0 12px 16px #001c1a88,inset 0 2px 5px #c1ffe255; }
#screen-tree .branch-snow { position:absolute; left:-2%; top:-6px; width:104%; height:var(--snow-depth,7px); border-radius:50%; background:linear-gradient(180deg,#fff 0%,#e4f8ff 45%,#a9dff2 100%); box-shadow:0 3px 8px #c9f3ff99; transition:height .24s ease,opacity .24s ease; }
#screen-tree .tree-trunk { position:absolute; z-index:1; left:43%; bottom:2%; width:14%; height:16%; border-radius:8px 8px 13px 13px; background:linear-gradient(90deg,#4a251b,#a76a3c 40%,#482318); box-shadow:inset 5px 0 7px #fff2; }
#screen-tree .tree-pot { position:absolute; z-index:2; left:37%; bottom:0; width:26%; height:8%; border-radius:5px 5px 15px 15px; background:linear-gradient(90deg,#7d2633,#e75a55 48%,#772333); box-shadow:0 8px 14px #0007,inset 0 3px #ffc5a344; }
#screen-tree .tree-topper { position:absolute; z-index:9; top:-1%; left:50%; width:34px; height:44px; transform:translateX(-50%); display:grid; place-items:center; color:#fff0a5; font-size:34px; text-shadow:0 0 9px #ffe58c,0 0 24px #ffcf4c; animation:treeTopperGlow 2.2s ease-in-out infinite alternate; }
#screen-tree .tree-garland { position:absolute; z-index:6; left:13%; width:74%; height:30%; border-bottom:3px solid #ffcf77; border-radius:0 0 50% 50%; filter:drop-shadow(0 0 7px #ffd46b); pointer-events:none; }
#screen-tree .garland-one { top:25%; transform:rotate(8deg); }
#screen-tree .garland-two { top:44%; transform:rotate(-7deg); }
#screen-tree .garland-three { top:63%; transform:rotate(7deg); }
#screen-tree #tree-ornaments { position:absolute; inset:6% 0 7%; z-index:8; pointer-events:none; }
#screen-tree .tree-bauble { position:absolute; width:clamp(27px,5vw,42px); height:clamp(29px,5.5vw,46px); border:2px solid #ffe6a7; border-radius:50% 50% 48% 48%; padding:2px; display:grid; place-items:center; background:radial-gradient(circle at 28% 20%,#fff9,#fff0 38%),linear-gradient(135deg,#e14e5c,#7d102f); box-shadow:0 5px 12px #0009,inset 0 0 9px #fff7,0 0 12px #ffcf7855; transform:rotate(var(--sway,0deg)); transform-origin:50% -10%; animation:treeBaubleSway 3.2s ease-in-out infinite alternate; pointer-events:auto; }
#screen-tree .tree-bauble img { width:100%; height:100%; object-fit:contain; border-radius:50%; pointer-events:none; }
#screen-tree .tree-bauble.gold { background:linear-gradient(135deg,#fff1a5,#d99a27,#fff0a8); }
#screen-tree .tree-bauble.light,#screen-tree .tree-bauble.tinsel,#screen-tree .tree-bauble.snow,#screen-tree .tree-bauble.topper,#screen-tree .tree-bauble.ribbon,#screen-tree .tree-bauble.bell,#screen-tree .tree-bauble.candy { width:34px;height:34px;border-radius:50%;font-size:20px;display:grid;place-items:center; }
#screen-tree .tree-bauble.light { background:linear-gradient(135deg,#b7fff3,#3299d4); }
#screen-tree .tree-bauble.tinsel { background:linear-gradient(135deg,#f3a9eb,#8d4cb3); }
#screen-tree .tree-bauble.snow { background:linear-gradient(135deg,#fff,#8bdcff); }
#screen-tree .tree-bauble.topper { background:linear-gradient(135deg,#ffe9a1,#c28b29); }
#screen-tree .tree-bauble.ribbon { background:linear-gradient(135deg,#ffb1c7,#b62b5d); }
#screen-tree .tree-bauble.bell { background:linear-gradient(135deg,#fff0a5,#b98125); }
#screen-tree .tree-bauble.candy { background:repeating-linear-gradient(45deg,#fff 0 5px,#d94c5d 5px 10px); }
#screen-tree .tree-bauble.selected { outline:3px solid #fff; z-index:12; }
#screen-tree .tree-floor-snow { position:absolute; z-index:9; left:0; right:0; bottom:0; height:16px; border-radius:50%; background:linear-gradient(#fff,#a8d7ed); box-shadow:0 0 18px #b9ecff88; }
#screen-tree .tree-snowbank { position:absolute; z-index:11; bottom:0; left:5%; width:90%; height:22px; border-radius:50% 50% 0 0; background:linear-gradient(#f5fdff,#a8d7ed); box-shadow:0 -4px 18px #d6f6ff44; pointer-events:none; }
.tree-place-hint { position:absolute; z-index:12; left:50%; bottom:13px; transform:translateX(-50%); width:max-content; max-width:90%; padding:8px 12px; border:1px solid #a4eaff38; border-radius:30px; background:#09172bc9; color:#d8efff; font-size:9px; text-align:center; backdrop-filter:blur(12px); pointer-events:none; }
.tree-controls { margin-top:14px; padding:15px 17px; border-radius:19px; border:1px solid #8bdfff27; background:linear-gradient(145deg,#1b2c45,#101a2c); }
.tree-controls-title { display:flex;align-items:center;justify-content:space-between;margin-bottom:10px; }
.tree-controls-title>div>span { font-size:8px;letter-spacing:1.3px;color:#83dfff;font-weight:1000; }
.tree-controls-title h3 { margin:4px 0 0;font-size:15px; }
.tree-live-dot { color:#7be6bd;font-size:8px;letter-spacing:1px; }
.tree-motion-actions { display:grid;grid-template-columns:1fr 1fr;gap:8px; }
.tree-motion-actions button { min-height:40px;border:1px solid #8bdfff55;border-radius:12px;padding:9px 7px;background:#183a52;color:#dff7ff;font-size:10px;font-weight:900; }
.tree-motion-actions button+button { background:#4a352d;border-color:#f4c77b55;color:#ffe7bd; }
.tree-controls>p { margin:9px 0 0;color:#93a9c2;font-size:10px;line-height:1.5;text-align:center; }
#tree-sidebar.winter-market { position:sticky;top:12px;min-width:0;max-height:calc(100dvh - 150px);overflow:auto;margin:0;padding:15px;border:1px solid #ffd38340;border-radius:22px;background:radial-gradient(circle at 100% 0%,#ffca6a1c,transparent 35%),linear-gradient(145deg,#1b2d46f5,#111d31f7 70%);box-shadow:0 18px 45px #0006,inset 0 1px #ffffff12;backdrop-filter:blur(18px); }
#tree-sidebar .winter-market-head { display:flex;align-items:flex-start;justify-content:space-between;gap:9px; }
#tree-sidebar .winter-market-head>div:first-child { min-width:0; }
#tree-sidebar .winter-market-head h3 { font-size:17px;margin:5px 0 4px;color:#fff3d0; }
#tree-sidebar .winter-market-head p { max-width:200px;font-size:10px;line-height:1.4;color:#a9bdd2; }
#tree-sidebar .market-wallet { padding:8px 9px; }
#tree-sidebar .market-wallet strong { font-size:15px; }
#tree-sidebar .market-tabs { position:sticky;top:-15px;z-index:3;margin:0 -2px;padding:13px 2px 10px;background:linear-gradient(#172941 78%,transparent); }
#tree-sidebar .winter-market-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px; }
#tree-sidebar .market-product { min-width:0;overflow:hidden;border-radius:15px;background:linear-gradient(145deg,#263b56,#17263b);border:1px solid #ffffff17;box-shadow:0 7px 17px #0003;display:flex;flex-direction:column; }
#tree-sidebar .market-product.is-selected { border-color:#ffe19a;box-shadow:0 0 0 2px #ffdc8b44,0 10px 24px #0005; }
#tree-sidebar .market-product-art { height:100px;position:relative;display:grid;place-items:center;overflow:hidden;background:radial-gradient(circle at 50% 35%,#47708c,#1b304a 75%); }
#tree-sidebar .market-product-art img { position:relative;z-index:1;width:86%;height:94px;object-fit:contain;filter:drop-shadow(0 6px 8px #0008); }
#tree-sidebar .market-product-art>span:not(.market-rarity) { font-size:42px;filter:drop-shadow(0 5px 10px #0008);z-index:1; }
#tree-sidebar .market-rarity { position:absolute;z-index:2;top:7px;left:7px;padding:4px 6px;border-radius:20px;background:#071322b8;color:#dcecff;font-size:7px;font-weight:1000; }
#tree-sidebar .market-product-info { padding:9px;display:flex;flex-direction:column;flex:1; }
#tree-sidebar .market-product-info h4 { font-size:10px;line-height:1.3;margin:0 0 4px;color:#fff;font-weight:1000; }
#tree-sidebar .market-product-info p { font-size:8px;line-height:1.4;color:#9db1c9;margin:0 0 9px;min-height:22px; }
#tree-sidebar .market-product-foot { display:flex;align-items:center;justify-content:space-between;gap:5px;margin-top:auto; }
#tree-sidebar .market-price { font-size:9px;color:#ffdc8b;white-space:nowrap; }
#tree-sidebar .market-buy { border:0;border-radius:8px;padding:7px 8px;background:linear-gradient(110deg,#ffe29a,#ffbc5c);color:#2b2432;font-size:8px;font-weight:1000;white-space:nowrap; }
#tree-sidebar .market-buy.owned-btn { background:#284c60;color:#bceeff;border:1px solid #80dfff55; }
#tree-sidebar .market-note { padding-top:11px;text-align:center;color:#91a8c2;font-size:9px;line-height:1.5; }
#screen-tree .tree-scene.is-entering { animation:winterSceneReveal 1.45s cubic-bezier(.18,.72,.18,1) both; }
#screen-tree .holiday-tree.shaking { animation:treePhysicalShake .78s cubic-bezier(.2,.7,.3,1); }
body.tree-edit-mode>header { flex:0 0 0;height:0;min-height:0;margin:0;padding:0;overflow:hidden;opacity:0;transform:translateY(-18px);pointer-events:none;transition:flex-basis .36s,height .36s,opacity .28s,transform .36s,padding .36s; }
body.tree-edit-mode nav { opacity:0;transform:translateY(120%);pointer-events:none;transition:opacity .32s,transform .42s; }
body.tree-edit-mode #screen-tree .tree-page { padding-top:10px;padding-bottom:20px; }
body.tree-edit-mode #tree-exit-edit { position:fixed;z-index:1001;top:calc(env(safe-area-inset-top,0px) + 12px);left:12px;box-shadow:0 10px 30px #0008; }
body.tree-edit-mode #screen-tree .tree-workshop { grid-template-columns:minmax(0,1fr) minmax(300px,360px); }
body.tree-edit-mode #screen-tree .tree-scene { height:calc(100dvh - 150px);min-height:430px; }
@keyframes winterSceneReveal { 0%{filter:blur(12px);transform:scale(1.045);opacity:.45} 45%{filter:blur(3px);opacity:.85} 100%{filter:blur(0);transform:scale(1);opacity:1} }
@keyframes treePhysicalShake { 0%,100%{transform:rotateX(7deg) rotateY(var(--tree-tilt,0deg))} 18%{transform:rotateX(7deg) rotateY(calc(var(--tree-tilt,0deg) - 5deg))} 42%{transform:rotateX(7deg) rotateY(calc(var(--tree-tilt,0deg) + 6deg))} 68%{transform:rotateX(7deg) rotateY(calc(var(--tree-tilt,0deg) - 3deg))} }
@keyframes treeBaubleSway { from{rotate:-4deg;translate:0 0} to{rotate:5deg;translate:0 2px} }
@keyframes treeTopperGlow { from{filter:drop-shadow(0 0 5px #ffe58c)} to{filter:drop-shadow(0 0 19px #ffe58c)} }
@keyframes treeStarDrift { from{transform:translateY(0)} to{transform:translateY(-18px)} }
@media(max-width:760px) {
  #screen-tree .tree-page { padding:14px 11px calc(var(--nav-height,82px) + 28px + env(safe-area-inset-bottom,0px)); }
  .tree-workshop-top { align-items:flex-start;flex-direction:column;gap:10px; }
  .tree-workshop { grid-template-columns:minmax(0,1fr);gap:12px; }
  #screen-tree .tree-scene { height:clamp(430px,58vh,530px);min-height:430px; }
  #screen-tree .holiday-tree { width:min(84%,370px);height:88%; }
  #tree-sidebar.winter-market { position:relative;top:auto;max-height:none;overflow:visible; }
  body.tree-edit-mode #screen-tree .tree-workshop { grid-template-columns:minmax(0,1fr); }
  body.tree-edit-mode #screen-tree .tree-scene { height:calc(100dvh - 210px);min-height:380px; }
  body.tree-edit-mode #tree-sidebar.winter-market { max-height:34dvh;overflow:auto; }
}
@media(max-width:420px) {
  .tree-edit-button,.tree-exit-button { min-height:40px;padding:0 14px;font-size:9px; }
  #tree-sidebar .market-product-art { height:86px; }
  #tree-sidebar .market-product-art img { height:82px; }
  #tree-sidebar .market-product-info { padding:7px; }
  #tree-sidebar .market-buy { padding:7px 6px; }
  .tree-motion-actions { grid-template-columns:1fr; }
  .tree-place-hint { font-size:8px; }
}
@media(prefers-reduced-motion:reduce) {
  #screen-tree .tree-scene.is-entering,.tree-scene-stars,#screen-tree .holiday-tree,#screen-tree .tree-bauble,#screen-tree .tree-topper { animation:none!important;transition:none!important; }
}

/* Match-3 start CTA remains above decorative effects and is always tappable. */
#screen-minigames #match-start { position:relative;z-index:5;pointer-events:auto;touch-action:manipulation; }
#screen-minigames #match-start:disabled { opacity:.72;cursor:wait; }


/* Procedural Three.js tree. If WebGL/CDN is unavailable, the layered CSS tree remains visible. */
#tree-3d-canvas { position:absolute;inset:0;z-index:2;width:100%;height:100%;display:block;pointer-events:none; }
#tree-3d-canvas[hidden] { display:none!important; }
#screen-tree .holiday-tree.has-3d-tree .tree-layer,
#screen-tree .holiday-tree.has-3d-tree .tree-trunk,
#screen-tree .holiday-tree.has-3d-tree .tree-pot,
#screen-tree .holiday-tree.has-3d-tree .tree-garland,
#screen-tree .holiday-tree.has-3d-tree .tree-topper { opacity:0!important;pointer-events:none!important; }
#screen-tree .holiday-tree.has-3d-tree #tree-ornaments { z-index:8; }

/* 3D scene owns snow and ground; leave CSS fallback intact. */
#screen-tree .tree-scene.has-3d-snow .tree-snowbank,
#screen-tree .tree-scene.has-3d-snow #tree-snow-canvas,
#screen-tree .holiday-tree.has-3d-tree .tree-floor-snow,
#screen-tree .holiday-tree.has-3d-tree .tree-layer,
#screen-tree .holiday-tree.has-3d-tree .tree-trunk,
#screen-tree .holiday-tree.has-3d-tree .tree-pot {display:none!important}
#screen-tree .holiday-tree {touch-action:none;user-select:none;-webkit-user-select:none}



/* Patch63: chosen volumetric winter tree skin, kept lightweight for Telegram/Android. */
#screen-tree .holiday-tree {
  width:min(80%,410px);
  height:min(86%,510px);
  max-height:510px;
  background:url("../img/winter-tree-selected.webp") center bottom/contain no-repeat;
  filter:drop-shadow(0 26px 24px rgba(0,0,0,.46));
}
#screen-tree .holiday-tree::before {
  content:"";
  position:absolute;
  inset:0;
  border-radius:28px;
  background:radial-gradient(circle at 50% 84%, rgba(255,239,185,.12), transparent 34%);
  pointer-events:none;
}
#screen-tree .holiday-tree > .tree-topper,
#screen-tree .holiday-tree > .tree-layer,
#screen-tree .holiday-tree > .tree-trunk,
#screen-tree .holiday-tree > .tree-pot,
#screen-tree .holiday-tree > .tree-garland,
#screen-tree .holiday-tree > .tree-floor-snow,
#tree-3d-canvas {
  display:none !important;
}
#screen-tree #tree-ornaments {
  inset:7% 4% 8%;
}
#screen-tree .tree-bauble {
  box-shadow:0 10px 18px rgba(0,0,0,.28), 0 0 0 2px rgba(255,255,255,.08);
}
