:root { --gold: #e7b74e; --ink: #f6ead6; --panel: rgba(28, 18, 13, .92); --line: #5a4034; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0604; color: var(--ink);
  font-family: Georgia, "Times New Roman", serif; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#uvtint { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(60, 0, 120, .45) 100%); }
body.uv #uvtint { opacity: 1; }

#top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: linear-gradient(rgba(0,0,0,.6), transparent); pointer-events: none; }
#roomName { flex: 1; color: var(--gold); font-size: 18px; text-shadow: 0 1px 3px #000; }
.ib { pointer-events: auto; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); font-size: 18px; display: grid; place-items: center; padding: 0; }

.arrow { position: fixed; top: 50%; transform: translateY(-50%); width: 54px; height: 90px; border: 0;
  background: rgba(0,0,0,.35); color: #fff; font-size: 54px; line-height: 1; border-radius: 14px; z-index: 5; }
.arrow:active { background: rgba(231,183,78,.4); }
#left { left: max(8px, env(safe-area-inset-left)); }
#right { right: max(8px, env(safe-area-inset-right)); }
#back { position: fixed; left: 50%; transform: translateX(-50%); top: max(8px, env(safe-area-inset-top)); z-index: 5; border: 1px solid var(--gold);
  background: var(--panel); border-radius: 22px; padding: 8px 22px; font-size: 17px; }
#mode { position: fixed; bottom: 96px; left: max(12px, env(safe-area-inset-left)); z-index: 6; background: #4a1f8a;
  border: 1px solid #b38cff; border-radius: 18px; padding: 8px 16px; font-size: 15px; white-space: nowrap; }

#toast { position: fixed; left: 50%; top: 58px; transform: translate(-50%, -10px); max-width: min(92vw, 640px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; font-size: 16px;
  line-height: 1.4; opacity: 0; transition: .25s; pointer-events: none; z-index: 8; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#inv { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; z-index: 6; min-height: 70px; min-width: 120px; }
#inv:empty { display: none; }
.slot { width: 54px; height: 54px; border-radius: 12px; border: 1px solid var(--line); background: #2a1c17; font-size: 28px; padding: 0; }
.slot.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.slot.on { background: #4a1f8a; }
.slot.new { animation: pop .6s; }
@keyframes pop { 0% { transform: scale(.3); } 60% { transform: scale(1.2); } }
#pop { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 7; background: var(--panel);
  border: 1px solid var(--gold); border-radius: 14px; padding: 10px 14px; text-align: center; }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--gold); background: #4a3020; border-radius: 12px; padding: 10px 16px; font-size: 16px; }
