:root {
  --ink: #121626; --panel: #1b2136; --panel2: #252d48; --line: #313a5c; --edge: #0a0d17;
  --parch: #efe3c4; --text2: #c9c3b0; --muted: #9da4bf; --gold: #e6b551; --red: #ff6b6b;
  --david: #5b8de8; --lucia: #62c463;
  --display: "Pixelify Sans", "Courier New", monospace;
  --data: "VT323", "Courier New", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--parch); overflow: hidden; font-family: var(--display); -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#game, #ov { position: absolute; image-rendering: pixelated; image-rendering: crisp-edges; }
#ov { pointer-events: none; }
button { font: inherit; color: inherit; }
a { color: var(--gold); }
[hidden] { display: none !important; }

/* ---------- obrazovky ---------- */
#screens { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(10, 13, 23, 0.35), rgba(10, 13, 23, 0.82)); padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow: auto; }
#screens > section { width: min(560px, 100%); }
#menu { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.logo h1 { margin: 0; font-size: clamp(40px, 9vw, 84px); font-weight: 700; letter-spacing: 0.04em; color: var(--gold); text-shadow: 4px 4px 0 var(--edge), 8px 8px 0 #3a2a14; line-height: 0.95; }
.logo p { margin: 8px 0 0; font-family: var(--data); font-size: 22px; color: var(--text2); text-shadow: 2px 2px 0 var(--edge); }
.mm { display: flex; flex-direction: column; gap: 8px; width: min(340px, 100%); }
.row2 { display: flex; gap: 6px; }
.row2 .btn { flex: 1; }
.foot { font-family: var(--data); font-size: 18px; color: var(--muted); margin: 4px 0 0; text-shadow: 1px 1px 0 var(--edge); }
.acct { display: flex; align-items: center; gap: 8px; font-family: var(--data); font-size: 20px; background: rgba(27, 33, 54, 0.85); border: 2px solid var(--edge); padding: 4px 10px; }
.acct img { width: 22px; height: 22px; image-rendering: auto; }
.acct b { color: var(--gold); font-weight: 400; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; background: var(--panel2); border: 2px solid var(--edge); box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.06); color: var(--parch); font-family: var(--display); font-size: 17px; cursor: pointer; text-decoration: none; }
.btn:hover { background: #323c63; }
.btn:active { box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.35); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: #8a5f1e; border-color: #2a1a06; color: #fff6dc; }
.btn.primary:hover { background: #a3721f; }
.btn.danger { background: #6a1e28; }
.btn.sm { min-height: 36px; font-size: 14px; padding: 6px 10px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.dlg { background: var(--panel); border: 3px solid var(--edge); outline: 2px solid var(--panel2); padding: 18px 20px; box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45); max-height: calc(100vh - 32px); overflow: auto; }
.dlg.wide { width: min(820px, 100%) !important; }
.dlg h2 { margin: 0 0 10px; color: var(--gold); font-size: 28px; text-shadow: 2px 2px 0 var(--edge); }
.dlg h4 { margin: 16px 0 6px; color: var(--parch); font-size: 18px; }
.dlg p { margin: 6px 0; color: var(--text2); font-family: var(--data); font-size: 20px; line-height: 1.15; }
.dlg input, .dlg select { font-family: var(--data); font-size: 22px; background: var(--ink); color: var(--parch); border: 2px solid var(--line); padding: 6px 8px; width: 100%; }
.dlg input[type=checkbox] { width: auto; }
.dlg label { display: flex; align-items: center; gap: 8px; font-family: var(--data); font-size: 20px; color: var(--text2); margin: 6px 0; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btns.col { flex-direction: column; }
.muted { color: var(--muted) !important; }
.gold { color: var(--gold); }
.red { color: var(--red); }
.scroll { max-height: 60vh; overflow: auto; padding-right: 6px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel2); border: 2px solid var(--edge); padding: 10px 12px; cursor: pointer; text-align: left; }
.list .row span { font-family: var(--data); font-size: 19px; color: var(--muted); }
.set input[type=range] { flex: 1; accent-color: var(--gold); }

/* lobby */
.code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--data); font-size: 20px; }
.code-row b { font-family: var(--display); font-size: 34px; color: var(--gold); letter-spacing: 0.08em; text-shadow: 2px 2px 0 var(--edge); }
.code-row input { flex: 1; min-width: 180px; font-size: 16px; }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.pl { background: var(--panel2); border: 2px solid var(--edge); padding: 10px; }
.pl.mine { border-color: #4a5a8a; }
.pl.empty { display: grid; place-items: center; text-align: center; min-height: 160px; }
.pl .who { font-size: 18px; margin-bottom: 8px; }
.pl .who i { font-style: normal; font-family: var(--data); font-size: 16px; color: var(--gold); border: 1px solid currentColor; padding: 0 4px; }
.pl .who i.off { color: var(--red); }
.chars { display: flex; gap: 8px; }
.pc { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--ink); border: 2px solid var(--edge); padding: 6px; cursor: pointer; }
.pc canvas { width: 100%; max-width: 144px; aspect-ratio: 72 / 52; image-rendering: pixelated; }
.pc b { font-size: 14px; font-weight: 400; }
.pc.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.pc[disabled] { cursor: default; opacity: 0.85; }
.pc[data-taken] { opacity: 0.4; }
.rdy { margin-top: 8px; font-family: var(--data); font-size: 20px; color: var(--muted); }
.rdy.on { color: #9be08a; }
.lset { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }

/* koniec hry */
.stars { font-size: 48px; color: var(--gold); text-shadow: 3px 3px 0 var(--edge); letter-spacing: 0.1em; }
#over table, .help table { width: 100%; border-collapse: collapse; font-family: var(--data); font-size: 19px; color: var(--text2); }
#over td, .help td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.help td:first-child { color: var(--parch); }
.lead { font-size: 22px !important; color: var(--parch) !important; }
.badge { display: inline-block; border: 1px solid var(--gold); color: var(--gold); padding: 0 6px; margin: 2px; font-family: var(--data); }
.ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.ui-item { background: var(--panel2); border: 2px solid var(--edge); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.ui-item b { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.ui-item span { font-family: var(--data); font-size: 17px; color: var(--muted); }
.ui-item em { font-family: var(--data); color: #9be08a; font-style: normal; }
.ui-item.r1 { border-color: #2f5f9e; } .ui-item.r2 { border-color: #9e7a2f; }
.ui-item .sw { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--edge); }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--data); }
.panel { background: rgba(14, 16, 28, 0.72); border: 2px solid rgba(10, 13, 23, 0.9); padding: 4px 10px; text-shadow: 1px 1px 0 #000; }
#top { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; font-size: 20px; min-width: min(420px, 60vw); }
#top b { font-family: var(--display); font-weight: 600; color: var(--gold); }
#top small { display: block; font-size: 17px; color: var(--text2); }
.tbar { position: relative; height: 6px; background: linear-gradient(90deg, #6fa8dc 0%, #8ec4ec 70%, #e08a5a 78%, #1c2850 84%, #0a1028 100%); margin: 3px 0; border: 1px solid #000; }
.tbar i { position: absolute; top: -3px; width: 3px; height: 12px; background: #fff; margin-left: -1px; box-shadow: 0 0 4px #fff; }
.tbar span { position: absolute; top: 0; width: 1px; height: 100%; background: rgba(0, 0, 0, 0.6); }
#me { position: absolute; top: max(6px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); font-size: 19px; min-width: 190px; }
#me .nm, #partner .nm { font-family: var(--display); font-size: 16px; }
.coins { font-size: 24px; transition: transform 0.15s; transform-origin: left center; }
.coins.big { transform: scale(1.5); }
.coins b, #partner b { color: var(--gold); font-weight: 400; }
.coin { display: inline-block; width: 10px; height: 12px; background: #f2c94c; box-shadow: inset -2px 0 0 #c9a02a, 1px 1px 0 #000; margin-right: 6px; vertical-align: -1px; }
.crown { color: #ffd84a; }
.crown.off { color: var(--red); animation: blink 0.6s steps(2) infinite; }
.st { height: 4px; background: rgba(0, 0, 0, 0.5); margin-top: 3px; }
.st i { display: block; height: 100%; background: #9be08a; }
#me i.sel { color: #ff9a3a; font-style: normal; }
#me i { font-style: normal; color: var(--muted); }
#partner { position: absolute; top: max(6px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); font-size: 19px; text-align: right; min-width: 170px; }
#boss { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); width: min(460px, 70vw); text-align: center; font-size: 18px; color: #ffb0a0; }
#boss b { font-family: var(--display); color: #ff6b6b; }
#boss .bar { height: 8px; background: #2a0a10; border: 1px solid #000; margin-top: 3px; }
#boss .bar i { display: block; height: 100%; background: linear-gradient(90deg, #c0203a, #ff5a6a); }
#msgs { position: absolute; top: 110px; left: 50%; transform: translateX(-50%); text-align: center; font-size: 22px; text-shadow: 2px 2px 0 #000, 0 0 6px #000; width: min(700px, 90vw); }
#hint { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); width: min(620px, 86vw); font-size: 20px; color: #dfe6ff; border-color: #3a4a7a; }
#hint .ghost { filter: grayscale(0.3); }
#abil { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); left: max(8px, env(safe-area-inset-left)); display: flex; gap: 4px; }
.ab { position: relative; width: 64px; height: 50px; background: rgba(14, 16, 28, 0.78); border: 2px solid #0a0d17; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.ab kbd { font-family: var(--display); font-size: 12px; color: var(--gold); }
.ab span { font-size: 15px; line-height: 1; text-align: center; padding: 0 2px; }
.ab i { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); }
.ab em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 22px; color: #fff; }
.ab.on { border-color: var(--gold); }
.ab.lock { opacity: 0.4; }
.ab.info { width: 52px; opacity: 0.8; }
#cards { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: auto; text-align: center; background: rgba(10, 12, 22, 0.86); border: 3px solid #000; padding: 12px 14px; width: min(760px, 94vw); }
#cards h3 { margin: 0 0 10px; font-family: var(--display); color: var(--gold); font-size: 22px; }
.cl { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card { position: relative; width: 200px; min-height: 150px; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 24px; background: linear-gradient(#2a3150, #1b2036); border: 3px solid #5a6488; cursor: pointer; text-align: center; animation: flip 0.45s both; }
.card:hover { transform: translateY(-4px); }
.card em { font-style: normal; font-family: var(--data); font-size: 16px; color: var(--muted); text-transform: uppercase; }
.card b { font-family: var(--display); font-size: 19px; color: var(--parch); }
.card span { font-family: var(--data); font-size: 19px; color: var(--text2); line-height: 1.05; }
.card kbd { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 12px; color: var(--muted); }
.card.r1 { border-color: #4a8ae0; }
.card.r2 { border-color: #f2c94c; box-shadow: 0 0 14px rgba(242, 201, 76, 0.45); background: linear-gradient(#3a3420, #1f1c12); }
.card.r2 em { color: var(--gold); }
#cards small { display: block; margin-top: 8px; color: var(--muted); font-size: 17px; }
#fish { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); width: 200px; text-align: center; font-size: 18px; }
#fish p { margin: 6px 0; color: #cfe8ff; }
#fish p.bite { color: #ffd36b; font-size: 26px; animation: blink 0.3s steps(2) infinite; }
.fbar { position: relative; width: 26px; height: 160px; margin: 6px auto; background: #0c1a2a; border: 2px solid #000; }
.fbar .zone { position: absolute; left: 0; right: 0; background: rgba(110, 220, 120, 0.6); }
.fbar .ptr { position: absolute; left: -4px; right: -4px; height: 3px; background: #fff; margin-bottom: -1px; }
.fprog { height: 5px; background: #222; } .fprog i { display: block; height: 100%; background: #9be08a; }
#pingmenu { position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%); display: flex; gap: 12px; font-size: 20px; }
#pingmenu b { color: var(--gold); }
#volley { position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%); color: #ffd36b; font-size: 20px; }
#wait { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; font-size: 22px; pointer-events: auto; padding: 14px 18px; }
#wait .btn { margin-top: 10px; }
#toasts { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: rgba(14, 16, 28, 0.92); border: 2px solid #000; padding: 6px 12px; font-family: var(--data); font-size: 20px; animation: fadeout 4.2s forwards; }

/* ---------- dotykové ovládanie ---------- */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#touch .tb { pointer-events: auto; width: 54px; height: 54px; border-radius: 0; background: rgba(20, 24, 40, 0.55); border: 2px solid rgba(255, 255, 255, 0.25); color: #fff; font-size: 22px; touch-action: none; }
#touch .tb.on { background: rgba(230, 181, 81, 0.5); }
#touch .tb.big { width: 70px; height: 70px; font-size: 28px; }
#touch .tb.sm { width: 40px; height: 40px; font-size: 18px; }
#touch .tl { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(76px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; }
#touch .tr { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, auto); gap: 6px; align-items: end; }
#touch .tr .tb { font-size: 14px; }
#touch .tt { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(64px, env(safe-area-inset-top)); display: flex; gap: 6px; }
#touch .tb.pay { background: rgba(140, 100, 20, 0.6); }
#t-aim { pointer-events: auto; width: 120px; height: 120px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.35); background: rgba(40, 80, 50, 0.35); display: grid; place-items: center; font-size: 12px; text-align: center; grid-row: span 2; touch-action: none; }
#touch[data-mode="david"] .q, #touch[data-mode="lucia"] .k, #touch[data-mode="solo"] .duo { display: none !important; }
#touch:not([hidden]) ~ * #abil { display: none; }

#rotate { display: none; position: fixed; inset: 0; z-index: 100; background: var(--ink); place-items: center; font-size: 24px; text-align: center; padding: 20px; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: grid; } }
@media (max-width: 760px), (max-height: 480px) {
  #top { font-size: 16px; min-width: 0; }
  #top small { font-size: 14px; }
  #me, #partner { font-size: 15px; min-width: 0; }
  #me .nm, #partner .nm { font-size: 13px; }
  .coins { font-size: 18px; }
  #msgs { top: 70px; font-size: 17px; }
  #boss { top: 56px; }
  #hint { bottom: auto; top: 96px; font-size: 16px; }
  .ab { width: 50px; height: 40px; }
  .ab span { font-size: 12px; }
  .players { grid-template-columns: 1fr; }
  .card { width: 150px; min-height: 120px; }
  .card span { font-size: 16px; }
  .logo h1 { font-size: 38px; }
}
@media (pointer: coarse) { #abil { display: none; } #hint { bottom: auto; top: 96px; } }

@keyframes blink { 50% { opacity: 0.3; } }
@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } to { transform: rotateY(0); opacity: 1; } }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (max-height: 480px) {
  #menu { gap: 6px; }
  .logo h1 { font-size: 34px; }
  .logo p { font-size: 16px; margin-top: 2px; }
  .mm { gap: 5px; width: min(300px, 100%); }
  .mm .btn { min-height: 34px; font-size: 15px; padding: 4px 12px; }
  .foot { display: none; }
  .dlg { padding: 10px 14px; }
  .dlg h2 { font-size: 22px; }
}

/* ---------- prihlásenie a menu s hrami ---------- */
#login { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.dlg.narrow { width: min(420px, 100%); }
.btn.big { min-height: 54px; font-size: 20px; }
.small { font-size: 16px !important; }
.center { text-align: center; }
.devlogin { display: flex; gap: 6px; margin-top: 8px; }
.devlogin input { font-family: var(--data); font-size: 18px; background: var(--ink); color: var(--parch); border: 2px solid var(--line); padding: 4px 8px; flex: 1; }
#screens > section#menu { width: min(980px, 100%); }
.menu-grid { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 16px; width: 100%; align-items: start; text-align: left; }
.games-box { background: rgba(27, 33, 54, 0.88); border: 3px solid var(--edge); padding: 10px 12px; min-height: 120px; }
.games-box h3 { margin: 0 0 8px; color: var(--gold); font-size: 20px; }
.games { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.game { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel2); border: 2px solid var(--edge); padding: 8px 10px; }
.game .gi { font-family: var(--data); font-size: 20px; color: var(--text2); min-width: 0; }
.game .gi b { font-family: var(--display); font-weight: 600; color: var(--parch); font-size: 15px; }
.game .gi small { display: block; color: var(--muted); font-size: 17px; }
.game .code { color: var(--gold); font-family: var(--display); font-size: 14px; border: 1px solid var(--gold); padding: 0 4px; }
.game .gb { display: flex; gap: 4px; flex: none; }
.pl .who i.on { color: #9be08a; }
#lobby-msg:empty { display: none; }

/* ---------- úvod, ciele, karty ---------- */
#intro { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(640px, 92vw); font-size: 20px; padding: 14px 18px; pointer-events: auto; border-color: #3a4a7a; background: rgba(12, 14, 26, 0.92); }
#intro h3 { margin: 0 0 6px; font-family: var(--display); color: var(--gold); font-size: 26px; }
#intro ul { margin: 0 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; color: var(--text2); }
#intro p { margin: 6px 0; color: #cfe0ff; }
#goals { position: absolute; top: 96px; left: max(8px, env(safe-area-inset-left)); width: min(320px, 34vw); font-size: 17px; color: var(--text2); line-height: 1.1; }
#goals b { font-family: var(--display); color: var(--gold); font-size: 14px; }
#goals small { color: var(--muted); font-size: 14px; }
#goals div { margin-top: 3px; }
#goals .urgent { color: #ffb0a0; }
.cexp { margin: -4px 0 8px; color: var(--muted); font-size: 17px; }
@media (max-width: 760px), (max-height: 480px) {
  .menu-grid { grid-template-columns: 1fr; }
  .games { max-height: none; }
  #goals { top: 74px; font-size: 14px; width: min(260px, 40vw); }
  #intro { font-size: 15px; }
}
@media (pointer: coarse) { #goals { top: 78px; } }
