:root {
  --ink: #2a2140;
  --paper: #fffaf0;
  --bg1: #3b2a8f;
  --bg2: #6a3fd1;
  --yellow: #ffd23f;
  --yellow-d: #e0a800;
  --green: #3ccf6e;
  --green-d: #22994a;
  --blue: #3d8bff;
  --blue-d: #1d56c0;
  --red: #ff5247;
  --red-d: #c0281f;
  --muted: #6d6488;
  --font: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(255,210,63,0.18) 0 8%, transparent 9%),
    radial-gradient(circle at 85% 75%, rgba(61,139,255,0.25) 0 10%, transparent 11%),
    radial-gradient(circle at 75% 15%, rgba(255,82,71,0.2) 0 6%, transparent 7%),
    radial-gradient(1200px 800px at 50% 0%, var(--bg2), var(--bg1));
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
body[data-screen="game"] { overflow: hidden; touch-action: none; background: #1d1640; }
input { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- obrazovky ---------- */
.screen { display: none; }
.screen.active { display: block; }
#scr-game.active { display: block; position: fixed; inset: 0; }

/* ---------- tlačítka ---------- */
.btn {
  --c: #fff; --d: #c9c1dd;
  appearance: none;
  border: 3px solid var(--ink);
  background: var(--c);
  border-radius: 16px;
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transform: translateY(0);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
  touch-action: manipulation;
  line-height: 1.15;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.big { font-size: 26px; padding: 14px 26px; border-radius: 20px; }
.btn.small { font-size: 15px; padding: 7px 12px; border-radius: 12px; box-shadow: 0 4px 0 var(--ink); }
.btn.tiny { font-size: 14px; padding: 3px 10px; border-radius: 10px; border-width: 2px; box-shadow: 0 3px 0 var(--ink); }
.btn.yellow { background: var(--yellow); }
.btn.green { background: var(--green); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.25); }
.btn.blue { background: var(--blue); color: #fff; }
.btn.red { background: var(--red); color: #fff; }

.card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 18px 20px;
}

/* ---------- logo ---------- */
.logo { text-align: center; padding: calc(18px + var(--safe-t)) 16px 6px; }
.logo h1 {
  margin: 0;
  font-size: clamp(56px, 11vw, 104px);
  line-height: 0.95;
  letter-spacing: 2px;
  font-weight: 800;
}
.logo h1 span {
  display: inline-block;
  color: var(--yellow);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink);
  animation: hop 2.4s ease-in-out infinite;
}
.logo h1 span:nth-child(2) { color: #7ee081; animation-delay: 0.1s; }
.logo h1 span:nth-child(3) { color: #ff8a5c; animation-delay: 0.2s; }
.logo h1 span:nth-child(4) { color: #6fc3ff; animation-delay: 0.3s; }
.logo h1 span:nth-child(5) { color: #ff7eb6; animation-delay: 0.4s; }
.logo h1 span:nth-child(6) { color: var(--yellow); animation-delay: 0.5s; }
@keyframes hop { 0%, 70%, 100% { transform: translateY(0) rotate(0); } 80% { transform: translateY(-10px) rotate(-4deg); } 90% { transform: translateY(0) rotate(2deg); } }
.logo p { margin: 4px 0 0; color: #fff; font-weight: 700; font-size: 19px; letter-spacing: 1px; opacity: 0.9; }

/* ---------- domů ---------- */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 22px;
  max-width: 1000px;
  margin: 14px auto 30px;
  padding: 0 16px calc(16px + var(--safe-b));
}
@media (max-width: 760px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
.card h2 { margin: 0 0 6px; font-size: 26px; }
.card h3 { margin: 18px 0 8px; font-size: 20px; }
.prof-top { display: flex; align-items: center; gap: 14px; }
#avatar { width: 150px; height: 150px; flex: none; background: radial-gradient(circle, #fff3c4 0 55%, transparent 56%); border-radius: 50%; }
.name-l { flex: 1; display: flex; flex-direction: column; font-weight: 800; font-size: 16px; color: var(--muted); }
.name-l input {
  margin-top: 4px;
  font: 800 24px var(--font);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 12px;
  width: 100%;
  background: #fff;
  outline: none;
}
.name-l input:focus { box-shadow: 0 0 0 4px rgba(255,210,63,0.7); }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pick-title { font-weight: 800; color: var(--muted); margin: 14px 0 6px; }
.hats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pick {
  border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 4px 2px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; font-size: 12px; font-weight: 700; touch-action: manipulation;
}
.pick img { width: 54px; height: 54px; }
.pick.sel { background: var(--yellow); box-shadow: 0 4px 0 var(--ink); transform: translateY(-2px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 3px solid var(--ink); background: #fff; border-radius: 999px; padding: 4px 14px; font-weight: 800; font-size: 16px; cursor: pointer; touch-action: manipulation; }
.chip.sel { background: var(--yellow); }

.play { display: flex; flex-direction: column; }
.play #btn-create { width: 100%; }
.rooms { display: flex; flex-direction: column; gap: 10px; min-height: 90px; }
.room { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 10px 12px; animation: pop 0.25s; }
.room .ri { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room .ri b { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .ri small { color: var(--muted); font-weight: 700; font-size: 14px; }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; background: #eee; color: var(--ink); font-size: 12px; margin-left: 4px; }
.tag.live { background: #ffd0cc; }
.tag.wait { background: #c9f5d6; }
.empty { color: var(--muted); font-weight: 700; text-align: center; padding: 18px 8px; border: 3px dashed #cfc6e6; border-radius: 16px; }
.hint { color: var(--muted); font-weight: 600; font-size: 15px; margin: 16px 0 12px; }
.play .fs-btn { align-self: flex-start; margin-top: auto; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- účet ---------- */
.prof-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.prof-head h2 { margin: 0; }
.ktabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.ktab {
  display: inline-flex; align-items: center; gap: 4px; border: 3px solid var(--ink); background: #fff; border-radius: 14px;
  padding: 2px 10px 2px 2px; font-weight: 800; font-size: 15px; cursor: pointer; touch-action: manipulation; max-width: 100%;
}
.ktab img { width: 34px; height: 34px; flex: none; }
.ktab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ktab.sel { background: var(--yellow); box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }
.ktab.add { padding: 2px 10px; font-size: 20px; color: var(--muted); border-style: dashed; }
.ktab.add span { font-size: 14px; }
.name-note { margin: 8px 0 0; font-size: 14px; font-weight: 700; color: var(--red-d); }
.acct-cta { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.cta-box { display: flex; align-items: center; gap: 10px; background: #fff3c4; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 10px; font-weight: 700; font-size: 15px; }
.cta-box span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cta-box.warn { background: #ffe0dc; }
.cta-row { display: flex; gap: 8px; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; z-index: 25; background: rgba(20,10,40,0.6); display: grid; place-items: center; padding: 16px; overflow: auto; }
.dlg-card { position: relative; width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto; animation: pop 0.2s; }
.dlg-card h2 { margin: 0 40px 8px 0; }
.dlg-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; font-size: 16px; font-weight: 800; cursor: pointer; padding: 0; }
.dlg-card form { display: flex; flex-direction: column; gap: 10px; }
.fl { display: flex; flex-direction: column; font-weight: 800; color: var(--muted); font-size: 15px; gap: 3px; }
.fl input { font: 700 18px var(--font); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px; padding: 7px 10px; width: 100%; background: #fff; outline: none; }
.fl input:focus { box-shadow: 0 0 0 4px rgba(255,210,63,0.7); }
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; font-size: 18px; cursor: pointer; padding: 4px; }
.ferr { margin: 0; color: var(--red-d); font-weight: 800; }
.ferr:empty { display: none; }
.dlg-sub { margin: 0 0 12px; font-weight: 600; color: var(--muted); }
.dlg-note { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.dlg-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-weight: 700; }
.dlg-links a { color: var(--blue-d); }
.acct-email { font-weight: 600; overflow-wrap: anywhere; margin: 0; }
.acct-kuliks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; align-items: flex-start; }
.ak { display: flex; align-items: center; gap: 6px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 2px 6px 2px 2px; width: 100%; }
.ak img { width: 36px; height: 36px; }
.ak b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dlg-more { margin-top: 12px; border-top: 2px dashed #cfc6e6; padding-top: 10px; }
.dlg-more summary { font-weight: 800; cursor: pointer; margin-bottom: 8px; }

/* ---------- statistiky ---------- */
#scr-stats { padding: calc(12px + var(--safe-t)) 16px calc(24px + var(--safe-b)); max-width: 900px; margin: 0 auto; }
.st-tabs { display: flex; gap: 6px; }
.st-tabs .segb { font-size: 16px; padding: 5px 12px; }
.st-tabs .segb.sel { background: var(--yellow); }
.st-spacer { width: 84px; flex: none; }
@media (max-width: 520px) { .st-spacer { display: none; } }
.st-card h2 { margin: 0 0 10px; }
.st-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.st-head img { width: 72px; height: 72px; flex: none; }
.st-head h2 { margin: 0; font-size: 32px; line-height: 1.05; overflow-wrap: anywhere; }
.st-head small { color: var(--muted); font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 6px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.tile .ti { font-size: 24px; line-height: 1.15; }
.tile b { font-size: 26px; line-height: 1.1; }
.tile small { color: var(--muted); font-weight: 700; }
.tile em { font-style: normal; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.st-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 640px) { .st-cols { grid-template-columns: minmax(0, 1fr); } }
.st-table { width: 100%; border-collapse: collapse; font-weight: 700; }
.st-table td, .st-table th { padding: 3px 6px; text-align: center; }
.st-table td:first-child { text-align: left; }
.st-table th { color: var(--muted); }
.records { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; font-weight: 700; }
.records span { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 4px 8px; }
.games { display: flex; flex-direction: column; gap: 8px; }
.gm { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; }
.gm-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; }
.gm-date { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 700; }
.gm-score { font-size: 18px; }
.res { border-radius: 999px; padding: 0 10px; font-size: 14px; border: 2px solid var(--ink); }
.res.win { background: var(--yellow); }
.res.loss { background: #e6e1f2; }
.res.draw { background: #c9f5d6; }
.res.none { background: #eee; color: var(--muted); }
.gm-st { font-weight: 700; font-size: 15px; margin-top: 2px; }
.gm-who { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-by { margin-bottom: 8px; }
.top-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-weight: 700; }
.top-table th { color: var(--muted); text-align: left; padding: 0 8px; }
.top-table td { background: #fff; padding: 4px 8px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.top-table td:first-child { border-left: 2px solid var(--ink); border-radius: 12px 0 0 12px; text-align: center; width: 44px; font-size: 18px; }
.top-table td:last-child { border-right: 2px solid var(--ink); border-radius: 0 12px 12px 0; font-size: 18px; }
.top-table .nm img { width: 32px; height: 32px; vertical-align: middle; margin-right: 6px; }
.top-table tr[data-k] { cursor: pointer; }
.top-table tr.me td { background: #fff3c4; }
.end-saved { margin: 0 0 12px; font-weight: 700; color: var(--muted); }

/* ---------- lobby ---------- */
#scr-lobby { padding: calc(12px + var(--safe-t)) 16px calc(24px + var(--safe-b)); max-width: 1100px; margin: 0 auto; }
.lobby-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.lobby-top .code { color: #fff; font-weight: 800; font-size: 20px; text-align: center; }
.lobby-top .code .btn { color: var(--ink); vertical-align: middle; }
.lobby-top .code b { font-size: 28px; letter-spacing: 3px; color: var(--yellow); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; }
@media (max-width: 860px) { .lobby-grid { grid-template-columns: minmax(0, 1fr); } }
.teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: start; }
.team { border-radius: 18px; padding: 10px; border: 3px solid var(--ink); min-height: 220px; display: flex; flex-direction: column; gap: 8px; }
.team.t0 { background: linear-gradient(#d6e7ff, #b5d3ff); }
.team.t1 { background: linear-gradient(#ffe0dc, #ffc2ba); }
.team h3 { margin: 0; text-align: center; font-size: 22px; }
.team.t0 h3 { color: var(--blue-d); }
.team.t1 h3 { color: var(--red-d); }
.members { display: flex; flex-direction: column; gap: 6px; }
.mem { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.75); border-radius: 12px; padding: 3px 8px 3px 3px; font-weight: 800; font-size: 16px; animation: pop 0.25s; min-width: 0; }
.mem span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem img { width: 40px; height: 40px; flex: none; }
.mem.me { outline: 3px solid var(--ink); }
.mem.off { opacity: 0.5; }
.none { color: var(--muted); font-weight: 700; text-align: center; padding: 6px; }
.botrow { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 700; font-size: 15px; background: rgba(255,255,255,0.5); border-radius: 12px; padding: 4px 6px; flex-wrap: wrap; }
.botrow .pm { display: flex; gap: 6px; }
.botrow .pm .btn { width: 36px; padding: 2px 0; font-size: 18px; }
.join-team { margin-top: auto; font-size: 15px; padding: 7px 8px; }
.vs { align-self: center; font-weight: 800; font-size: 26px; color: var(--ink); background: var(--yellow); border: 3px solid var(--ink); border-radius: 50%; width: 52px; height: 52px; display: grid; place-items: center; }
.tip { grid-column: 1 / -1; margin: 4px 0 0; text-align: center; font-weight: 700; color: var(--muted); }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.mode { border: 3px solid var(--ink); border-radius: 18px; background: #fff; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; text-align: center; cursor: pointer; touch-action: manipulation; }
.mode img, .mode .emo { width: 46px; height: 46px; font-size: 36px; line-height: 46px; }
.mode b { font-size: 19px; }
.mode small { font-size: 12.5px; color: var(--muted); font-weight: 600; line-height: 1.2; }
.mode.sel { background: var(--yellow); box-shadow: 0 5px 0 var(--ink); transform: translateY(-3px); }
.mode:disabled { cursor: default; }
.mode:disabled:not(.sel) { opacity: 0.7; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.row > span { width: 78px; flex: none; font-weight: 800; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.segb { border: 3px solid var(--ink); background: #fff; border-radius: 12px; padding: 4px 12px; font-weight: 800; font-size: 15.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; touch-action: manipulation; }
.segb.sel { background: var(--yellow); }
.segb:disabled { cursor: default; }
.segb:disabled:not(.sel) { opacity: 0.55; }
.sw { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.sw.meadow { background: #7ec355; }
.sw.snow { background: #e7f0f8; }
.sw.desert { background: #ecce8b; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 800; margin-top: 14px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sw-t { width: 52px; height: 30px; border: 3px solid var(--ink); border-radius: 999px; background: #ddd; position: relative; flex: none; transition: background 0.15s; }
.sw-t::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: left 0.15s; }
.toggle input:checked + .sw-t { background: var(--green); }
.toggle input:checked + .sw-t::after { left: 24px; }
.host-only-note { margin: 10px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; }
body.is-host .host-only-note { display: none; }
.lobby-bottom { text-align: center; margin: 26px 0 18px; }
.lobby-bottom .btn.big { font-size: 32px; padding: 14px 44px; }
.wait { color: #fff; font-weight: 800; font-size: 22px; }
.wait b { color: var(--yellow); }
.help summary { font-weight: 800; font-size: 19px; cursor: pointer; }
.help-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .help-grid { grid-template-columns: minmax(0, 1fr); } }
.help h4 { margin: 10px 0 4px; font-size: 18px; }
.help p { margin: 0; font-weight: 600; line-height: 1.5; }
kbd { display: inline-block; border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; padding: 0 5px; font: 800 13px var(--font); background: #fff; margin: 0 1px; }

/* ---------- hra ---------- */
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#cv.aim { cursor: none; } /* zaměřovač kreslí hra sama */
#hud { position: absolute; inset: 0; pointer-events: none; font-weight: 800; }
#hud button, #hud .wbtn { pointer-events: auto; }
#hud-top {
  position: absolute; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 8px;
}
.score {
  display: flex; align-items: center; gap: 4px; padding: 2px 14px 2px 8px; border: 3px solid var(--ink); border-radius: 16px;
  color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 4px 0 rgba(20,10,40,0.6); min-width: 86px; justify-content: center;
}
.score img { width: 38px; height: 38px; }
.score .emo { font-size: 26px; }
.score b { text-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.score.t0 { background: var(--blue); }
.score.t1 { background: var(--red); flex-direction: row-reverse; padding: 2px 8px 2px 14px; }
.score.mine { outline: 3px solid #fff; outline-offset: -7px; }
#hud-top .mid { display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(20,10,40,0.75); border-radius: 14px; padding: 2px 12px; color: #fff; }
#timer { font-size: 24px; line-height: 1.05; }
#timer.low { color: #ff8a8a; animation: pulse 0.8s infinite; }
#goal { font-size: 12px; opacity: 0.85; white-space: nowrap; }
@keyframes pulse { 50% { transform: scale(1.12); } }
#hud-left { position: absolute; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); display: flex; flex-direction: column; gap: 6px; }
.hud-row { display: flex; align-items: center; gap: 6px; }
.hbtn {
  width: 44px; height: 44px; border-radius: 14px; border: 3px solid var(--ink); background: rgba(255,250,240,0.92);
  font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 3px 0 rgba(20,10,40,0.6); padding: 0; touch-action: manipulation;
}
.hp { position: relative; width: 170px; height: 26px; border: 3px solid var(--ink); border-radius: 14px; background: rgba(20,10,40,0.7); overflow: hidden; }
#hp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(#7cf07c, #3cc43c); transition: width 0.15s; }
#hp-num { position: absolute; inset: 0; text-align: center; color: #fff; font-size: 17px; line-height: 21px; text-shadow: 0 2px 0 rgba(0,0,0,0.5); }
#bonuses { display: flex; gap: 6px; margin-left: 50px; }
.bon { display: flex; align-items: center; gap: 2px; background: rgba(20,10,40,0.7); color: #fff; border-radius: 12px; padding: 0 8px 0 2px; font-size: 16px; animation: pop 0.2s; }
.bon img { width: 30px; height: 30px; }
#emo-pal { display: grid; grid-template-columns: repeat(4, 50px); gap: 6px; background: rgba(255,250,240,0.95); border: 3px solid var(--ink); border-radius: 16px; padding: 8px; pointer-events: auto; width: max-content; }
#emo-pal button { width: 50px; height: 50px; font-size: 30px; border: 0; background: transparent; cursor: pointer; border-radius: 12px; padding: 0; }
#emo-pal button:active { background: var(--yellow); }
#hud-right { position: absolute; top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#minimap { width: 190px; height: 118px; border: 3px solid var(--ink); border-radius: 12px; background: rgba(20,10,40,0.6); display: block; }
#feed { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.kf { display: flex; align-items: center; gap: 4px; background: rgba(20,10,40,0.72); border-radius: 10px; padding: 1px 8px; color: #fff; font-size: 14px; transition: opacity 0.6s; animation: pop 0.2s; white-space: nowrap; }
.kf img { width: 26px; height: 26px; }
.kf.fade { opacity: 0; }
#msg { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(92vw, 640px); text-align: center; }
#msg .m { font-size: 26px; line-height: 1.1; -webkit-text-stroke: 5px rgba(20,10,40,0.9); paint-order: stroke fill; animation: msgIn 0.35s cubic-bezier(.2,1.6,.4,1); transition: opacity 0.5s, transform 0.5s; }
#msg .m.fade { opacity: 0; transform: translateY(-10px); }
@keyframes msgIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#banner {
  position: absolute; bottom: calc(96px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 16px; padding: 4px 16px; font-size: 20px; white-space: nowrap;
  box-shadow: 0 4px 0 rgba(20,10,40,0.6); animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateX(-50%) translateY(-4px); } }
#respawn { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: #fff; font-size: 22px; -webkit-text-stroke: 5px rgba(20,10,40,0.9); paint-order: stroke fill; }
#respawn .big { font-size: 46px; }
#respawn b { color: var(--yellow); font-size: 30px; }
#weapons {
  position: absolute; bottom: calc(10px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; flex-wrap: nowrap; justify-content: center;
  /* 9 zbraní vždy v jedné řadě – tlačítka se zmenší, ať zůstane místo pro joysticky */
  --wb: clamp(40px, calc((100vw - 330px) / 9 - 6px), 62px);
}
.wbtn {
  position: relative; width: var(--wb); height: var(--wb); flex: none; border: 3px solid var(--ink); border-radius: 16px; background: rgba(255,250,240,0.9);
  cursor: pointer; padding: 0; box-shadow: 0 4px 0 rgba(20,10,40,0.6); touch-action: none; animation: pop 0.2s;
}
.wbtn img { width: calc(var(--wb) - 12px); height: calc(var(--wb) - 12px); display: block; margin: 0 auto; }
.wbtn .ammo { position: absolute; right: 3px; bottom: -1px; font-size: 15px; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.wbtn .key { position: absolute; left: 5px; top: 1px; font-size: 12px; color: var(--muted); }
.wbtn.sel { background: var(--yellow); transform: translateY(-4px); box-shadow: 0 6px 0 rgba(20,10,40,0.7); }
body.touch .wbtn .key { display: none; }

.overlay { position: absolute; inset: 0; background: rgba(20,10,40,0.55); display: grid; place-items: center; padding: 16px; z-index: 5; }
.menu-card { display: flex; flex-direction: column; gap: 12px; min-width: min(340px, 90vw); text-align: center; }
.menu-card h2 { margin: 0; }
.small { margin: 0; color: var(--muted); font-weight: 600; }
.end-card { text-align: center; max-width: min(640px, 94vw); max-height: 92vh; overflow: auto; animation: msgIn 0.45s cubic-bezier(.2,1.6,.4,1); }
#end-title { font-size: 40px; margin: 0; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
#end-title.t0 { color: var(--blue); }
#end-title.t1 { color: var(--red); }
#end-title.draw { color: var(--yellow); }
#end-sub { margin: 0; font-weight: 700; color: var(--muted); font-size: 18px; }
#end-score { font-size: 46px; font-weight: 800; margin: 4px 0; }
#end-score .t0 { color: var(--blue); }
#end-score .t1 { color: var(--red); }
#end-table { width: 100%; border-collapse: collapse; font-weight: 700; font-size: 16px; margin: 6px 0 14px; }
#end-table th { color: var(--muted); font-size: 18px; }
#end-table td, #end-table th { padding: 4px 6px; }
#end-table td:nth-child(2) { text-align: left; }
#end-table tr.t0 td { background: #e3eeff; }
#end-table tr.t1 td { background: #ffe6e2; }
#end-table tr.me td { font-weight: 800; box-shadow: inset 0 -3px 0 var(--ink); }
.end-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.end-btns p { margin: 0; font-weight: 800; color: var(--muted); }

#conn { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20,10,40,0.5); z-index: 20; font-weight: 800; font-size: 22px; }
#conn .card { animation: pulse 1.2s infinite; }
#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 140%);
  background: var(--ink); color: #fff; font-weight: 800; padding: 10px 18px; border-radius: 14px; z-index: 30;
  transition: transform 0.25s, opacity 0.25s, visibility 0.25s; max-width: 92vw; text-align: center;
  opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) and (pointer: coarse) {
  body[data-screen="game"] #rotate {
    display: grid; position: fixed; inset: 0; z-index: 40; place-items: center; background: var(--bg1); color: #fff; font-size: 30px; font-weight: 800; text-align: center;
  }
}
@media (max-height: 560px) {
  #weapons { --wb: clamp(40px, calc((100vw - 330px) / 9 - 6px), 50px); }
  .wbtn { border-radius: 13px; }
  #minimap { width: 150px; height: 92px; }
  .score { font-size: 24px; min-width: 70px; }
  .score img { width: 30px; height: 30px; }
  #msg .m { font-size: 21px; }
}
@media (max-width: 700px) {
  #minimap { width: 130px; height: 80px; }
  .hp { width: 110px; }
}
