/* Hlubina – rozhraní nad plátnem */
:root {
  --bg: #07060a;
  --panel: #1d1611;
  --panel-2: #271d16;
  --wood: #6b4426;
  --wood-hi: #a8743f;
  --text: #f4ead2;
  --muted: #bfae92;
  --gold: #ffd25a;
  --gold-2: #e5a72a;
  --red: #ff6a50;
  --green: #5dff8a;
  --ui: "Barlow", system-ui, sans-serif;
  --head: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--ui);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
img.px { image-rendering: pixelated; image-rendering: crisp-edges; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font: 20px var(--ui); }
[hidden] { display: none !important; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .4em;
  border: 1px solid #8a6a48;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #2e231a;
  color: var(--gold);
  font: 700 .95em/1.3 var(--head);
  text-align: center;
}

/* ------------------------------------------------------------ ukazatele */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-left { position: absolute; top: calc(10px + var(--safe-t)); left: calc(12px + var(--safe-l)); display: grid; gap: 6px; }
.hp { display: flex; gap: 2px; flex-wrap: wrap; max-width: 260px; }
.hp .heart { display: block; width: 24px; height: 24px; }
.hp img { width: 24px; height: 24px; display: block; filter: drop-shadow(0 2px 0 rgba(0,0,0,.55)); }
.hp .off img { filter: grayscale(1) brightness(.35); opacity: .75; }
.lampbar { display: flex; align-items: center; gap: 6px; }
.ico { width: 22px; height: 22px; display: inline-block; background-size: contain; background-repeat: no-repeat; image-rendering: pixelated; flex: none; }
.lampbar .bar { width: 120px; height: 10px; border-radius: 6px; background: rgba(10,8,6,.75); border: 1px solid rgba(255,226,138,.35); overflow: hidden; }
.lampbar .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#fff3b0, #ffc23a); transition: width .3s; }
.lampbar .bar i.mid { background: linear-gradient(#ffd98a, #ff9a2a); }
.lampbar .bar i.low { background: linear-gradient(#ffb0a0, #e8402a); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.steam { display: flex; gap: 4px; margin-left: 4px; }
.steam i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.45); }
.steam i.on { background: #eef6fa; box-shadow: 0 0 6px #fff; }
.hud-right { position: absolute; top: calc(10px + var(--safe-t)); right: calc(12px + var(--safe-r)); display: flex; align-items: flex-start; gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: rgba(16,12,9,.78);
  border: 1px solid rgba(201,146,90,.55);
  font: 700 21px/1 var(--head);
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.pill.full { border-color: var(--red); color: #ffd0c4; }
.pill.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.14); } }
.depth { display: grid; justify-items: end; padding: 2px 4px; text-shadow: 0 2px 0 rgba(0,0,0,.7); }
.depth b { font: 800 26px/1 var(--head); }
.depth small { font: 600 13px/1.2 var(--ui); color: var(--muted); }
.hotbar { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 6px; pointer-events: auto; }
.slot {
  position: relative; width: 50px; height: 50px; padding: 0;
  display: grid; place-items: center;
  border-radius: 10px; border: 2px solid rgba(201,146,90,.5);
  background: rgba(16,12,9,.78); color: var(--text); cursor: pointer;
}
.slot img { width: 32px; height: 32px; }
.slot b { position: absolute; right: 4px; bottom: 1px; font: 700 16px/1 var(--head); text-shadow: 0 1px 0 #000; }
.slot kbd { position: absolute; left: -6px; top: -8px; font-size: 12px; min-width: 1.3em; padding: 0 .25em; }
.slot.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,210,90,.25); }
.slot.empty img { filter: grayscale(1) brightness(.5); }
body.touch .hotbar { display: none; }

/* ------------------------------------------------------------ oznámení, nápověda */
#toasts { position: fixed; top: calc(64px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; z-index: 8; pointer-events: none; width: min(92vw, 560px); }
.toast {
  padding: 8px 16px; border-radius: 10px;
  background: rgba(20,15,11,.92); border: 1px solid rgba(201,146,90,.6);
  font: 500 16px/1.35 var(--ui); text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  animation: tin .25s ease-out;
  transition: opacity .5s, transform .5s;
}
.toast b { color: var(--gold); }
.toast.gold { border-color: var(--gold); }
.toast.warn { border-color: #ff9a5a; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
#hint {
  position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%);
  width: min(92vw, 600px); padding: 11px 16px 12px;
  border-radius: 12px; background: rgba(20,15,11,.9);
  border: 1px solid rgba(201,146,90,.45); border-left: 4px solid var(--gold);
  font: 500 17px/1.45 var(--ui); z-index: 6; pointer-events: none;
  transition: opacity .6s;
}
#hint b { color: var(--gold); }
#hint.out { opacity: 0; }
body.touch #hint { bottom: auto; top: calc(110px + var(--safe-t)); }
@media (max-height: 520px) {
  body.touch #hint { top: calc(8px + var(--safe-t)); width: min(44vw, 420px); font-size: 14px; padding: 8px 12px; }
}

