/* svet – rozprávkové, teplé rozhranie, ktoré necháva vyniknúť mapu. */
:root {
  --parchment: #fbf3e4;
  --parchment-2: #f3e6cc;
  --parchment-3: #ead9b8;
  --ink: #4a3524;
  --ink-soft: #7a634c;
  --ink-faint: #a08a72;
  --ember: #d9772b;
  --ember-dark: #b45e1c;
  --moss: #5f7f3a;
  --moss-dark: #4a6630;
  --river: #3f7f95;
  --line: rgba(74, 53, 36, 0.14);
  --shadow: 0 10px 30px rgba(50, 32, 14, 0.22), 0 2px 6px rgba(50, 32, 14, 0.12);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7da24b; color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#map.dragging { cursor: grabbing; }
#map.pointer { cursor: pointer; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui > .topbar, #ui > .toast { pointer-events: none; }
.topbar-right { pointer-events: none; }
.topbar-right > * { pointer-events: auto; }
.card { background: rgba(251, 243, 228, 0.94); border: 1px solid rgba(255, 255, 255, 0.6); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(6px); }

/* ---------- horná lišta ---------- */
.topbar { position: absolute; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; min-width: 0; }
.brand-icon { width: 40px; height: 40px; flex: none; border-radius: 12px; background: linear-gradient(160deg, #f0b45e, #d9772b); display: grid; place-items: center; box-shadow: inset 0 -2px 0 rgba(0,0,0,0.12); }
.brand-icon svg { width: 24px; height: 24px; }
.brand h1 { margin: 0; font: 700 19px/1.1 var(--serif); letter-spacing: 0.2px; }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal { display: flex; align-items: center; gap: 8px; margin-top: 5px; border: 0; background: none; padding: 0; cursor: pointer; font-size: 11.5px; font-weight: 650; color: var(--ink-soft); max-width: 100%; }
.goal-bar { width: 84px; height: 7px; border-radius: 4px; background: var(--parchment-3); overflow: hidden; flex: none; }
.goal-bar span { display: block; height: 100%; background: linear-gradient(90deg, #e8a53a, var(--ember)); border-radius: 4px; transition: width .6s ease; }
#goal-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 12px; border-radius: 6px; background: var(--parchment-3); overflow: hidden; margin: 8px 0 4px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #e8a53a, var(--ember)); }
.chip.founder { background: linear-gradient(180deg, #d9e8b0, #b9d27e); color: #34481c; }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.resources { display: flex; gap: 4px; padding: 6px; }
.res { display: flex; align-items: center; gap: 5px; padding: 4px 9px 4px 6px; border-radius: 12px; background: rgba(255,255,255,0.55); font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14px; }
.res svg { width: 20px; height: 20px; }
.demo-badge { background: #f4c95d; color: #5a3d12; font: 700 11.5px/1 var(--sans); letter-spacing: 0.6px; padding: 7px 11px; border-radius: 999px; box-shadow: var(--shadow); text-transform: uppercase; }

/* ---------- ovládanie mapy ---------- */
.map-controls { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; }
.ctl { width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(251,243,228,0.94); box-shadow: var(--shadow); font-size: 22px; font-weight: 600; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.ctl:hover { background: #fff8ea; }
.ctl:focus-visible, .act:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(217,119,43,0.6); outline-offset: 2px; }
.ctl svg { width: 22px; height: 22px; }

/* ---------- uvítanie ---------- */
.welcome { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); width: min(440px, calc(100% - 24px)); padding: 14px 40px 14px 16px; font-size: 14px; }
.welcome p { margin: 0; color: var(--ink-soft); }
.welcome .welcome-title { font: 700 17px/1.2 var(--serif); color: var(--ink); margin-bottom: 4px; }

/* ---------- hlavné akcie ---------- */
.actionbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--safe-b)); display: flex; gap: 10px; padding: 8px; border-radius: 26px; background: rgba(251,243,228,0.9); box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.act { display: flex; align-items: center; gap: 8px; border: 0; border-radius: 18px; padding: 12px 18px; background: var(--parchment-2); font-weight: 650; cursor: pointer; white-space: nowrap; transition: transform .12s ease, background .12s ease; }
.act:hover { background: var(--parchment-3); }
.act:active { transform: scale(0.97); }
.act .i svg { width: 20px; height: 20px; display: block; }
.act.primary { background: linear-gradient(180deg, #e58a3c, var(--ember)); color: #fffaf0; box-shadow: 0 4px 12px rgba(217,119,43,0.35); }
.act.primary:hover { background: linear-gradient(180deg, #ea944a, var(--ember-dark)); }

/* ---------- panel ---------- */
.sheet { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; bottom: 12px; width: min(420px, calc(100% - 24px)); background: var(--parchment); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: slideIn .22s ease; }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { display: none; }
.sheet-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.close { width: 36px; height: 36px; border-radius: 12px; border: 0; background: rgba(74,53,36,0.07); font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-soft); position: absolute; top: 8px; right: 8px; }
.close:hover { background: rgba(74,53,36,0.13); }
.sheet-body { overflow-y: auto; padding: 20px 20px calc(24px + var(--safe-b)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet h2 { font: 700 23px/1.15 var(--serif); margin: 0 44px 6px 0; }
.sheet h3 { font: 700 16px/1.25 var(--serif); margin: 22px 0 8px; }
.sheet p { margin: 0 0 10px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-faint); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 650; cursor: pointer; background: var(--parchment-2); color: var(--ink); text-decoration: none; min-height: 44px; }
.btn:hover { background: var(--parchment-3); }
.btn.primary { background: var(--ember); color: #fffaf0; }
.btn.primary:hover { background: var(--ember-dark); }
.btn.moss { background: var(--moss); color: #f7f3e6; }
.btn.moss:hover { background: var(--moss-dark); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.box { background: #fffaf0; border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 0; }
.box.ember { background: linear-gradient(160deg, #fff3df, #fde6c8); border-color: rgba(217,119,43,0.25); }
.box.moss { background: linear-gradient(160deg, #f1f4e2, #e3ebc9); border-color: rgba(95,127,58,0.25); }
.box.demo { background: #fff5d6; border: 1.5px dashed #e1b44a; }
.label { font: 700 11.5px/1 var(--sans); letter-spacing: 0.7px; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; display: block; }
.question { font: 700 19px/1.3 var(--serif); margin: 2px 0 8px; }
.deadline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 650; color: var(--ember-dark); font-size: 14px; }
.deadline svg, .chip svg, .label svg { width: 16px; height: 16px; flex: none; }
.sheet svg { max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--parchment-2); font-size: 13px; font-weight: 600; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.title { background: linear-gradient(180deg, #f8d58a, #eebb57); color: #5a3d12; }
.chip.demo { background: #f4c95d; color: #5a3d12; }

input[type=text], input[type=search], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fffaf0; border: 1.5px solid var(--line); border-radius: 14px; padding: 11px 13px; min-height: 46px;
}
textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.search-field { position: relative; }
.search-field input { padding-left: 38px; font-size: 16px; }
.search-field .at { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-weight: 700; }

.list { list-style: none; margin: 8px 0; padding: 0; }
.list li { margin: 0; }
.list button.item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 14px; background: transparent; text-align: left; cursor: pointer; }
.list button.item:hover { background: rgba(74,53,36,0.06); }
.item canvas { width: 44px; height: 44px; flex: none; }
.item .name { font-weight: 700; }
.item .sub { font-size: 12.5px; color: var(--ink-soft); }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 10px 0; }
.steps li { position: relative; padding: 2px 0 14px 44px; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--ember); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.steps li strong { display: block; font-family: var(--serif); font-size: 16px; }

.tabs { display: flex; gap: 4px; background: var(--parchment-2); border-radius: 14px; padding: 4px; margin: 10px 0 6px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 9px 6px; font-weight: 650; cursor: pointer; color: var(--ink-soft); min-height: 40px; }
.tabs button[aria-selected=true] { background: #fffaf0; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.res-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.res-row .res { justify-content: center; background: #fffaf0; border: 1px solid var(--line); padding: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.stat { background: #fffaf0; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font: 700 22px/1.1 var(--serif); }
.stat span { font-size: 12.5px; color: var(--ink-soft); }

.winner { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px dashed var(--line); }
.winner:first-of-type { border-top: 0; }
.winner .likes { margin-left: auto; font-weight: 700; color: #c0533a; white-space: nowrap; font-variant-numeric: tabular-nums; }
.winner .who { font-weight: 700; background: none; border: 0; padding: 0; cursor: pointer; color: var(--river); text-decoration: underline; text-underline-offset: 2px; }

.chron-day { font: 700 13px/1 var(--sans); letter-spacing: .6px; text-transform: uppercase; color: var(--ink-faint); margin: 18px 0 6px; }
.chron { display: flex; gap: 10px; padding: 8px 0; }
.chron .ico { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--parchment-2); }
.chron .ico svg { width: 18px; height: 18px; }
.chron .t { font-weight: 700; }
.chron .b { font-size: 13.5px; color: var(--ink-soft); }
.chron.retracted .t, .chron.retracted .b { text-decoration: line-through; opacity: .55; }
.chron button.link { background: none; border: 0; padding: 0; color: var(--river); cursor: pointer; font-size: 13px; text-decoration: underline; }

.res-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.res-head canvas { width: 96px; height: 96px; flex: none; background: radial-gradient(circle at 50% 70%, #cfe0a0, #a7c768 70%); border-radius: 22px; }
.res-head h2 { margin: 0; word-break: break-word; }
.res-num { font-size: 13px; color: var(--ink-faint); font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 6px 0; border-left: 2px solid var(--parchment-3); }
.timeline li { padding: 4px 0 10px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--ember); border: 2px solid var(--parchment); }

.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.styles button { border: 2px solid transparent; border-radius: 14px; background: #fffaf0; padding: 4px; cursor: pointer; }
.styles button[aria-pressed=true] { border-color: var(--ember); }
.styles canvas { width: 100%; aspect-ratio: 1; display: block; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--ember); }
.code { font: 800 26px/1 ui-monospace, Consolas, monospace; letter-spacing: 2px; background: #fffaf0; border: 2px dashed var(--ember); border-radius: 14px; padding: 14px; text-align: center; margin: 10px 0; user-select: all; }
.share-preview { width: 100%; border-radius: 16px; box-shadow: var(--shadow); margin: 8px 0; display: block; }

.toast { position: absolute; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #3d2c1e; color: #fdf4e3; padding: 11px 18px; border-radius: 14px; font-weight: 600; opacity: 0; transition: all .25s ease; pointer-events: none; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.empty { text-align: center; padding: 16px 8px; color: var(--ink-soft); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--parchment-3); border-top-color: var(--ember); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
a { color: var(--river); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mobil ---------- */
@media (max-width: 720px) {
  .topbar { left: 8px; right: 8px; top: calc(8px + var(--safe-t)); flex-direction: column; align-items: stretch; gap: 6px; }
  .topbar-right { flex-direction: row-reverse; justify-content: space-between; align-items: center; }
  .brand { padding: 6px 12px 6px 6px; }
  .brand-icon { width: 34px; height: 34px; border-radius: 10px; }
  .brand h1 { font-size: 17px; }
  .goal-bar { width: 64px; }
  .resources { padding: 4px; }
  .res { padding: 3px 7px 3px 4px; font-size: 13px; }
  .res svg { width: 17px; height: 17px; }
  .demo-badge { font-size: 10.5px; padding: 6px 9px; white-space: nowrap; }
  .demo-badge .long { display: none; }
  .map-controls { top: auto; bottom: calc(150px + var(--safe-b)); transform: none; right: 8px; }
  .ctl { width: 42px; height: 42px; }
  .actionbar { left: 8px; right: 8px; transform: none; bottom: calc(8px + var(--safe-b)); display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; border-radius: 22px; }
  .act { justify-content: center; padding: 12px 8px; font-size: 14px; }
  .act.primary { grid-column: 1 / -1; order: -1; }
  .welcome { bottom: auto; top: calc(132px + var(--safe-t)); padding: 12px 40px 12px 14px; font-size: 13.5px; }
  .sheet.compact { max-height: 62vh; max-height: 62dvh; }
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 82vh; max-height: 82dvh; border-radius: 24px 24px 0 0; animation: slideUp .24s ease; }
  @keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-handle { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--parchment-3); margin: 8px auto 0; flex: none; }
  .sheet-body { padding: 10px 16px calc(20px + var(--safe-b)); }
  .sheet h2 { font-size: 21px; }
  .toast { bottom: calc(150px + var(--safe-b)); }
  body.sheet-open .actionbar, body.sheet-open .map-controls, body.sheet-open .welcome { display: none; }
}
@media (max-width: 360px) {
  .act { font-size: 13px; }
  .res span.lbl { display: none; }
}

/* ---------- režim nahrávania 9:16 ---------- */
body.record #ui { display: none; }
body.record { background: #111; }
body.record #map { cursor: default; }
.record-frame { position: fixed; pointer-events: none; }
.record-guides { position: absolute; inset: 0; }
.record-guides::before, .record-guides::after { content: ""; position: absolute; left: 0; right: 0; background: rgba(255,0,80,0.18); border: 1px dashed rgba(255,0,80,0.6); }
.record-guides::before { top: 0; height: 14%; }
.record-guides::after { bottom: 0; height: 22%; }
.record-caption { position: absolute; left: 6%; right: 6%; bottom: 26%; background: rgba(251,243,228,0.92); color: var(--ink); border-radius: 18px; padding: 14px 18px; font: 700 clamp(16px, 3.4vh, 30px)/1.25 var(--serif); text-align: center; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .toast { animation: none; transition: none; }
}
.note { background: #fbeccb; border-radius: 12px; padding: 10px 12px; color: var(--ink); }
.ctl.only3d { display: none; font-size: 20px; }
body.map3d .ctl.only3d { display: grid; }
.map-overlay { z-index: 0; }
