.tabs { display:flex; gap:7px; margin:9px 0 }
.tabs button { background:#27344e; border:1px solid #a798b95e; padding:7px 12px; border-radius:8px }
.tabs button[aria-pressed=true] { border-color:#ffd69b }
#drawing { width:100%; touch-action:none; border:1px solid #867696; border-radius:12px; background:#fff9e8; cursor:crosshair }
#drawing:focus-visible { outline-offset:1px }
.popup{color-scheme:dark;width:min(calc(100vw - 24px),540px);max-height:92dvh;overflow:auto;border:1px solid #9eabc168;border-radius:22px;padding:22px;background:#10233c;color:#f8efd9;box-shadow:0 16px 80px #01071799}.popup::backdrop{background:#020b1bba;backdrop-filter:blur(5px)}.dialog-top{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px}.popup h2{font:500 29px/1.12 var(--display)}.dialog-note{font-size:13px;color:#b9c9de;margin:12px 0;line-height:1.6}.eyebrow{font-size:9px;letter-spacing:.18em;color:#cbb581;margin-bottom:6px}.quiet{background:transparent;border:1px solid #73859e72;border-radius:50%;width:35px;height:35px;font-size:25px;flex:none}.primary{background:#ffe6a7;border:0;border-radius:11px;color:#10223b;font-weight:700;padding:13px 15px;min-height:48px;width:100%}.primary:disabled{opacity:.45}.plain{background:#253c58;border:1px solid #7d94b55c;border-radius:8px;padding:7px 10px;font-size:13px;min-height:38px}.plain:hover{background:#35516e}.plain[aria-pressed=true]{border-color:#ffe69f;color:#ffe69f}.danger{color:#ffb6b3}.qr-popup{text-align:center}.qr-popup a{width:min(100%,360px);margin:0 auto 18px}.qr-popup img{display:block;width:100%;aspect-ratio:1}.kind-picker{border:0;padding:0;margin:0 0 12px;display:grid;grid-template-columns:repeat(4,1fr);gap:6px}.photo-area{display:grid;place-items:center;width:100%;aspect-ratio:560/400;border:1px solid #607791;border-radius:12px;background-color:#193149;background-image:linear-gradient(45deg,#8ba9b01a 25%,transparent 25%),linear-gradient(-45deg,#8ba9b01a 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#8ba9b01a 75%),linear-gradient(-45deg,transparent 75%,#8ba9b01a 75%);background-size:24px 24px;background-position:0 0,0 12px,12px -12px,-12px 0;font-size:14px;color:#b8c8d8}.photo-area canvas{width:100%;height:auto;border-radius:12px;touch-action:none}#photo[data-cropping],#photo[data-outlining]{cursor:crosshair}.edit-tools{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-top:8px}.upload-label{position:relative;display:inline-flex;align-items:center;cursor:pointer}.upload-label input{position:absolute;inset:0;width:100%;opacity:0;cursor:pointer}.upload-label:focus-within{outline:3px solid #ffe69f}.brush-size{display:flex;gap:5px;align-items:center;font-size:12px}.brush-size input{width:75px}.edit-status{font-size:13px;min-height:20px;color:#ffd8a5;margin:12px 0}.report-link{display:block;text-align:center;background:none;border:0;font-size:12px;color:#b1bfd2;padding:8px;margin:8px auto 0;text-decoration:underline;text-underline-offset:3px}.parts-list{display:grid;gap:8px}.parts-list:empty::after{content:'В королевстве пока нет загруженных леденцов';color:#b9c9de}.part-row{display:flex;gap:8px;align-items:center;padding:8px;border:1px solid #566e886b;border-radius:11px;flex-wrap:wrap}.part-row figure{display:grid;place-items:center;width:48px;height:48px;margin:0;background:#1a3450;border-radius:8px}.part-row img{max-width:44px;max-height:44px}.part-title{flex:1;min-width:90px;font-size:13px}.part-row button{font-size:12px}.host-actions{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0}.toast{position:fixed;z-index:10;left:50%;top:46%;transform:translate(-50%,-50%);max-width:calc(100% - 32px);width:max-content;text-align:center;background:#0c2137ed;color:#fff0c4;padding:15px 22px;border:1px solid #dbc88d80;border-radius:15px;box-shadow:0 10px 45px #020a1e;font-weight:600}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

:root {
  color-scheme: dark;
  --display: Georgia, 'Times New Roman', serif;
  --body: 'Segoe UI', Arial, sans-serif;
  --cream: #fff2df;
  --berry: #371927;
  --rose: #ffc0ca;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; background: #241622; color: var(--cream); font: 16px/1.45 var(--body) }
h1,h2,p { margin: 0 }
button,input { font: inherit }
button { cursor: pointer; color: inherit }
button:disabled { cursor: default }
:focus-visible { outline: 3px solid #ffd583; outline-offset: 4px }
.kingdom { min-height: 100svh; display: flex; flex-direction: column }
.masthead,.actions {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding-inline: clamp(12px,3vw,52px); background: var(--berry);
}
.masthead { padding-block: 9px 13px; border-bottom: 1px solid #edada445 }
.brand { color: var(--rose); font-size: 11px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase }
.identity h1 { font: 700 clamp(24px,3.15vw,54px)/1.05 var(--display); letter-spacing: -.035em; text-wrap: balance; margin-top: 3px }
.view-controls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end }
.view-controls button {
  border: 1px solid #efb9a965; border-radius: 20px; background: #552c42; padding: 7px 12px; min-height: 36px; font-size: 12px;
}
#fullscreen { font-size: 19px; padding-block: 1px; min-width: 38px }
.view-controls button[aria-pressed=true] { background: #fff2df; color: #3e1c2c }
.scene { position: relative; flex: 1 1 auto; min-height: clamp(300px,55svh,720px); isolation: isolate; overflow: hidden; container-type: size; background: #7fc3df }
.stage { position: absolute; bottom: 0; left: 50%; translate: -50%; width: var(--stage-width,100%); aspect-ratio: 16/9; container-type: inline-size }
.stage > .backdrop,.stage > canvas,#grove,#sprinkles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none }
.stage > .backdrop { object-fit: fill }
.scene[data-plantable="true"] { cursor: crosshair }
.milestone {
  position: absolute; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 9px; padding: 7px 12px; border-radius: 15px;
  top: clamp(9px,2vw,23px); left: clamp(10px,3vw,50px); background: #fff1ddf2; color: #472338;
  box-shadow: 0 4px 20px #4c2c4366; font-size: 12px; font-weight: 650; pointer-events: none;
}
#tree-count { font-size: 16px; font-weight: 850; font-variant-numeric: tabular-nums }
.pips { display: flex; gap: 4px; flex-basis: 100% }
.pips i { width: 17px; height: 4px; border-radius: 4px; background: #d3a6ab }
.pips .filled { background: #b62c67 }
.celebration .milestone { background: #fff0ba }
.tree { position: absolute; width: var(--size); height: var(--size); transform: translate(-50%, -100%); transform-origin: center bottom }
.tree::before { content: ''; position: absolute; width: 67%; left: 16.5%; bottom: -2%; height: 12%; border-radius: 50%; background: #4b291077; filter: blur(2px) }
.tree img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 2px 2px #41211791); transform-origin: center bottom }
.tree.growing { animation: sprout .85s cubic-bezier(.18,.72,.19,1.12) both }
@keyframes sprout { from { transform: translate(-50%,-100%) scale(.12); opacity: .18 } to { transform: translate(-50%,-100%) scale(1); opacity: 1 } }
.blooms { opacity: 0; transition: opacity .6s; position: absolute; top: 13%; inset-inline: 14%; height: 51% }
.celebration .blooms { opacity: 1 }
.blooms i {
  position: absolute; width: clamp(7px,1.1cqw,18px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, #ffcf48 0 28%, transparent 31%),
   radial-gradient(circle at 50% 23%, #fff1fc 0 28%, transparent 31%), radial-gradient(circle at 77% 50%, #ffaed9 0 27%, transparent 30%),
   radial-gradient(circle at 50% 77%, #fff1fc 0 28%, transparent 31%), radial-gradient(circle at 23% 50%, #ffaed9 0 27%, transparent 30%);
  filter: drop-shadow(0 1px 1px #7d274d8c);
}
.blooms i:nth-child(1) { left: 10%; top: 35% }
.blooms i:nth-child(2) { left: 45%; top: 0 }
.blooms i:nth-child(3) { right: 0; top: 67% }
.rainbow {
  position: absolute; pointer-events: none; inset: 9% 9% auto; height: 58%;
  background: radial-gradient(ellipse at 50% 100%, transparent 59%,#ad91fbba 59% 60.3%,#71ddffcb 60.3% 61.6%,#78f9bdcb 61.6% 62.9%,#fff584dd 62.9% 64.2%,#ffc28dd9 64.2% 65.5%,#fb7caacf 65.5% 66.8%, transparent 67.1%);
  opacity: 0; transition: opacity 1.1s; mask-image: linear-gradient(to bottom,#000 48%,transparent 94%);
}
.celebration .rainbow { opacity: 1 }
#sprinkles { overflow: hidden; z-index: 4 }
#sprinkles i { position: absolute; top: -1%; width: clamp(4px,1cqw,13px); height: clamp(2px,.36cqw,5px); border-radius: 5px; animation: sprinkle-fall var(--fall) var(--delay) linear both; box-shadow: 0 0 3px #fff7 }
@keyframes sprinkle-fall { 0% { transform: translateY(0) rotate(0); opacity: 0 } 12% { opacity: .95 } 94% { opacity: .85 } to { transform: translate(var(--drift),56vw) rotate(610deg); opacity: 0 } }
#arrival {
  position: absolute; bottom: var(--root-y); left: var(--root-x); display: grid; justify-items: center; z-index: 5; pointer-events: none;
  transform: translateX(-50%); transform-origin: bottom center;
  animation: arrive 2.65s ease-in-out both; color: #522235; filter: drop-shadow(0 8px 18px #34182480);
}
#arrival img { width: var(--arrival-size); height: var(--arrival-size); object-fit: contain; object-position: bottom }
#arrival span { position: absolute; top: -24px; white-space: nowrap; padding: 4px 11px; font-size: 13px; font-weight: 800; border-radius: 14px; background: #fff1d3; animation: arrival-label 2.65s both }
@keyframes arrive { 0% { opacity: 0; transform: translate(-50%,-20%) scale(.98) } 12%,42% { opacity: 1; transform: translate(-50%,-13%) scale(1) } 100% { opacity: 1; transform: translate(-50%,0) scale(var(--end-scale)) } }
@keyframes arrival-label { 0%,75%,100% { opacity: 0 } 10%,55% { opacity: 1 } }
.actions { padding-block: 10px; border-top: 1px solid #edada445 }
.plant-actions { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center }
.plant-actions p { flex: 1 1 100%; color: #ffe4d6; font-size: 14px }
.plant-actions .plain { background: #583249; border-color: #efb9a96b; min-height: 34px }
.plant-actions .plain:disabled { opacity: .5 }
.plant-actions .report-link { margin: 0; color: var(--rose) }
.world-upload { display: flex; gap: 11px; align-items: center; flex: none }
.world-upload .qr,.qr-popup a { display: block; background: white; border-radius: 8px; overflow: hidden; flex: none }
.world-upload img { display: block; width: 72px; height: 72px }
.upload-copy p { color: #ffe4d7; font-size: 12px; margin-bottom: 4px }
.upload-copy .primary {
  display: inline-flex; align-items: center; width: auto; padding: 5px 9px; min-height: 32px;
  border-radius: 7px; text-decoration: none; font-size: 13px; margin-right: 4px;
}
#open-qr { background: transparent; border: 0; color: var(--rose); text-decoration: underline; text-underline-offset: 3px; padding: 4px; font-size: 12px }
.calm .tree.growing,.calm #arrival,.calm #arrival span { animation: none }
.calm #arrival { display: none }
.calm .rainbow,.calm .blooms { transition: none }
@media(max-width:650px) and (orientation:portrait) {
  .masthead { align-items: flex-start }
  .brand { font-size: 10px }
  .identity h1 { max-width: 13ch }
  .view-controls { max-width: 115px }
  .view-controls button { padding: 4px 7px }
  .scene { min-height: clamp(244px,51svh,570px) }
  .actions { flex-direction: column; align-items: stretch; gap: 11px }
  .world-upload { border-top: 1px solid #efb9a93b; padding-top: 10px }
  .world-upload img { width: 62px; height: 62px }
  .popup { padding: 15px !important }
}
@media(max-height:550px) and (orientation:landscape) {
  .masthead { padding-block: 4px 6px }
  .identity h1 { font-size: clamp(20px,3vw,34px) }
  .scene { min-height: 61svh }
  .actions { padding-block: 5px }
  .world-upload img { width: 50px; height: 50px }
  .plant-actions p { font-size: 12px }
}
@media (prefers-reduced-motion: reduce) {
  .tree.growing,#arrival,#arrival span,#sprinkles i { animation: none }
  .rainbow,.blooms { transition: none }
}
#grove { z-index: 2 }
.rainbow { z-index: 1 }
@media(max-width:650px) and (orientation:portrait) {
  .kingdom { min-height: 0 }
  .scene { flex: 0 0 auto; height: clamp(244px,43svh,350px); min-height: 0 }
}
@media(min-width:651px), (orientation:landscape) {
  .scene::before {
    content: ''; position: absolute; inset: -22px;
    background: #acbace url('/kingdom.jpg') center 46% / cover no-repeat;
    filter: blur(18px) brightness(.72) saturate(.76);
  }
  .stage { box-shadow: 0 0 25px #44223455 }
}
.milestone { width: max-content; max-width: calc(100% - 20px) }