#banner { position: fixed; left: 0; right: 0; top: 24%; display: grid; justify-items: center; gap: 2px; pointer-events: none; z-index: 6; opacity: 0; text-align: center; }
#banner b { font: 800 clamp(40px, 7vw, 76px)/1 var(--head); text-transform: uppercase; color: var(--gold); letter-spacing: .03em; text-shadow: 0 4px 0 #4a2410, 0 0 30px rgba(0,0,0,.8); }
#banner small { font: 700 clamp(15px, 2vw, 20px)/1 var(--head); letter-spacing: .2em; text-transform: uppercase; color: #ffe9b8; text-shadow: 0 2px 0 #000; }
#banner.show { animation: banner 3.6s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translateY(10px); } 12% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------------------------------------ okna */
#modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(5,4,8,.62); padding: 16px; }
.panel {
  width: min(100%, 720px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 18px 20px 20px; border-radius: 16px;
  background: linear-gradient(var(--panel-2), var(--panel));
  border: 3px solid var(--wood);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 1px #000, 0 18px 50px rgba(0,0,0,.6);
  -webkit-user-select: text; user-select: text;
  overscroll-behavior: contain; touch-action: pan-y;
}
.panel h2 { margin: 0; font: 800 34px/1 var(--head); text-transform: uppercase; letter-spacing: .02em; color: var(--gold); text-shadow: 0 2px 0 #4a2410; }
.panel h3 { margin: 0 0 2px; font: 700 21px/1.1 var(--head); }
.panel p { margin: 0; }
.panel button {
  font: 700 19px/1 var(--head); color: var(--text);
  padding: 10px 16px; min-height: 44px;
  border-radius: 10px; border: 2px solid var(--wood); background: #2e231a;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 3px 0 rgba(0,0,0,.45);
}
.panel button img { width: 20px; height: 20px; }
.panel button:hover:not([disabled]) { border-color: var(--wood-hi); }
.panel button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.panel button.primary { background: linear-gradient(#ffe08a, var(--gold-2)); color: #2a1a10; border-color: #ffe9b0; }
.panel button[disabled] { opacity: .45; cursor: default; }
.panel button[aria-disabled="true"] { opacity: .6; }
.panel button.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.shop-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid rgba(201,146,90,.3); }
.shop-head .npc img { width: 60px; height: 78px; display: block; }
.shop-head > div { flex: 1; min-width: 0; }
.npc-line { color: var(--muted); margin-top: 4px !important; }
.wallet { display: flex; align-items: center; gap: 6px; font: 700 22px var(--head); padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.3); border: 1px solid rgba(201,146,90,.45); }
.wallet img { width: 22px; height: 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.note { color: var(--muted); font-size: 15px; margin-top: 10px !important; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
table.sell { width: 100%; border-collapse: collapse; font-size: 17px; }
table.sell th { text-align: left; font: 600 13px var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px; }
table.sell td { padding: 5px 6px; border-top: 1px solid rgba(201,146,90,.18); }
table.sell img { width: 28px; height: 28px; display: block; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.cards { display: grid; gap: 8px; }
@media (min-width: 980px) and (min-height: 560px) {
  .panel.kovarna { width: min(100%, 920px); }
  .kovarna .cards { grid-template-columns: 1fr 1fr; }
}
.card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.22); border: 1px solid rgba(201,146,90,.22); }
.card > img { width: 48px; height: 48px; flex: none; }
.card .txt { flex: 1; min-width: 0; }
.card .txt p { color: var(--muted); font-size: 15px; }
.card .cur { font-size: 13px !important; margin-top: 2px !important; opacity: .85; }
.card button { flex: none; min-width: 112px; }
.card.locked > img { filter: brightness(0) opacity(.5); }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); }
.pips i.on { background: var(--gold); }
.relics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.panel .relic { flex-direction: column; min-height: 96px; padding: 8px 4px; gap: 4px; background: rgba(0,0,0,.25); border-color: rgba(201,146,90,.25); font: 600 13px/1.15 var(--ui); }
.panel .relic img { width: 40px; height: 40px; }
.panel .relic small { font-size: 12.5px; color: var(--muted); text-align: center; }
.panel .relic.have { border-color: var(--gold); }
.panel .relic.have small { color: var(--text); }
.panel .relic.carry { border-color: var(--green); animation: glowp 1.4s infinite; }
@keyframes glowp { 50% { box-shadow: 0 0 0 3px rgba(93,255,138,.25); } }
.relic .q { font: 800 34px/40px var(--head); color: rgba(255,255,255,.18); }
.relic-text { margin-top: 12px !important; min-height: 3em; color: var(--muted); }
.relic-text b { color: var(--text); }
.dests { display: grid; gap: 8px; }
.panel .dest { justify-content: space-between; text-align: left; }
.panel .dest span { font: 500 15px var(--ui); color: var(--muted); }
.panel .dest.off b { opacity: .6; }
.panel.center { text-align: center; width: min(100%, 520px); }
.panel.center .actions { justify-content: center; }
.kicker { font: 700 14px var(--head) !important; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px !important; }
.ability img { width: 80px; height: 80px; margin: 6px auto 8px; display: block; filter: drop-shadow(0 0 18px rgba(255,226,138,.6)); }
.ability p { margin-top: 8px !important; font-size: 17px; }
.ability .how { color: var(--gold); }
.ending p { margin: 10px 0 !important; font-size: 17px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 14px 0 0; }
.stats div { background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font: 700 20px var(--head); }
.panel.small { width: min(100%, 400px); }
.menu { display: grid; gap: 8px; }
.menu h2 { margin-bottom: 6px; }
.menu p { color: var(--muted); margin-bottom: 6px !important; }
.help table { width: 100%; border-collapse: collapse; text-align: left; font-size: 16px; }
.help th { font-weight: 500; color: var(--muted); padding: 6px 4px; border-top: 1px solid rgba(201,146,90,.18); }
.help td { font: 700 18px var(--head); padding: 6px 4px; border-top: 1px solid rgba(201,146,90,.18); text-align: right; }
.panel.mapwin { width: min(100%, 900px); height: calc(100vh - 32px); height: calc(100dvh - 32px); display: flex; flex-direction: column; padding: 14px; }
.map { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.map header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.map header h2 { flex: none; }
.legend { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 14px; color: var(--muted); }
.legend i { display: inline-block; width: 11px; height: 11px; border: 1px solid #000; margin-right: 4px; vertical-align: -1px; }
.legend .lp { background: #fff; } .legend .ls { background: #5dff8a; } .legend .lb { background: #ffb030; } .legend .lr { background: #ffe28a; }
.map-scroll { flex: 1; min-height: 0; overflow: auto; border-radius: 10px; background: #0b0a0e; text-align: center; border: 1px solid rgba(201,146,90,.3); }
.map-scroll canvas { width: min(100%, 512px); image-rendering: pixelated; display: block; margin: 0 auto; }

/* ------------------------------------------------------------ úvodní obrazovka */
#title {
  position: fixed; inset: 0; z-index: 15; display: flex; align-items: center;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
  background: linear-gradient(90deg, rgba(12,8,5,.9) 0%, rgba(12,8,5,.7) 38%, rgba(12,8,5,0) 72%);
}
.title-inner { max-width: 520px; padding-left: clamp(0px, 4vw, 60px); }
#title .kicker { color: var(--muted); }
#title h1 {
  margin: 0; font: 800 clamp(72px, 13vw, 150px)/0.86 var(--head); letter-spacing: .01em; text-transform: uppercase;
  color: var(--gold); text-shadow: 0 5px 0 #7a3f1a, 0 10px 30px rgba(0,0,0,.6);
}
.tagline { margin: 10px 0 0; font: 700 clamp(20px, 2.6vw, 28px)/1.1 var(--head); letter-spacing: .08em; text-transform: uppercase; color: #ffe9b8; }
.intro { margin: 18px 0 0; font-size: 17px; line-height: 1.5; color: #e6dcc6; max-width: 46ch; }
.title-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.title-btns button {
  font: 800 22px/1 var(--head); text-transform: uppercase; letter-spacing: .04em;
  padding: 14px 22px; min-height: 52px; border-radius: 12px; cursor: pointer;
  color: var(--text); background: rgba(46,35,26,.9); border: 2px solid var(--wood); box-shadow: 0 4px 0 rgba(0,0,0,.5);
}
.title-btns button.primary { background: linear-gradient(#ffe08a, var(--gold-2)); color: #2a1a10; border-color: #ffe9b0; }
.title-btns button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.title-note { margin-top: 16px; font-size: 14px; color: var(--muted); }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 30; }
#fade.on { animation: fade .8s ease-out; }
@keyframes fade { 0% { opacity: 1; } 35% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------------------------------------ dotykové ovládání */
#touch { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
body.on-title #touch { display: none; }
#touch button, .t-stick { pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; }
.t-top { position: absolute; top: calc(66px + var(--safe-t)); right: calc(12px + var(--safe-r)); display: flex; gap: 8px; }
.t-small { font: 700 15px var(--head); color: var(--text); padding: 8px 12px; border-radius: 10px; background: rgba(16,12,9,.65); border: 1px solid rgba(201,146,90,.5); }
.t-stick {
  position: absolute; left: calc(18px + var(--safe-l)); bottom: calc(18px + var(--safe-b));
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(rgba(255,255,255,.06), rgba(255,255,255,.12));
  border: 2px solid rgba(255,255,255,.22);
}
.t-knob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%; background: rgba(255,226,138,.35); border: 2px solid rgba(255,226,138,.7); pointer-events: none; }
.t-btns { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: 230px; height: 220px; }
.t-btn {
  position: absolute; border-radius: 50%; display: grid; place-items: center;
  font: 800 17px var(--head); text-transform: uppercase; color: #fff;
  background: rgba(16,12,9,.55); border: 2px solid rgba(255,255,255,.35);
}
.t-btn.on { background: rgba(255,210,90,.45); }
.t-jump { right: 0; bottom: 0; width: 92px; height: 92px; border-color: rgba(255,226,138,.8); }
.t-dig { right: 100px; bottom: 6px; width: 84px; height: 84px; border-color: rgba(255,154,90,.8); }
.t-hook { right: 14px; bottom: 102px; width: 66px; height: 66px; font-size: 14px; }
.t-item-wrap { position: absolute; right: 104px; bottom: 102px; }
.t-item { position: relative; width: 66px; height: 66px; }
.t-item img { width: 32px; height: 32px; }
.t-item b { position: absolute; right: 8px; bottom: 6px; font: 700 15px var(--head); }
.t-next { position: absolute; left: -30px; top: 16px; width: 30px; height: 36px; border-radius: 8px; font: 800 20px var(--head); color: #fff; background: rgba(16,12,9,.55); border: 1px solid rgba(255,255,255,.3); }
.t-act { position: absolute; right: 0; bottom: 186px; padding: 10px 16px; border-radius: 12px; font: 800 18px var(--head); color: #2a1a10; background: linear-gradient(#ffe08a, var(--gold-2)); border: 2px solid #ffe9b0; }

@media (max-width: 700px), (max-height: 520px) {
  .hp img, .hp .heart { width: 20px; height: 20px; }
  .lampbar .bar { width: 90px; }
  .pill { font-size: 18px; padding: 4px 10px 4px 6px; }
  .depth b { font-size: 21px; }
  .depth small { display: none; }
  #toasts { top: calc(56px + var(--safe-t)); }
  .toast { font-size: 14.5px; }
  #hint { font-size: 15px; }
  .panel { padding: 14px; }
  .panel h2 { font-size: 28px; }
  .shop-head .npc img { width: 46px; height: 60px; }
  .relics { grid-template-columns: repeat(3, 1fr); }
  .card { flex-wrap: wrap; }
  .card button { min-width: 0; }
  .t-stick { width: 128px; height: 128px; }
}
@media (max-height: 520px) {
  #title { align-items: flex-start; overflow: auto; }
  #title h1 { font-size: 64px; }
  .intro { font-size: 15px; margin-top: 10px; }
  .title-btns { margin-top: 12px; }
  .title-btns button { padding: 10px 16px; min-height: 44px; font-size: 19px; }
  .t-top { top: calc(56px + var(--safe-t)); }
}
@media (prefers-reduced-motion: reduce) {
  .toast, #fade.on, .pill.bump { animation: none; }
}
