:root {
  --bg: #0b0908;
  --panel: #15110e;
  --panel2: #1c1612;
  --line: #3a2c20;
  --gold: #c8a45a;
  --gold2: #e6c987;
  --text: #d8cdb8;
  --dim: #8d8170;
  --red: #b3281e;
  --blue: #2f66c4;
  --green: #4c9a52;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Georgia, "Times New Roman", serif; }
body { min-height: 100vh; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--gold); color: var(--gold2); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: #3b2a14; border-color: var(--gold); color: var(--gold2); font-weight: bold; padding: 10px 22px; }
button.primary:hover { background: #503817; }
kbd { font: 11px/1 ui-monospace, Consolas, monospace; background: #0c0a08; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 2px 5px; color: var(--gold2); }

#app { max-width: 1280px; margin: 0 auto; padding: 10px 14px 16px; }
#topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.28em; color: var(--gold); }
.brand .sub { color: var(--dim); font-size: 13px; font-style: italic; }
.topbtns { display: flex; gap: 8px; }
.topbtns button { font-size: 13px; padding: 5px 10px; }

#layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 10px; align-items: start; }
#viewwrap { position: relative; aspect-ratio: 8 / 5; background: #000; border: 3px solid #2b2018; box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #4a3826; overflow: hidden; }
#view { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%); }
#flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(180,0,0,0.0) 30%, rgba(190,10,0,0.55) 100%); opacity: 0; }
#flash.on { animation: flashRed 0.45s ease-out; }
@keyframes flashRed { 0% { opacity: 1; } 100% { opacity: 0; } }
#viewwrap.gas::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(110,210,70,0.16), rgba(40,130,20,0.5)); animation: gasPulse 1.6s ease-in-out infinite; }
@keyframes gasPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
#compass { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 34px; height: 34px; border: 2px solid var(--gold); border-radius: 50%; background: rgba(10,8,6,0.75); color: var(--gold2); text-align: center; line-height: 30px; font-weight: bold; font-size: 17px; }
#banner { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font-size: clamp(14px, 2.2vw, 22px); color: var(--gold2); text-shadow: 0 0 6px #000, 0 0 2px #000; opacity: 0; pointer-events: none; transition: opacity 0.4s; }
#banner.on { opacity: 1; }

#side { display: flex; flex-direction: column; gap: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px; }
.panel h2 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); font-weight: normal; }
#minimap { width: 100%; image-rendering: pixelated; background: #050403; display: block; }
#inventory { display: grid; gap: 4px; font-size: 14px; }
.inv { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 6px; }
.inv b { color: var(--gold2); }
.inv-ico { text-align: center; opacity: 0.9; }
#pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#pad button { font-size: 20px; padding: 8px 0; }
#logpanel { flex: 1; min-height: 120px; }
#log { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.35; max-height: 190px; overflow: hidden; }
#log li { padding: 1px 0; color: var(--text); }
#log li.bad { color: #e07a6c; }
#log li.good { color: #8ad08f; }
#log li.info { color: var(--gold2); }
#log li:nth-child(n+4) { opacity: 0.7; }
#log li:nth-child(n+6) { opacity: 0.45; }

#party { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.hero { display: grid; grid-template-columns: 84px 1fr; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px; position: relative; transition: border-color 0.2s; }
.hero.hurt { animation: shake 0.3s; border-color: var(--red); }
.hero.healed { border-color: var(--green); box-shadow: 0 0 10px rgba(76,154,82,0.5); }
.hero.dead { opacity: 0.55; filter: grayscale(1); }
.hero.poisoned { border-color: #4c9a52; box-shadow: inset 0 0 12px rgba(76,154,82,0.35); }
.hero.poisoned::after { content: "otrávený"; position: absolute; top: 3px; right: 6px; font-size: 10px; color: #8fe08f; letter-spacing: 0.05em; }
.hero.burning { border-color: #e0782a; box-shadow: inset 0 0 12px rgba(224,120,42,0.4); }
.hero.burning::before { content: "horí"; position: absolute; top: 3px; right: 70px; font-size: 10px; color: #ffb36a; letter-spacing: 0.05em; z-index: 1; }
.hero.blinded .portrait img { filter: brightness(0.3) blur(1.5px); }
.hero.blinded .nm small::after { content: " (slepý)"; color: #c9a6ff; }
#lvlname { color: var(--gold2); font-size: 13px; padding-left: 10px; border-left: 1px solid var(--line); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.portrait { position: relative; width: 84px; height: 84px; border: 2px solid #4a3826; border-radius: 3px; overflow: hidden; background: #000; }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait .skull { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 40px; background: rgba(0,0,0,0.6); }
.hero.dead .portrait .skull { display: flex; }
.hero .nm { font-size: 14px; color: var(--gold2); line-height: 1.1; }
.hero .nm small { display: block; color: var(--dim); font-size: 11px; }
.bar { position: relative; height: 13px; background: #090706; border: 1px solid #000; margin-top: 4px; border-radius: 2px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(#d23a2c, #8b1b12); transition: width 0.12s; }
.bar.mp i { background: linear-gradient(#4a85e0, #234c93); }
.bar b { position: absolute; inset: 0; text-align: center; font: 10px/13px ui-monospace, Consolas, monospace; color: #fff; text-shadow: 0 0 2px #000; font-weight: normal; }
.bar.none { visibility: hidden; }
.act { position: relative; width: 100%; margin-top: 5px; padding: 5px 6px; font-size: 13px; text-align: left; overflow: hidden; }
.act .key { display: inline-block; min-width: 16px; text-align: center; margin-right: 6px; color: var(--gold2); font: 11px ui-monospace, Consolas, monospace; background: #0c0a08; border: 1px solid var(--line); border-radius: 3px; padding: 1px 3px; }
.act .cdfill { position: absolute; left: 0; bottom: 0; height: 100%; width: 0; background: rgba(0,0,0,0.55); pointer-events: none; }
.act .cost { float: right; color: #7fa5e6; font-size: 11px; }
#foot { margin-top: 10px; font-size: 12px; color: var(--dim); text-align: center; }

.overlay { position: fixed; inset: 0; background: rgba(5,4,3,0.88); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 20; overflow: auto; }
.overlay.show { display: flex; }
.card { background: var(--panel); border: 1px solid var(--gold); border-radius: 6px; padding: 22px 26px; max-width: 560px; text-align: center; box-shadow: 0 0 40px rgba(0,0,0,0.8); }
.card.big { max-width: 640px; }
.card.wide { max-width: 1180px; width: 100%; max-height: 92vh; overflow: auto; text-align: left; }
.card h1 { margin: 0 0 10px; color: var(--gold); letter-spacing: 0.25em; }
.card .lead { line-height: 1.5; }
.card .goal { color: var(--gold2); }
.card .small { color: var(--dim); font-size: 12px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; text-align: left; margin: 14px 0; font-size: 14px; }
.keys kbd { margin-right: 3px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.bhead { display: flex; align-items: baseline; gap: 14px; position: sticky; top: -22px; background: var(--panel); padding: 4px 0 8px; z-index: 2; }
.bhead h1 { margin: 0; font-size: 20px; }
.bhead button { margin-left: auto; }
#bestiaryBody h2 { margin: 18px 0 8px; font-size: 14px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.bcard { background: radial-gradient(ellipse at 50% 70%, #2a1f17, #120d0a); border: 1px solid var(--line); border-radius: 4px; padding: 8px; }
.bcard .im { height: 170px; display: flex; align-items: flex-end; justify-content: center; }
.bcard img { max-width: 100%; max-height: 100%; display: block; }
.bcard b { display: block; color: var(--gold2); font-size: 14px; margin-top: 6px; }
.bcard span { display: block; color: var(--dim); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.bcard span.note { color: #9ec48c; }
.bcard em { display: block; font-style: normal; color: #6f6354; font-size: 11px; margin-top: 4px; }

@media (max-width: 980px) {
  #layout { grid-template-columns: 1fr; }
  #side { display: grid; grid-template-columns: 1fr 1fr; }
  #logpanel { grid-column: 1 / -1; }
  #party { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  #party { grid-template-columns: 1fr; }
  .keys { grid-template-columns: 1fr; }
}
