:root {
  --coral: #ff6b4a;
  --coral-d: #d9482a;
  --teal: #2fb3a3;
  --teal-d: #1f8c7f;
  --sun: #ffd23f;
  --ink: #2b2233;
  --muted: #7a6f80;
  --paper: #fffaf2;
  --line: #efe3d3;
  --radius: 18px;
  --font: "Segoe UI", Roboto, "Trebuchet MS", Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #fff4e3; color: var(--ink); font-family: var(--font); }
body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#scene, #scene canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--teal-d); }

/* ---- кнопки ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 14px; font-weight: 800;
  background: #fff; box-shadow: 0 3px 0 var(--line); transition: transform .08s; text-decoration: none; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--coral); color: #fff; box-shadow: 0 4px 0 var(--coral-d); }
.btn.primary:active { box-shadow: 0 1px 0 var(--coral-d); }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn.sm svg { width: 17px; height: 17px; }

/* ---- верхняя панель ---- */
.hud-top { position: fixed; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 5; }
.hud-top > * { pointer-events: auto; }
.logo { font-weight: 900; font-size: 22px; padding: 8px 16px; border-radius: 16px; background: var(--coral); color: #fff; box-shadow: 0 4px 0 var(--coral-d); letter-spacing: -.5px; }
.logo span { color: var(--sun); }
.hud-right { display: flex; gap: 8px; }
.hud-btn { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 var(--line); font-weight: 800; }
.hud-btn.cart { background: var(--teal); color: #fff; box-shadow: 0 4px 0 var(--teal-d); position: relative; }
.hud-btn.cart b { position: absolute; top: -8px; left: 26px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--sun); color: var(--ink); font-size: 13px; display: grid; place-items: center; padding: 0 5px; }
.hud-btn.cart b.zero { display: none; }
.hud-btn.bump { animation: bump .45s; }
@keyframes bump { 30% { transform: scale(1.15) rotate(-4deg); } 60% { transform: scale(.95); } }

.hint, .toast { position: fixed; left: 50%; transform: translate(-50%, -12px); max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 14px; background: rgba(43,34,51,.88); color: #fff;
  font-weight: 700; font-size: 15px; text-align: center; opacity: 0; transition: .3s; pointer-events: none; z-index: 6; }
.hint { top: calc(72px + var(--safe-t)); }
.toast { bottom: calc(26px + var(--safe-b)); transform: translate(-50%, 12px); }
.hint.on, .toast.on { opacity: 1; transform: translate(-50%, 0); }

.tooltip { position: fixed; left: 0; top: 0; padding: 8px 12px; border-radius: 12px; background: #fff; box-shadow: 0 6px 20px rgba(60,30,20,.2); pointer-events: none; opacity: 0;
  transition: opacity .15s; z-index: 6; display: flex; flex-direction: column; max-width: 250px; }
.tooltip.on { opacity: 1; }
.tooltip b { font-size: 14px; line-height: 1.2; }
.tooltip span { color: var(--coral); font-weight: 900; font-size: 18px; }

.joy { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255,255,255,.28); border: 3px solid rgba(255,255,255,.7);
  display: none; place-items: center; pointer-events: none; z-index: 4; }
.joy.on { display: grid; }
.joy-knob { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.95); box-shadow: 0 4px 10px rgba(0,0,0,.2); }

.pay-prompt { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); padding: 16px 22px; border-radius: 18px; background: var(--coral); color: #fff;
  font-weight: 900; font-size: 18px; box-shadow: 0 5px 0 var(--coral-d); z-index: 5; animation: pulse 1.4s infinite; white-space: nowrap; }
.pay-prompt[hidden] { display: none; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.05); } }