.btn.primary { background: var(--gold); color: #2a1a0c; font-weight: bold; }

#inspect { position: fixed; inset: 0; z-index: 20; background: radial-gradient(ellipse at center, #3c281e, #080402); }
#icv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.ihead { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; padding: 12px 16px; font-size: 19px; color: var(--gold); pointer-events: none; }
.ihead b { flex: 1; font-weight: normal; }
.ifoot { position: absolute; bottom: 0; left: 0; right: 0; padding: 10px 18px 16px; text-align: center; pointer-events: none; }
.ifoot p { margin: 4px auto; max-width: 640px; font-size: 16px; }
.ifoot .hint { color: #a8957a; font-size: 13px; font-style: italic; }

#panel { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.sheet { background: #2a1c17; border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; width: min(94vw, 520px); max-height: 94vh; overflow: auto; }
.phead { display: flex; align-items: center; margin-bottom: 6px; color: var(--gold); font-size: 19px; }
.phead b { flex: 1; font-weight: normal; }
.padlock { background: linear-gradient(135deg, #e0c070, #8a6a24); border-radius: 18px 18px 26px 26px; padding: 14px; margin: 10px auto; max-width: 300px; box-shadow: inset 0 0 0 4px #5a4010, 0 8px 20px #000a; }
.wheels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.wheel { display: flex; flex-direction: column; gap: 4px; }
.wheel button { border: 0; border-radius: 8px; background: rgba(0,0,0,.35); color: #fff3c4; padding: 6px 0; font-size: 16px; }
.wheel .d { font: bold 30px "Courier New", monospace; text-align: center; background: linear-gradient(#a8864a, #f3dca0 50%, #a8864a); color: #2a1a0c; border-radius: 4px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.mag { margin: 10px auto; width: 240px; height: 240px; border-radius: 50%; border: 12px solid #c9a14a; display: grid; place-content: center;
  background: radial-gradient(circle, #e8eef8, #b8c8e0); box-shadow: 0 8px 26px #000a, inset 0 0 30px rgba(0,0,0,.25); text-align: center; color: #3a2a1c; }
.magtext { font: italic bold 44px Georgia; }
.magcap { font-size: 13px; opacity: .7; margin-top: 6px; }

/* úvod: na nízkém displeji (telefon na šířku, velké písmo v systému) jde posouvat a tlačítko je pořád vidět dole */
#intro { position: fixed; inset: 0; z-index: 40; text-align: center; padding: 16px 20px 0; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at 50% 30%, #2d4a6e, #0a0f1d); }
#intro .inner { max-width: 640px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; }
#intro .row { position: sticky; bottom: 0; padding: 10px 0 14px; margin-top: auto; background: linear-gradient(transparent, #0d1424 35%); display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#intro h1 { font-weight: normal; color: #fff3d6; margin: 0 0 8px; }
#intro small { display: block; font-size: 16px; color: var(--gold); }
#intro p { font-size: 17px; line-height: 1.5; color: #dfe6f3; }
#intro .goal { color: #fff3d6; }
#rotate { display: none; }
@media (orientation: portrait) {
  #rotate { display: grid; position: fixed; inset: 0; z-index: 50; place-items: center; background: #0b0604ee; text-align: center; font-size: 60px; }
  #rotate p { font-size: 20px; }
}

/* návod */
#coach { position: fixed; top: max(54px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); z-index: 9;
  width: min(290px, 32vw); background: var(--panel); border: 1px solid var(--gold); border-radius: 14px; padding: 10px 14px 8px;
  font-size: 14px; line-height: 1.38; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#coach .cstep { color: var(--gold); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
#coach #cskip { margin-top: 8px; background: none; border: 0; color: #a8957a; font-size: 13px; text-decoration: underline; padding: 2px 0; }
#coach.flash { animation: coachIn .45s; }
@keyframes coachIn { 0% { transform: translateX(-20px); opacity: 0; } }
body.coaching #toast { left: auto; right: max(12px, env(safe-area-inset-right)); transform: translateY(-10px); max-width: calc(100vw - min(290px, 32vw) - 48px); }
body.coaching #toast.show { transform: none; }
#ring { position: fixed; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; border: 3px solid var(--gold);
  box-shadow: 0 0 18px var(--gold); pointer-events: none; z-index: 4; animation: ring 1.4s infinite; }
@keyframes ring { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
.pulse { animation: pulseEl 1.2s infinite; }
#inv.pulse, #back.pulse { animation: pulseEl 1.2s infinite; }
@keyframes pulseEl { 0%, 100% { box-shadow: 0 0 0 0 rgba(231,183,78,.9); } 50% { box-shadow: 0 0 0 8px rgba(231,183,78,0); } }
ul.help { padding-left: 4px; list-style: none; line-height: 1.5; }
ul.help li { margin: 6px 0; }
.muted { color: #a8957a; font-size: 14px; }
#mode small { opacity: .7; }

/* ---- hlavolamy (plná hra) ---- */
.sheet p { line-height: 1.45; margin: 6px 0; }
.center { text-align: center; }
.success { color: #8fe08a; }
.paper { background: linear-gradient(#f3e8cc, #e6d6b0); color: #2a1a0c; border-radius: 6px; padding: 10px 14px; margin: 8px 0;
  font-style: italic; box-shadow: inset 0 0 24px rgba(120,80,30,.25), 0 3px 10px #0007; }
.paper h3 { margin: 12px 0 2px; font-size: 16px; font-style: normal; color: #6a2a12; border-bottom: 1px solid #b8986088; }
.paper .pg { font-size: 15px; }
.mirrored { transform: scaleX(-1); font-size: 18px; text-align: center; line-height: 1.6; background: linear-gradient(#7a5a3a, #5a3e26); color: #efe3c4; }
.mirrorview { font-size: 18px; text-align: center; line-height: 1.6; background: linear-gradient(#b8c4c8, #8a989e); color: #1a2a30; }
.letter { font-size: 16px; line-height: 1.55; }
.ending p { font-size: 16px; }
#hint { pointer-events: auto; }

.dirlock { background: linear-gradient(#3a3a3e, #1a1a1c); border-radius: 16px; padding: 12px; margin: 8px auto; max-width: 260px; box-shadow: inset 0 0 0 3px #555, 0 6px 18px #000a; }
.dseq { text-align: center; min-height: 30px; font: bold 22px "Segoe UI Symbol", sans-serif; color: #b8fff2; letter-spacing: 2px; margin-bottom: 8px; }
.dpad { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(3, 60px); gap: 6px; justify-content: center; }
.dbtn { border: 1px solid #888; border-radius: 12px; background: linear-gradient(#6a6e74, #3a3e44); color: #fff; font-size: 28px; padding: 0; }
.dbtn:active { background: #9aa; }
.dknob { display: grid; place-items: center; font-size: 34px; color: #aab; }

.fusebox { display: flex; gap: 8px; justify-content: center; background: linear-gradient(#9aa098, #6a7068); border-radius: 10px; padding: 12px 8px; margin: 8px 0; }
.breaker { width: 74px; border: 1px solid #333; border-radius: 6px; background: #e8e4da; color: #222; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.breaker .lever { width: 22px; height: 40px; border-radius: 4px; background: linear-gradient(#333, #111); position: relative; }
.breaker .lever::after { content: ''; position: absolute; left: 3px; right: 3px; height: 16px; bottom: 3px; border-radius: 3px; background: #c02020; transition: .15s; }
.breaker.on .lever::after { bottom: 21px; background: #20a040; }
.breaker .bn { font: bold 11px Arial, sans-serif; }
.breaker .ba { font: 12px Arial, sans-serif; color: #555; }
.fsum { text-align: center; font-size: 16px; }

.treesvg { width: min(240px, 52vh); height: auto; }
.scalesvg { width: min(320px, 70vh); height: auto; display: block; margin: 0 auto; }
.pkgs { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.pkg { background: #2a1d14; border: 2px solid #5a4030; border-radius: 10px; padding: 6px 8px 4px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 64px; min-height: 64px; color: #e8dcc0; cursor: pointer; }
.pkg.on { border-color: #d8b050; }
.pkg small { font-size: 12px; white-space: nowrap; }
.gift { display: block; width: 34px; border-radius: 3px; position: relative; box-shadow: inset 0 -6px 8px rgba(0,0,0,.25); }
.gift i { position: absolute; left: 14px; top: 0; bottom: 0; width: 6px; }
.bulb { cursor: pointer; }
.hintflash { animation: hintflash .6s 4; }
@keyframes hintflash { 50% { stroke: #fff; stroke-width: 6; } }

.clockface { width: min(210px, 50vh); height: auto; }
.ctrl { display: grid; grid-template-columns: auto 56px 56px; gap: 6px 8px; align-items: center; justify-content: center; margin-top: 6px; }
.ctrl .btn { padding: 6px 0; font-size: 20px; }

.shelf { display: flex; gap: 6px; justify-content: center; align-items: flex-end; height: 200px; padding: 8px; background: linear-gradient(#3a2414, #2a180c); border-bottom: 10px solid #5a3a20; border-radius: 6px; }
.book { width: 48px; border: 0; border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 8px 0; color: #e8c878;
  box-shadow: inset -6px 0 10px #0006, inset 6px 0 10px #0004; transition: transform .15s; }
.book.sel { transform: translateY(-14px); outline: 2px solid var(--gold); }
.book .bt { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; max-height: 120px; overflow: hidden; }
.book .by { font: bold 11px Georgia; }

.polaroid { background: #f5f0e6; padding: 8px 8px 4px; margin: 6px auto; width: min(240px, 60%); box-shadow: 0 6px 16px #000a; transform: rotate(-1.5deg); }
.polaroid img { width: 100%; display: block; max-height: 34vh; object-fit: contain; background: #222; }
.polaroid .cap { color: #3a2a1c; font-style: italic; text-align: center; font-size: 14px; padding: 4px 0; }
.answer { display: flex; gap: 8px; }
.answer input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--gold); background: #1a120c; color: var(--ink); user-select: text; -webkit-user-select: text; }

.paint { display: grid; grid-template-columns: repeat(4, 1fr); width: min(260px, 58vh); aspect-ratio: 1; margin: 8px auto; border: 12px solid #b8902e;
  box-shadow: inset 0 0 0 3px #6a4a10, 0 8px 20px #000a; background: #222; }
.ptile { background-size: 400% 400%; transition: transform .25s; outline: 1px solid #0006; cursor: pointer; }
.paint.done .ptile { outline: none; }

.safe { background: linear-gradient(135deg, #6a7078, #3a4048); border-radius: 12px; padding: 12px; margin: 8px auto; max-width: 340px; box-shadow: inset 0 0 0 4px #22262a, 0 6px 18px #000a; }
.syms { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; font-size: 26px; margin-bottom: 6px; }
.wheels.five { grid-template-columns: repeat(5, 1fr); }
.crypt { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; background: linear-gradient(#c8a050, #7a5a1a); border-radius: 30px; padding: 10px 16px; margin: 10px auto; max-width: 380px; box-shadow: 0 6px 18px #000a; }
.crypt .lt { display: flex; flex-direction: column; align-items: center; font: bold 26px Georgia; color: #2a1a0c; background: linear-gradient(#a8864a, #f3dca0 50%, #a8864a); border-radius: 4px; line-height: 1.05; }
.crypt .lt small { font-size: 13px; opacity: .45; }

/* telefon na šířku: nízká obrazovka */
@media (max-height: 500px) {
  .sheet { width: min(94vw, 640px); padding: 10px 16px; }
  .sheet p { margin: 4px 0; font-size: 15px; }
  .dpad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 4px; }
  .dbtn { font-size: 22px; }
  .dirlock { padding: 8px; margin: 4px auto; }
  .dseq { margin-bottom: 4px; min-height: 26px; }
  .shelf { height: 150px; }
  .polaroid img { max-height: 26vh; }
  .scalesvg { width: min(300px, 62vh); }
  .pkg { min-width: 56px; min-height: 54px; padding: 4px 6px 3px; }
  .wheel .d { font-size: 24px; }
  .wheel button { padding: 3px 0; }
  .padlock, .safe { padding: 8px 10px; margin: 6px auto; }
  .row { margin-top: 4px; }
  .btn { padding: 8px 14px; }
  #intro h1 { font-size: 26px; margin-bottom: 2px; }
  #intro small { font-size: 14px; }
  #intro p { font-size: 15px; line-height: 1.35; margin: 6px 0; }
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#fs { font-size: 16px; }

/* kuchyňka: mikrovlnka s klávesnicí, recept */
.micro { display: flex; gap: 14px; align-items: center; justify-content: center; background: linear-gradient(135deg, #c8ccd2, #7a7e86); border-radius: 12px; padding: 12px; margin: 8px auto; max-width: 420px; box-shadow: inset 0 0 0 3px #4a4e56, 0 8px 20px #000a; }
.mdisp { min-width: 130px; font: bold 30px "Courier New", monospace; color: #5aff7a; text-shadow: 0 0 8px #5aff7a; background: #061006; border-radius: 6px; padding: 10px 8px; text-align: center; }
.mkeys { display: grid; grid-template-columns: repeat(3, 52px); gap: 6px; }
.mkeys button { border: 0; border-radius: 8px; background: #1e1e22; color: #eee; font: bold 18px Arial; padding: 8px 0; }
.mkeys button.go { background: #2a6a3a; }
.recipe { background: #f4ead2; color: #4a2410; border-radius: 6px; padding: 10px 18px; font-family: Georgia, serif; }
.recipe table { margin: 6px 0; font-size: 20px; } .recipe td { padding: 2px 18px 2px 0; } .recipe td + td { letter-spacing: 4px; color: #7a2a14; }
@media (max-height: 450px) { .mkeys button { padding: 5px 0; } .micro { padding: 8px; } }

/* odezva na klepnutí */
.tapfx { position: fixed; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; border: 2px solid rgba(220, 220, 220, .55); pointer-events: none; z-index: 30; animation: tapfx .45s ease-out forwards; }
.tapfx.hot { border-color: rgba(255, 214, 120, .95); box-shadow: 0 0 10px rgba(255, 200, 90, .6); }
@keyframes tapfx { from { transform: scale(.35); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
#music.off { opacity: .45; text-decoration: line-through; }

/* návod pro iPhone v úvodu */
#intro .iostip { background: rgba(255, 255, 255, .08); border: 1px solid rgba(231, 183, 78, .5); border-radius: 10px; padding: 8px 12px; font-size: 15px; color: #fff3d6; }
#intro .iostip .share { display: inline-block; border: 1px solid #fff3d6; border-radius: 4px; padding: 0 4px; font-size: 13px; }
#intro .iostip small { display: block; opacity: .75; font-size: 13px; margin-top: 2px; }
/* výběr hráče v úvodu */
#intro .players { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 4px 0 2px; }
#intro .plab { color: var(--gold); font-size: 15px; }
#intro .pchip { position: relative; border: 1px solid rgba(231, 183, 78, .5); background: rgba(255, 255, 255, .06); color: #fff3d6; border-radius: 12px; padding: 6px 14px; font-size: 15px; line-height: 1.2; min-height: 44px; }
#intro .pchip.on { border-color: var(--gold); background: rgba(231, 183, 78, .22); }
#intro .pchip small { display: block; font-size: 12px; color: #c9cfdb; }
#intro .pchip.add { border-style: dashed; color: var(--gold); }
#intro .pdel { position: absolute; top: -9px; right: -9px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(231, 183, 78, .6); background: #2a1a0c; color: #fff3d6; font-size: 11px; padding: 0; line-height: 20px; }
/* ⚙️ nastavení zvuku */
#snd { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; }
#snd.hidden { display: none; }
#snd .sbox { background: #2a1a0c; border: 1px solid var(--gold); border-radius: 14px; padding: 10px 16px 12px; width: min(420px, 92vw); color: #fff3d6; }
#snd .phead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
#snd .srow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 16px; }
#snd input[type=range] { width: 52%; accent-color: #e7b74e; height: 32px; }
#snd input[type=range]:disabled { opacity: .35; }
#snd .tog { min-width: 96px; min-height: 36px; border-radius: 18px; border: 1px solid var(--gold); background: #4a3020; color: #c9cfdb; font-size: 15px; }
#snd .tog.on { background: var(--gold); color: #2a1a0c; font-weight: bold; }
#snd .snote { margin: 6px 0 0; font-size: 13px; color: #c9cfdb; }
