:root {
  --bg: #07080c;
  --board: #0b0d13;
  --ink: #e8ecf4;
  --dim: #79839a;
  --dimmer: #4a5265;
  --line: #1a1e2a;
  --glass: rgba(14, 17, 25, 0.72);
  --accent: #38bdf8;
  --warn: #ff7a45;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Jemné světlo pod plátnem, aby střed obrazovky "dýchal". */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, #141a2b 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ------------------------------------------------------------- plátno */

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1;
  touch-action: none;
}

#board {
  display: block;
  cursor: crosshair;
  image-rendering: pixelated;
}

#board.locked { cursor: default; }
#board.panning { cursor: grabbing; }

/* --------------------------------------------------------------- hlava */

#brand {
  position: fixed;
  top: clamp(16px, 3vh, 30px);
  left: clamp(16px, 3vw, 34px);
  z-index: 3;
  pointer-events: none;
  animation: rise 0.9s 0.15s both cubic-bezier(0.2, 0.7, 0.3, 1);
}

#brand h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.025em;
}

#brand .mark {
  display: block;
  font-size: clamp(19px, 2.4vw, 25px);
}

#brand .mark i {
  font-style: normal;
  color: var(--dimmer);
}

#brand .claim {
  display: block;
  max-width: 27ch;
  margin-top: 5px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--dim);
  letter-spacing: 0.005em;
}

/* -------------------------------------------------------------- statistiky */

#stats {
  position: fixed;
  top: clamp(16px, 3vh, 30px);
  right: clamp(16px, 3vw, 34px);
  z-index: 3;
  display: flex;
  gap: 26px;
  align-items: flex-start;
  pointer-events: none;
  animation: rise 0.9s 0.25s both cubic-bezier(0.2, 0.7, 0.3, 1);
}

.stat { text-align: right; }

.stat b {
  display: block;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat span {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--dimmer);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.live {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--glass);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
}

.live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: pulse 2.4s infinite;
}

/* ------------------------------------------------------------- odečet */

#readout {
  position: fixed;
  left: 50%;
  bottom: calc(clamp(96px, 15vh, 132px) + 26px);
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
}

#readout.on { opacity: 1; }
#readout b { color: var(--ink); font-weight: 600; }
#readout .sep { color: var(--line); }
#readout .own { color: var(--accent); }

/* ---------------------------------------------------------------- dok */

#dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 0 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  animation: rise 0.9s 0.35s both cubic-bezier(0.2, 0.7, 0.3, 1);
}

.dock-inner {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.5vw, 26px);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.9);
  max-width: 100%;
}

/* ------------------------------------------------------------- paleta */

#palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.13s cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 0.13s;
}

.swatch:hover { transform: translateY(-2px) scale(1.06); }

.swatch[aria-checked="true"] {
  transform: translateY(-2px) scale(1.1);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--ink);
}

/* --------------------------------------------------------------- akce */

#action {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 216px;
}

#place {
  padding: 11px 18px;
  border: 0;
  border-radius: 11px;
  background: var(--ink);
  color: #0a0c12;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.18s, background 0.18s;
}

#place:hover:not(:disabled) { transform: translateY(-1px); }
#place:active:not(:disabled) { transform: translateY(0); }

#place:disabled {
  background: #161a24;
  color: var(--dimmer);
  cursor: default;
}

#place.armed {
  background: var(--accent);
  color: #04121c;
  animation: breathe 1.9s ease-in-out infinite;
}

#place.waiting {
  background: #161a24;
  color: var(--dim);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

#hint {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--dimmer);
}

/* -------------------------------------------------------------- nářadí */

#tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  width: 212px;
}

.ghost {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ghost:hover { color: var(--ink); border-color: #2a3040; }
.ghost[aria-pressed="true"] { color: var(--accent); border-color: rgba(56, 189, 248, 0.4); background: rgba(56, 189, 248, 0.07); }

/* ----------------------------------------------------------- časosběr */

#lapse {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 0 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

#lapse[hidden] { display: none; }

.lapse-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(620px, 100%);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.9);
}

