:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg2: #111830;
  --panel: #141d38;
  --panel2: #1a2547;
  --line: #26335e;
  --text: #e8ecf8;
  --muted: #8d98bd;
  --accent: #3ee6c1;
  --accent-ink: #062a22;
  --amber: #ffc857;
  --bad: #ff6b6b;
  --near: #ffb35c;
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --c-alkalicky: #ff7a6b;
  --c-zeminy: #ffb35c;
  --c-prechodny: #f2d15c;
  --c-kov: #8fd694;
  --c-polokov: #5fd6c5;
  --c-nekov: #6fb6ff;
  --c-halogen: #b89cff;
  --c-vzacny: #ff8fd0;
  --c-lanthanoid: #62d7f5;
  --c-aktinoid: #ff9eb0;
  --c-nezname: #8a93a6;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(62, 230, 193, .09), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(111, 182, 255, .08), transparent 60%),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
  color: var(--text);
  font: 16px/1.5 'Space Grotesk', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; }

/* ---------- hlavička ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, .8);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-tile {
  position: relative; width: 40px; height: 40px; border-radius: 9px;
  border: 2px solid var(--accent); display: grid; place-items: center;
  font: 700 17px var(--mono); color: var(--accent);
  box-shadow: 0 0 18px rgba(62, 230, 193, .25) inset;
}
.brand-tile small { position: absolute; top: 1px; left: 4px; font-size: 8px; opacity: .7; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.brand-by { font-style: italic; font-size: 12.5px; color: var(--amber); letter-spacing: .01em; margin-top: 2px; white-space: nowrap; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--muted); padding: 7px 12px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.nav a.on, .nav a:hover { color: var(--text); background: var(--panel); }
.nav .lvl-chip { display: inline-flex; align-items: center; gap: 6px; }
.lvl-mini { font: 700 11px var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--accent); color: var(--accent-ink); }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 16px 26px; }

/* ---------- obecné ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel2); padding: 10px 16px;
  border-radius: 11px; cursor: pointer; font-weight: 600; color: var(--text); transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover { border-color: #3a4a85; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: 14px 26px; font-size: 18px; border-radius: 13px; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.chip[disabled] { opacity: .4; cursor: not-allowed; }
.chip.on { background: rgba(62, 230, 193, .12); border-color: var(--accent); color: var(--text); }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62, 230, 193, .18); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- úvod ---------- */
.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(28px, 4.2vw, 46px); letter-spacing: -.03em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); max-width: 52ch; margin: 12px 0 18px; }
.daily {
  background: linear-gradient(135deg, rgba(255, 200, 87, .14), rgba(255, 107, 107, .08)), var(--panel);
  border-color: rgba(255, 200, 87, .4);
  display: flex; flex-direction: column; gap: 10px;
}
.daily h2 { font-size: 22px; }
.daily .tiles { display: flex; gap: 5px; flex-wrap: wrap; }
.daily .tiles span {
  width: 30px; height: 30px; border-radius: 7px; border: 1px dashed rgba(255, 200, 87, .55);
  display: grid; place-items: center; font: 700 12px var(--mono); color: var(--amber);
}
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.mode {
  text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 13px;
  padding: 14px; cursor: pointer; transition: border-color .15s, transform .1s, background .15s;
}
.mode:hover { border-color: #3a4a85; transform: translateY(-1px); }
.mode.on { border-color: var(--accent); background: linear-gradient(180deg, rgba(62, 230, 193, .1), transparent), var(--panel); }
.mode .ic { font-size: 22px; }
.mode b { display: block; font-size: 17px; margin: 4px 0 2px; }
.mode span { color: var(--muted); font-size: 13.5px; line-height: 1.4; display: block; }
.settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.startbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feed li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.feed li:last-child { border: 0; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.stat b { display: block; font: 700 22px var(--mono); }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- periodická tabulka ---------- */
.ptable-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.ptable {
  --gap: 3px;
  display: grid; gap: var(--gap);
  grid-template-columns: 18px repeat(18, minmax(0, 1fr));
  grid-template-rows: 16px repeat(7, auto) 10px repeat(2, auto);
  min-width: 520px;
  user-select: none;
}
.ptable .lbl { font: 600 10px var(--mono); color: var(--muted); display: grid; place-items: center; opacity: .75; }
.cell {
  position: relative; aspect-ratio: 1 / 1.08; border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .09); background: rgba(255, 255, 255, .04);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0; cursor: default; transition: transform .12s, box-shadow .2s, background .2s, border-color .2s;
  container-type: inline-size; overflow: hidden;
}
.cell.colored { background: color-mix(in srgb, var(--c) 17%, transparent); border-color: color-mix(in srgb, var(--c) 42%, transparent); }
.ptable.clickable .cell:not(.ph) { cursor: pointer; }
.ptable.clickable .cell:not(.ph):hover { transform: scale(1.1); z-index: 3; border-color: var(--text); box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }
.cell .s { font: 700 clamp(9px, 38cqi, 22px) var(--mono); line-height: 1; }
.cell .z { position: absolute; top: 2px; left: 3px; font: 500 clamp(6px, 18cqi, 10px) var(--mono); opacity: .7; }
.cell .nm { font-size: clamp(5px, 13cqi, 9px); opacity: .75; margin-top: 2px; white-space: nowrap; }
.cell.ph { border-style: dashed; background: transparent; font: 500 clamp(6px, 16cqi, 9px) var(--mono); color: var(--muted); }
.cell.ok { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink); animation: pop .45s; z-index: 2; }
.cell.bad { background: var(--bad) !important; border-color: var(--bad) !important; color: #2b0707; animation: shake .4s; z-index: 2; }
.cell.near { background: var(--near) !important; border-color: var(--near) !important; color: #2b1800; }
.cell.target { background: rgba(62, 230, 193, .25) !important; border: 2px solid var(--accent) !important; animation: pulse 1.1s infinite; z-index: 2; }
.cell.ask { background: rgba(255, 200, 87, .22) !important; border: 2px solid var(--amber) !important; animation: pulseA 1.1s infinite; z-index: 2; }
.cell.nbq { border: 2px dashed var(--amber) !important; background: rgba(255, 200, 87, .1) !important; }
.cell.nbq::after { content: attr(data-arrow); font: 700 clamp(8px, 34cqi, 16px) var(--mono); color: var(--amber); }
.cell.nbq.ok::after, .cell.nbq.bad::after { content: none; }
.cell.dim { opacity: .35; }
.cell.heat { background: color-mix(in srgb, var(--h) 70%, var(--bg)); border-color: color-mix(in srgb, var(--h) 80%, transparent); color: #0b1020; }
.cell.heat.none { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .09); color: var(--muted); }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(62, 230, 193, .55); } 50% { box-shadow: 0 0 0 7px rgba(62, 230, 193, 0); } }
@keyframes pulseA { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 87, .6); } 50% { box-shadow: 0 0 0 8px rgba(255, 200, 87, 0); } }