.fade { position: fixed; inset: 0; background: #fff4e3; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 7; }
.fade.on { opacity: 1; }

/* ---- заставка ---- */
.start { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, #ffd9a8, transparent 60%), radial-gradient(circle at 80% 90%, #9fe3d5, transparent 55%), #fff1dc; transition: opacity .4s; }
.start.gone { opacity: 0; pointer-events: none; }
.start-card { width: min(420px, 100%); background: #fff; border-radius: 28px; padding: 28px 24px 18px; box-shadow: 0 8px 0 var(--line), 0 20px 50px rgba(120,60,20,.15); text-align: center; }
.start-logo { font-size: 44px; font-weight: 900; color: var(--coral); letter-spacing: -1.5px; }
.start-logo span { color: var(--teal); }
.start-lead { margin: 2px 0 16px; font-weight: 700; color: var(--muted); }
.start-help { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; text-align: left; font-size: 15px; }
.start-help li { background: var(--paper); border-radius: 12px; padding: 8px 12px; }
.start-help b { color: var(--coral-d); }
body.touch .only-desk, body:not(.touch) .only-touch { display: none; }
.load { display: grid; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.load[hidden] { display: none; }
.load-track { height: 14px; border-radius: 7px; background: var(--paper); overflow: hidden; border: 2px solid var(--line); }
.load-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--coral), var(--sun)); border-radius: 7px; transition: width .2s; }
.start-note { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
#enter[hidden] { display: none; }

/* ---- карточка товара ---- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(43,34,51,.45); display: grid; place-items: center; padding: 16px; animation: fadeIn .2s; }
.modal[hidden], .drawer[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.card { position: relative; width: min(760px, 100%); max-height: calc(100% - 10px); overflow: auto; background: #fff; border-radius: 26px; display: grid; grid-template-columns: 1fr 1fr;
  box-shadow: 0 8px 0 var(--line), 0 30px 60px rgba(0,0,0,.25); animation: pop .25s; -webkit-user-select: text; user-select: text; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.card-3d { position: relative; background: radial-gradient(circle at 50% 40%, #fff, #fdecd4); min-height: 320px; }
.card-3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.hint3d { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.card-body { padding: 26px 22px 20px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.crumbs { font-size: 13px; font-weight: 700; color: var(--teal-d); text-transform: uppercase; letter-spacing: .5px; }
.meta { color: var(--muted); font-weight: 700; }
.desc { margin: 0; line-height: 1.45; color: #4a4052; }
.buy { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.price { font-size: 30px; font-weight: 900; color: var(--coral); }
.qty { display: flex; align-items: center; gap: 4px; background: var(--paper); border-radius: 14px; padding: 4px; }
.qty button { width: 38px; height: 38px; border-radius: 11px; background: #fff; display: grid; place-items: center; box-shadow: 0 2px 0 var(--line); }
.qty span { min-width: 30px; text-align: center; font-weight: 900; font-size: 18px; }
.qty.sm button { width: 30px; height: 30px; }
.qty.sm svg { width: 16px; height: 16px; }
.qty.sm span { min-width: 22px; font-size: 15px; }
.x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 12px; background: var(--paper); display: grid; place-items: center; z-index: 2; }

/* ---- выдвижная панель ---- */
.drawer { position: fixed; inset: 0; z-index: 20; background: rgba(43,34,51,.4); display: flex; justify-content: flex-end; animation: fadeIn .2s; }
.panel { width: min(440px, 100%); height: 100%; background: var(--paper); display: flex; flex-direction: column; animation: slide .25s; padding-bottom: var(--safe-b); -webkit-user-select: text; user-select: text; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.panel header { position: relative; display: flex; align-items: center; gap: 8px; padding: calc(14px + var(--safe-t)) 64px 12px 18px; }
.panel header h2 { margin: 0; font-size: 24px; }
.panel header .x { top: calc(10px + var(--safe-t)); }
.panel header .x.back { position: static; }
.scroll { flex: 1; overflow: auto; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lines li { display: grid; grid-template-columns: 56px 1fr auto; grid-template-areas: "img name name" "img qty sum"; gap: 4px 10px; align-items: center; background: #fff; border-radius: 16px; padding: 8px 10px; box-shadow: 0 2px 0 var(--line); }
.lines .thumb { grid-area: img; width: 56px; height: 56px; object-fit: contain; }
.lines .ln { grid-area: name; display: flex; flex-direction: column; min-width: 0; }
.lines .ln b { font-size: 15px; line-height: 1.2; }
.lines .ln span { font-size: 13px; color: var(--muted); font-weight: 600; }
.lines .qty { grid-area: qty; justify-self: start; }
.lines .lsum { grid-area: sum; font-weight: 900; }
.results li { grid-template-areas: "img name" "img acts"; grid-template-columns: 56px 1fr; }
.results .acts { grid-area: acts; display: flex; gap: 6px; flex-wrap: wrap; }
.results li.none { display: block; text-align: center; color: var(--muted); box-shadow: none; background: none; }
.free { position: relative; background: #fff; border-radius: 14px; padding: 10px 12px 16px; font-size: 14px; overflow: hidden; }
.free i { position: absolute; left: 0; bottom: 0; height: 6px; background: linear-gradient(90deg, var(--sun), var(--coral)); border-radius: 0 3px 3px 0; }
.free.ok { color: var(--teal-d); font-weight: 800; }
.free.ok i { background: var(--teal); }
.totals { background: #fff; border-radius: 16px; padding: 12px 14px; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; font-weight: 600; }
.totals .grand { font-size: 20px; font-weight: 900; border-top: 2px dashed var(--line); padding-top: 8px; }
.empty, .done { text-align: center; align-items: center; justify-content: center; }
.empty-ico, .done-ico { font-size: 64px; }
.empty p, .done p { color: #4a4052; line-height: 1.45; margin: 0; }

.form label { display: grid; gap: 5px; font-weight: 700; font-size: 14px; }
.form input, .form select, .form textarea { font: inherit; font-weight: 500; padding: 12px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); width: 100%; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--teal); }
.form .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.form .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; line-height: 1.4; }
.form .check input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--coral); }
.note { background: #e3f6f2; color: #16695f; border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.err { background: #ffe3dd; color: #b3261e; border-radius: 12px; padding: 10px 12px; font-weight: 700; }
.err[hidden] { display: none; }

.search-box { padding: 0 16px 8px; }
.search-box input { width: 100%; font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: #fff; }
.search-box input:focus { outline: none; border-color: var(--teal); }
.zones, .cats { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.zones span { font-weight: 800; font-size: 14px; width: 100%; }
.chip { padding: 8px 12px; border-radius: 12px; background: var(--teal); color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 3px 0 var(--teal-d); }
.chip.ghost { background: #fff; color: var(--ink); box-shadow: 0 2px 0 var(--line); }
.chip.ghost.on { background: var(--sun); }

.about p { margin: 0; line-height: 1.5; }
.about h3 { margin: 8px 0 0; }
.help { margin: 0; padding-left: 18px; display: grid; gap: 6px; line-height: 1.4; }
.seller { background: #fff; border-radius: 12px; padding: 10px 12px; }
.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 700px) {
  .logo { font-size: 18px; padding: 8px 12px; }
  .hud-btn { height: 42px; padding: 0 11px; }
  .hud-btn span { display: none; }
  .hud-btn.cart span { display: inline; font-size: 14px; }
  .modal { padding: 0; place-items: end stretch; }
  .card { grid-template-columns: 1fr; border-radius: 26px 26px 0 0; max-height: 92%; width: 100%; animation: up .25s; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
  .card-3d { min-height: 0; height: 36vh; }
  .card-body { padding: 16px 16px calc(16px + var(--safe-b)); }
  .card h2 { font-size: 19px; }
  .panel { width: 100%; }
}
