:root {
  --bg: #1a1410;
  --bg-elev: #221a14;
  --bg-elev-2: #2b211a;
  --line: #3a2c22;
  --text: #f5ead8;
  --muted: #b6a48a;
  --accent: #e8b04a;
  --accent-strong: #ffc764;
  --danger: #d94f6a;
  --good: #5fa86b;
  --warn: #e69330;

  --color-A: #c98a3a;
  --color-B: #7a4fb0;
  --color-C: #3a8fc9;
  --color-D: #5fa86b;
  --color-E: #d94f6a;

  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* `hidden` atribut musí spolehlivě skrýt — jinak autor CSS s display:flex/grid
   přebije UA pravidlo [hidden]{display:none} a element zůstane viditelný. */
[hidden] { display: none !important; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3, .display, .serif {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  margin: 0;
}
.display { font-size: 56px; letter-spacing: 1px; color: var(--accent-strong); }
.lead { color: var(--muted); margin: 8px 0 24px; font-size: 18px; }
.muted { color: var(--muted); font-size: 14px; }

button {
  font: inherit;
  border: 0;
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 60ms ease, background-color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.primary { background: var(--accent); color: #1a1410; font-weight: 700; }
.primary:hover { background: var(--accent-strong); }
.secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--line); }
.danger { background: var(--danger); color: #fff; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

input, select {
  font: inherit;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* ──────── landing ──────── */
body.landing main {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(48px + var(--safe-top)) 20px calc(48px + var(--safe-bottom));
  text-align: center;
}
body.landing form { display: grid; gap: 12px; }
body.landing #code-input {
  text-align: center;
  font-size: 28px;
  letter-spacing: 8px;
  font-weight: 700;
}
body.landing .footer { margin-top: 24px; color: var(--muted); font-size: 13px; }
.status-pill {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}
.status-pill.good { color: var(--good); border-color: rgba(95,168,107,0.4); }
.status-pill.warn { color: var(--warn); border-color: rgba(230,147,48,0.4); }
.status-pill.bad  { color: var(--danger); border-color: rgba(217,79,106,0.4); }
.card.info { background: var(--bg-elev-2); border-color: rgba(232,176,74,0.25); }

/* ──────── slot machine uprostřed kola ──────── */
.slot-window {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 190px;
  height: 60px;
  background: linear-gradient(180deg, #0e0805 0%, #1a1006 50%, #0e0805 100%);
  border: 3px solid var(--accent);
  border-radius: 14px;
  overflow: hidden;
  z-index: 4;
  box-shadow:
    0 0 24px rgba(232, 176, 74, 0.55),
    inset 0 0 18px rgba(0, 0, 0, 0.85),
    inset 0 0 0 1px rgba(255, 220, 130, 0.25);
  pointer-events: none;
  transition: opacity 200ms ease;
}
.slot-window.mini {
  width: 140px;
  height: 44px;
  border-width: 2px;
  border-radius: 10px;
}
.slot-window.hidden { opacity: 0; }
.slot-inner { will-change: transform; }
.slot-item {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--accent-strong);
  text-shadow: 0 0 8px rgba(232, 176, 74, 0.5);
  white-space: nowrap;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.slot-window.mini .slot-item { height: 44px; font-size: 17px; }
.slot-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.75) 0%,
    transparent 35%,
    transparent 65%,
    rgba(0,0,0,0.75) 100%);
}
.slot-window.spinning {
  animation: slot-glow 0.5s ease-in-out infinite alternate;
}
.slot-window.locked {
  animation: slot-lock 0.8s ease-out;
}
@keyframes slot-glow {
  from {
    box-shadow:
      0 0 16px rgba(232,176,74,0.35),
      inset 0 0 18px rgba(0,0,0,0.85),
      inset 0 0 0 1px rgba(255,220,130,0.2);
  }
  to {
    box-shadow:
      0 0 36px rgba(232,176,74,0.85),
      inset 0 0 18px rgba(0,0,0,0.85),
      inset 0 0 0 1px rgba(255,255,200,0.5);
  }
}
@keyframes slot-lock {
  0%   { box-shadow: 0 0 48px rgba(255,255,255,0.9), inset 0 0 24px rgba(255,255,255,0.4); transform: translate(-50%, -50%) scale(1.18); }
  35%  { transform: translate(-50%, -50%) scale(0.96); }
  100% { box-shadow: 0 0 24px rgba(232,176,74,0.55), inset 0 0 18px rgba(0,0,0,0.85), inset 0 0 0 1px rgba(255,220,130,0.25); transform: translate(-50%, -50%) scale(1); }
}

/* ──────── legenda kola (sdílená) ──────── */
.legend-wrap { display: flex; flex-direction: column; gap: 6px; }
.legend-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 700;
  padding: 0 4px;
}
.legend-dot-hint { color: var(--accent); margin: 0 4px; }
.legend { display: flex; gap: 8px; }
.legend-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 12px;
  min-width: 0;
}
.legend-chip.legend-A { border-left-color: var(--color-A); }
.legend-chip.legend-B { border-left-color: var(--color-B); }
.legend-chip.legend-C { border-left-color: var(--color-C); }
.legend-chip.legend-D { border-left-color: var(--color-D); }
.legend-chip.legend-E { border-left-color: var(--color-E); }
.legend-icon {
  font-size: 24px;
  line-height: 1;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}