.rotate-tip { display: none; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
@media (orientation: landscape) { .rotate-tip { display: none !important; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 5px; vertical-align: -1px; }

/* ---------- hra ---------- */
.hud { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.hud .mode-name { font-weight: 700; font-size: 18px; }
.hud .spacer { flex: 1; }
.hud .pill { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; display: flex; gap: 6px; align-items: baseline; }
.hud .pill b { font: 700 18px var(--mono); }
.hud .pill span { font-size: 12px; color: var(--muted); }
.hud .pill.streak b { color: var(--amber); }
.hud .pill.timer.low b { color: var(--bad); }
.progress { height: 6px; background: var(--panel); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--accent), #6fb6ff); transition: width .3s; }
.stage { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.prompt { position: sticky; top: 84px; }
.prompt .what { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.prompt .big { font-size: clamp(30px, 4vw, 42px); font-weight: 700; letter-spacing: -.02em; margin: 6px 0 4px; word-break: break-word; }
.prompt .big.mono { font-family: var(--mono); }
.prompt .sub { color: var(--muted); font-size: 14px; }
.prompt .fb { margin-top: 14px; padding: 12px; border-radius: 11px; font-weight: 600; display: none; }
.prompt .fb.show { display: block; animation: fadein .25s; }
.prompt .fb.ok { background: rgba(62, 230, 193, .13); color: var(--accent); }
.prompt .fb.bad { background: rgba(255, 107, 107, .13); color: #ff9a9a; }
.prompt .fb.near { background: rgba(255, 179, 92, .13); color: var(--near); }
.prompt .fb small { display: block; font-weight: 400; color: var(--text); opacity: .85; margin-top: 3px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.cross { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.cross .c { display: flex; flex-direction: column; gap: 3px; }
.cross .c label { font-size: 11px; color: var(--muted); text-align: center; }
.cross input {
  width: 100%; text-align: center; background: var(--bg2); border: 2px dashed var(--amber); border-radius: 10px;
  padding: 9px 4px; font: 700 18px var(--mono); outline: none; min-width: 0;
}
.cross input:focus { border-style: solid; box-shadow: 0 0 0 3px rgba(255, 200, 87, .2); }
.cross input:disabled { border: 1px solid var(--line); opacity: .35; }
.cross input.ok:disabled, .cross input.bad:disabled { opacity: 1; }
.cross input.ok { border: 2px solid var(--accent); color: var(--accent); }
.cross input.bad { border: 2px solid var(--bad); color: var(--bad); text-decoration: line-through; }
.cross .mid { display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: 700 20px var(--mono); aspect-ratio: auto; min-height: 44px; }
.cross .fix { font: 700 12px var(--mono); color: var(--accent); text-align: center; min-height: 16px; }
.typed { margin-top: 14px; display: flex; gap: 8px; }
.typed input { font: 700 18px var(--mono); }
.actions { margin-top: 12px; display: flex; gap: 8px; }
.actions .btn { flex: 1; }
.kbd { font: 500 11px var(--mono); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--muted); }
.floater { position: fixed; pointer-events: none; font: 700 20px var(--mono); color: var(--accent); z-index: 50; animation: floatup 1s forwards; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }
.floater.bad { color: var(--bad); }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -48px); } }

/* ---------- výsledky ---------- */
.result-hero { text-align: center; padding: 30px 18px; }
.result-hero .score { font: 700 clamp(52px, 10vw, 88px) var(--mono); color: var(--accent); line-height: 1; margin: 8px 0; }
.result-hero .pb { display: inline-block; background: var(--amber); color: #2b1800; font-weight: 700; padding: 4px 12px; border-radius: 99px; margin-top: 6px; }
.answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ans { border: 1px solid var(--line); border-radius: 11px; padding: 9px 11px; background: var(--bg2); display: flex; gap: 10px; align-items: center; }
.ans .t { width: 38px; height: 40px; border-radius: 7px; display: grid; place-items: center; font: 700 15px var(--mono); flex: none; }
.ans.ok .t { background: var(--accent); color: var(--accent-ink); }
.ans.near .t { background: var(--near); color: #2b1800; }
.ans.bad .t { background: var(--bad); color: #2b0707; }
.ans .i { font-size: 13px; line-height: 1.3; min-width: 0; }
.ans .i b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ans .i span { color: var(--muted); }

/* ---------- žebříček ---------- */
.board-filters { display: grid; gap: 12px; margin-bottom: 14px; }
.board-filters .row > * { flex: none; }
select.input { width: auto; min-width: 180px; }
table.lb { width: 100%; border-collapse: collapse; }
.lb th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.lb td { padding: 10px; border-bottom: 1px solid rgba(38, 51, 94, .6); }
.lb tr.me td { background: rgba(62, 230, 193, .08); }
.lb .rk { width: 52px; font: 700 16px var(--mono); }
.lb .sc { font: 700 16px var(--mono); text-align: right; }
.lb th.r, .lb td.r { text-align: right; }
.lb a { color: var(--text); font-weight: 600; }
.lb .g { color: var(--muted); font-size: 13px; }
.acc { display: inline-flex; align-items: center; gap: 6px; }
.acc i { display: inline-block; width: 46px; height: 5px; border-radius: 9px; background: var(--line); overflow: hidden; position: relative; }
.acc i::after { content: ''; position: absolute; inset: 0; width: var(--p); background: var(--accent); }
.hide-sm { }

/* ---------- profil ---------- */
.lvl-card { display: flex; gap: 18px; align-items: center; }
.lvl-tile {
  width: 104px; height: 112px; border-radius: 14px; flex: none; position: relative;
  background: color-mix(in srgb, var(--c) 22%, var(--panel)); border: 2px solid var(--c);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 0 30px color-mix(in srgb, var(--c) 30%, transparent);
}
.lvl-tile .z { position: absolute; top: 6px; left: 9px; font: 700 14px var(--mono); }
.lvl-tile .s { font: 700 40px var(--mono); line-height: 1; }
.lvl-tile .nm { font-size: 12px; margin-top: 4px; }
.xpbar { height: 9px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; border: 1px solid var(--line); }
.xpbar div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--amber)); }
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.weak { display: flex; flex-wrap: wrap; gap: 6px; }
.weak span { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 13px; background: var(--bg2); }
.weak span b { font-family: var(--mono); margin-right: 4px; }
.heatlegend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.heatlegend .grad { width: 140px; height: 8px; border-radius: 9px; background: linear-gradient(90deg, #ff6b6b, #ffc857, #3ee6c1); }

/* ---------- přihlášení ---------- */
.auth { max-width: 420px; margin: 20px auto; }
.auth form { display: grid; gap: 12px; margin-top: 14px; }
.tabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; border: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--panel2); color: var(--text); }
.err { color: #ff9a9a; font-size: 14px; min-height: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--panel2); border: 1px solid var(--line); padding: 11px 18px; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4); max-width: calc(100vw - 32px);
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100vw; height: 100vh; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { font-size: 20px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

@media (max-width: 900px) {
  .hero, .grid2 { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 1fr; }
  .prompt { position: static; }
  .settings { grid-template-columns: 1fr; }
  .stats4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .top { padding: 10px 16px; }
  .brand-name { font-size: 16px; }
  .brand-by { font-size: 11px; }
  .nav a { padding: 6px 7px; font-size: 14.5px; }
  .hide-sm { display: none; }
  .nav .lvl-chip .nm-txt { display: none; }
  .rotate-tip { display: block; }
  .lb td, .lb th { padding: 8px 5px; }
  .stats3 { grid-template-columns: repeat(3, 1fr); }
  .hud { gap: 8px; }
  .hud .mode-name { width: 100%; }
}
