:root {
  --brand: #2f5d50;
  --brand-2: #3f7a69;
  --brand-ink: #ffffff;
  --gold: #ffd54a;
  --ink: #1f1d1a;
  --muted: #6d6860;
  --card: #ffffff;
  --bg: #f6f4f0;
  --line: #e3dfd7;
  --sale: #c0392b;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --card: #22201d; --bg: #171614; --ink: #ece8e1; --muted: #a39d93; --line: #3a3732; --sale: #ff7b6e; color-scheme: dark; }
}
:root[data-theme="dark"] { --card: #22201d; --bg: #171614; --ink: #ece8e1; --muted: #a39d93; --line: #3a3732; --sale: #ff7b6e; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3f5; overscroll-behavior: none; }
body { color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: none; }
input { -webkit-user-select: text; user-select: text; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; touch-action: none; }
[hidden] { display: none !important; }

.btn { font: inherit; font-weight: 650; border: 0; border-radius: 999px; padding: 11px 18px; cursor: pointer; transition: transform .08s, filter .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 18px rgba(47, 93, 80, .35); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.gold { background: var(--gold); color: #1f1d1a; }
.btn.ghost { background: rgba(255,255,255,.92); color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.btn.big { padding: 15px 24px; font-size: 1.05rem; }
.btn.block { width: 100%; display: block; text-align: center; text-decoration: none; }

/* ---------- Intro ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 30; }
#intro { background: radial-gradient(circle at 50% 20%, rgba(47,93,80,.55), rgba(20,35,30,.85)); }
.intro-card { width: min(420px, 100%); background: var(--card); color: var(--ink); border-radius: 24px; padding: 26px 22px 20px; box-shadow: 0 30px 80px rgba(0,0,0,.35); max-height: calc(100dvh - 32px); overflow: auto; }
.logo { font-weight: 900; font-size: 2.3rem; letter-spacing: .04em; color: #fff; background: var(--brand); border-radius: 14px; text-align: center; padding: 10px 0 8px; }
.tagline { text-align: center; color: var(--muted); margin: 10px 0 16px; }
.steps { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.steps li { color: var(--ink); display: flex; gap: 10px; align-items: center; background: var(--bg); border-radius: 12px; padding: 9px 12px; font-size: .93rem; }
.steps span { font-size: 1.2rem; }
.field { display: grid; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.field input { font: inherit; font-size: 1rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.swatches button[aria-pressed="true"] { border-color: var(--ink); }
#startBtn { width: 100%; margin-top: 4px; }
.controls-hint { font-size: .8rem; color: var(--muted); text-align: center; margin: 12px 0 0; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: none; }
.hud-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; }
#minimap { width: 120px; height: 120px; border-radius: 14px; background: rgba(255,255,255,.85); box-shadow: 0 4px 16px rgba(0,0,0,.18); pointer-events: auto; }
@media (min-width: 700px) { #minimap { width: 150px; height: 150px; } }
.hud-right { display: flex; gap: 8px; pointer-events: auto; }
.pill { font: inherit; display: inline-flex; align-items: center; gap: 6px; border: 0; background: rgba(255,255,255,.95); color: #1f1d1a; border-radius: 999px; padding: 9px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.18); cursor: pointer; pointer-events: auto; }
.pill.icon { padding: 9px 11px; }
.pill .muted { color: #6d6860; font-size: .9em; }
.pill.bump { animation: bump .45s; }
@keyframes bump { 30% { transform: scale(1.18); } }
.hint { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 64px); left: 50%; transform: translateX(-50%); background: rgba(20,30,27,.78); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: .95rem; text-align: center; max-width: calc(100% - 32px); opacity: 0; transition: opacity .25s; }
@media (min-width: 700px) { .hint { top: 18px; } }
.hint.show { opacity: 1; }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom)); padding: 0 16px; display: flex; justify-content: space-between; align-items: flex-end; }
.actions { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: auto; }
.actions .btn { pointer-events: auto; }
#actionBtn { animation: pop .25s; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
.joystick { width: 128px; height: 128px; border-radius: 50%; background: rgba(255,255,255,.28); border: 2px solid rgba(255,255,255,.6); position: relative; pointer-events: auto; touch-action: none; }
.joystick .knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: 0 4px 12px rgba(0,0,0,.25); }

/* ---------- Sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.25); }
.sheet .sheet-card { background: var(--card); color: var(--ink); width: min(760px, 100%); max-height: min(78dvh, 720px); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .25s ease-out; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 800px) {
  .sheet { align-items: center; }
  .sheet .sheet-card { border-radius: 22px; }
  .sheet.right { justify-content: flex-end; padding: 16px; }
  .sheet.right .sheet-card { width: 400px; max-height: calc(100dvh - 32px); height: 100%; }
}
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 2px 0 0; font-size: 1.2rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.close, .back { font: inherit; border: 0; background: var(--bg); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; flex: none; font-size: 1rem; }
.close.floating { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; background: rgba(255,255,255,.9); color: #1f1d1a; }
.sheet-body { overflow: auto; padding: 14px 16px 22px; -webkit-overflow-scrolling: touch; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pcard { font: inherit; text-align: left; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.pcard:hover { border-color: var(--brand-2); }
.pcard .img { aspect-ratio: 1; background: #ddd center/cover no-repeat; position: relative; }
.pcard .meta { padding: 8px 10px 10px; display: grid; gap: 4px; }
.pcard .t { font-size: .86rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-weight: 800; }
.price s { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: .85em; }
.badge { position: absolute; top: 8px; left: 8px; font-size: .7rem; font-weight: 800; padding: 3px 7px; border-radius: 999px; background: #fff; color: #1f1d1a; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.badge.nou { background: var(--brand); color: #fff; }
.badge.in-cart { left: auto; right: 8px; background: var(--gold); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.detail { display: grid; gap: 16px; }
@media (min-width: 700px) { .detail { grid-template-columns: 1fr 1fr; } }
.gallery { position: relative; border-radius: 14px; overflow: hidden; background: #ddd; aspect-ratio: 1; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.9); cursor: pointer; font-size: 1rem; color: #1f1d1a; }
.gallery .prev { left: 8px; } .gallery .next { right: 8px; }
.gallery .dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
.gallery .dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.55); }
.gallery .dots i.on { background: #fff; }
.info h3 { margin: 0 0 6px; font-size: 1.1rem; line-height: 1.3; }
.info .vendor { color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.info .price { font-size: 1.35rem; margin: 8px 0 12px; }
.opt { margin-bottom: 12px; }
.opt .lbl { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 7px 12px; cursor: pointer; min-width: 44px; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip:disabled { opacity: .35; text-decoration: line-through; cursor: default; }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.qty button { font: inherit; border: 0; background: var(--bg); color: var(--ink); width: 38px; height: 38px; cursor: pointer; font-size: 1.1rem; }
.qty span { min-width: 36px; text-align: center; font-weight: 700; }
.stock { font-size: .82rem; color: var(--muted); margin: 6px 0 12px; }
.desc { font-size: .9rem; line-height: 1.5; color: var(--ink); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; -webkit-user-select: text; user-select: text; }
.desc h2, .desc h3, .desc h4 { font-size: .95rem; margin: 12px 0 4px; }
.desc ul { padding-left: 18px; margin: 4px 0; }

.cart-line { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line img { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; background: #ddd; }
.cart-line .t { font-size: .88rem; line-height: 1.25; }
.cart-line .v { font-size: .78rem; color: var(--muted); }
.cart-line .rm { font: inherit; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .8rem; padding: 4px 0 0; text-decoration: underline; }
.cart-line .qty button { width: 30px; height: 30px; }
.cart-sum { display: flex; justify-content: space-between; font-size: 1.1rem; font-weight: 800; padding: 14px 0 6px; }
.cart-note { font-size: .85rem; color: var(--muted); margin: 4px 0 14px; }
.linkish { font: inherit; background: none; border: 0; color: var(--brand-2); text-decoration: underline; cursor: pointer; padding: 10px 0 0; width: 100%; font-size: .88rem; }

/* ---------- Casa de marcat ---------- */
.dim { background: rgba(10,16,14,.6); z-index: 25; }
.register { position: relative; display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; max-height: 100%; overflow: auto; padding: 50px 0 10px; }
.receipt { width: min(330px, 100%); background: #fffdf7; color: #222; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .84rem; padding: 16px 16px 20px; border-radius: 4px; box-shadow: 0 20px 50px rgba(0,0,0,.35); position: relative; mask: linear-gradient(#000 0 0) top/100% calc(100% - 10px) no-repeat, radial-gradient(circle 6px at 50% 100%, #0000 98%, #000) bottom/14px 10px repeat-x; }
.r-head { display: flex; justify-content: space-between; border-bottom: 1px dashed #aaa; padding-bottom: 8px; margin-bottom: 8px; }
.scanbar { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-bottom: 10px; position: relative; }
.scanbar .laser { position: absolute; top: 0; bottom: 0; width: 30%; background: linear-gradient(90deg, transparent, #ff3b3b, transparent); animation: laser 0.9s linear infinite; }
.scanbar.done .laser { display: none; }
.scanbar.done { background: #53c28b; }
@keyframes laser { from { left: -30%; } to { left: 100%; } }
#rLines { list-style: none; margin: 0; padding: 0; min-height: 40px; }
#rLines li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; animation: line .25s; }
#rLines li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#rLines li span:last-child { white-space: nowrap; flex: none; }
@keyframes line { from { background: #fff3a8; } }
.r-total { display: flex; justify-content: space-between; border-top: 1px dashed #aaa; margin-top: 10px; padding-top: 10px; font-size: 1.05rem; }
.r-note { color: #666; margin: 10px 0 0; text-align: center; }

.terminal { width: min(300px, 100%); background: #22272b; border-radius: 26px; padding: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.45); animation: pop .3s; }
.t-screen { background: #f4f7f6; color: #1f1d1a; border-radius: 14px; padding: 16px 14px; min-height: 290px; display: flex; flex-direction: column; }
.t-amount { font-size: 1.6rem; font-weight: 900; text-align: center; margin-bottom: 4px; }
#tStep { flex: 1; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
#tStep .sub { text-align: center; color: #555; font-size: .88rem; margin: 0; }
.payopt { font: inherit; display: flex; align-items: center; gap: 12px; text-align: left; border: 1.5px solid #d9dedc; background: #fff; color: #1f1d1a; border-radius: 12px; padding: 11px 12px; cursor: pointer; }
.payopt:hover { border-color: var(--brand); }
.payopt b { display: block; font-size: .95rem; }
.payopt small { color: #666; }
.payopt .i { font-size: 1.5rem; width: 34px; text-align: center; }
.tap { width: 92px; height: 92px; margin: 6px auto; border-radius: 50%; display: grid; place-items: center; font-size: 2.6rem; background: #e8f3ef; position: relative; }
.tap::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--brand); opacity: 0; animation: ring 1.4s infinite; }
@keyframes ring { 0% { transform: scale(.8); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.secure { font-size: .76rem; color: #666; text-align: center; margin: 0; }
.t-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.t-keys span { height: 18px; border-radius: 6px; background: #3a4146; }

.toast { position: fixed; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 150px); transform: translate(-50%, 20px); background: #1f1d1a; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: .95rem; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 40; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fade { position: fixed; inset: 0; background: #0d1512; opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 35; }
.fade.on { opacity: 1; }

/* Pe telefon: joystick-ul în dreapta, butoanele de acțiune în stânga */
body.touch .hud-bottom { flex-direction: row-reverse; }
body.touch .actions { margin-left: 0; margin-right: auto; align-items: flex-start; max-width: calc(100% - 150px); }
body.touch .actions .btn { text-align: left; }