.legend-body { min-width: 0; }
.legend-label { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.1; }
.legend-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-full { flex-wrap: wrap; }
.legend-full .legend-chip { flex: 1 1 180px; }
.legend-cycle .legend-chip.fade-in { animation: legend-in 600ms ease-out; }
@keyframes legend-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ──────── obecné mobil layouty ──────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar.your-turn {
  background: var(--accent);
  color: #1a1410;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,176,74,0.45); }
  50% { box-shadow: 0 0 0 12px rgba(232,176,74,0); }
}

.content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}
.bottombar {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.4) 30%, var(--bg) 100%);
}

.action-btn {
  width: 100%;
  min-height: 64px;
  font-size: 18px;
  font-weight: 700;
}

.conn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--good);
  margin-left: auto;
  transition: background-color 200ms ease;
}
.conn-dot.reconnecting { background: var(--warn); }
.conn-dot.offline { background: var(--danger); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  font-size: 20px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 28px; }
.avatar.xs { width: 28px; height: 28px; font-size: 16px; }

.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  margin-bottom: 8px;
}
.player-chip .name { font-weight: 600; }
.player-chip .meta { margin-left: auto; color: var(--muted); font-size: 13px; }
.player-chip.disconnected .name { color: var(--danger); }
.player-chip.current { border-color: var(--accent); background: var(--bg-elev-2); }

/* ──────── overlay pro reconnect ──────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,8,6,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 100;
  text-align: center;
  padding: 20px;
}
.overlay.show { display: flex; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ──────── toast ──────── */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
  width: min(92%, 460px);
}
.toast {
  background: rgba(43,33,26,0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
  font-size: 14px;
  animation: toast-in 200ms ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ──────── bottom sheet ──────── */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 90;
}
.sheet-backdrop.show { display: block; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-elev);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  z-index: 91;
  transform: translateY(100%);
  transition: transform 220ms ease;
  max-height: 80vh;
  overflow-y: auto;
  touch-action: pan-y;
}
.sheet.show { transform: translateY(0); }
.sheet .handle {
  width: 44px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 6px auto 14px;
}
.sheet h3 { margin-bottom: 12px; }
.sheet .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  min-height: 64px;
  cursor: pointer;
}
.sheet .row:hover, .sheet .row:active { border-color: var(--accent); background: var(--bg-elev-2); }
.sheet .row .name { font-weight: 600; font-size: 17px; }
.sheet .cancel { width: 100%; margin-top: 8px; }
.sheet .row.disabled { opacity: 0.45; cursor: not-allowed; }
.sheet .row-meta { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ──────── reactions floater ──────── */
.reaction-bar {
  display: flex;
  gap: 8px;
  justify-content: space-around;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 10px;
}
.reaction-bar button {
  flex: 1;
  min-height: 48px;
  background: transparent;
  font-size: 24px;
}
.reaction-bar button:active { background: var(--bg-elev-2); }
