:root {
  --ink: #3b2418;
  --ink2: #7a5440;
  --paper: #fbf1e1;
  --paper2: #f1dfc3;
  --sage: #8fbf7f;
  --sage2: #5f8f58;
  --rose: #e07f74;
  --honey: #f2c46d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1a12; }
body {
  font-family: 'Pixelify Sans', 'Courier New', monospace;
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  -webkit-font-smoothing: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
img.px { image-rendering: pixelated; vertical-align: middle; width: 20px; height: 20px; }

#gl {
  position: fixed; inset: 0; width: 100vw; height: 100vh; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
#gl.grab { cursor: grab; }
#gl.grabbing { cursor: grabbing; }
#gl.point { cursor: pointer; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 30; pointer-events: none;
  display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
}
.hud-l, .hud-r { display: flex; gap: 12px; align-items: center; pointer-events: auto; }
.htitle {
  position: absolute; left: 50%; transform: translateX(-50%); top: 12px;
  font-weight: 700; font-size: 24px; color: #fff4dc; letter-spacing: 2px; white-space: nowrap;
  text-shadow: 3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink), 3px 3px var(--ink), 3px 6px rgba(0,0,0,.3);
}
.pill {
  background: var(--paper); padding: 3px 10px; font-weight: 600; font-size: 18px; line-height: 22px;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 6px 0 rgba(0,0,0,.3);
  display: inline-flex; align-items: center; gap: 5px;
}
.pill.coins { background: #ffe9a8; }
.pill.bump { animation: bump .3s steps(3); }
@keyframes bump { 50% { transform: translateY(-6px); } }
.ibtn {
  width: 34px; height: 30px; border: 0; background: var(--paper); font-size: 16px; line-height: 1; padding: 0;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 6px 0 rgba(0,0,0,.3);
}
.ibtn:hover { background: #ffe9a8; }
.ibtn.off { opacity: .45; text-decoration: line-through; }

#bBook {
  position: fixed; right: 18px; bottom: 18px; z-index: 30; border: 0;
  background: #ffe9a8; font-size: 20px; font-weight: 700; padding: 8px 16px; letter-spacing: 1px;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 7px 0 rgba(0,0,0,.35);
  display: flex; align-items: center; gap: 8px;
}
#bBook img { width: 32px; height: 32px; image-rendering: pixelated; }
#bBook:hover { background: #fff2c4; }
#bBook:active { transform: translateY(3px); }

/* ---------- popisky stanovišť ---------- */
#labels, #bubbles, #fx { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#bubbles { z-index: 12; }
#fx { z-index: 50; }
.lab {
  position: absolute; transform: translate(-50%, -100%); text-align: center; white-space: nowrap;
  font-size: 13px; font-weight: 600; letter-spacing: 1px;
}
.lab .nm { color: #fff4dc; text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink); }
.lab .st { display: block; margin-top: 4px; }
.lab .st:empty { display: none; }
.lab .pips { display: inline-flex; gap: 4px; }
.lab .pips i { width: 9px; height: 9px; background: #6b5246; box-shadow: 0 0 0 2px var(--ink); }
.lab .pips i.on { background: #9cdf8a; }
.lab .hint { display: block; font-size: 12px; color: #fff4dc; text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink); margin-top: 5px; }
.lab .bar { display: inline-block; width: 70px; height: 9px; background: #6b5246; box-shadow: 0 0 0 2px var(--ink); vertical-align: middle; }
.lab .bar i { display: block; height: 100%; width: 0; background: #9cdf8a; }
.lab.done .bar i { background: var(--honey); }
.lab.burnt .bar i { background: #b0745a; }
.lab .cnt { display: inline-block; margin-left: 6px; background: var(--ink); color: #fff4dc; padding: 0 5px; font-size: 13px; }
.lab .flip {
  display: none; margin-top: 5px; background: var(--rose); color: #fff; font-size: 18px; font-weight: 700; padding: 2px 10px;
  box-shadow: 0 0 0 3px var(--ink); animation: blink .35s steps(2) infinite;
}
.lab.flipwin .flip { display: inline-block; }
@keyframes blink { 50% { transform: scale(1.15); } }
.lab.done:not(.burnt) .nm { display: inline-block; animation: labhop .7s steps(2) infinite; }
@keyframes labhop { 50% { transform: translateY(-4px); } }
.newtag { animation: taghop .9s steps(2) infinite; }
@keyframes taghop { 50% { transform: translate(-50%, calc(-100% - 4px)); } }
.newtag { position: absolute; transform: translate(-50%, -100%); background: var(--rose); color: #fff; font-size: 10px; font-weight: 700; padding: 0 4px; box-shadow: 0 0 0 2px var(--ink); }

/* ---------- bubliny hostů ---------- */
.bub {
  position: absolute; transform: translate(0, -100%); min-width: 116px; max-width: 160px; padding: 6px 8px 8px;
  background: #fffaf0; text-align: center; pointer-events: auto; cursor: help;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 7px 0 rgba(0,0,0,.3);
}
.bub::after { content: ''; position: absolute; left: -12px; bottom: 6px; width: 12px; height: 9px; background: #fffaf0; box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink); }
.bub .say { font-size: 11px; color: var(--ink2); line-height: 1.15; }
.bub img { width: 48px; height: 48px; image-rendering: pixelated; display: block; margin: 2px auto; }
.bub .dn { font-size: 13px; font-weight: 700; }
.bub.thanks { cursor: default; font-size: 14px; font-weight: 700; padding: 8px 10px; }
.bub.hidden, .gname.hidden { display: none; }
.gname { position: absolute; transform: translate(-50%, 0); font-size: 12px; font-weight: 600; color: #fff4dc; white-space: nowrap;
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink); }

/* ---------- nápovědy ---------- */
#tipbox {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 40; max-width: min(640px, 70vw);
  background: #fffaf0; padding: 8px 16px; font-size: 16px; text-align: center; pointer-events: none;
  box-shadow: 0 -3px 0 var(--sage2), 0 3px 0 var(--sage2), -3px 0 0 var(--sage2), 3px 0 0 var(--sage2), 0 7px 0 rgba(0,0,0,.3);
  opacity: 0; transition: opacity .3s steps(3);
}
#tipbox { transition: opacity .3s steps(3), transform .3s steps(3); transform: translate(-50%, 14px); }
#tipbox.show { opacity: 1; transform: translate(-50%, 0); }
#tipbox.warn { box-shadow: 0 -3px 0 var(--rose), 0 3px 0 var(--rose), -3px 0 0 var(--rose), 3px 0 0 var(--rose), 0 7px 0 rgba(0,0,0,.3); }
#hover {
  position: fixed; z-index: 45; pointer-events: none; display: none; background: var(--ink); color: #fff4dc;
  padding: 3px 8px; font-size: 14px; white-space: nowrap;
}
#hover .q { color: var(--honey); margin-left: 4px; }
#rtip {
  position: fixed; z-index: 70; display: none; pointer-events: none; width: 320px;
  background: #fffaf0; padding: 10px 12px; font-size: 14px;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 8px 0 rgba(0,0,0,.3);
}
#rtip h4 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 6px; }
#rtip ol { margin: 0; padding-left: 20px; }
#rtip li { margin: 3px 0; }
#rtip img { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: -5px; }
#rtip h4 img { width: 32px; height: 32px; }
.float {
  position: absolute; transform: translate(-50%, 0); font-weight: 700; font-size: 22px; color: #ffd36b; white-space: nowrap;
  text-shadow: 3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink);
  animation: floatup 1.4s steps(14) forwards;
}
@keyframes floatup { to { transform: translate(-50%, -60px); opacity: 0; } }

/* ---------- překryvy ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(0deg, rgba(30, 16, 10, .55) 0 2px, rgba(30, 16, 10, .42) 2px 4px);
}
.overlay.hidden { display: none; }
.card {
  position: relative; background: var(--paper); padding: 22px 30px; max-height: 92vh; overflow: auto; max-width: 94vw;
  box-shadow: 0 -4px 0 var(--ink), 0 4px 0 var(--ink), -4px 0 0 var(--ink), 4px 0 0 var(--ink), 0 12px 0 rgba(0,0,0,.4),
    inset 0 -4px 0 var(--paper2);
}
.card h1 { font-size: 54px; line-height: 1; margin: 10px 0; color: #fff4dc; letter-spacing: 3px;
  text-shadow: 4px 0 var(--ink), -4px 0 var(--ink), 0 4px var(--ink), 0 -4px var(--ink), 4px 4px var(--ink), 4px 10px rgba(0,0,0,.25); }
.card h2 { margin: 0 0 12px; font-size: 30px; letter-spacing: 2px; }
.card h3 { margin: 16px 0 8px; font-size: 20px; color: var(--ink2); letter-spacing: 1px; }
.title-card { text-align: center; width: 600px; }
.logo { display: flex; justify-content: center; gap: 10px; }
.logo img { width: 72px; height: 72px; image-rendering: pixelated; animation: hop 1.2s steps(4) infinite; }
.logo img:nth-child(2) { animation-delay: .3s; } .logo img:nth-child(3) { animation-delay: .6s; }
@keyframes hop { 50% { transform: translateY(-8px); } }
.title-card .sub { font-size: 19px; color: var(--ink2); }
.small { font-size: 13px; color: var(--ink2); }
.btns { display: flex; gap: 18px; justify-content: center; margin-top: 18px; }
.btns.col { flex-direction: column; }
.big {
  font-size: 20px; font-weight: 600; padding: 10px 24px; border: 0; background: var(--sage); color: var(--ink);
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 7px 0 rgba(0,0,0,.35), inset 0 -4px 0 var(--sage2);
}
.big:hover { filter: brightness(1.08); }
.big:active { transform: translateY(3px); }
.big.ghost { background: #fffaf0; box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 7px 0 rgba(0,0,0,.35), inset 0 -4px 0 var(--paper2); }
.close { position: absolute; right: 14px; top: 12px; width: 34px; height: 34px; border: 0; background: #fffaf0; font-size: 16px;
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink); }

.book-card { width: 880px; }
#bookList { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rcp { background: #fffaf0; padding: 8px 12px; box-shadow: 0 0 0 3px var(--paper2); }
.rcp h4 { margin: 0 0 4px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.rcp h4 img { width: 36px; height: 36px; image-rendering: pixelated; }
.rcp h4 .pr { margin-left: auto; font-size: 15px; color: #b07a10; }
.rcp ol { margin: 0; padding-left: 20px; font-size: 14px; }
.rcp ol img { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: -5px; }
.rcp.lock { opacity: .5; }

.day-card { width: 900px; }
#dStats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { background: #fffaf0; padding: 6px 14px; font-size: 15px; box-shadow: 0 0 0 3px var(--paper2); }
.stat b { display: block; font-size: 24px; }
.newrec { flex-basis: 100%; background: #eef6e8; padding: 8px 12px; font-size: 15px; box-shadow: 0 0 0 3px var(--sage); }
.newrec img { width: 24px; height: 24px; image-rendering: pixelated; vertical-align: -6px; }
#shop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sitem { background: #fffaf0; padding: 8px 10px; display: flex; gap: 10px; align-items: center; box-shadow: 0 0 0 3px var(--paper2); }
.sitem img { width: 40px; height: 40px; image-rendering: pixelated; }
.sitem button img.px, .stat img.px { width: 18px; height: 18px; vertical-align: -3px; }
.sitem .st { flex: 1; font-size: 13px; color: var(--ink2); }
.sitem .st b { display: block; font-size: 15px; color: var(--ink); }
.sitem button { border: 0; padding: 6px 8px; background: var(--honey); font-weight: 700; font-size: 14px; white-space: nowrap; box-shadow: 0 0 0 3px var(--ink); }
.sitem button:disabled { background: #e8e0d4; color: #a99; cursor: default; box-shadow: 0 0 0 3px #c9b9a6; }
.sitem.owned { background: #eef6e8; box-shadow: 0 0 0 3px var(--sage); }
.sitem.owned button { background: none; box-shadow: none; color: var(--sage2); }
.menu-card { width: 380px; text-align: center; }

@media (max-width: 760px) {
  .htitle { display: none; }
  .pill { font-size: 14px; padding: 2px 6px; }
  #shop, #bookList { grid-template-columns: 1fr; }
  .card h1 { font-size: 38px; }
}

/* ---------- animace rozhraní ---------- */
.bub { transform-origin: left bottom; animation: bubin .3s steps(4) both; }
.bub.thanks { animation: bubin2 .3s steps(4) both; }
@keyframes bubin { from { transform: translate(0, -100%) scale(.2); } 60% { transform: translate(0, -100%) scale(1.12); } to { transform: translate(0, -100%) scale(1); } }
@keyframes bubin2 { from { transform: translate(0, -100%) scale(.2); } 60% { transform: translate(0, -100%) scale(1.12); } to { transform: translate(0, -100%) scale(1); } }
.bub:not(.thanks) img { animation: hop 1.4s steps(2) infinite; }
.overlay:not(.hidden) { animation: fadein .25s steps(3) both; }
.overlay:not(.hidden) .card { animation: cardin .35s steps(5) both; }
@keyframes fadein { from { opacity: 0; } }
@keyframes cardin { from { transform: translateY(50px) scale(.85); opacity: 0; } 70% { transform: translateY(-6px) scale(1.02); opacity: 1; } }
.stat, .newrec { animation: cardin .3s steps(4) both; }
.stat:nth-child(2) { animation-delay: .15s; } .stat:nth-child(3) { animation-delay: .3s; }
.stat:nth-child(4) { animation-delay: .45s; } .newrec { animation-delay: .6s; }
.sitem.bought { animation: bought .5s steps(5); }
@keyframes bought { 30% { transform: scale(1.08) rotate(-2deg); background: #fff2c4; } 60% { transform: scale(.97) rotate(1deg); } }
.big:hover, #bBook:hover { animation: wiggle .4s steps(4); }
@keyframes wiggle { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.coinfly { position: absolute; left: 0; top: 0; width: 26px; height: 26px; image-rendering: pixelated; pointer-events: none; }
.pill.bump { animation: bump .3s steps(3); }
.float { animation: floatup 1.4s steps(14) forwards, popin .2s steps(3); }
@keyframes popin { from { font-size: 8px; } }
.dayban {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); text-align: center; white-space: nowrap;
  font-size: 64px; font-weight: 700; color: #fff4dc; letter-spacing: 4px; pointer-events: none;
  text-shadow: 4px 0 var(--ink), -4px 0 var(--ink), 0 4px var(--ink), 0 -4px var(--ink), 4px 4px var(--ink), 4px 10px rgba(0,0,0,.3);
  animation: dayban 2.5s steps(25) forwards;
}
.dayban small { display: block; font-size: 22px; letter-spacing: 2px; margin-top: 4px; }
@keyframes dayban {
  from { transform: translate(-50%, -160%); opacity: 0; }
  15% { transform: translate(-50%, -40%); opacity: 1; }
  22% { transform: translate(-50%, -55%); }
  75% { transform: translate(-50%, -50%); opacity: 1; }
  to { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bub, .overlay, .card, .stat, .newrec, .dayban, .lab .nm, .newtag, .bub img { animation: none !important; }
}

/* ---------- vylepšení vzhledu ---------- */
/* kostkovaný ubrus nahoře na kartách */
.card { padding-top: 34px; }
.card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 14px;
  background:
    linear-gradient(90deg, rgba(224,127,116,.55) 50%, transparent 50%) 0 0 / 14px 14px,
    linear-gradient(0deg, rgba(224,127,116,.55) 50%, transparent 50%) 0 0 / 14px 14px,
    #fff6ee;
  box-shadow: 0 3px 0 var(--ink);
}
.card { background:
  radial-gradient(rgba(122,84,64,.07) 1px, transparent 1px) 0 0 / 6px 6px,
  var(--paper); }
.close { top: 24px; }
/* teplé ztmavení místo pruhů */
.overlay {
  background:
    repeating-linear-gradient(0deg, rgba(30,16,10,.08) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, rgba(60,32,18,.35), rgba(30,16,10,.72));
}
/* plasticita tlačítek a odznaků */
.pill, .ibtn { background-image: linear-gradient(rgba(255,255,255,.55) 0 3px, transparent 3px); }
.pill.coins { background-color: #ffe9a8; }
.big { background-image: linear-gradient(rgba(255,255,255,.35) 0 4px, transparent 4px); }
.title-card h1 { margin-top: 4px; }
.title-card .logo img { filter: drop-shadow(0 5px 0 rgba(59,36,24,.25)); }
/* popisky stanovišť jako malé cedulky */
.lab .nm {
  display: inline-block; background: var(--ink); color: #fff4dc; padding: 1px 6px 2px; text-shadow: none;
  box-shadow: 0 0 0 2px #fff4dc, 0 0 0 4px var(--ink), 0 4px 0 2px rgba(0,0,0,.25);
}
.lab .nm::after {
  content: ''; position: absolute; left: 50%; margin-left: -3px; top: 17px; width: 6px; height: 4px; background: var(--ink);
}
.lab { padding-bottom: 6px; }
/* nápověda s lístečkem */
#tipbox { padding-left: 38px; }
#tipbox::before {
  content: ''; position: absolute; left: 14px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  background: var(--sage); box-shadow: 0 0 0 2px var(--sage2); transform: rotate(45deg);
}
#tipbox.warn::before { background: var(--rose); box-shadow: 0 0 0 2px #b9574d; }
.bub { background-image: linear-gradient(rgba(255,255,255,.7) 0 3px, transparent 3px); }
.rcp, .stat, .sitem { box-shadow: 0 0 0 3px var(--paper2), 0 4px 0 2px rgba(122,84,64,.18); }
.rcp h4 .pr img { width: 18px; height: 18px; vertical-align: -3px; }
.card { scrollbar-width: thin; scrollbar-color: var(--ink2) var(--paper2); }
.card::-webkit-scrollbar { width: 10px; }
.card::-webkit-scrollbar-track { background: var(--paper2); }
.card::-webkit-scrollbar-thumb { background: var(--ink2); border: 2px solid var(--paper2); }
@media (max-width: 760px) {
  #tipbox { max-width: calc(100vw - 32px); width: calc(100vw - 32px); bottom: 70px; font-size: 14px; }
}