#lapse-play {
  flex: none;
  width: 74px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
}

#lapse-scrub {
  flex: 1;
  height: 3px;
  min-width: 0;
  appearance: none;
  border-radius: 3px;
  background: var(--line);
  cursor: pointer;
}

#lapse-scrub::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

#lapse-scrub::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

#lapse-time {
  flex: none;
  min-width: 116px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- boot */

#boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.5s;
}

#boot span {
  width: 9px;
  height: 9px;
  background: var(--accent);
  animation: blink 1.15s ease-in-out infinite;
}

#boot.gone { opacity: 0; pointer-events: none; }

/* -------------------------------------------------------------- podpis */

#open-sign.calls {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.08);
}

#signer {
  position: fixed;
  left: 50%;
  bottom: calc(clamp(96px, 15vh, 132px) + 26px);
  transform: translateX(-50%);
  z-index: 6;
  width: min(430px, calc(100% - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 70px -22px rgba(0, 0, 0, 0.92);
}

#signer[hidden] { display: none; }

#signer label {
  display: block;
  margin-bottom: 9px;
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.signer-row { display: flex; gap: 7px; }

#nick {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #232838;
  border-radius: 9px;
  background: #0a0c12;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13.5px;
}

#nick:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.55);
}

#nick.bad { border-color: var(--warn); }

#sign-save {
  flex: none;
  padding: 9px 15px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: #0a0c12;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#sign-save:disabled { background: #161a24; color: var(--dimmer); cursor: default; }

#sign-note {
  margin: 10px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--dimmer);
}

#sign-note.bad { color: var(--warn); }

/* ------------------------------------------------------------- o projektu */

#about {
  width: min(660px, calc(100% - 28px));
  max-height: min(82vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0d1017;
  color: var(--ink);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.95);
}

#about::backdrop {
  background: rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(6px);
}

#about article {
  position: relative;
  padding: 34px 38px 40px;
  overflow-y: auto;
  max-height: inherit;
}

#about-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  padding: 6px 0;
  text-align: center;
}

#about h2 {
  margin: 0 0 18px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

#about h3 {
  margin: 30px 0 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#about p {
  margin: 0 0 13px;
  font-size: 14.5px;
  line-height: 1.65;
  color: #c3cad8;
  max-width: 62ch;
}

#about ul {
  margin: 0;
  padding-left: 19px;
  font-size: 14.5px;
  line-height: 1.65;
  color: #c3cad8;
  max-width: 62ch;
}

#about li { margin-bottom: 7px; }
#about strong { color: var(--ink); font-weight: 600; }
#about em { color: var(--ink); font-style: normal; font-family: var(--mono); font-size: 0.9em; }

/* ------------------------------------------------------------ animace */

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0); }
}

@keyframes blink {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* -------------------------------------------------------------- mobil */

@media (max-width: 760px) {
  #brand .claim, #stats .stat:nth-child(2) { display: none; }
  #stats { gap: 16px; }

  .dock-inner {
    flex-direction: column;
    gap: 12px;
    width: 100%;
    border-radius: 16px;
  }

  #palette { grid-template-columns: repeat(16, 1fr); gap: 4px; width: 100%; }
  .swatch { width: 100%; height: 24px; border-radius: 5px; }
  #action { width: 100%; min-width: 0; }
  #place { width: 100%; }
  #tools { width: 100%; }
  #readout { bottom: auto; top: 74px; }
  #lapse-time { min-width: 0; font-size: 10.5px; }
  #signer { bottom: auto; top: 50%; transform: translate(-50%, -50%); width: calc(100% - 32px); }
  #about article { padding: 26px 22px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Turnstile se rendruje jen pri vyzve; display:none by ho rozbil. */
#turnstile {
  position: fixed;
  left: 50%;
  bottom: calc(clamp(96px, 15vh, 132px) + 74px);
  transform: translateX(-50%);
  z-index: 7;
}

/* Obsah jen pro ctecky obrazovky - nesmi byt display:none. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#board:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
